mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
Badge creation UI improvements.
This commit is contained in:
parent
a4461022a3
commit
89d3835d64
4 changed files with 41 additions and 8 deletions
|
@ -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();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<a {{action selectBadge this}} {{bind-attr class="selected:active"}}>
|
||||
{{displayName}}
|
||||
{{#if newBadge}}
|
||||
(*)
|
||||
({{i18n filters.new.lower_title}})
|
||||
{{/if}}
|
||||
</a>
|
||||
</li>
|
||||
|
@ -19,7 +19,7 @@
|
|||
|
||||
{{#if selectedItem}}
|
||||
{{#with selectedItem}}
|
||||
<div class='current-badge span12'>
|
||||
<div class='current-badge span13'>
|
||||
<form class="form-horizontal">
|
||||
<div>
|
||||
<label for="name">{{i18n admin.badges.name}}</label>
|
||||
|
@ -51,7 +51,8 @@
|
|||
</div>
|
||||
|
||||
<div class='buttons'>
|
||||
<button {{action save}} {{bind-attr disabled=disableSave}} class='btn btn-primary'>{{i18n admin.badges.save}}</button>
|
||||
<button {{action save}} {{bind-attr disabled=controller.disableSave}} class='btn btn-primary'>{{i18n admin.badges.save}}</button>
|
||||
<span class='saving'>{{savingStatus}}</span>
|
||||
<a {{action destroy}} class='delete-link'>{{i18n admin.badges.delete}}</a>
|
||||
</div>
|
||||
</form>
|
||||
|
|
|
@ -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;
|
||||
});
|
||||
},
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue