mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
Merge pull request #2146 from vikhyat/badge-system
Badge creation UI improvements
This commit is contained in:
commit
eab30d1c28
6 changed files with 49 additions and 10 deletions
|
@ -26,6 +26,14 @@ Discourse.AdminBadgesController = Ember.ArrayController.extend({
|
||||||
**/
|
**/
|
||||||
canEditDescription: Em.computed.none('selectedItem.translatedDescription'),
|
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: {
|
actions: {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -57,11 +65,9 @@ Discourse.AdminBadgesController = Ember.ArrayController.extend({
|
||||||
@method save
|
@method save
|
||||||
**/
|
**/
|
||||||
save: function() {
|
save: function() {
|
||||||
var badge = this.get('selectedItem');
|
if (!this.get('disableSave')) {
|
||||||
badge.set('disableSave', true);
|
this.get('selectedItem').save();
|
||||||
badge.save().then(function() {
|
}
|
||||||
badge.set('disableSave', false);
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -6,4 +6,8 @@
|
||||||
@namespace Discourse
|
@namespace Discourse
|
||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
Discourse.AdminController = Discourse.Controller.extend({});
|
Discourse.AdminController = Discourse.Controller.extend({
|
||||||
|
showBadges: function() {
|
||||||
|
return this.get('currentUser.admin') && Discourse.SiteSettings.enable_badges;
|
||||||
|
}.property()
|
||||||
|
});
|
||||||
|
|
|
@ -14,6 +14,9 @@
|
||||||
<li>{{#link-to 'adminSiteContents'}}{{i18n admin.site_content.title}}{{/link-to}}</li>
|
<li>{{#link-to 'adminSiteContents'}}{{i18n admin.site_content.title}}{{/link-to}}</li>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<li>{{#link-to 'adminUsersList'}}{{i18n admin.users.title}}{{/link-to}}</li>
|
<li>{{#link-to 'adminUsersList'}}{{i18n admin.users.title}}{{/link-to}}</li>
|
||||||
|
{{#if showBadges}}
|
||||||
|
<li>{{#link-to 'admin.badges'}}{{i18n admin.badges.title}}{{/link-to}}</li>
|
||||||
|
{{/if}}
|
||||||
{{#if currentUser.admin}}
|
{{#if currentUser.admin}}
|
||||||
<li>{{#link-to 'admin.groups'}}{{i18n admin.groups.title}}{{/link-to}}</li>
|
<li>{{#link-to 'admin.groups'}}{{i18n admin.groups.title}}{{/link-to}}</li>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
@ -24,7 +27,6 @@
|
||||||
<li>{{#link-to 'admin.customize'}}{{i18n admin.customize.title}}{{/link-to}}</li>
|
<li>{{#link-to 'admin.customize'}}{{i18n admin.customize.title}}{{/link-to}}</li>
|
||||||
<li>{{#link-to 'admin.api'}}{{i18n admin.api.title}}{{/link-to}}</li>
|
<li>{{#link-to 'admin.api'}}{{i18n admin.api.title}}{{/link-to}}</li>
|
||||||
<li>{{#link-to 'admin.backups'}}{{i18n admin.backups.title}}{{/link-to}}</li>
|
<li>{{#link-to 'admin.backups'}}{{i18n admin.backups.title}}{{/link-to}}</li>
|
||||||
<li>{{#link-to 'admin.badges'}}{{i18n admin.badges.title}}{{/link-to}}</li>
|
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<a {{action selectBadge this}} {{bind-attr class="selected:active"}}>
|
<a {{action selectBadge this}} {{bind-attr class="selected:active"}}>
|
||||||
{{displayName}}
|
{{displayName}}
|
||||||
{{#if newBadge}}
|
{{#if newBadge}}
|
||||||
(*)
|
({{i18n filters.new.lower_title}})
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
{{#if selectedItem}}
|
{{#if selectedItem}}
|
||||||
{{#with selectedItem}}
|
{{#with selectedItem}}
|
||||||
<div class='current-badge span12'>
|
<div class='current-badge span13'>
|
||||||
<form class="form-horizontal">
|
<form class="form-horizontal">
|
||||||
<div>
|
<div>
|
||||||
<label for="name">{{i18n admin.badges.name}}</label>
|
<label for="name">{{i18n admin.badges.name}}</label>
|
||||||
|
@ -51,7 +51,8 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class='buttons'>
|
<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>
|
<a {{action destroy}} class='delete-link'>{{i18n admin.badges.delete}}</a>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -79,14 +79,19 @@ Discourse.Badge = Discourse.Model.extend({
|
||||||
@returns {Promise} A promise that resolves to the updated `Discourse.Badge`
|
@returns {Promise} A promise that resolves to the updated `Discourse.Badge`
|
||||||
**/
|
**/
|
||||||
save: function() {
|
save: function() {
|
||||||
|
this.set('savingStatus', I18n.t('saving'));
|
||||||
|
this.set('saving', true);
|
||||||
|
|
||||||
var url = "/admin/badges",
|
var url = "/admin/badges",
|
||||||
requestType = "POST",
|
requestType = "POST",
|
||||||
self = this;
|
self = this;
|
||||||
|
|
||||||
if (!this.get('newBadge')) {
|
if (!this.get('newBadge')) {
|
||||||
// We are updating an existing badge.
|
// We are updating an existing badge.
|
||||||
url += "/" + this.get('id');
|
url += "/" + this.get('id');
|
||||||
requestType = "PUT";
|
requestType = "PUT";
|
||||||
}
|
}
|
||||||
|
|
||||||
return Discourse.ajax(url, {
|
return Discourse.ajax(url, {
|
||||||
type: requestType,
|
type: requestType,
|
||||||
data: {
|
data: {
|
||||||
|
@ -96,6 +101,8 @@ Discourse.Badge = Discourse.Model.extend({
|
||||||
}
|
}
|
||||||
}).then(function(json) {
|
}).then(function(json) {
|
||||||
self.updateFromJson(json);
|
self.updateFromJson(json);
|
||||||
|
self.set('savingStatus', I18n.t('saved'));
|
||||||
|
self.set('saving', false);
|
||||||
return self;
|
return self;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -306,6 +306,25 @@ section.details {
|
||||||
margin-left: 15px;
|
margin-left: 15px;
|
||||||
margin-top: 5px;
|
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