fixing reselect letter after favourite is selected

sultan-q3
enadhilal 4 years ago
parent aaa18bfce1
commit 718ec53b2a

@ -45,6 +45,9 @@ export class WorkListReplacementItgComponent implements OnInit {
slidesPerView: 6, slidesPerView: 6,
spaceBetween: 5 spaceBetween: 5
}; };
public activeSelectedLetter:string;
constructor(public vacationRuleService: VacationRuleServiceService, constructor(public vacationRuleService: VacationRuleServiceService,
public ts: TranslatorService, public ts: TranslatorService,
public cs: CommonService, public cs: CommonService,
@ -323,21 +326,28 @@ export class WorkListReplacementItgComponent implements OnInit {
this.worklistService.getFavoriteWithoutImage({}, () => { this.worklistService.getFavoriteWithoutImage({}, () => {
}).subscribe((result) => { }).subscribe((result) => {
if (this.cs.validResponse(result)) { if (this.cs.validResponse(result)) {
this.favoriteUserList = result['Mohemm_GetFavoriteReplacementsList']; // this.favoriteUserList = result['Mohemm_GetFavoriteReplacementsList'];
this.favoriteUserList.forEach((obj) => { let favList = result['Mohemm_GetFavoriteReplacementsList'];
favList.forEach((obj) => {
obj.IsFavorite = true; obj.IsFavorite = true;
this.favLetter.push(obj.EMPLOYEE_DISPLAY_NAME.charAt(0).toUpperCase()); this.favLetter.push(obj.EMPLOYEE_DISPLAY_NAME.charAt(0).toUpperCase());
}); });
this.favLetter = this.favLetter.filter((elem, index, self) => { this.favLetter = this.favLetter.filter((elem, index, self) => {
return index === self.indexOf(elem); return index === self.indexOf(elem);
}); });
this.favLetter.forEach((obj, index) => { if (this.activeSelectedLetter) {
if (index === 0) { this.selectedLetter(this.activeSelectedLetter);
this.favIsActive.push(true); } else {
} else { this.favLetter.forEach((obj, index) => {
this.favIsActive.push(false); 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.favLetter);
console.log(this.favIsActive); console.log(this.favIsActive);
} }
@ -405,6 +415,7 @@ export class WorkListReplacementItgComponent implements OnInit {
this.favLetter.forEach((letter, index) => { this.favLetter.forEach((letter, index) => {
if (letter === el) { if (letter === el) {
this.favIsActive[index] = true; this.favIsActive[index] = true;
this.activeSelectedLetter = el;
this.worklistService.getFavoriteByLetter(letter,() => { this.worklistService.getFavoriteByLetter(letter,() => {
}).subscribe((result) => { }).subscribe((result) => {
if (this.cs.validResponse(result)) { if (this.cs.validResponse(result)) {

@ -55,6 +55,8 @@ export class WorkListReplacementRollComponent implements OnInit {
spaceBetween: 5 spaceBetween: 5
}; };
public activeSelectedLetter:string;
constructor(public worklistService: WorklistService, private cs: CommonService, public ts: TranslatorService, public workListMainService: WorklistMainService, public modalCtrl: ModalController) { constructor(public worklistService: WorklistService, private cs: CommonService, public ts: TranslatorService, public workListMainService: WorklistMainService, public modalCtrl: ModalController) {
this.P_PAGE_NUM = 1; this.P_PAGE_NUM = 1;
this.P_PAGE_LIMIT = 50; this.P_PAGE_LIMIT = 50;
@ -509,22 +511,28 @@ export class WorkListReplacementRollComponent implements OnInit {
this.worklistService.getFavoriteWithoutImage({}, () => { this.worklistService.getFavoriteWithoutImage({}, () => {
}).subscribe((result) => { }).subscribe((result) => {
if (this.cs.validResponse(result)) { if (this.cs.validResponse(result)) {
this.favoriteUserList = result['Mohemm_GetFavoriteReplacementsList']; // this.favoriteUserList = result['Mohemm_GetFavoriteReplacementsList'];
this.favoriteUserList.forEach((obj) => { let favList = result['Mohemm_GetFavoriteReplacementsList'];
favList.forEach((obj) => {
obj.IsFavorite = true; obj.IsFavorite = true;
this.favLetter.push(obj.EMPLOYEE_DISPLAY_NAME.charAt(0).toUpperCase()); this.favLetter.push(obj.EMPLOYEE_DISPLAY_NAME.charAt(0).toUpperCase());
}); });
this.favLetter = this.favLetter.filter((elem, index, self) => { this.favLetter = this.favLetter.filter((elem, index, self) => {
return index === self.indexOf(elem); return index === self.indexOf(elem);
}); });
this.favLetter.forEach((obj, index) => { if (this.activeSelectedLetter) {
if (index === 0) { this.selectedLetter(this.activeSelectedLetter);
this.selectedLetter(obj); } else {
this.favIsActive.push(true); this.favLetter.forEach((obj, index) => {
} else { if(this.activeSelectedLetter) {}
this.favIsActive.push(false); if (index === 0) {
} this.selectedLetter(obj);
}); this.favIsActive.push(true);
} else {
this.favIsActive.push(false);
}
});
}
console.log(this.favLetter); console.log(this.favLetter);
console.log(this.favIsActive); console.log(this.favIsActive);
} }
@ -554,7 +562,7 @@ export class WorkListReplacementRollComponent implements OnInit {
} }
this.getFavruite(); this.getFavruite();
} }
}) });
} }
setFavorite(selEmp) { setFavorite(selEmp) {
@ -645,6 +653,7 @@ export class WorkListReplacementRollComponent implements OnInit {
this.favLetter.forEach((letter, index) => { this.favLetter.forEach((letter, index) => {
if (letter === el) { if (letter === el) {
this.favIsActive[index] = true; this.favIsActive[index] = true;
this.activeSelectedLetter = el;
this.worklistService.getFavoriteByLetter(letter,() => { this.worklistService.getFavoriteByLetter(letter,() => {
}).subscribe((result) => { }).subscribe((result) => {
if (this.cs.validResponse(result)) { if (this.cs.validResponse(result)) {

Loading…
Cancel
Save