Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-22 17:30:29 +01:00
53 Zeilen
1,3 KiB
JavaScript
53 Zeilen
1,3 KiB
JavaScript
import Controller from "@ember/controller";
|
|
import CustomWizardCustomField from "../models/custom-wizard-custom-field";
|
|
|
|
export default Controller.extend({
|
|
messageKey: "create",
|
|
fieldKeys: ["klass", "type", "serializers", "name"],
|
|
documentationUrl: "https://thepavilion.io/t/3572",
|
|
|
|
actions: {
|
|
addField() {
|
|
this.get("customFields").pushObject(
|
|
CustomWizardCustomField.create({ edit: true })
|
|
);
|
|
},
|
|
|
|
saveField(field) {
|
|
return CustomWizardCustomField.saveField(field).then((result) => {
|
|
if (result.success) {
|
|
this.setProperties({
|
|
messageKey: "saved",
|
|
messageType: "success",
|
|
});
|
|
} else {
|
|
if (result.messages) {
|
|
this.setProperties({
|
|
messageKey: "error",
|
|
messageType: "error",
|
|
messageOpts: { messages: result.messages },
|
|
});
|
|
}
|
|
}
|
|
|
|
setTimeout(
|
|
() =>
|
|
this.setProperties({
|
|
messageKey: "create",
|
|
messageType: null,
|
|
messageOpts: null,
|
|
}),
|
|
10000
|
|
);
|
|
|
|
return result;
|
|
});
|
|
},
|
|
|
|
removeField(field) {
|
|
return CustomWizardCustomField.destroyField(field).then(() => {
|
|
this.get("customFields").removeObject(field);
|
|
});
|
|
},
|
|
},
|
|
});
|