mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 03:08:35 +08:00
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({
|
||||
actions: {
|
||||
selectTagGroup(tagGroup) {
|
||||
|
@ -9,8 +11,7 @@ export default Ember.Controller.extend({
|
|||
},
|
||||
|
||||
newTagGroup() {
|
||||
const newTagGroup = this.store.createRecord('tag-group');
|
||||
newTagGroup.set('name', I18n.t('tagging.groups.new_name'));
|
||||
const newTagGroup = TagGroup.create({ id: 'new', name: I18n.t('tagging.groups.new_name') });
|
||||
this.get('model').pushObject(newTagGroup);
|
||||
this.send('selectTagGroup', newTagGroup);
|
||||
}
|
||||
|
|
|
@ -9,9 +9,10 @@ const TagGroup = RestModel.extend({
|
|||
},
|
||||
|
||||
save() {
|
||||
var url = "/tag_groups",
|
||||
self = this;
|
||||
if (this.get('id')) {
|
||||
let url = "/tag_groups";
|
||||
const self = this,
|
||||
isNew = this.get('id') === 'new';
|
||||
if (!isNew) {
|
||||
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,
|
||||
one_per_topic: this.get('one_per_topic')
|
||||
},
|
||||
type: this.get('id') ? 'PUT' : 'POST'
|
||||
type: isNew ? 'POST' : 'PUT'
|
||||
}).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('saving', false);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user