Last active
May 13, 2022 22:25
-
-
Save onechiporenko/66f10ab6621a16e41887c39a2c649ce1 to your computer and use it in GitHub Desktop.
Rows Grouping (v2.3.0)
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 DS from 'ember-data'; | |
export default DS.RESTAdapter.extend({ | |
host: 'https://api.github.com', | |
namespace: 'repos/emberjs/ember.js/issues/13071/comments', | |
query(store, b, query) { | |
const url = `${this.get('host')}/${this.get('namespace')}`; | |
return this.ajax(url, 'GET', {data: query}); | |
} | |
}); |
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.Component.extend({ | |
}); |
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 layout from '../templates/components/expand-toggle'; | |
export default Ember.Component.extend({ | |
layout, | |
actions: { | |
collapseRow(index, record) { | |
this.get('collapseRow')(index, record); | |
}, | |
expandRow(index, record) { | |
this.get('expandRow')(index, record); | |
} | |
} | |
}); |
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'; | |
import DefaultComponent from './models-table/row-group-toggle'; | |
export default DefaultComponent.extend({ | |
classNames: ['grouping-cell'] | |
}); |
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'; | |
import layout from '../templates/components/select-toggle'; | |
export default Ember.Component.extend({ | |
layout, | |
actions: { | |
clickOnRow(index, record, event) { | |
this.get('clickOnRow')(index, record); | |
event.stopPropagation(); | |
} | |
} | |
}); |
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: 'Rows Grouping' | |
}); |
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'; | |
import Theme from '../themes/bootstrap3'; | |
export default Ember.Controller.extend({ | |
themeInstance: Theme.create({sortGroupedPropertyBtn: 'btn btn-link'}), | |
displayGroupedValueAs: Ember.computed('displayGroupedValueAsToggle', function () { | |
return this.get('displayGroupedValueAsToggle') ? 'row' : 'column'; | |
}), | |
currentGroupingPropertyName : 'createdDay', | |
dataGroupProperties: [{value: 'user.login', label: 'User'}, {value: 'createdDay', label: 'Created Day'}], | |
displayGroupedValueAsToggle: false, | |
columns: [ | |
{ | |
component: 'select-toggle', | |
useFilter: false, | |
mayBeHidden: false | |
}, | |
{ | |
component: 'expand-toggle', | |
useFilter: false, | |
mayBeHidden: false | |
}, | |
{propertyName: 'id'}, | |
{propertyName: 'user.login', title: 'User'}, | |
{propertyName: 'created_at'}, | |
{propertyName: 'updated_at'} | |
] | |
}); |
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 Model from "ember-data/model"; | |
import attr from "ember-data/attr"; | |
import { belongsTo, hasMany } from "ember-data/relationships"; | |
import Ember from 'ember'; | |
export default Model.extend({ | |
url: attr('string'), | |
html_url: attr('string'), | |
issue_url: attr('string'), | |
user: belongsTo('user'), | |
created_at: attr('string'), | |
updated_at: attr('string'), | |
author_association: attr('string'), | |
body: attr('string'), | |
createdDay: Ember.computed('created_at', function () { | |
const d = new Date(this.get('created_at')); | |
let month = d.getMonth(); | |
month = (month < 10 ? '0': '') + month; | |
let day = d.getDate(); | |
day = (day < 10 ? '0' : '') + day; | |
return `${d.getFullYear()}-${month}-${day}`; | |
}) | |
}); |
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 Model from "ember-data/model"; | |
import attr from "ember-data/attr"; | |
import { belongsTo, hasMany } from "ember-data/relationships"; | |
export default Model.extend({ | |
login: attr('string'), | |
avatar_url: attr('string'), | |
url: attr('string'), | |
html_url: attr('string'), | |
type: attr('string'), | |
site_admin: attr('boolean') | |
}); |
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.Route.extend({ | |
model() { | |
return this.get('store').query('comment', {per_page: 100}); | |
} | |
}); |
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'; | |
import DS from 'ember-data'; | |
export default DS.JSONAPISerializer.extend({ | |
_mapIncluded(data, type) { | |
const clb = item => ({id: item.id, type, attributes: item}); | |
return Ember.isArray(data) ? data.map(clb) : [clb(data)]; | |
}, | |
normalizeQueryResponse(a, b, payload) { | |
const included = []; | |
const newPayload = { | |
data: payload.map(item => { | |
const itemData = { | |
id: item.id, | |
type: 'comment', | |
attributes: item, | |
relationships: { | |
user: { | |
data: { id: item.user.id, type: 'user' } | |
} | |
} | |
}; | |
included.pushObjects(this._mapIncluded(item.user, 'user')); | |
return itemData; | |
}) | |
}; | |
newPayload.included = included; | |
console.log(newPayload); | |
return newPayload; | |
} | |
}); |
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
.models-table-clear { | |
margin-bottom: 20px; | |
} | |
.grouping-cell { | |
min-width: 240px; | |
} |
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.12.1", | |
"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.12.0", | |
"ember-template-compiler": "2.12.0", | |
"ember-testing": "2.12.0", | |
"bs3css": "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css", | |
"bs3js": "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js" | |
}, | |
"addons": { | |
"ember-data": "2.12.1", | |
"ember-models-table": "2.3.0", | |
"ember-cli-showdown": "4.1.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment