1
0
Fork 0

Commits vergleichen

...

6 Commits

Autor SHA1 Nachricht Datum
Faizaan Gagan
001651d153 added documentation for adding an new operator to the mapper 2021-05-10 11:00:59 +05:30
Faizaan Gagan
f3c29aba3c Merge branch 'master' into mapper_documentation 2021-05-10 05:57:57 +05:30
Faizaan Gagan
401c711fad FIX: removed redundant conditional 2021-05-02 23:03:29 +05:30
Faizaan Gagan
3e950036d0 various fixes 2021-04-26 06:46:23 +05:30
Faizaan Gagan
3d4c24d362 Merge branch 'master' into mapper_documentation 2021-04-26 01:51:11 +05:30
angusmcleod
ade8eaaeaa WIP
https://thepavilion.io/t/add-group-user-field-and-type-selector-to-if-statements/3985
2021-04-19 17:38:35 +10:00
8 geänderte Dateien mit 97 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -17,6 +17,9 @@ export default Component.extend({
showText: computed("activeType", function () {
return this.showInput("text");
}),
showLabel: computed("activeType", function() {
return this.showInput("wizardUser");
}),
showWizardField: computed("activeType", function () {
return this.showInput("wizardField");
}),
@ -38,6 +41,9 @@ export default Component.extend({
showGroup: computed("activeType", function () {
return this.showInput("group");
}),
showGroupUsers: computed("activeType", function () {
return this.showInput("groupUsers");
}),
showUser: computed("activeType", function () {
return this.showInput("user");
}),
@ -98,9 +104,15 @@ export default Component.extend({
groupEnabled: computed("options.groupSelection", "inputType", function () {
return this.optionEnabled("groupSelection");
}),
groupUsersEnabled: computed("options.groupUsersSelection", "inputType", function () {
return this.optionEnabled("groupUsersSelection");
}),
userEnabled: computed("options.userSelection", "inputType", function () {
return this.optionEnabled("userSelection");
}),
wizardUserEnabled: computed("options.wizardUserSelection", "inputType", function () {
return this.optionEnabled("wizardUserSelection");
}),
listEnabled: computed("options.listSelection", "inputType", function () {
return this.optionEnabled("listSelection");
}),
@ -114,7 +126,7 @@ export default Component.extend({
"showUserFieldOptions",
"showCustomField"
),
showMultiSelect: or("showCategory", "showGroup"),
showMultiSelect: or("showCategory", "showGroup", "showGroupUsers"),
hasTypes: gt("selectorTypes.length", 1),
showTypes: false,
@ -245,6 +257,7 @@ export default Component.extend({
return {
category: this.categories,
group: this.groups,
groupUsers: this.groups,
list: "",
}[activeType];
},

Datei anzeigen

@ -41,6 +41,7 @@ const connectors = {
"less_or_equal",
"regex",
"is",
"in"
],
output: ["then", "set"],
};
@ -101,8 +102,10 @@ const selectionTypes = [
"userField",
"userFieldOptions",
"group",
"groupUsers",
"category",
"tag",
"wizardUser",
"user",
"customField",
];

Datei anzeigen

@ -161,7 +161,7 @@ const CustomWizard = EmberObject.extend({
input.pairs = [];
inpt.pairs.forEach((pr) => {
if (present(pr.key) && present(pr.value)) {
if ((present(pr.key) && present(pr.value)) || pr.key_type == "wizardUser") {
let pairParams = {
index: pr.index,
key: pr.key,

Datei anzeigen

@ -274,6 +274,8 @@
userFieldSelection="key,value,assignment"
wizardActionSelection=true
groupSelection="value,output"
wizardUserSelection="key"
groupUsersSelection="value"
outputDefaultSelection="group"
context="action"
)}}

Datei anzeigen

@ -20,6 +20,10 @@
</div>
<div class="input">
{{#if showLabel}}
<div class="label">{{i18n placeholderKey}}</div>
{{/if}}
{{#if showText}}
{{input
type="text"

Datei anzeigen

@ -175,6 +175,15 @@
overflow: hidden;
}
}
.input > .label {
padding: 4px 10px;
border: 1px solid var(--primary-medium);
font-size: 1em;
line-height: 1;
min-height: 30px;
box-sizing: border-box;
}
}
.mapper-pairs {

Datei anzeigen

@ -114,12 +114,14 @@ en:
text: "text"
wizard_field: "wizard field"
wizard_action: "wizard action"
wizard_user: "current user"
user_field: "user field"
user_field_options: "user field options"
user: "user"
category: "category"
tag: "tag"
group: "group"
group_users: "group members"
list: "list"
custom_field: "custom field"
@ -128,12 +130,14 @@ en:
property: "Select property"
wizard_field: "Select field"
wizard_action: "Select action"
wizard_user: "Current user"
user_field: "Select field"
user_field_options: "Select field"
user: "Select user"
category: "Select category"
tag: "Select tag"
group: "Select group"
group_users: "Select group"
list: "Enter item"
custom_field: "Select field"
@ -227,6 +231,14 @@ en:
regex: '=~'
association: '→'
is: 'is'
##
# unit: custom_wizard:mapper adding_an_operator
# type: step
# number: 4
# title: Adding client translation for the operator
# description: Add the translation string for the said operator
##
in: 'in'
action:
header: "Actions"

Datei anzeigen

@ -1,4 +1,13 @@
# frozen_string_literal: true
##
# unit: custom_wizard:mapper adding_an_operator
# type: introduction
# title: Adding a new operator to the mapper
# description: In this unit, we'll learn about adding a new operator to
# custom wizard's mapper
##
class CustomWizard::Mapper
attr_accessor :inputs, :data, :user
@ -32,7 +41,17 @@ class CustomWizard::Mapper
present: "present?",
true: "==",
false: "=="
}
},
##
# unit: custom_wizard:mapper adding_an_operator
# type: step
# number: 1
# title: Adding the operator to the OPERATORS hash
# description: Add operator to this hash. The key will be used in code
# to refer to it and the value is generally the ruby operator
# to be used between the key and value
##
in: 'in'
}
def initialize(params)
@ -118,6 +137,16 @@ class CustomWizard::Mapper
def cast_value(value, key, connector)
if connector == 'regex'
Regexp.new(value)
##
# unit: custom_wizard:mapper adding_an_operator
# type: step
# number: 3
# title: Type casting mapper value
# description: You may want to typecast mapper values, based on certain conditions. Here,
# we're typecasting the value to an array so that we can use check for value contains key
##
elsif connector == 'in'
value.to_a
else
if key.is_a?(String)
value.to_s
@ -131,13 +160,24 @@ class CustomWizard::Mapper
def validation_result(key, value, operator)
result = nil
##
# unit: custom_wizard:mapper adding_an_operator
# type: step
# number: 2
# title: Defining operator's behaviour
# description: Define what happens when your operator is used between a key
# and value. The default behaviour is to use the operator hash value as a ruby
# operator between key and value. i.e. if operator is `equal`, then key == value or
# key.public_send('==', value).
##
if operator.is_a?(Hash) && (operator = operator[value.to_sym]).present?
if value == "present"
result = key.public_send(operator)
elsif ["true", "false"].include?(value)
result = key.public_send(operator, ActiveRecord::Type::Boolean.new.cast(value))
end
elsif operator === 'in'
result = value.include?(key)
elsif [key, value, operator].all? { |i| !i.nil? }
result = key.public_send(operator, value)
else
@ -213,6 +253,16 @@ class CustomWizard::Mapper
end
end
def map_wizard_user(value)
@user.username
end
def map_group_users(value)
if group = Group.find_by(id: value)
group.users.map(&:username)
end
end
def interpolate(string, opts = { user: true, wizard: true, value: true, template: false })
return string if string.blank?