Roughing in roles selection
This commit is contained in:
parent
abb57c9ee0
commit
c3e0da9cb4
4 changed files with 23 additions and 1 deletions
7
app/helpers/equal.js
Normal file
7
app/helpers/equal.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export function equalHelper(params) {
|
||||
return params[0] === params[1];
|
||||
}
|
||||
|
||||
export default Ember.HTMLBars.makeBoundHelper(equalHelper);
|
|
@ -1,6 +1,7 @@
|
|||
{{
|
||||
protected/users/user-form
|
||||
user=model
|
||||
currentUser=session.currentUser
|
||||
save="save"
|
||||
cancel="cancel"
|
||||
}}
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -16,7 +16,15 @@
|
|||
<div data-row-span="1">
|
||||
<div data-field-span="1">
|
||||
<label>Role</label>
|
||||
{{user.role}}
|
||||
{{#if isAdmin}}
|
||||
<select onchange={{action (mut user.role) value="target.value"}}>
|
||||
{{#each roles as |roleChoice|}}
|
||||
<option value={{roleChoice}} selected={{equal user.role roleChoice}}>{{roleChoice}}</option>
|
||||
{{/each}}
|
||||
</select>
|
||||
{{else}}
|
||||
{{user.role}}
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
|
Reference in a new issue