From c3e0da9cb4d9e0543f09036ba5649df357fbe845 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Mon, 12 Oct 2015 12:05:45 -0700 Subject: [PATCH] Roughing in roles selection --- app/helpers/equal.js | 7 +++++++ app/pods/protected/users/edit/template.hbs | 1 + app/pods/protected/users/user-form/component.js | 6 ++++++ app/pods/protected/users/user-form/template.hbs | 10 +++++++++- 4 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 app/helpers/equal.js diff --git a/app/helpers/equal.js b/app/helpers/equal.js new file mode 100644 index 0000000..db3e867 --- /dev/null +++ b/app/helpers/equal.js @@ -0,0 +1,7 @@ +import Ember from 'ember'; + +export function equalHelper(params) { + return params[0] === params[1]; +} + +export default Ember.HTMLBars.makeBoundHelper(equalHelper); diff --git a/app/pods/protected/users/edit/template.hbs b/app/pods/protected/users/edit/template.hbs index 68d66b4..2f2f678 100644 --- a/app/pods/protected/users/edit/template.hbs +++ b/app/pods/protected/users/edit/template.hbs @@ -1,6 +1,7 @@ {{ protected/users/user-form user=model + currentUser=session.currentUser save="save" cancel="cancel" }} diff --git a/app/pods/protected/users/user-form/component.js b/app/pods/protected/users/user-form/component.js index a53a469..d5ce463 100644 --- a/app/pods/protected/users/user-form/component.js +++ b/app/pods/protected/users/user-form/component.js @@ -1,6 +1,12 @@ import Ember from 'ember'; export default Ember.Component.extend({ + isAdmin: Ember.computed('currentUser', function() { + return this.get('currentUser.role') == 'A'; + }), + + roles: Ember.String.w('A R W'), + actions: { save: function() { this.sendAction('save'); diff --git a/app/pods/protected/users/user-form/template.hbs b/app/pods/protected/users/user-form/template.hbs index 60c2d77..a872aae 100644 --- a/app/pods/protected/users/user-form/template.hbs +++ b/app/pods/protected/users/user-form/template.hbs @@ -16,7 +16,15 @@
- {{user.role}} + {{#if isAdmin}} + + {{else}} + {{user.role}} + {{/if}}