From 8be8df2194b80493004251ad5e8fb2c57797b4b7 Mon Sep 17 00:00:00 2001 From: andrej romanov <50377758+auumgn@users.noreply.github.com> Date: Mon, 13 May 2024 15:27:11 +0300 Subject: [PATCH 1/2] default sorting direction should be ascending --- ui/src/app/affiliation/affiliations.component.ts | 2 +- ui/src/app/member/members.component.ts | 2 +- ui/src/app/user/users.component.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/src/app/affiliation/affiliations.component.ts b/ui/src/app/affiliation/affiliations.component.ts index cbbd95ae4..e646ab505 100644 --- a/ui/src/app/affiliation/affiliations.component.ts +++ b/ui/src/app/affiliation/affiliations.component.ts @@ -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() }) diff --git a/ui/src/app/member/members.component.ts b/ui/src/app/member/members.component.ts index 3446b32ef..062109bf3 100644 --- a/ui/src/app/member/members.component.ts +++ b/ui/src/app/member/members.component.ts @@ -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' }) } diff --git a/ui/src/app/user/users.component.ts b/ui/src/app/user/users.component.ts index c13009ad7..5f7f141ae 100644 --- a/ui/src/app/user/users.component.ts +++ b/ui/src/app/user/users.component.ts @@ -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' }) } From 7ee4f9539e2f770fdc992a3107a5784c672457df Mon Sep 17 00:00:00 2001 From: andrej romanov <50377758+auumgn@users.noreply.github.com> Date: Mon, 13 May 2024 15:40:53 +0300 Subject: [PATCH 2/2] fix test --- ui/src/app/user/users.component.spec.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ui/src/app/user/users.component.spec.ts b/ui/src/app/user/users.component.spec.ts index 3b0a1c70d..7725bf805 100644 --- a/ui/src/app/user/users.component.spec.ts +++ b/ui/src/app/user/users.component.spec.ts @@ -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', () => {