Forked from pleszkowicz/controllers.application.js
Last active
April 28, 2016 20:05
-
-
Save gustaff-weldon/cd805257bbc639f2b03ae656d8ff463e to your computer and use it in GitHub Desktop.
array problem
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle' | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export function arrayContains(params, namedArgs) { | |
let array = namedArgs.array || [], | |
key = namedArgs.key || ''; | |
console.log('contains', array, key) | |
return array.contains(key); | |
} | |
export default Ember.Helper.helper(arrayContains); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import config from './config/environment'; | |
const Router = Ember.Router.extend({ | |
location: 'none' | |
}); | |
Router.map(function() { | |
this.route('my-route') | |
}); | |
export default Router; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember' | |
export default Ember.Route.extend({ | |
redirect() { | |
this.transitionTo('my-route') | |
} | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
const RoleAssignment = Ember.Object.extend({ | |
computedRoles: Ember.computed('roles.[]', function() { | |
return this.get('roles') | |
}) | |
}) | |
export default Ember.Route.extend({ | |
actions: { | |
selectRole(member, role) { | |
let memberRoles = Ember.get(member, 'roles'); | |
if (memberRoles.contains(role)) { | |
Ember.set(member, 'roles', memberRoles.without(role)) | |
} else { | |
memberRoles.pushObject(role); | |
} | |
} | |
}, | |
model: function() { | |
return { | |
roleAssignment: RoleAssignment.create({ | |
"id": "4-8261", | |
"user": { | |
"id": 8261, | |
"last_login": "2015-09-02T14:32:41+0200", | |
"email": "assaaas", | |
"first_name": "Majid", | |
"last_name": "Mvulle" | |
}, | |
"roles": [ | |
"access-plan", | |
"invitation", | |
"policy", | |
"team", | |
"permission" | |
] | |
}), | |
rolesList: [{"id":"access-plan","label":"Access any plan"}, | |
{"id":"invitation","label":"Invite new members"},{"id":"policy","label":"Manage policies"},{"id":"team","label":"Manage team"},{"id":"permission","label":"Manage user permissions"}] | |
} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.7.2", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.4.4/ember.debug.js", | |
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.4.3/ember-data.js", | |
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.4.4/ember-template-compiler.js" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment