Skip to content

Instantly share code, notes, and snippets.

@sirvine
Forked from blimmer/controllers.application.js
Last active March 1, 2017 21:48
Show Gist options
  • Save sirvine/9357cee3702bea9893c18ad5003240b3 to your computer and use it in GitHub Desktop.
Save sirvine/9357cee3702bea9893c18ad5003240b3 to your computer and use it in GitHub Desktop.
Group-By Bug (Unable to set key with some symbols)
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
import Model from "ember-data/model";
import attr from "ember-data/attr";
export default Model.extend({
title: attr('string'),
supplierName: attr('string'),
});
import Ember from 'ember';
export default Ember.Route.extend({
model() {
return this.store.push({
data: [
{
id: '1',
type: 'contract',
attributes: {
title: 'Master Agreement',
supplierName: 'Fusible LLC'
}
},
{
id: '2',
type: 'contract',
attributes: {
title: 'Services Agreement',
supplierName: 'Betacone Data Inc'
}
},
{
id: '3',
type: 'contract',
attributes: {
title: 'Client Agreement',
supplierName: 'Betacone Data Inc'
}
},
// The bug is caused by the periods in the supplierName. Remove
// them to get this example to render properly.
{
id: '4',
type: 'contract',
attributes: {
title: 'User Agreement',
supplierName: 'Yamazaki Hinoki K.K.'
}
}
]
});
}
});
<h3>Ember Composable Helpers <br>
Group-By Bug</h3>
{{outlet}}
{{#each-in (group-by "supplierName" model) as |supplierName contracts|}}
<h5>{{supplierName}} Contracts</h5>
<ul>
{{#each contracts as |contract|}}
<li>{{contract.title}}</li>
{{/each}}
</ul>
{{/each-in}}
{
"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.6.0",
"ember-data": "2.6.0",
"ember-template-compiler": "2.6.0"
},
"addons": {
"ember-composable-helpers": "1.1.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment