Badges admin UI improvements.

* Query param to allow linking.
* Better handling of deleting unsaved badges.
* New badge list item style improvement.
This commit is contained in:
Vikhyat Korrapati 2014-05-19 10:50:57 +05:30
parent 4de700b49b
commit a25087b62a
3 changed files with 34 additions and 8 deletions

View File

@ -8,6 +8,15 @@
**/
Discourse.AdminBadgesController = Ember.ArrayController.extend({
itemController: 'adminBadge',
queryParams: ['badgeId'],
/**
ID of the currently selected badge.
@property badgeId
@type {Integer}
**/
badgeId: Em.computed.alias('selectedItem.id'),
/**
We don't allow setting a description if a translation for the given badge
@ -68,6 +77,13 @@ Discourse.AdminBadgesController = Ember.ArrayController.extend({
@method destroy
**/
destroy: function() {
// Delete immediately if the selected badge is new.
if (!this.get('selectedItem.id')) {
this.get('model').removeObject(this.get('selectedItem'));
this.set('selectedItem', null);
return;
}
var self = this;
return bootbox.confirm(I18n.t("admin.badges.delete_confirm"), I18n.t("no_value"), I18n.t("yes_value"), function(result) {
if (result) {

View File

@ -8,7 +8,7 @@
<a {{action selectBadge this}} {{bind-attr class="selected:active"}}>
{{displayName}}
{{#if newBadge}}
({{i18n filters.new.lower_title}})
<span class="list-badge">{{i18n filters.new.lower_title}}</span>
{{/if}}
</a>
</li>
@ -51,14 +51,14 @@
{{/if}}
</div>
{{#unless readOnly}}
<div>
<span>
{{input type="checkbox" checked=allow_title}}
{{i18n admin.badges.allow_title}}
</span>
</div>
<div>
<span>
{{input type="checkbox" checked=allow_title disabled=readOnly}}
{{i18n admin.badges.allow_title}}
</span>
</div>
{{#unless readOnly}}
<div class='buttons'>
<button {{action save}} {{bind-attr disabled=controller.disableSave}} class='btn btn-primary'>{{i18n admin.badges.save}}</button>
<span class='saving'>{{savingStatus}}</span>

View File

@ -326,6 +326,16 @@ section.details {
.badges {
.content-list ul {
margin-bottom: 10px;
.list-badge {
float: right;
font-size: 11px;
font-weight: normal;
padding: 0 6px;
color: $secondary;
background-color: scale-color($tertiary, $lightness: 50%);
border-radius: 3px;
}
}
.current-badge {