mirror of
https://github.com/discourse/discourse.git
synced 2024-11-30 14:26:12 +08:00
39 lines
877 B
JavaScript
39 lines
877 B
JavaScript
|
import RestModel from "discourse/models/rest";
|
||
|
import { ajax } from "discourse/lib/ajax";
|
||
|
|
||
|
export default class FormTemplate extends RestModel {}
|
||
|
|
||
|
FormTemplate.reopenClass({
|
||
|
createTemplate(data) {
|
||
|
return ajax("/admin/customize/form-templates.json", {
|
||
|
type: "POST",
|
||
|
data,
|
||
|
});
|
||
|
},
|
||
|
|
||
|
updateTemplate(id, data) {
|
||
|
return ajax(`/admin/customize/form-templates/${id}.json`, {
|
||
|
type: "PUT",
|
||
|
data,
|
||
|
});
|
||
|
},
|
||
|
|
||
|
deleteTemplate(id) {
|
||
|
return ajax(`/admin/customize/form-templates/${id}.json`, {
|
||
|
type: "DELETE",
|
||
|
});
|
||
|
},
|
||
|
|
||
|
findAll() {
|
||
|
return ajax(`/admin/customize/form-templates.json`).then((model) => {
|
||
|
return model.form_templates.sort((a, b) => a.id - b.id);
|
||
|
});
|
||
|
},
|
||
|
|
||
|
findById(id) {
|
||
|
return ajax(`/admin/customize/form-templates/${id}.json`).then((model) => {
|
||
|
return model.form_template;
|
||
|
});
|
||
|
},
|
||
|
});
|