delete tag group

This commit is contained in:
Neil Lalonde 2016-06-06 16:27:46 -04:00
parent 0181f22c70
commit aa3152530c
5 changed files with 30 additions and 2 deletions

View File

@ -1,7 +1,27 @@
export default Ember.Controller.extend({ export default Ember.Controller.extend({
needs: ['tagGroups'],
actions: { actions: {
save() { save() {
this.get('model').save(); this.get('model').save();
},
destroy() {
const self = this;
return bootbox.confirm(
I18n.t("tagging.groups.confirm_delete"),
I18n.t("no_value"),
I18n.t("yes_value"),
function(destroy) {
if (destroy) {
const c = self.controllerFor('tagGroups');
return self.get('model').destroy().then(function() {
c.removeObject(self.get('model'));
self.transitionToRoute('tagGroups');
});
}
}
);
} }
} }
}); });

View File

@ -7,7 +7,7 @@ const TagGroup = RestModel.extend({
return Ember.isEmpty(this.get('name')) || Ember.isEmpty(this.get('tag_names')) || this.get('saving'); return Ember.isEmpty(this.get('name')) || Ember.isEmpty(this.get('tag_names')) || this.get('saving');
}, },
save: function() { save() {
var url = "/tag_groups", var url = "/tag_groups",
self = this; self = this;
if (this.get('id')) { if (this.get('id')) {
@ -28,6 +28,10 @@ const TagGroup = RestModel.extend({
self.set('savingStatus', I18n.t('saved')); self.set('savingStatus', I18n.t('saved'));
self.set('saving', false); self.set('saving', false);
}); });
},
destroy() {
return Discourse.ajax("/tag_groups/" + this.get('id'), {type: "DELETE"});
} }
}); });

View File

@ -8,5 +8,6 @@
</div> </div>
<br/> <br/>
<button {{action "save"}} disabled={{model.disableSave}} class='btn'>{{i18n 'tagging.groups.save'}}</button> <button {{action "save"}} disabled={{model.disableSave}} class='btn'>{{i18n 'tagging.groups.save'}}</button>
<button {{action "destroy"}} class='btn btn-danger'><i class="fa fa-trash-o"></i> {{i18n 'tagging.groups.delete'}}</button>
<span class="saving {{unless model.savingStatus 'hidden'}}">{{model.savingStatus}}</span> <span class="saving {{unless model.savingStatus 'hidden'}}">{{model.savingStatus}}</span>
</div> </div>

View File

@ -229,7 +229,8 @@ header .discourse-tag {color: $tag-color !important; }
height: 150px !important; // to fight with select2.scss's important height: 150px !important; // to fight with select2.scss's important
} }
} }
.btn {margin-left: 10px;}
.saving { .saving {
margin-left: 10px; margin-left: 20px;
} }
} }

View File

@ -3014,6 +3014,8 @@ en:
tags_label: "Tags in this group:" tags_label: "Tags in this group:"
new_name: "New Tag Group" new_name: "New Tag Group"
save: "Save" save: "Save"
delete: "Delete"
confirm_delete: "Are you sure you want to delete this tag group?"
topics: topics:
none: none: