0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-22 09:20:29 +01:00

IMPROVE: Add value type to mapper selector

Dieser Commit ist enthalten in:
angusmcleod 2021-10-20 21:56:34 +08:00
Ursprung f908e5ec9d
Commit 5abc0f4a4c
4 geänderte Dateien mit 34 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -24,6 +24,12 @@ const customFieldActionMap = {
user: ["update_profile"],
};
const values = [
"present",
"true",
"false"
];
export default Component.extend({
classNameBindings: [":mapper-selector", "activeType"],
@ -60,6 +66,9 @@ export default Component.extend({
showCustomField: computed("activeType", function () {
return this.showInput("customField");
}),
showValue: computed("activeType", function () {
return this.showInput("value");
}),
textEnabled: computed("options.textSelection", "inputType", function () {
return this.optionEnabled("textSelection");
}),
@ -117,6 +126,9 @@ export default Component.extend({
listEnabled: computed("options.listSelection", "inputType", function () {
return this.optionEnabled("listSelection");
}),
valueEnabled: computed("connector", function () {
return this.connector === "is";
}),
groups: alias("site.groups"),
categories: alias("site.categories"),
@ -125,7 +137,8 @@ export default Component.extend({
"showWizardAction",
"showUserField",
"showUserFieldOptions",
"showCustomField"
"showCustomField",
"showValue"
),
showMultiSelect: or("showCategory", "showGroup"),
hasTypes: gt("selectorTypes.length", 1),
@ -157,7 +170,7 @@ export default Component.extend({
}
},
@discourseComputed
@discourseComputed("connector")
selectorTypes() {
return selectionTypes
.filter((type) => this[`${type}Enabled`])
@ -268,6 +281,13 @@ export default Component.extend({
}));
}
if (activeType === "value") {
content = values.map((value) => ({
id: value,
name: value
}));
}
return content;
},
@ -337,7 +357,7 @@ export default Component.extend({
resetActiveType() {
this.set(
"activeType",
defaultSelectionType(this.selectorType, this.options)
defaultSelectionType(this.selectorType, this.options, this.connector)
);
},

Datei anzeigen

@ -105,13 +105,18 @@ const selectionTypes = [
"tag",
"user",
"customField",
"value"
];
function defaultSelectionType(inputType, options = {}) {
function defaultSelectionType(inputType, options = {}, connector = null) {
if (options[`${inputType}DefaultSelection`]) {
return options[`${inputType}DefaultSelection`];
}
if (connector === "is") {
return "value";
}
let type = selectionTypes[0];
for (let t of selectionTypes) {

Datei anzeigen

@ -23,7 +23,8 @@
value=pair.value
activeType=pair.value_type
options=options
onUpdate=onUpdate}}
onUpdate=onUpdate
connector=pair.connector}}
</div>
{{#if showJoin}}

Datei anzeigen

@ -124,6 +124,7 @@ en:
group: "group"
list: "list"
custom_field: "custom field"
value: "value"
placeholder:
text: "Enter text"
@ -138,7 +139,8 @@ en:
group: "Select group"
list: "Enter item"
custom_field: "Select field"
value: "Select value"
error:
failed: "failed to save wizard"
required: "{{type}} requires {{property}}"