2020-10-17 03:31:07 +02:00
|
|
|
import Controller from "@ember/controller";
|
|
|
|
import EmberObject from '@ember/object';
|
|
|
|
import { ajax } from 'discourse/lib/ajax';
|
|
|
|
import { popupAjaxError } from 'discourse/lib/ajax-error';
|
2020-11-08 04:24:20 +01:00
|
|
|
import CustomWizardCustomField from "../models/custom-wizard-custom-field";
|
2020-10-17 03:31:07 +02:00
|
|
|
|
|
|
|
export default Controller.extend({
|
2020-10-20 07:40:23 +02:00
|
|
|
fieldKeys: ['klass', 'type', 'serializers', 'name'],
|
2020-11-08 04:24:20 +01:00
|
|
|
documentationUrl: "https://thepavilion.io/t/3572",
|
2020-10-17 03:31:07 +02:00
|
|
|
|
|
|
|
actions: {
|
|
|
|
addField() {
|
|
|
|
this.get('customFields').pushObject(
|
2020-11-08 04:24:20 +01:00
|
|
|
CustomWizardCustomField.create()
|
2020-10-17 03:31:07 +02:00
|
|
|
);
|
|
|
|
},
|
|
|
|
|
2020-10-20 07:40:23 +02:00
|
|
|
removeField(field) {
|
|
|
|
this.get('customFields').removeObject(field);
|
|
|
|
},
|
|
|
|
|
|
|
|
saveFields() {
|
|
|
|
this.set('saving', true);
|
2020-11-08 04:24:20 +01:00
|
|
|
CustomWizardCustomField.saveFields(this.customFields)
|
|
|
|
.then(result => {
|
|
|
|
if (result.success) {
|
|
|
|
this.set('saveIcon', 'check');
|
|
|
|
} else {
|
|
|
|
this.set('saveIcon', 'times');
|
|
|
|
}
|
|
|
|
setTimeout(() => this.set('saveIcon', ''), 5000);
|
|
|
|
}).finally(() => {
|
|
|
|
this.set('saving', false);
|
|
|
|
});
|
2020-10-17 03:31:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|