FIX: error when trying to create new tag groups
This commit is contained in:
parent
1ffbd9b4f6
commit
a82182e1e3
|
@ -1,3 +1,5 @@
|
||||||
|
import TagGroup from 'discourse/models/tag-group';
|
||||||
|
|
||||||
export default Ember.Controller.extend({
|
export default Ember.Controller.extend({
|
||||||
actions: {
|
actions: {
|
||||||
selectTagGroup(tagGroup) {
|
selectTagGroup(tagGroup) {
|
||||||
|
@ -9,8 +11,7 @@ export default Ember.Controller.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
newTagGroup() {
|
newTagGroup() {
|
||||||
const newTagGroup = this.store.createRecord('tag-group');
|
const newTagGroup = TagGroup.create({ id: 'new', name: I18n.t('tagging.groups.new_name') });
|
||||||
newTagGroup.set('name', I18n.t('tagging.groups.new_name'));
|
|
||||||
this.get('model').pushObject(newTagGroup);
|
this.get('model').pushObject(newTagGroup);
|
||||||
this.send('selectTagGroup', newTagGroup);
|
this.send('selectTagGroup', newTagGroup);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,9 +9,10 @@ const TagGroup = RestModel.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
save() {
|
save() {
|
||||||
var url = "/tag_groups",
|
let url = "/tag_groups";
|
||||||
self = this;
|
const self = this,
|
||||||
if (this.get('id')) {
|
isNew = this.get('id') === 'new';
|
||||||
|
if (!isNew) {
|
||||||
url = "/tag_groups/" + this.get('id');
|
url = "/tag_groups/" + this.get('id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,9 +26,11 @@ const TagGroup = RestModel.extend({
|
||||||
parent_tag_name: this.get('parent_tag_name') ? this.get('parent_tag_name') : undefined,
|
parent_tag_name: this.get('parent_tag_name') ? this.get('parent_tag_name') : undefined,
|
||||||
one_per_topic: this.get('one_per_topic')
|
one_per_topic: this.get('one_per_topic')
|
||||||
},
|
},
|
||||||
type: this.get('id') ? 'PUT' : 'POST'
|
type: isNew ? 'POST' : 'PUT'
|
||||||
}).then(function(result) {
|
}).then(function(result) {
|
||||||
if(result.id) { self.set('id', result.id); }
|
if(result.tag_group && result.tag_group.id) {
|
||||||
|
self.set('id', result.tag_group.id);
|
||||||
|
}
|
||||||
self.set('savingStatus', I18n.t('saved'));
|
self.set('savingStatus', I18n.t('saved'));
|
||||||
self.set('saving', false);
|
self.set('saving', false);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue