Extract edit tag submit data for extensibility

This commit is contained in:
Toby Zerner 2016-11-19 22:12:53 +10:30
parent 6f9c6ea3dc
commit 6a363ef4f1
2 changed files with 23 additions and 14 deletions

View File

@ -768,6 +768,17 @@ System.register('flarum/tags/components/EditTagModal', ['flarum/components/Modal
)
);
}
}, {
key: 'submitData',
value: function submitData() {
return {
name: this.name(),
slug: this.slug(),
description: this.description(),
color: this.color(),
isHidden: this.isHidden()
};
}
}, {
key: 'onsubmit',
value: function onsubmit(e) {
@ -777,13 +788,7 @@ System.register('flarum/tags/components/EditTagModal', ['flarum/components/Modal
this.loading = true;
this.tag.save({
name: this.name(),
slug: this.slug(),
description: this.description(),
color: this.color(),
isHidden: this.isHidden()
}).then(function () {
this.tag.save(this.submitData()).then(function () {
return _this3.hide();
}, function (response) {
_this3.loading = false;

View File

@ -88,18 +88,22 @@ export default class EditTagModal extends Modal {
);
}
onsubmit(e) {
e.preventDefault();
this.loading = true;
this.tag.save({
submitData() {
return {
name: this.name(),
slug: this.slug(),
description: this.description(),
color: this.color(),
isHidden: this.isHidden()
}).then(
};
}
onsubmit(e) {
e.preventDefault();
this.loading = true;
this.tag.save(this.submitData()).then(
() => this.hide(),
response => {
this.loading = false;