Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-22 17:30:29 +01:00
custom field input: further make generic, fix serializers dropdown
Dieser Commit ist enthalten in:
Ursprung
a3d59caee8
Commit
bd5edaffe9
2 geänderte Dateien mit 37 neuen und 41 gelöschten Zeilen
|
@ -8,6 +8,22 @@ import wizardSchema, {
|
||||||
subscriptionLevel,
|
subscriptionLevel,
|
||||||
} from "discourse/plugins/discourse-custom-wizard/discourse/lib/wizard-schema";
|
} from "discourse/plugins/discourse-custom-wizard/discourse/lib/wizard-schema";
|
||||||
|
|
||||||
|
const generateContent = function (kategory, subscription) {
|
||||||
|
let unsubscribedCustomFields = requiringAdditionalSubscription(
|
||||||
|
subscription, "custom_fields", kategory
|
||||||
|
);
|
||||||
|
return wizardSchema.custom_field[kategory].reduce((result, item) => {
|
||||||
|
let disabled = unsubscribedCustomFields.includes(item);
|
||||||
|
result.push({
|
||||||
|
id: item,
|
||||||
|
name: I18n.t(`admin.wizard.custom_field.${kategory}.${item}`),
|
||||||
|
subscription: subscriptionLevel(item, "custom_fields", kategory),
|
||||||
|
disabled,
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}, []);
|
||||||
|
};
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
tagName: "tr",
|
tagName: "tr",
|
||||||
topicSerializers: ["topic_view", "topic_list_item"],
|
topicSerializers: ["topic_view", "topic_list_item"],
|
||||||
|
@ -25,49 +41,29 @@ export default Component.extend({
|
||||||
this.set("originalField", JSON.parse(JSON.stringify(this.field)));
|
this.set("originalField", JSON.parse(JSON.stringify(this.field)));
|
||||||
},
|
},
|
||||||
|
|
||||||
// @discourseComputed("field.klass")
|
@discourseComputed("field.klass")
|
||||||
// serializerContent(klass) {
|
serializerContent(klass) {
|
||||||
// const serializers = this.get(`${klass}Serializers`);
|
const serializers = this.get(`${klass}Serializers`);
|
||||||
|
|
||||||
// if (serializers) {
|
if (serializers) {
|
||||||
// return generateContent(serializers, "serializers", this.subscribed);
|
return serializers.reduce((result, key) => {
|
||||||
// } else {
|
|
||||||
// return [];
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
|
|
||||||
@discourseComputed("subscription")
|
|
||||||
customFieldTypes(subscription) {
|
|
||||||
let unsubscribedCustomFields = requiringAdditionalSubscription(
|
|
||||||
subscription, "custom_fields", "types"
|
|
||||||
);
|
|
||||||
return wizardSchema.custom_field.types.reduce((result, type) => {
|
|
||||||
let disabled = unsubscribedCustomFields.includes(type);
|
|
||||||
result.push({
|
result.push({
|
||||||
id: type,
|
id: key,
|
||||||
name: I18n.t(`admin.wizard.custom_field.type.${type}`),
|
name: I18n.t(`admin.wizard.custom_field.serializers.${key}`),
|
||||||
subscription: subscriptionLevel(type, "custom_fields", "types"),
|
|
||||||
disabled,
|
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
}, []);
|
}, []);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
@discourseComputed("subscription")
|
||||||
|
customFieldTypes(subscription) {
|
||||||
|
return generateContent("type", this.subscription);
|
||||||
},
|
},
|
||||||
|
|
||||||
@discourseComputed("subscription")
|
@discourseComputed("subscription")
|
||||||
customFieldKlasses(subscription) {
|
customFieldKlasses(subscription) {
|
||||||
let unsubscribedCustomFields = requiringAdditionalSubscription(
|
return generateContent("klass", this.subscription);
|
||||||
subscription, "custom_fields", "klasses"
|
|
||||||
);
|
|
||||||
return wizardSchema.custom_field.klasses.reduce((result, klass) => {
|
|
||||||
let disabled = unsubscribedCustomFields.includes(klass);
|
|
||||||
result.push({
|
|
||||||
id: klass,
|
|
||||||
name: I18n.t(`admin.wizard.custom_field.klass.${klass}`),
|
|
||||||
subscription: subscriptionLevel(klass, "custom_fields", "klasses"),
|
|
||||||
disabled,
|
|
||||||
});
|
|
||||||
return result;
|
|
||||||
}, []);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
@observes("field.klass")
|
@observes("field.klass")
|
||||||
|
|
|
@ -198,24 +198,24 @@ const action = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const custom_field = {
|
const custom_field = {
|
||||||
klasses: ["topic", "post", "group", "category"],
|
klass: ["topic", "post", "group", "category"],
|
||||||
types: ["string", "boolean", "integer", "json"],
|
type: ["string", "boolean", "integer", "json"],
|
||||||
};
|
};
|
||||||
|
|
||||||
const subscription_levels = {
|
const subscription_levels = {
|
||||||
standard: {
|
standard: {
|
||||||
actions: ["send_message", "add_to_group", "watch_categories"],
|
actions: ["send_message", "add_to_group", "watch_categories"],
|
||||||
custom_fields: {
|
custom_fields: {
|
||||||
klasses: [],
|
klass: [],
|
||||||
types: ["json"]
|
type: ["json"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
business: {
|
business: {
|
||||||
actions: ["create_category", "create_group", "send_to_api"],
|
actions: ["create_category", "create_group", "send_to_api"],
|
||||||
custom_fields: {
|
custom_fields: {
|
||||||
klasses: ["group", "category"],
|
klass: ["group", "category"],
|
||||||
types: []
|
type: []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Laden …
In neuem Issue referenzieren