Last active
December 30, 2016 23:22
-
-
Save Kilowhisky/1eba1236f9d5c78a30589eb4dfb0663c to your computer and use it in GitHub Desktop.
Helper issue
This file contains 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 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'; | |
/** | |
* This helper returns if the user has any of the supplied permission or not. | |
* If all=true is applied then all the supplied permissions have to be present. | |
* | |
* @example {{has-permission 'communicate' 'communicate.send' all=true }} | |
*/ | |
export default Ember.Helper.extend({ | |
compute: function(params, hash) { | |
//let permissions = this.get('sessionAccount.user.permissions'); | |
return this.hasPermission(/*permissions*/['track'], params, hash.all); | |
}, | |
// This function is usually in its own util file | |
hasPermission(userPermissions, permissions, allRequired) { | |
for (let i = 0; i < permissions.get('length'); i++) { | |
if (userPermissions.includes(permissions.objectAt(i))) { | |
return true; | |
} | |
} | |
return false; | |
} | |
}); | |
This file contains 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.10.7", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "canary", | |
"ember-data": "2.10.0", | |
"ember-template-compiler": "canary", | |
"ember-testing": "canary" | |
}, | |
"addons": {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment