Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-26 02:50:28 +01:00
IMPROVE: Add value type to mapper selector
Dieser Commit ist enthalten in:
Ursprung
f908e5ec9d
Commit
5abc0f4a4c
4 geänderte Dateien mit 34 neuen und 6 gelöschten Zeilen
|
@ -24,6 +24,12 @@ const customFieldActionMap = {
|
||||||
user: ["update_profile"],
|
user: ["update_profile"],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const values = [
|
||||||
|
"present",
|
||||||
|
"true",
|
||||||
|
"false"
|
||||||
|
];
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
classNameBindings: [":mapper-selector", "activeType"],
|
classNameBindings: [":mapper-selector", "activeType"],
|
||||||
|
|
||||||
|
@ -60,6 +66,9 @@ export default Component.extend({
|
||||||
showCustomField: computed("activeType", function () {
|
showCustomField: computed("activeType", function () {
|
||||||
return this.showInput("customField");
|
return this.showInput("customField");
|
||||||
}),
|
}),
|
||||||
|
showValue: computed("activeType", function () {
|
||||||
|
return this.showInput("value");
|
||||||
|
}),
|
||||||
textEnabled: computed("options.textSelection", "inputType", function () {
|
textEnabled: computed("options.textSelection", "inputType", function () {
|
||||||
return this.optionEnabled("textSelection");
|
return this.optionEnabled("textSelection");
|
||||||
}),
|
}),
|
||||||
|
@ -117,6 +126,9 @@ export default Component.extend({
|
||||||
listEnabled: computed("options.listSelection", "inputType", function () {
|
listEnabled: computed("options.listSelection", "inputType", function () {
|
||||||
return this.optionEnabled("listSelection");
|
return this.optionEnabled("listSelection");
|
||||||
}),
|
}),
|
||||||
|
valueEnabled: computed("connector", function () {
|
||||||
|
return this.connector === "is";
|
||||||
|
}),
|
||||||
|
|
||||||
groups: alias("site.groups"),
|
groups: alias("site.groups"),
|
||||||
categories: alias("site.categories"),
|
categories: alias("site.categories"),
|
||||||
|
@ -125,7 +137,8 @@ export default Component.extend({
|
||||||
"showWizardAction",
|
"showWizardAction",
|
||||||
"showUserField",
|
"showUserField",
|
||||||
"showUserFieldOptions",
|
"showUserFieldOptions",
|
||||||
"showCustomField"
|
"showCustomField",
|
||||||
|
"showValue"
|
||||||
),
|
),
|
||||||
showMultiSelect: or("showCategory", "showGroup"),
|
showMultiSelect: or("showCategory", "showGroup"),
|
||||||
hasTypes: gt("selectorTypes.length", 1),
|
hasTypes: gt("selectorTypes.length", 1),
|
||||||
|
@ -157,7 +170,7 @@ export default Component.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@discourseComputed
|
@discourseComputed("connector")
|
||||||
selectorTypes() {
|
selectorTypes() {
|
||||||
return selectionTypes
|
return selectionTypes
|
||||||
.filter((type) => this[`${type}Enabled`])
|
.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;
|
return content;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -337,7 +357,7 @@ export default Component.extend({
|
||||||
resetActiveType() {
|
resetActiveType() {
|
||||||
this.set(
|
this.set(
|
||||||
"activeType",
|
"activeType",
|
||||||
defaultSelectionType(this.selectorType, this.options)
|
defaultSelectionType(this.selectorType, this.options, this.connector)
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -105,13 +105,18 @@ const selectionTypes = [
|
||||||
"tag",
|
"tag",
|
||||||
"user",
|
"user",
|
||||||
"customField",
|
"customField",
|
||||||
|
"value"
|
||||||
];
|
];
|
||||||
|
|
||||||
function defaultSelectionType(inputType, options = {}) {
|
function defaultSelectionType(inputType, options = {}, connector = null) {
|
||||||
if (options[`${inputType}DefaultSelection`]) {
|
if (options[`${inputType}DefaultSelection`]) {
|
||||||
return options[`${inputType}DefaultSelection`];
|
return options[`${inputType}DefaultSelection`];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (connector === "is") {
|
||||||
|
return "value";
|
||||||
|
}
|
||||||
|
|
||||||
let type = selectionTypes[0];
|
let type = selectionTypes[0];
|
||||||
|
|
||||||
for (let t of selectionTypes) {
|
for (let t of selectionTypes) {
|
||||||
|
|
|
@ -23,7 +23,8 @@
|
||||||
value=pair.value
|
value=pair.value
|
||||||
activeType=pair.value_type
|
activeType=pair.value_type
|
||||||
options=options
|
options=options
|
||||||
onUpdate=onUpdate}}
|
onUpdate=onUpdate
|
||||||
|
connector=pair.connector}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{#if showJoin}}
|
{{#if showJoin}}
|
||||||
|
|
|
@ -124,6 +124,7 @@ en:
|
||||||
group: "group"
|
group: "group"
|
||||||
list: "list"
|
list: "list"
|
||||||
custom_field: "custom field"
|
custom_field: "custom field"
|
||||||
|
value: "value"
|
||||||
|
|
||||||
placeholder:
|
placeholder:
|
||||||
text: "Enter text"
|
text: "Enter text"
|
||||||
|
@ -138,6 +139,7 @@ en:
|
||||||
group: "Select group"
|
group: "Select group"
|
||||||
list: "Enter item"
|
list: "Enter item"
|
||||||
custom_field: "Select field"
|
custom_field: "Select field"
|
||||||
|
value: "Select value"
|
||||||
|
|
||||||
error:
|
error:
|
||||||
failed: "failed to save wizard"
|
failed: "failed to save wizard"
|
||||||
|
|
Laden …
In neuem Issue referenzieren