UX: Add saving status to groups admin.

This commit is contained in:
Guo Xiang Tan 2015-12-28 11:21:07 +08:00
parent 2fd228d95a
commit 778ae06000
3 changed files with 9 additions and 3 deletions

View File

@ -4,6 +4,7 @@ import { propertyEqual } from 'discourse/lib/computed';
export default Ember.Controller.extend({ export default Ember.Controller.extend({
needs: ['adminGroupsType'], needs: ['adminGroupsType'],
disableSave: false, disableSave: false,
savingStatus: '',
currentPage: function() { currentPage: function() {
if (this.get("model.user_count") === 0) { return 0; } if (this.get("model.user_count") === 0) { return 0; }
@ -95,12 +96,15 @@ export default Ember.Controller.extend({
groupType = groupsController.get("type"); groupType = groupsController.get("type");
this.set('disableSave', true); this.set('disableSave', true);
this.set('savingStatus', I18n.t('saving'));
let promise = group.get("id") ? group.save() : group.create().then(() => groupsController.addObject(group)); let promise = group.get("id") ? group.save() : group.create().then(() => groupsController.addObject(group));
promise.then(() => this.transitionToRoute("adminGroup", groupType, group.get('name'))) promise.then(() => {
.catch(popupAjaxError) this.transitionToRoute("adminGroup", groupType, group.get('name'));
.finally(() => this.set('disableSave', false)); this.set('savingStatus', I18n.t('saved'));
}).catch(popupAjaxError)
.finally(() => this.set('disableSave', false));
}, },
destroy() { destroy() {

View File

@ -21,6 +21,7 @@ export default Discourse.Route.extend({
setupController: function(controller, model) { setupController: function(controller, model) {
controller.set("model", model); controller.set("model", model);
controller.set("model.usernames", null); controller.set("model.usernames", null);
controller.set("savingStatus", '');
model.findMembers(); model.findMembers();
} }

View File

@ -106,6 +106,7 @@
{{#unless model.automatic}} {{#unless model.automatic}}
<button {{action "destroy"}} class='btn btn-danger'>{{fa-icon "trash-o"}}{{i18n 'admin.customize.delete'}}</button> <button {{action "destroy"}} class='btn btn-danger'>{{fa-icon "trash-o"}}{{i18n 'admin.customize.delete'}}</button>
{{/unless}} {{/unless}}
<span {{bind-attr class=":saving savingStatus::hidden"}}>{{savingStatus}}</span>
</div> </div>
</form> </form>