From d224bafd2283a24bf52ab712a4a59aa3dcc24cc4 Mon Sep 17 00:00:00 2001 From: Leo Wong Date: Fri, 14 Oct 2016 00:52:43 +0800 Subject: [PATCH] Use `descending` instead of `sortDesc` --- app/adapters/application.js | 4 ++-- app/appointments/search/template.hbs | 10 +++++----- app/components/sortable-column.js | 8 ++++---- app/controllers/abstract-paged-controller.js | 8 ++++---- app/inventory/listing/template.hbs | 10 +++++----- app/patients/index/template.hbs | 12 ++++++------ app/routes/abstract-index-route.js | 6 +++--- app/templates/components/sortable-column.hbs | 2 +- app/utils/pouch-views.js | 2 +- 9 files changed, 31 insertions(+), 31 deletions(-) diff --git a/app/adapters/application.js b/app/adapters/application.js index 1ab7fd8aea..52bef695e0 100644 --- a/app/adapters/application.js +++ b/app/adapters/application.js @@ -152,8 +152,8 @@ export default Adapter.extend(PouchAdapterUtils, { if (query.options) { queryParams = Ember.copy(query.options); if (query.sortKey || query.filterBy) { - if (query.sortDesc) { - queryParams.sortDesc = query.sortDesc; + if (query.descending) { + queryParams.descending = query.descending; } if (query.sortKey) { queryParams.sortKey = query.sortKey; diff --git a/app/appointments/search/template.hbs b/app/appointments/search/template.hbs index 92dd510597..297a802387 100644 --- a/app/appointments/search/template.hbs +++ b/app/appointments/search/template.hbs @@ -24,12 +24,12 @@ - {{#sortable-column sortBy='date' sortDesc=sortDesc sortKey=sortKey }}{{t 'labels.date'}}{{/sortable-column}} + {{#sortable-column sortBy='date' descending=descending sortKey=sortKey }}{{t 'labels.date'}}{{/sortable-column}} - {{#sortable-column sortBy='appointmentType' sortDesc=sortDesc sortKey=sortKey }}{{t 'labels.type'}}{{/sortable-column}} - {{#sortable-column sortBy='location' sortDesc=sortDesc sortKey=sortKey }}{{t 'labels.location'}}{{/sortable-column}} - {{#sortable-column sortBy='provider' sortDesc=sortDesc sortKey=sortKey }}{{t 'labels.with'}}{{/sortable-column}} - {{#sortable-column sortBy='status' sortDesc=sortDesc sortKey=sortKey }}{{t 'labels.status'}}{{/sortable-column}} + {{#sortable-column sortBy='appointmentType' descending=descending sortKey=sortKey }}{{t 'labels.type'}}{{/sortable-column}} + {{#sortable-column sortBy='location' descending=descending sortKey=sortKey }}{{t 'labels.location'}}{{/sortable-column}} + {{#sortable-column sortBy='provider' descending=descending sortKey=sortKey }}{{t 'labels.with'}}{{/sortable-column}} + {{#sortable-column sortBy='status' descending=descending sortKey=sortKey }}{{t 'labels.status'}}{{/sortable-column}} {{#each model as |appointment|}} diff --git a/app/components/sortable-column.js b/app/components/sortable-column.js index 2fe151ed83..a1f12d63fe 100644 --- a/app/components/sortable-column.js +++ b/app/components/sortable-column.js @@ -3,7 +3,7 @@ export default Ember.Component.extend({ classNames: ['sortable-column'], tagName: 'th', action: 'sortByKey', - sortDesc: false, + descending: false, sortBy: null, sortKey: null, sorted: function() { @@ -15,10 +15,10 @@ export default Ember.Component.extend({ click() { let sortBy = this.get('sortBy'); let sorted = this.get('sorted'); - let sortDesc = false; + let descending = false; if (sorted) { - sortDesc = this.toggleProperty('sortDesc'); + descending = this.toggleProperty('descending'); } - this.sendAction('action', sortBy, sortDesc); + this.sendAction('action', sortBy, descending); } }); diff --git a/app/controllers/abstract-paged-controller.js b/app/controllers/abstract-paged-controller.js index 792a07d7ab..d4a6e9a15d 100644 --- a/app/controllers/abstract-paged-controller.js +++ b/app/controllers/abstract-paged-controller.js @@ -10,8 +10,8 @@ export default Ember.Controller.extend(PaginationProps, ProgressDialog, UserSess previousStartKeys: [], progressMessage: 'Loading Records. Please wait...', progressTitle: 'Loading', - queryParams: ['startKey', 'sortKey', 'sortDesc'], - sortDesc: false, + queryParams: ['startKey', 'sortKey', 'descending'], + descending: false, sortKey: null, canAdd: function() { @@ -73,11 +73,11 @@ export default Ember.Controller.extend(PaginationProps, ProgressDialog, UserSess this.set('previousStartKeys', previousStartKeys); this.showProgressModal(); }, - sortByKey: function(sortKey, sortDesc) { + sortByKey: function(sortKey, descending) { this.setProperties({ previousStartKey: null, previousStartKeys: [], - sortDesc: sortDesc, + descending: descending, sortKey: sortKey, startKey: null }); diff --git a/app/inventory/listing/template.hbs b/app/inventory/listing/template.hbs index 14dbb9fda6..ab0e723c3f 100644 --- a/app/inventory/listing/template.hbs +++ b/app/inventory/listing/template.hbs @@ -2,12 +2,12 @@ {{#if hasRecords}}
{{t 'labels.name'}}{{t 'labels.actions'}}
- {{#sortable-column sortBy='friendlyId' sortDesc=sortDesc sortKey=sortKey }}{{t 'labels.id'}}{{/sortable-column}} - {{#sortable-column sortBy='name' sortDesc=sortDesc sortKey=sortKey }}{{t 'labels.name'}}{{/sortable-column}} - {{#sortable-column sortBy='inventoryType' sortDesc=sortDesc sortKey=sortKey }}{{t 'labels.type'}}{{/sortable-column}} - {{#sortable-column sortBy='quantity' sortDesc=sortDesc sortKey=sortKey }}{{t 'labels.quantity'}}{{/sortable-column}} + {{#sortable-column sortBy='friendlyId' descending=descending sortKey=sortKey }}{{t 'labels.id'}}{{/sortable-column}} + {{#sortable-column sortBy='name' descending=descending sortKey=sortKey }}{{t 'labels.name'}}{{/sortable-column}} + {{#sortable-column sortBy='inventoryType' descending=descending sortKey=sortKey }}{{t 'labels.type'}}{{/sortable-column}} + {{#sortable-column sortBy='quantity' descending=descending sortKey=sortKey }}{{t 'labels.quantity'}}{{/sortable-column}} - {{#sortable-column sortBy='crossReference' sortDesc=sortDesc sortKey=sortKey }}{{t 'inventory.labels.xref'}}{{/sortable-column}} + {{#sortable-column sortBy='crossReference' descending=descending sortKey=sortKey }}{{t 'inventory.labels.xref'}}{{/sortable-column}} {{#each model as |inventory|}} diff --git a/app/patients/index/template.hbs b/app/patients/index/template.hbs index 124f881c73..cb036011e8 100644 --- a/app/patients/index/template.hbs +++ b/app/patients/index/template.hbs @@ -3,12 +3,12 @@
{{t 'inventory.labels.location'}}{{t 'labels.actions'}}
- {{#sortable-column sortBy='id' sortDesc=sortDesc sortKey=sortKey }}{{t 'labels.id'}}{{/sortable-column}} - {{#sortable-column sortBy='firstName' sortDesc=sortDesc sortKey=sortKey }}{{t 'patients.labels.firstName'}}{{/sortable-column}} - {{#sortable-column sortBy='lastName' sortDesc=sortDesc sortKey=sortKey }}{{t 'patients.labels.lastName'}}{{/sortable-column}} - {{#sortable-column sortBy='sex' sortDesc=sortDesc sortKey=sortKey }}{{t 'patients.labels.sex'}}{{/sortable-column}} - {{#sortable-column sortBy='dateOfBirth' sortDesc=sortDesc sortKey=sortKey }}{{t 'patients.labels.dob'}}{{/sortable-column}} - {{#sortable-column sortBy='status' sortDesc=sortDesc sortKey=sortKey }}{{t 'labels.status'}}{{/sortable-column}} + {{#sortable-column sortBy='id' descending=descending sortKey=sortKey }}{{t 'labels.id'}}{{/sortable-column}} + {{#sortable-column sortBy='firstName' descending=descending sortKey=sortKey }}{{t 'patients.labels.firstName'}}{{/sortable-column}} + {{#sortable-column sortBy='lastName' descending=descending sortKey=sortKey }}{{t 'patients.labels.lastName'}}{{/sortable-column}} + {{#sortable-column sortBy='sex' descending=descending sortKey=sortKey }}{{t 'patients.labels.sex'}}{{/sortable-column}} + {{#sortable-column sortBy='dateOfBirth' descending=descending sortKey=sortKey }}{{t 'patients.labels.dob'}}{{/sortable-column}} + {{#sortable-column sortBy='status' descending=descending sortKey=sortKey }}{{t 'labels.status'}}{{/sortable-column}} {{#if showActions}} {{/if}} diff --git a/app/routes/abstract-index-route.js b/app/routes/abstract-index-route.js index 971437c963..7d7f2527df 100644 --- a/app/routes/abstract-index-route.js +++ b/app/routes/abstract-index-route.js @@ -58,8 +58,8 @@ export default Ember.Route.extend(PouchDbMixin, ProgressDialog, AuthenticatedRou let queryParams = this._modelQueryParams(params); if (!Ember.isEmpty(params.sortKey)) { queryParams.sortKey = params.sortKey; - if (!Ember.isEmpty(params.sortDesc)) { - queryParams.sortDesc = params.sortDesc; + if (!Ember.isEmpty(params.descending)) { + queryParams.descending = params.descending; } } if (!Ember.isEmpty(filterParams)) { @@ -88,7 +88,7 @@ export default Ember.Route.extend(PouchDbMixin, ProgressDialog, AuthenticatedRou }, queryParams: { - sortDesc: { refreshModel: true }, + descending: { refreshModel: true }, sortKey: { refreshModel: true }, startKey: { refreshModel: true } }, diff --git a/app/templates/components/sortable-column.hbs b/app/templates/components/sortable-column.hbs index df77cd44f2..258f9b0e72 100644 --- a/app/templates/components/sortable-column.hbs +++ b/app/templates/components/sortable-column.hbs @@ -1,5 +1,5 @@ {{#if sorted}} - + {{else}} {{/if}} diff --git a/app/utils/pouch-views.js b/app/utils/pouch-views.js index 086803ad45..0be82cd34b 100644 --- a/app/utils/pouch-views.js +++ b/app/utils/pouch-views.js @@ -99,7 +99,7 @@ function generateSortFunction(sortFunction, includeCompareDate, filterFunction) '}' + '}' + '}' + - 'if (req.query.sortDesc) {' + + 'if (req.query.descending) {' + 'rows = rows.reverse();' + '}' + 'if (req.query.sortLimit) {' +
{{t 'labels.actions'}}