From 3135fb97613ff3cd7ac6dd76ad2ee2e98e34519e Mon Sep 17 00:00:00 2001 From: Jason Williams Date: Thu, 9 Jul 2015 12:10:00 -0500 Subject: [PATCH] Refactor role selects; pause transition if saving Refs #5501 - Switch role select dropdowns from gh-select based components to gh-select-native. - Prevent transition out of editor while there is an in-flight save. --- .../client/app/components/gh-role-selector.js | 15 ---- core/client/app/components/gh-select.js | 79 ------------------- .../app/controllers/modals/invite-new-user.js | 17 ++-- core/client/app/controllers/team/user.js | 4 + .../client/app/initializers/store-injector.js | 10 --- core/client/app/mixins/editor-base-route.js | 11 +++ .../templates/components/gh-role-selector.hbs | 5 -- .../app/templates/modals/invite-new-user.hbs | 34 ++++---- core/client/app/templates/team/user.hbs | 21 +++-- core/test/functional/client/editor_test.js | 23 ++---- core/test/functional/client/team_test.js | 32 ++++---- 11 files changed, 80 insertions(+), 171 deletions(-) delete mode 100644 core/client/app/components/gh-role-selector.js delete mode 100644 core/client/app/components/gh-select.js delete mode 100644 core/client/app/initializers/store-injector.js delete mode 100644 core/client/app/templates/components/gh-role-selector.hbs diff --git a/core/client/app/components/gh-role-selector.js b/core/client/app/components/gh-role-selector.js deleted file mode 100644 index 20a5e75542..0000000000 --- a/core/client/app/components/gh-role-selector.js +++ /dev/null @@ -1,15 +0,0 @@ -import Ember from 'ember'; -import GhostSelect from 'ghost/components/gh-select'; - -var RolesSelector = GhostSelect.extend({ - roles: Ember.computed.alias('options'), - - options: Ember.computed(function () { - var rolesPromise = this.store.find('role', {permissions: 'assign'}); - - return Ember.ArrayProxy.extend(Ember.PromiseProxyMixin) - .create({promise: rolesPromise}); - }) -}); - -export default RolesSelector; diff --git a/core/client/app/components/gh-select.js b/core/client/app/components/gh-select.js deleted file mode 100644 index f053bc3422..0000000000 --- a/core/client/app/components/gh-select.js +++ /dev/null @@ -1,79 +0,0 @@ -import Ember from 'ember'; -// GhostSelect is a solution to Ember.Select being evil and worthless. -// (Namely, this solves problems with async data in Ember.Select) -// Inspired by (that is, totally ripped off from) this JSBin -// http://emberjs.jsbin.com/rwjblue/40/edit - -// Usage: -// Extend this component and create a template for your component. -// Your component must define the `options` property. -// Optionally use `initialValue` to set the object -// you want to have selected to start with. -// Both options and initalValue are promise safe. -// Set onChange in your template to be the name -// of the action you want called in your -// For an example, see gh-roles-selector - -var GhostSelect = Ember.Component.extend({ - tagName: 'span', - classNames: ['gh-select'], - attributeBindings: ['tabindex'], - - tabindex: '0', // 0 must be a string, or else it's interpreted as false - - options: null, - initialValue: null, - - resolvedOptions: null, - resolvedInitialValue: null, - - // Convert promises to their values - init: function () { - var self = this; - - this._super.apply(this, arguments); - - Ember.RSVP.hash({ - resolvedOptions: this.get('options'), - resolvedInitialValue: this.get('initialValue') - }).then(function (resolvedHash) { - self.setProperties(resolvedHash); - - // Run after render to ensure the