0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-15 14:22:53 +01:00
angusmcleod 2021-04-19 17:38:35 +10:00
Ursprung 772392efae
Commit ade8eaaeaa
7 geänderte Dateien mit 51 neuen und 2 gelöschten Zeilen

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -175,6 +175,15 @@
overflow: hidden; 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 { .mapper-pairs {

Datei anzeigen

@ -112,12 +112,14 @@ en:
text: "text" text: "text"
wizard_field: "wizard field" wizard_field: "wizard field"
wizard_action: "wizard action" wizard_action: "wizard action"
wizard_user: "current user"
user_field: "user field" user_field: "user field"
user_field_options: "user field options" user_field_options: "user field options"
user: "user" user: "user"
category: "category" category: "category"
tag: "tag" tag: "tag"
group: "group" group: "group"
group_users: "group members"
list: "list" list: "list"
custom_field: "custom field" custom_field: "custom field"
@ -126,12 +128,14 @@ en:
property: "Select property" property: "Select property"
wizard_field: "Select field" wizard_field: "Select field"
wizard_action: "Select action" wizard_action: "Select action"
wizard_user: "Current user"
user_field: "Select field" user_field: "Select field"
user_field_options: "Select field" user_field_options: "Select field"
user: "Select user" user: "Select user"
category: "Select category" category: "Select category"
tag: "Select tag" tag: "Select tag"
group: "Select group" group: "Select group"
group_users: "Select group"
list: "Enter item" list: "Enter item"
custom_field: "Select field" custom_field: "Select field"
@ -222,6 +226,7 @@ en:
regex: '=~' regex: '=~'
association: '→' association: '→'
is: 'is' is: 'is'
in: 'in'
action: action:
header: "Actions" header: "Actions"

Datei anzeigen

@ -32,7 +32,8 @@ class CustomWizard::Mapper
present: "present?", present: "present?",
true: "==", true: "==",
false: "==" false: "=="
} },
in: 'in'
} }
def initialize(params) def initialize(params)
@ -138,6 +139,8 @@ class CustomWizard::Mapper
elsif ["true", "false"].include?(value) elsif ["true", "false"].include?(value)
result = key.public_send(operator, ActiveRecord::Type::Boolean.new.cast(value)) result = key.public_send(operator, ActiveRecord::Type::Boolean.new.cast(value))
end end
elsif operator === 'in'
result = value.includes?(key)
elsif [key, value, operator].all? { |i| !i.nil? } elsif [key, value, operator].all? { |i| !i.nil? }
result = key.public_send(operator, value) result = key.public_send(operator, value)
else else
@ -213,6 +216,16 @@ class CustomWizard::Mapper
end end
end end
def map_current_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 }) def interpolate(string, opts = { user: true, wizard: true, value: true, template: false })
return string if string.blank? return string if string.blank?