Last active
August 1, 2016 08:43
-
-
Save aalasolutions-zz/22539ad04d436607d1f46a5ffdc95b0b to your computer and use it in GitHub Desktop.
Multiche ckboxes
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', | |
acl2: {"carpet_design":{ | |
"title":"Manage Carpet Designs", | |
"create":{"title":"Create","allowed":0}, | |
"read":{"title":"View","allowed":1}, | |
"update":{"title":"Edit","allowed":0}, | |
"delete":{"title":"Delete","allowed":0}, | |
"columns":{ | |
"design_collection":{"title":"Design Collection","allowed":1}, | |
"status":{"title":"Status","allowed":1} | |
}}}, | |
actions: { | |
updateAllCheckValue(key, obj, event, c, f, g){ | |
this.recursiveObjItr(obj, event); | |
}, | |
updateCheckValue: function (action, key, value, nested) { | |
if (typeof nested === 'object') { | |
if (value[action]['allowed'] === 1) { | |
Ember.set(value[action], 'allowed', 0); | |
} else { | |
Ember.set(value[action], 'allowed', 1); | |
} | |
} | |
}, | |
}, | |
recursiveObjItr(obj, event){ | |
for (var k in obj) { | |
if (typeof obj[k] === "object" && obj[k] !== null) { | |
this.recursiveObjItr(obj[k], event); | |
} | |
else { | |
if (obj.hasOwnProperty('allowed')) { | |
if (event.target.checked === true) { | |
console.log(`%c acl update to ${event.target.checked}`, 'background:#254;color:white;'); | |
Ember.set(obj, 'allowed' , 1); | |
// obj['allowed'] = 1; | |
} else { | |
console.log(`%c acl update to ${event.target.checked}`, 'background:#254;color:yellow;'); | |
Ember.set(obj, 'allowed' , 0); | |
// obj['allowed'] = 0; | |
} | |
} | |
} | |
} | |
}, | |
}); |
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 isEqual([leftSide, rightSide]/*, hash*/) { | |
return leftSide === rightSide; | |
} | |
export default Ember.Helper.helper(isEqual); |
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.10.4", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.7.0", | |
"ember-data": "2.7.0", | |
"ember-template-compiler": "2.7.0" | |
}, | |
"addons": {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment