diff --git a/app/assets/javascripts/admin/controllers/admin_badges_controller.js b/app/assets/javascripts/admin/controllers/admin_badges_controller.js index 705aad553..1cf2615ad 100644 --- a/app/assets/javascripts/admin/controllers/admin_badges_controller.js +++ b/app/assets/javascripts/admin/controllers/admin_badges_controller.js @@ -26,6 +26,14 @@ Discourse.AdminBadgesController = Ember.ArrayController.extend({ **/ canEditDescription: Em.computed.none('selectedItem.translatedDescription'), + /** + Disable saving if the currently selected item is being saved. + + @property disableSave + @type {Boolean} + **/ + disableSave: Em.computed.alias('selectedItem.saving'), + actions: { /** @@ -57,11 +65,9 @@ Discourse.AdminBadgesController = Ember.ArrayController.extend({ @method save **/ save: function() { - var badge = this.get('selectedItem'); - badge.set('disableSave', true); - badge.save().then(function() { - badge.set('disableSave', false); - }); + if (!this.get('disableSave')) { + this.get('selectedItem').save(); + } }, /** diff --git a/app/assets/javascripts/admin/templates/badges.js.handlebars b/app/assets/javascripts/admin/templates/badges.js.handlebars index ff39e7418..e11ba2ff7 100644 --- a/app/assets/javascripts/admin/templates/badges.js.handlebars +++ b/app/assets/javascripts/admin/templates/badges.js.handlebars @@ -8,7 +8,7 @@ {{displayName}} {{#if newBadge}} - (*) + ({{i18n filters.new.lower_title}}) {{/if}} @@ -19,7 +19,7 @@ {{#if selectedItem}} {{#with selectedItem}} -
+
@@ -51,7 +51,8 @@
- + + {{savingStatus}} {{i18n admin.badges.delete}}
diff --git a/app/assets/javascripts/discourse/models/badge.js b/app/assets/javascripts/discourse/models/badge.js index 0845892eb..3a4ad3b87 100644 --- a/app/assets/javascripts/discourse/models/badge.js +++ b/app/assets/javascripts/discourse/models/badge.js @@ -79,14 +79,19 @@ Discourse.Badge = Discourse.Model.extend({ @returns {Promise} A promise that resolves to the updated `Discourse.Badge` **/ save: function() { + this.set('savingStatus', I18n.t('saving')); + this.set('saving', true); + var url = "/admin/badges", requestType = "POST", self = this; + if (!this.get('newBadge')) { // We are updating an existing badge. url += "/" + this.get('id'); requestType = "PUT"; } + return Discourse.ajax(url, { type: requestType, data: { @@ -96,6 +101,8 @@ Discourse.Badge = Discourse.Model.extend({ } }).then(function(json) { self.updateFromJson(json); + self.set('savingStatus', I18n.t('saved')); + self.set('saving', false); return self; }); }, diff --git a/app/assets/stylesheets/common/admin/admin_base.scss b/app/assets/stylesheets/common/admin/admin_base.scss index 7a69efcd8..932612e10 100644 --- a/app/assets/stylesheets/common/admin/admin_base.scss +++ b/app/assets/stylesheets/common/admin/admin_base.scss @@ -306,6 +306,25 @@ section.details { margin-left: 15px; margin-top: 5px; } + + input, textarea, select { + width: 350px; + } + + textarea { + height: 200px; + } + } + + .buttons { + float: left; + width: 200px; + .saving { + padding: 5px 0 0 0; + margin-left: 10px; + width: 80px; + color: $secondary_text_color; + } } }