fixing favruite in worklist and my team

MOHEMM-SFH-COLORS
enadhilal 4 years ago
parent b12eeb4a1a
commit a03b32a2b0

@ -78,7 +78,7 @@
<ion-item *ngIf='userInfo?.show_business' (click)="openBusinessCard()">
<ion-thumbnail slot="start" class="menu-thumb">
<img style= "height: 25px !important;" src="../assets/imgs/ID_ico_menu.png" item-left>
<img style= "height: 25px !important;" src="../assets/imgs/business-card-design.png" item-left>
</ion-thumbnail>
<ion-label class="changepassword" >
{{ts.trPK('general','business-card')}}
@ -177,7 +177,7 @@
<ion-item *ngIf='userInfo?.show_business' (click)="openBusinessCard()">
<ion-thumbnail slot="start" class="menu-thumb">
<img style= "height: 25px !important;" src="../assets/imgs/ID_ico_menu.png" item-left>
<img style= "height: 25px !important;" src="../assets/imgs/business-card-design.png" item-left>
</ion-thumbnail>
<ion-label class="changepassword" >
{{ts.trPK('general','business-card')}}

@ -14,6 +14,7 @@ import { GetTimeCardSummaryRequest } from 'src/app/time-card/service/models/get-
import { DashboredService } from 'src/app/hmg-common/services/dashbored/dashbored.service';
import { AttendanceTrackingResponse } from 'src/app/hmg-common/services/dashbored/attendance-tracking.response';
import { WorklistService } from 'src/app/notification/service/worklist.service';
import { element } from 'protractor';
@Component({
selector: 'app-details',
templateUrl: './details.component.html',
@ -93,9 +94,9 @@ export class DetailsComponent implements OnInit {
public itemType = '';
public monthNo: any;
isFavorite = false;
public EmpNumer:any;
public isFavor:any;
public EmployeeTotal:any;
public EmpNumer: any;
public isFavor: any;
public EmployeeTotal: any;
// public activeSegment = 'About';
@ -247,7 +248,7 @@ export class DetailsComponent implements OnInit {
let jobTitle = this.employee.POSITION_NAME.split('.');
if (jobTitle && jobTitle.length > 1) {
this.jobName = jobTitle[0] + " " + jobTitle[1];
}
}
const request = {
P_SELECTED_EMPLOYEE_NUMBER: this.employee.EMPLOYEE_NUMBER
@ -266,7 +267,7 @@ export class DetailsComponent implements OnInit {
this.common.startLoading();
this.initAttendance();
}
else if(this.activeSegment != 'Attendance' && this.activeSegment != 'TeamMembers'){
else if (this.activeSegment != 'Attendance' && this.activeSegment != 'TeamMembers') {
this.activeSegment = 'About';
}
}
@ -539,7 +540,7 @@ export class DetailsComponent implements OnInit {
this.isSpecialist = this.common.sharedService.getSharedData('isSpecialist', false) ? true : false;
if (this.employee) {
this.getEmpSubordinate(userID);
this.isFavorite = false;
// this.isFavorite = false;
this.getFavorit();
}
}
@ -611,7 +612,7 @@ export class DetailsComponent implements OnInit {
}
handleEmpResult(result) {
this.EmployeeTotal = result.length;
this.EmployeeTotal = result.length;
const lastItemIndex = result.length - 1;
const lastItem = result[lastItemIndex];
if (lastItem) {
@ -790,90 +791,75 @@ export class DetailsComponent implements OnInit {
selEmp.EMPLOYEE_DISPLAY_NAME = selEmp.EMPLOYEE_DISPLAY_NAME ? selEmp.EMPLOYEE_DISPLAY_NAME : selEmp.NAME;
selEmp.EMPLOYEE_IMAGE = selEmp.EMPLOYEE_IMAGE ? selEmp.EMPLOYEE_IMAGE : '';
selEmp.EMAIL_ADDRESS = selEmp.EMAIL_ADDRESS ? selEmp.EMAIL_ADDRESS : '';
var confirmBoxhtml = `<div>
<h4>Do you want to add ` + selEmp.EMPLOYEE_DISPLAY_NAME + ` in your favorite list </h4>
<br/>
<br/>
<div class="fav-profileImageDiv"><ion-row>`;
if (selEmp.EMPLOYEE_IMAGE)
confirmBoxhtml += '<div class="img-box"><img class="empImgeRep" src="data:image/png;base64,' + selEmp.EMPLOYEE_IMAGE + '"></div>';
if (!selEmp.EMPLOYEE_IMAGE)
confirmBoxhtml += '<div class="img-box"><img class="empImgeRep" src="../assets/imgs/profile.png"></div>';
confirmBoxhtml += ` <div class="name-box"><ion-label class="fav-employee-details">
<span>` + selEmp.EMPLOYEE_DISPLAY_NAME + `</span>
</ion-label>
</div></ion-row> </div>
</div>`
let userIndex = this.favoriteUserList.findIndex(x => x['USER_NAME'] == selEmp.USER_NAME)
if (userIndex == -1)
this.common.presentConfirmDialog(
confirmBoxhtml
, () => {
var request =
[ { "USER_NAME": this.employee.EMPLOYEE_NUMBER, "EMPLOYEE_DISPLAY_NAME": this.employee.EMPLOYEE_DISPLAY_NAME, "EMAIL_ADDRESS": this.employee.EMAIL_ADDRESS, "EMPLOYEE_IMAGE": this.employee.EMPLOYEE_IMAGE, "IsFavorite": !this.isFavorite}];
this.saveUserFavruiteList(request);
// this.isFavorite = false;
}, () => {
})
// if (selectValue == "1" || selectValue == "2" || selectValue == "3") {
// this.isSelect = true;
// }
// else {
// this.isSelect = false;
// }
}
getFavruite() {
this.worklistService.getFavorite({}, () => {
}).subscribe((result) => {
if (this.common.validResponse(result)) {
this.common.stopLoading();
this.favoriteUserList = result['Mohemm_GetFavoriteReplacementsList'];
if(!this.isFavorite) {
let confirmBoxhtml = `<div>
<h4>Do you want to add ` + selEmp.EMPLOYEE_DISPLAY_NAME + ` in your favorite list </h4>
<br/>
<br/>
<div class="fav-profileImageDiv"><ion-row>`;
if (selEmp.EMPLOYEE_IMAGE) {
confirmBoxhtml += '<div class="img-box"><img class="empImgeRep" src="data:image/png;base64,' + selEmp.EMPLOYEE_IMAGE + '"></div>';
}
if (!selEmp.EMPLOYEE_IMAGE) {
confirmBoxhtml += '<div class="img-box"><img class="empImgeRep" src="../assets/imgs/profile.png"></div>';
}
confirmBoxhtml += ` <div class="name-box"><ion-label class="fav-employee-details">
<span>` + selEmp.EMPLOYEE_DISPLAY_NAME + `</span>
</ion-label>
</div></ion-row> </div>
</div>`;
const userIndex = this.favoriteUserList.findIndex(x => x['USER_NAME'] === selEmp.USER_NAME)
if (userIndex === -1) {
this.common.presentConfirmDialog(
confirmBoxhtml
, () => {
const request =
[
{
"USER_NAME": this.employee.EMPLOYEE_NUMBER,
"EMPLOYEE_DISPLAY_NAME": this.employee.EMPLOYEE_DISPLAY_NAME,
"EMAIL_ADDRESS": this.employee.EMAIL_ADDRESS,
"EMPLOYEE_IMAGE": this.employee.EMPLOYEE_IMAGE,
"IsFavorite": true
}
];
this.saveUserFavruiteList(request);
},
() => {});
}
})
} else {
const request =
[
{
"USER_NAME": this.employee.EMPLOYEE_NUMBER,
"EMPLOYEE_DISPLAY_NAME": this.employee.EMPLOYEE_DISPLAY_NAME,
"EMAIL_ADDRESS": this.employee.EMAIL_ADDRESS,
"EMPLOYEE_IMAGE": this.employee.EMPLOYEE_IMAGE,
"IsFavorite": false
}
];
this.saveUserFavruiteList(request);
}
}
saveUserFavruiteList(request) {
this.worklistService.saveFavoriteList(request, () => {
}).subscribe((result) => {
if (this.common.validResponse(result)) {
this.common.toastPK("replacementRoll", "favorite-saved");
this.isFavorite = !this.isFavorite;
this.getFavorit();
}
})
});
}
getFavorit(){
getFavorit() {
this.worklistService.getFavoriteMyTeam({}, () => {
}).subscribe((result) => {
this.EmpNumer = result.Mohemm_GetFavoriteReplacementsList;
this.EmpNumer.forEach(element => {
if(element.USER_NAME === this.employee.EMPLOYEE_NUMBER){
this.isFavorite = true;
}
});
}).subscribe((result) => {
this.EmpNumer = result.Mohemm_GetFavoriteReplacementsList;
this.isFavorite = this.EmpNumer.some(element => element.USER_NAME === this.employee.EMPLOYEE_NUMBER);
this.common.stopLoading();
});
}
}

@ -94,9 +94,12 @@
<span (click)="select(employee,i)">{{employee.NAME}}</span>
</ion-label>
<div [ngClass]="direction == 'en' ? 'star-fav' : 'star-fav-left'" (click)="setFavorite(employee)">
<div *ngIf='!employee.isInFavorite' [ngClass]="direction == 'en' ? 'star-fav' : 'star-fav-left'" (click)="setFavorite(employee)">
<img src="assets/imgs/fav.svg" />
</div>
<div *ngIf='employee.isInFavorite' [ngClass]="direction == 'en' ? 'star-fav' : 'star-fav-left'" (click)="setFavorite(employee)">
<img src="assets/imgs/fav filled.svg" />
</div>
</div>
</div>
</div>

@ -53,26 +53,26 @@ export class WorkListReplacementRollComponent implements OnInit {
this.P_PAGE_NUM = 1;
this.P_PAGE_LIMIT = 50;
this.getPassActionMode = this.cs.sharedService.getSharedData('passActionMode', false);
console.log(this.getPassActionMode);
// this.getFavruite();
this.getPassNotificationDetails = this.cs.sharedService.getSharedData('passNotificationInfo', false);
this.getpassResAttr = this.cs.sharedService.getSharedData('passResAttr', false);
console.log(this.getpassResAttr);
this.pQuestion = this.cs.sharedService.getSharedData('pQuestion', false);
// tslint:disable-next-line: max-line-length
this.arr = this.cs.sharedService.getSharedData('actionHistoryData', false) ? this.cs.sharedService.getSharedData('actionHistoryData', false) : [];
var lookupObject = {};
var lookupObject = {};
for(var i in this.arr) {
// tslint:disable-next-line: forin
for (var i in this.arr) {
lookupObject[this.arr[i]['USER_NAME']] = this.arr[i];
}
}
// tslint:disable-next-line: forin
for (i in lookupObject) {
this.actionHistory.push(lookupObject[i]);
}
for(i in lookupObject) {
this.actionHistory.push(lookupObject[i]);
}
console.log(this.actionHistory);
if (this.getPassActionMode === 'ANSWER_INFO') {
this.isAnswer = true;
@ -214,7 +214,6 @@ export class WorkListReplacementRollComponent implements OnInit {
select(selectEmp, index) {
console.log(selectEmp.EMPLOYEE_DISPLAY_NAME);
this.selEmp = selectEmp
this.active = index;
this.userSelected = true;
@ -251,11 +250,7 @@ export class WorkListReplacementRollComponent implements OnInit {
if (this.selEmp && this.isAnswer == false) {
// this.selectedUserInf = this.ReplacementList[this.selEmp];
this.selectedUserInf = this.selEmp;
console.log("selEmp " + this.selEmp.USER_NAME);
if (this.selectedUserInf && this.selectedUserInf.USER_NAME) {
console.log("userInfo " + this.selectedUserInf.USER_NAME);
if (this.userNote) {
if (this.getPassActionMode == "APPROVE_AND_FORWARD" || this.getPassActionMode == "FORWARD") {
@ -267,7 +262,6 @@ export class WorkListReplacementRollComponent implements OnInit {
this.getpassResAttr[index_Note].ATTRIBUTE_TEXT_VALUE = this.userNote;
this.P_RESPOND_ATTRIBUTES_TBL = this.getpassResAttr;
console.log(this.P_RESPOND_ATTRIBUTES_TBL);
this.WorkListActionObj.P_FORWARD_TO_USER_NAME = this.selectedUserInf.USER_NAME;
this.WorkListActionObj.P_ACTION_MODE = this.getPassActionMode;
this.WorkListActionObj.P_COMMENTS = ""// response Attr
@ -353,8 +347,9 @@ export class WorkListReplacementRollComponent implements OnInit {
'dismissed': true,
data: "Success"
});
if (this.selEmp && this.isAnswer == false)
if (this.selEmp && this.isAnswer == false) {
this.setFavorite(this.selEmp);
}
}, 5000);
this.cs.openNotificationPage();
@ -416,15 +411,16 @@ export class WorkListReplacementRollComponent implements OnInit {
}
}
//this.P_PAGE_NUM++;
if (infiniteScroll)
if (infiniteScroll) {
infiniteScroll.target.complete();
}
// console.log(resFlag);
}, (Error) => console.log(Error), () => infiniteScroll.target.complete());
} else {
if (infiniteScroll)
if (infiniteScroll) {
infiniteScroll.target.complete();
}
}
}
@ -438,7 +434,6 @@ export class WorkListReplacementRollComponent implements OnInit {
selectedType;
onChangeSelect(select) {
console.log(select.detail.value);
let selectValue = select.detail.value;
if (selectValue == '1') {
@ -446,14 +441,13 @@ export class WorkListReplacementRollComponent implements OnInit {
this.isFilter = true;
this.selectedType = 1;
this.listOfRealted = this.actionHistory;
} else if(selectValue === '4'){
console.log(this.listOfFav.length)
if(this.favoriteUserList.length === 0 || this.favoriteUserList === undefined ) {
} else if (selectValue === '4') {
if (this.favoriteUserList.length === 0 || this.favoriteUserList === undefined) {
this.getFavruite();
}
this.isFilter = true;
this.selectedType = 4;
} else if( selectValue === '2' || selectValue === '3' || selectValue === '5'){
} else if (selectValue === '2' || selectValue === '3' || selectValue === '5') {
this.isSelect = true;
this.isFilter = false;
this.selectedType = 0;
@ -494,8 +488,20 @@ export class WorkListReplacementRollComponent implements OnInit {
this.cs.stopLoading();
this.favoriteUserList = result['Mohemm_GetFavoriteReplacementsList'];
this.listOfFav = this.favoriteUserList;
/**** THIS CODE TO CHECK STAR OF EMPLOYEE IF THE IT IS IN FAVOORIT LIST AND SHOW IN WORKFLOW LIST****/
// this.actionHistory.forEach((obj, i) => {
// if(this.favoriteUserList.some(x => x['USER_NAME'] === obj.USER_NAME)) {
// this.actionHistory[i].isInFavorite = true;
// } else {
// this.actionHistory[i].isInFavorite = false;
// }
// });
// console.log(this.actionHistory);
/**** END ****/
}
})
});
}
saveUserFavruiteList(request) {
this.worklistService.saveFavoriteList(request, () => {
@ -511,80 +517,80 @@ export class WorkListReplacementRollComponent implements OnInit {
selEmp.EMPLOYEE_DISPLAY_NAME = selEmp.EMPLOYEE_DISPLAY_NAME ? selEmp.EMPLOYEE_DISPLAY_NAME : selEmp.NAME;
selEmp.EMPLOYEE_IMAGE = selEmp.EMPLOYEE_IMAGE ? selEmp.EMPLOYEE_IMAGE : '';
selEmp.EMAIL_ADDRESS = selEmp.EMAIL_ADDRESS ? selEmp.EMAIL_ADDRESS : '';
var confirmBoxhtml = `<div>
<h4>Do you want to add ` + selEmp.EMPLOYEE_DISPLAY_NAME + ` in your favorite list </h4>
<br/>
<br/>
<div class="fav-profileImageDiv"><ion-row>`;
if (selEmp.EMPLOYEE_IMAGE)
confirmBoxhtml += '<div class="img-box"><img class="empImgeRep" src="data:image/png;base64,' + selEmp.EMPLOYEE_IMAGE + '"></div>';
if (!selEmp.EMPLOYEE_IMAGE)
confirmBoxhtml += '<div class="img-box"><img class="empImgeRep" src="../assets/imgs/profile.png"></div>';
confirmBoxhtml += ` <div class="name-box"><ion-label class="fav-employee-details">
<span>` + selEmp.EMPLOYEE_DISPLAY_NAME + `</span>
</ion-label>
</div></ion-row> </div>
</div>`
let userIndex = this.favoriteUserList.findIndex(x => x['USER_NAME'] == selEmp.USER_NAME)
if (userIndex == -1)
this.cs.presentConfirmDialog(
confirmBoxhtml
, () => {
var request =
[{ "USER_NAME": selEmp['USER_NAME'], "EMPLOYEE_DISPLAY_NAME": selEmp['EMPLOYEE_DISPLAY_NAME'], "EMAIL_ADDRESS": selEmp.EMAIL_ADDRESS, "EMPLOYEE_IMAGE": selEmp.EMPLOYEE_IMAGE, "IsFavorite": true }];
this.saveUserFavruiteList(request);
}, () => {
})
// if (selectValue == "1" || selectValue == "2" || selectValue == "3") {
// this.isSelect = true;
// }
// else {
// this.isSelect = false;
if (this.favoriteUserList.some(x => x['USER_NAME'] === selEmp.USER_NAME)) {
let confirmBoxhtml = `<div>
<h4>Do you want to add ` + selEmp.EMPLOYEE_DISPLAY_NAME + ` in your favorite list </h4>
<br/>
<br/>
<div class="fav-profileImageDiv"><ion-row>`;
if (selEmp.EMPLOYEE_IMAGE) {
confirmBoxhtml += '<div class="img-box"><img class="empImgeRep" src="data:image/png;base64,' + selEmp.EMPLOYEE_IMAGE + '"></div>';
}
if (!selEmp.EMPLOYEE_IMAGE) {
confirmBoxhtml += '<div class="img-box"><img class="empImgeRep" src="../assets/imgs/profile.png"></div>';
}
confirmBoxhtml += ` <div class="name-box"><ion-label class="fav-employee-details">
<span>` + selEmp.EMPLOYEE_DISPLAY_NAME + `</span>
</ion-label>
</div></ion-row> </div>
</div>`;
const userIndex = this.favoriteUserList.findIndex(x => x['USER_NAME'] === selEmp.USER_NAME)
if (userIndex === -1) {
this.cs.presentConfirmDialog(
confirmBoxhtml
, () => {
const request =
[
{
'USER_NAME': selEmp['USER_NAME'],
'EMPLOYEE_DISPLAY_NAME': selEmp['EMPLOYEE_DISPLAY_NAME'],
'EMAIL_ADDRESS': selEmp.EMAIL_ADDRESS,
'EMPLOYEE_IMAGE': selEmp.EMPLOYEE_IMAGE,
'IsFavorite': true
}
];
// }
this.saveUserFavruiteList(request);
}, () => { });
}
} else {
const request =
[
{
'USER_NAME': selEmp['USER_NAME'],
'EMPLOYEE_DISPLAY_NAME': selEmp['EMPLOYEE_DISPLAY_NAME'],
'EMAIL_ADDRESS': selEmp.EMAIL_ADDRESS,
'EMPLOYEE_IMAGE': selEmp.EMPLOYEE_IMAGE,
'IsFavorite': false
}
];
this.saveUserFavruiteList(request);
}
}
// onChangeInput() {
// if (this.inputSearch.length > 0) {
// this.searchKeyEnter = true;
// } else {
// this.searchKeyEnter = false;
// }
// }
listOfRealted: any = [];
listOfFav: any = [];
filterList(event){
filterList(event) {
const val = event.target.value;
if(this.selectedType === 1){
if(val === '') {
if (this.selectedType === 1) {
if (val === '') {
this.actionHistory = this.listOfRealted;
} else {
this.actionHistory = this.listOfRealted.filter((item) => {
return (item.NAME.toLowerCase().indexOf(val.toLowerCase()) > -1);
});
}
} else if(this.selectedType === 4) {
if(val === '') {
} else if (this.selectedType === 4) {
if (val === '') {
this.favoriteUserList = this.listOfFav;
} else {
this.favoriteUserList = this.listOfFav.filter((item) => {
return (item.EMPLOYEE_DISPLAY_NAME.toLowerCase().indexOf(val.toLowerCase()) > -1);
});
}
}else{
} else {
return;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Loading…
Cancel
Save