diff --git a/src/app.json.template b/src/app.json.template index f38abc58..530e7584 100644 --- a/src/app.json.template +++ b/src/app.json.template @@ -28,7 +28,8 @@ "field": "[ FILTER FIELD HERE ]", "values": [ "[ FILTER VALUE HERE ]" - ] + ], + "sort": "-dateLastPublished" }, "defaultGridState": "list-view", "eeoc": { diff --git a/src/app/services/search.service.js b/src/app/services/search.service.js index bf56f789..87551769 100644 --- a/src/app/services/search.service.js +++ b/src/app/services/search.service.js @@ -18,10 +18,6 @@ class SearchService { return SearchService._.fields || (SearchService._.fields = 'id,title,publishedCategory(id,name),address(city,state),employmentType,dateLastPublished,publicDescription,isOpen,isPublic,isDeleted'); } - static get _sort() { - return SearchService._.sort || (SearchService._.sort = '-dateLastPublished'); - } - get _() { return this.__ || (this.__ = Object.create(null)); } @@ -96,7 +92,7 @@ class SearchService { get requestParams() { return this._.requestParams || (this._.requestParams = { - sort: () => this.searchParams.sort || SearchService._sort, + sort: () => this.searchParams.sort || this.configuration.additionalJobCriteria.sort, count: () => this.searchParams.count || SearchService._count, start: () => this.searchParams.start || 0, publishedCategory: (isSearch, fields) => { @@ -207,10 +203,10 @@ class SearchService { return '?start=0&query=' + where + '&fields=id&count=' + SearchService._count; }, assembleForQueryForIDs: (start, count) => { - return '?where=' + this.requestParams.query(false) + '&fields=' + SearchService._fields + '&count=' + count + '&orderBy=' + SearchService._sort + '&start=' + start; + return '?where=' + this.requestParams.query(false) + '&fields=' + SearchService._fields + '&count=' + count + '&orderBy=' + this.configuration.additionalJobCriteria.sort + '&start=' + start; }, assembleForSearchForJobs: (start, count) => { - return '?query=' + this.requestParams.query(true) + '&fields=' + SearchService._fields + '&count=' + count + '&sort=' + SearchService._sort + '&start=' + start; + return '?query=' + this.requestParams.query(true) + '&fields=' + SearchService._fields + '&count=' + count + '&sort=' + this.configuration.additionalJobCriteria.sort + '&start=' + start; }, assembleForGroupByWhereIDs: (fields, orderByFields, start, count, jobs) => { return '?where=' + this.requestParams.whereIDs(jobs, false) + '&groupBy=' + fields + '&fields=' + fields + ',count(id)&count=' + count + '&orderBy=+' + orderByFields + ',-count.id&start=' + start; diff --git a/test/unit/services/search.service.spec.js b/test/unit/services/search.service.spec.js index 309ba725..8232faf6 100755 --- a/test/unit/services/search.service.spec.js +++ b/test/unit/services/search.service.spec.js @@ -12,7 +12,8 @@ describe('Service: SearchService', () => { field: '[ FILTER FIELD HERE ]', values: [ '[ FILTER VALUE HERE ]' - ] + ], + sort: "-dateLastPublished" } }); //$provide.value('job', {}); @@ -124,7 +125,8 @@ describe('Service: SearchService', () => { field: 'employmentType', values: [ 'blah' - ] + ], + sort: "-dateLastPublished" }, }; expect(SearchService.jobCriteria(true)).toBe(' AND (employmentType:"blah")'); @@ -136,7 +138,8 @@ describe('Service: SearchService', () => { values: [ 'blah', 'blahy' - ] + ], + sort: "-dateLastPublished" }, }; expect(SearchService.jobCriteria(true)).toBe(' AND (employmentType:"blah" OR employmentType:"blahy")'); @@ -147,7 +150,8 @@ describe('Service: SearchService', () => { field: '[ FILTER FIELD HERE ]', values: [ '[ FILTER VALUE HERE ]' - ] + ], + sort: "-dateLastPublished" }, }; expect(SearchService.jobCriteria(true)).toBe(''); @@ -158,7 +162,8 @@ describe('Service: SearchService', () => { field: 'employmentType', values: [ 'blah' - ] + ], + sort: "-dateLastPublished" }, }; expect(SearchService.jobCriteria(false)).toBe(' AND (employmentType=\'blah\')');