Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-15 14:22:53 +01:00
WIP
https://thepavilion.io/t/add-group-user-field-and-type-selector-to-if-statements/3985
Dieser Commit ist enthalten in:
Ursprung
772392efae
Commit
ade8eaaeaa
7 geänderte Dateien mit 51 neuen und 2 gelöschten Zeilen
|
@ -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];
|
||||
},
|
||||
|
|
|
@ -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",
|
||||
];
|
||||
|
|
|
@ -274,6 +274,8 @@
|
|||
userFieldSelection="key,value,assignment"
|
||||
wizardActionSelection=true
|
||||
groupSelection="value,output"
|
||||
wizardUserSelection="key"
|
||||
groupUsersSelection="value"
|
||||
outputDefaultSelection="group"
|
||||
context="action"
|
||||
)}}
|
||||
|
|
|
@ -20,6 +20,10 @@
|
|||
</div>
|
||||
|
||||
<div class="input">
|
||||
{{#if showLabel}}
|
||||
<div class="label">{{i18n placeholderKey}}</div>
|
||||
{{/if}}
|
||||
|
||||
{{#if showText}}
|
||||
{{input
|
||||
type="text"
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -112,12 +112,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"
|
||||
|
||||
|
@ -126,12 +128,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"
|
||||
|
||||
|
@ -222,6 +226,7 @@ en:
|
|||
regex: '=~'
|
||||
association: '→'
|
||||
is: 'is'
|
||||
in: 'in'
|
||||
|
||||
action:
|
||||
header: "Actions"
|
||||
|
|
|
@ -32,7 +32,8 @@ class CustomWizard::Mapper
|
|||
present: "present?",
|
||||
true: "==",
|
||||
false: "=="
|
||||
}
|
||||
},
|
||||
in: 'in'
|
||||
}
|
||||
|
||||
def initialize(params)
|
||||
|
@ -138,6 +139,8 @@ class CustomWizard::Mapper
|
|||
elsif ["true", "false"].include?(value)
|
||||
result = key.public_send(operator, ActiveRecord::Type::Boolean.new.cast(value))
|
||||
end
|
||||
elsif operator === 'in'
|
||||
result = value.includes?(key)
|
||||
elsif [key, value, operator].all? { |i| !i.nil? }
|
||||
result = key.public_send(operator, value)
|
||||
else
|
||||
|
@ -213,6 +216,16 @@ class CustomWizard::Mapper
|
|||
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 })
|
||||
return string if string.blank?
|
||||
|
||||
|
|
Laden …
In neuem Issue referenzieren