Skip to content

Commit

Permalink
Use descending instead of sortDesc
Browse files Browse the repository at this point in the history
  • Loading branch information
gnowoel committed Oct 13, 2016
1 parent 50c7e13 commit d224baf
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 31 deletions.
4 changes: 2 additions & 2 deletions app/adapters/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions app/appointments/search/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
</div>
<table class="table">
<tr class="table-header">
{{#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}}
<th>{{t 'labels.name'}}</th>
{{#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}}
<th>{{t 'labels.actions'}}</th>
</tr>
{{#each model as |appointment|}}
Expand Down
8 changes: 4 additions & 4 deletions app/components/sortable-column.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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);
}
});
8 changes: 4 additions & 4 deletions app/controllers/abstract-paged-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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
});
Expand Down
10 changes: 5 additions & 5 deletions app/inventory/listing/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
{{#if hasRecords}}
<table class="table">
<tr class="table-header">
{{#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}}
<th>{{t 'inventory.labels.location'}}</th>
{{#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}}
<th>{{t 'labels.actions'}}</th>
</tr>
{{#each model as |inventory|}}
Expand Down
12 changes: 6 additions & 6 deletions app/patients/index/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
<table class="table">
<thead>
<tr class="table-header">
{{#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}}
<th>{{t 'labels.actions'}}</th>
{{/if}}
Expand Down
6 changes: 3 additions & 3 deletions app/routes/abstract-index-route.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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 }
},
Expand Down
2 changes: 1 addition & 1 deletion app/templates/components/sortable-column.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{#if sorted}}
<span class="octicon {{if sortDesc 'octicon-triangle-down' 'octicon-triangle-up'}}"></span>
<span class="octicon {{if descending 'octicon-triangle-down' 'octicon-triangle-up'}}"></span>
{{else}}
<span class="octicon octicon-triangle-down inactive"></span>
{{/if}}
Expand Down
2 changes: 1 addition & 1 deletion app/utils/pouch-views.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function generateSortFunction(sortFunction, includeCompareDate, filterFunction)
'}' +
'}' +
'}' +
'if (req.query.sortDesc) {' +
'if (req.query.descending) {' +
'rows = rows.reverse();' +
'}' +
'if (req.query.sortLimit) {' +
Expand Down

0 comments on commit d224baf

Please sign in to comment.