Last active
August 23, 2018 10:05
-
-
Save selvagsz/dda60118011cd5c57f30f2b5a59cc2cb to your computer and use it in GitHub Desktop.
New 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'; | |
const Grouped = Ember.ArrayProxy.extend({ | |
}); | |
export default Ember.Component.extend({ | |
groupedSettings: Ember.computed('appSettings.[]', function() { | |
let appSettings = this.appSettings; | |
return appSettings.reduce((iter, curr) => { | |
let existingGroup | |
iter.some((item) => { | |
let found = item.findBy('oauth_applications_id', curr.oauth_applications_id); | |
if (found) { | |
existingGroup = item; | |
return true | |
} | |
}) | |
if (existingGroup) { | |
existingGroup.pushObject(curr) | |
} else { | |
iter.pushObject(Grouped.create({ | |
content: Ember.makeArray(curr), | |
oauth_applications_id: curr.oauth_applications_id | |
})) | |
} | |
return iter; | |
}, []) | |
}) | |
}); | |
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.Component.extend({ | |
label: Ember.computed('groupedSetting', { | |
get() { | |
// should be computed based on channel | |
return 'All boo' | |
} | |
}), | |
isGrouped: Ember.computed('groupedSetting.[]', { | |
get() { | |
return this.get('groupedSetting.length') > 1 | |
} | |
}) | |
}); |
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 data = { "app_settings": [{ "id": 82, "account_id": 4, "channel_id": 4, "default_sales_ledger_account_id": "7", "default_shipping_revenue_ledger_account_id": null, "oauth_applications_id": 6 }, { "id": 79, "account_id": 4, "channel_id": 3, "default_sales_ledger_account_id": null, "default_shipping_revenue_ledger_account_id": null, "oauth_applications_id": 5 }, { "id": 78, "account_id": 4, "channel_id": 3, "default_sales_ledger_account_id": "7", "default_shipping_revenue_ledger_account_id": "7", "oauth_applications_id": 4 }, { "id": 75, "account_id": 4, "channel_id": 2, "default_sales_ledger_account_id": null, "default_shipping_revenue_ledger_account_id": "1", "oauth_applications_id": 5 }, { "id": 74, "account_id": 4, "channel_id": 2, "default_sales_ledger_account_id": "1", "default_shipping_revenue_ledger_account_id": null, "oauth_applications_id": 4 }, { "id": 73, "account_id": 4, "channel_id": null, "default_sales_ledger_account_id": null, "default_shipping_revenue_ledger_account_id": "1", "oauth_applications_id": 34 }] } | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
data: data, | |
}); |
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.15.0", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js", | |
"ember": "3.2.2", | |
"ember-template-compiler": "3.2.2", | |
"ember-testing": "3.2.2" | |
}, | |
"addons": { | |
"ember-data": "3.2.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment