0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-25 10:40:28 +01:00
discourse-custom-wizard/assets/javascripts/discourse/models/custom-wizard-custom-field.js.es6

34 Zeilen
767 B
Text

import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error";
import EmberObject from "@ember/object";
import { isEmpty } from "@ember/utils";
const CustomWizardCustomField = EmberObject.extend({
isNew: isEmpty("id"),
});
const basePath = "/admin/wizards/custom-fields";
CustomWizardCustomField.reopenClass({
listFields() {
return ajax(basePath).catch(popupAjaxError);
},
2020-11-10 01:56:11 +01:00
saveField(customField) {
return ajax(basePath, {
type: "PUT",
2020-11-10 01:56:11 +01:00
data: {
custom_field: customField,
},
}).catch(popupAjaxError);
2020-11-09 11:44:32 +01:00
},
2020-11-10 01:56:11 +01:00
destroyField(field) {
2020-11-09 11:44:32 +01:00
return ajax(`${basePath}/${field.name}`, {
type: "DELETE",
2020-11-09 11:44:32 +01:00
}).catch(popupAjaxError);
},
});
export default CustomWizardCustomField;