Skip to content

Commit

Permalink
Merge pull request #1183 from ORCID/change-default-sorting-direction
Browse files Browse the repository at this point in the history
default sorting direction should be ascending
  • Loading branch information
bobcaprice authored May 14, 2024
2 parents 09f1f22 + 7ee4f95 commit e11848e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion ui/src/app/affiliation/affiliations.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export class AffiliationsComponent implements OnInit, OnDestroy {
})
this.routeData = this.activatedRoute.data.subscribe((data) => {
this.page = data['queryParams'] ? data['queryParams'].page : 1
this.ascending = data['queryParams'] ? data['queryParams'].page.sort.split(',')[1] : false
this.ascending = data['queryParams'] ? data['queryParams'].page.sort.split(',')[1] : true
this.sortColumn = data['queryParams'] ? data['queryParams'].page.sort.split(',')[0] : 'id'
this.loadAll()
})
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/member/members.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class MembersComponent implements OnInit {
this.itemsPerPage = ITEMS_PER_PAGE
this.routeData = this.activatedRoute.data.subscribe((data: any) => {
this.page = data['queryParams'] ? data['queryParams'].page : 1
this.ascending = data['queryParams'] ? data['queryParams'].page.sort.split(',')[1] : false
this.ascending = data['queryParams'] ? data['queryParams'].page.sort.split(',')[1] : true
this.sortColumn = data['queryParams'] ? data['queryParams'].page.sort.split(',')[0] : 'salesforceId'
})
}
Expand Down
16 changes: 8 additions & 8 deletions ui/src/app/user/users.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,35 +106,35 @@ describe('UsersComponent', () => {
expect(component.users![0]).toEqual(jasmine.objectContaining({ id: '123' }))
})

it('sort should be id,desc by default', () => {
it('sort should be id,asc by default', () => {
const result = component.sort()
expect(result).toEqual(['id,desc'])
expect(result).toEqual(['id,asc'])
})

it('direction should be desc and id should be secondary sort column by default', () => {
it('direction should be asc and id should be secondary sort column by default', () => {
component.sortColumn = 'name'
const result = component.sort()
expect(result).toEqual(['name,desc', 'id'])
expect(result).toEqual(['name,asc', 'id'])
})

it('updating sort column to different value should maintain sort direction', () => {
component.sortColumn = 'name'
let result = component.sort()
expect(result).toEqual(['name,desc', 'id'])
expect(result).toEqual(['name,asc', 'id'])

component.updateSort('email')
result = component.sort()
expect(result).toEqual(['email,desc', 'id'])
expect(result).toEqual(['email,asc', 'id'])
})

it('updating sort column with same value should flip sort direction', () => {
component.sortColumn = 'name'
let result = component.sort()
expect(result).toEqual(['name,desc', 'id'])
expect(result).toEqual(['name,asc', 'id'])

component.updateSort('name')
result = component.sort()
expect(result).toEqual(['name,asc', 'id'])
expect(result).toEqual(['name,desc', 'id'])
})

it('clear should reset page to zero', () => {
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/user/users.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class UsersComponent implements OnInit, OnDestroy {
this.itemsPerPage = ITEMS_PER_PAGE
this.routeData = this.activatedRoute.data.subscribe((data) => {
this.page = data['queryParams'] ? data['queryParams'].page : 1
this.ascending = data['queryParams'] ? data['queryParams'].page.sort.split(',')[1] : false
this.ascending = data['queryParams'] ? data['queryParams'].page.sort.split(',')[1] : true
this.sortColumn = data['queryParams'] ? data['queryParams'].page.sort.split(',')[0] : 'id'
})
}
Expand Down

0 comments on commit e11848e

Please sign in to comment.