From 718ec53b2ac6f888ecbacfc76a8d104704829b42 Mon Sep 17 00:00:00 2001 From: enadhilal Date: Wed, 29 Dec 2021 11:36:42 +0300 Subject: [PATCH] fixing reselect letter after favourite is selected --- .../work-list-replacement-itg.component.ts | 29 +++++++++++------ .../work-list-replacement-roll.component.ts | 31 ++++++++++++------- 2 files changed, 40 insertions(+), 20 deletions(-) diff --git a/Mohem/src/app/notification/work-list-replacement-itg/work-list-replacement-itg.component.ts b/Mohem/src/app/notification/work-list-replacement-itg/work-list-replacement-itg.component.ts index 5a540eb1..ffddbe54 100644 --- a/Mohem/src/app/notification/work-list-replacement-itg/work-list-replacement-itg.component.ts +++ b/Mohem/src/app/notification/work-list-replacement-itg/work-list-replacement-itg.component.ts @@ -45,6 +45,9 @@ export class WorkListReplacementItgComponent implements OnInit { slidesPerView: 6, spaceBetween: 5 }; + + public activeSelectedLetter:string; + constructor(public vacationRuleService: VacationRuleServiceService, public ts: TranslatorService, public cs: CommonService, @@ -323,21 +326,28 @@ export class WorkListReplacementItgComponent implements OnInit { this.worklistService.getFavoriteWithoutImage({}, () => { }).subscribe((result) => { if (this.cs.validResponse(result)) { - this.favoriteUserList = result['Mohemm_GetFavoriteReplacementsList']; - this.favoriteUserList.forEach((obj) => { + // this.favoriteUserList = result['Mohemm_GetFavoriteReplacementsList']; + let favList = result['Mohemm_GetFavoriteReplacementsList']; + favList.forEach((obj) => { obj.IsFavorite = true; this.favLetter.push(obj.EMPLOYEE_DISPLAY_NAME.charAt(0).toUpperCase()); }); this.favLetter = this.favLetter.filter((elem, index, self) => { return index === self.indexOf(elem); }); - this.favLetter.forEach((obj, index) => { - if (index === 0) { - this.favIsActive.push(true); - } else { - this.favIsActive.push(false); - } - }); + if (this.activeSelectedLetter) { + this.selectedLetter(this.activeSelectedLetter); + } else { + this.favLetter.forEach((obj, index) => { + if(this.activeSelectedLetter) {} + if (index === 0) { + this.selectedLetter(obj); + this.favIsActive.push(true); + } else { + this.favIsActive.push(false); + } + }); + } console.log(this.favLetter); console.log(this.favIsActive); } @@ -405,6 +415,7 @@ export class WorkListReplacementItgComponent implements OnInit { this.favLetter.forEach((letter, index) => { if (letter === el) { this.favIsActive[index] = true; + this.activeSelectedLetter = el; this.worklistService.getFavoriteByLetter(letter,() => { }).subscribe((result) => { if (this.cs.validResponse(result)) { diff --git a/Mohem/src/app/notification/work-list-replacement-roll/work-list-replacement-roll.component.ts b/Mohem/src/app/notification/work-list-replacement-roll/work-list-replacement-roll.component.ts index 262e4962..480ed036 100644 --- a/Mohem/src/app/notification/work-list-replacement-roll/work-list-replacement-roll.component.ts +++ b/Mohem/src/app/notification/work-list-replacement-roll/work-list-replacement-roll.component.ts @@ -55,6 +55,8 @@ export class WorkListReplacementRollComponent implements OnInit { spaceBetween: 5 }; + public activeSelectedLetter:string; + constructor(public worklistService: WorklistService, private cs: CommonService, public ts: TranslatorService, public workListMainService: WorklistMainService, public modalCtrl: ModalController) { this.P_PAGE_NUM = 1; this.P_PAGE_LIMIT = 50; @@ -509,22 +511,28 @@ export class WorkListReplacementRollComponent implements OnInit { this.worklistService.getFavoriteWithoutImage({}, () => { }).subscribe((result) => { if (this.cs.validResponse(result)) { - this.favoriteUserList = result['Mohemm_GetFavoriteReplacementsList']; - this.favoriteUserList.forEach((obj) => { + // this.favoriteUserList = result['Mohemm_GetFavoriteReplacementsList']; + let favList = result['Mohemm_GetFavoriteReplacementsList']; + favList.forEach((obj) => { obj.IsFavorite = true; this.favLetter.push(obj.EMPLOYEE_DISPLAY_NAME.charAt(0).toUpperCase()); }); this.favLetter = this.favLetter.filter((elem, index, self) => { return index === self.indexOf(elem); }); - this.favLetter.forEach((obj, index) => { - if (index === 0) { - this.selectedLetter(obj); - this.favIsActive.push(true); - } else { - this.favIsActive.push(false); - } - }); + if (this.activeSelectedLetter) { + this.selectedLetter(this.activeSelectedLetter); + } else { + this.favLetter.forEach((obj, index) => { + if(this.activeSelectedLetter) {} + if (index === 0) { + this.selectedLetter(obj); + this.favIsActive.push(true); + } else { + this.favIsActive.push(false); + } + }); + } console.log(this.favLetter); console.log(this.favIsActive); } @@ -554,7 +562,7 @@ export class WorkListReplacementRollComponent implements OnInit { } this.getFavruite(); } - }) + }); } setFavorite(selEmp) { @@ -645,6 +653,7 @@ export class WorkListReplacementRollComponent implements OnInit { this.favLetter.forEach((letter, index) => { if (letter === el) { this.favIsActive[index] = true; + this.activeSelectedLetter = el; this.worklistService.getFavoriteByLetter(letter,() => { }).subscribe((result) => { if (this.cs.validResponse(result)) {