From aa3152530ce690bb321aac3f616ffbed6a119b6b Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Mon, 6 Jun 2016 16:27:46 -0400 Subject: [PATCH] delete tag group --- .../controllers/tag-groups-show.js.es6 | 20 +++++++++++++++++++ .../discourse/models/tag-group.js.es6 | 6 +++++- .../discourse/templates/tag-groups-show.hbs | 1 + .../stylesheets/common/base/tagging.scss | 3 ++- config/locales/client.en.yml | 2 ++ 5 files changed, 30 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/discourse/controllers/tag-groups-show.js.es6 b/app/assets/javascripts/discourse/controllers/tag-groups-show.js.es6 index 1def5910f..1eca5728a 100644 --- a/app/assets/javascripts/discourse/controllers/tag-groups-show.js.es6 +++ b/app/assets/javascripts/discourse/controllers/tag-groups-show.js.es6 @@ -1,7 +1,27 @@ export default Ember.Controller.extend({ + needs: ['tagGroups'], + actions: { 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'); + }); + } + } + ); } } }); diff --git a/app/assets/javascripts/discourse/models/tag-group.js.es6 b/app/assets/javascripts/discourse/models/tag-group.js.es6 index 2bebcc333..6ab079c37 100644 --- a/app/assets/javascripts/discourse/models/tag-group.js.es6 +++ b/app/assets/javascripts/discourse/models/tag-group.js.es6 @@ -7,7 +7,7 @@ const TagGroup = RestModel.extend({ return Ember.isEmpty(this.get('name')) || Ember.isEmpty(this.get('tag_names')) || this.get('saving'); }, - save: function() { + save() { var url = "/tag_groups", self = this; if (this.get('id')) { @@ -28,6 +28,10 @@ const TagGroup = RestModel.extend({ self.set('savingStatus', I18n.t('saved')); self.set('saving', false); }); + }, + + destroy() { + return Discourse.ajax("/tag_groups/" + this.get('id'), {type: "DELETE"}); } }); diff --git a/app/assets/javascripts/discourse/templates/tag-groups-show.hbs b/app/assets/javascripts/discourse/templates/tag-groups-show.hbs index e2555d40e..aec3ce6e5 100644 --- a/app/assets/javascripts/discourse/templates/tag-groups-show.hbs +++ b/app/assets/javascripts/discourse/templates/tag-groups-show.hbs @@ -8,5 +8,6 @@
+ {{model.savingStatus}} \ No newline at end of file diff --git a/app/assets/stylesheets/common/base/tagging.scss b/app/assets/stylesheets/common/base/tagging.scss index c1ed04ec9..3d90c7709 100644 --- a/app/assets/stylesheets/common/base/tagging.scss +++ b/app/assets/stylesheets/common/base/tagging.scss @@ -229,7 +229,8 @@ header .discourse-tag {color: $tag-color !important; } height: 150px !important; // to fight with select2.scss's important } } + .btn {margin-left: 10px;} .saving { - margin-left: 10px; + margin-left: 20px; } } \ No newline at end of file diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index b9e43f883..1cbcce0e7 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -3014,6 +3014,8 @@ en: tags_label: "Tags in this group:" new_name: "New Tag Group" save: "Save" + delete: "Delete" + confirm_delete: "Are you sure you want to delete this tag group?" topics: none: