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,
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)) {

@ -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)) {

Loading…
Cancel
Save