Roughing in roles selection

This commit is contained in:
Matthew Dillon 2015-10-12 12:05:45 -07:00
parent abb57c9ee0
commit c3e0da9cb4
4 changed files with 23 additions and 1 deletions

7
app/helpers/equal.js Normal file
View file

@ -0,0 +1,7 @@
import Ember from 'ember';
export function equalHelper(params) {
return params[0] === params[1];
}
export default Ember.HTMLBars.makeBoundHelper(equalHelper);

View file

@ -1,6 +1,7 @@
{{
protected/users/user-form
user=model
currentUser=session.currentUser
save="save"
cancel="cancel"
}}

View file

@ -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');

View file

@ -16,7 +16,15 @@
<div data-row-span="1">
<div data-field-span="1">
<label>Role</label>
{{#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>