Skip to content

Commit

Permalink
Merge pull request #63 from sandersky/13.x
Browse files Browse the repository at this point in the history
Add sort functionality
  • Loading branch information
sandersky committed Jun 23, 2016
2 parents b051ffe + a7f8f77 commit b302bf0
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 20 deletions.
36 changes: 22 additions & 14 deletions addon/templates/components/frost-object-browser.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,29 @@
{{/yield-slot}}
<div class="content">
<div class="tools">
<div class="sort"/>
{{#yield-slot 'pagination'}}
<div class="pagination">
{{yield (block-params
(hash control=(component
'frost-object-browser-paginator'
itemsPerPage=itemsPerPage
page=computedPageNumber
total=computedValuesTotal
)
<div class="sort">
{{#if sortData}}
{{frost-sort
onChange=onSortChange
sortableProperties=sortData.sortableProperties
sortParams=sortData.sortParams
}}
{{/if}}
</div>
{{#yield-slot 'pagination'}}
<div class="pagination">
{{yield (block-params
(hash control=(component
'frost-object-browser-paginator'
itemsPerPage=itemsPerPage
page=computedPageNumber
total=computedValuesTotal
)
(action 'onPageChanged')
)}}
</div>
{{/yield-slot}}
)
(action 'onPageChanged')
)}}
</div>
{{/yield-slot}}
<div class="detail">
<span class="text">
<!-- TODO: make this a variable to support i18n better -->
Expand Down
3 changes: 2 additions & 1 deletion blueprints/ember-frost-object-browser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ module.exports = {
return this.addAddonsToProject({
packages: [
{name: 'ember-block-slots', target: '>=0.12.1 <2.0.0'},
{name: 'ember-frost-core', target: '>=0.2.1 <2.0.0'},
{name: 'ember-frost-core', target: '>=0.11.18 <2.0.0'},
{name: 'ember-frost-bunsen', target: '^6.0.0'},
{name: 'ember-frost-info-bar', target: '^2.0.0'},
{name: 'ember-frost-list', target: '>=0.5.0 <2.0.0'},
{name: 'ember-frost-sort', target: '^2.1.1'},
{name: 'ember-prop-types', target: '^2.0.0'},
{name: 'liquid-fire', target: '>=0.23.0 <2.0.0'}
]
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ember-frost-object-browser",
"version": "13.0.1",
"version": "13.1.0",
"description": "Object browser addon for ember apps.",
"directories": {
"doc": "doc",
Expand Down Expand Up @@ -29,7 +29,7 @@
"broccoli-asset-rev": "^2.4.2",
"ember-block-slots": ">=0.12.1 <2.0.0",
"ember-browserify": "^1.1.9",
"ember-cli": "^2.4.3",
"ember-cli": "2.5.1",
"ember-cli-app-version": "^1.0.0",
"ember-cli-autoprefixer": "0.6.0",
"ember-cli-babel": "^5.1.5",
Expand All @@ -49,9 +49,10 @@
"ember-disable-proxy-controllers": "^1.0.1",
"ember-export-application-global": "^1.0.5",
"ember-frost-bunsen": "^6.0.0",
"ember-frost-core": ">=0.8.0 <2.0.0",
"ember-frost-core": ">=0.11.18 <2.0.0",
"ember-frost-info-bar": "^2.0.0",
"ember-frost-list": "^0.7.0",
"ember-frost-sort": "^2.1.1",
"ember-load-initializers": "^0.5.1",
"ember-lodash": "0.0.7",
"ember-one-way-controls": "0.8.0",
Expand Down Expand Up @@ -82,4 +83,4 @@
"ember-addon": {
"configPath": "tests/dummy/config"
}
}
}
17 changes: 17 additions & 0 deletions tests/dummy/app/pods/demo/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ export default Ember.Controller.extend({
}
],

sortData: {
sortableProperties: [{label: 'Label', value: 'label'}],
sortParams: []
},

actions: {
onCreate () {
window.alert('One does not merely create things')
Expand Down Expand Up @@ -179,6 +184,18 @@ export default Ember.Controller.extend({
})
},

onSortChange ([sortData]) {
if (sortData) {
let sortedList = this.get('model.resources').sortBy(sortData.get('value'))

if (this.get('direction') === ':desc') {
sortedList = sortedList.reverse()
}

this.set('model.resources', sortedList)
}
},

onActionClick (buttonId) {
const selectedItems = this.get('selectedItems')

Expand Down
4 changes: 3 additions & 1 deletion tests/dummy/app/pods/demo/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
onDetailChange=(action 'onDetailChange')
onFacetChange=(action 'onOptionSelected')
onRowSelect=(action 'onRowSelect')
title='Resources'
onSortChange=(action "onSortChange")
sortData=sortData
subtitle='L3VPN Services'
title='Resources'
values=model.resources
viewSchema=viewSchema
filters=filters
Expand Down

0 comments on commit b302bf0

Please sign in to comment.