|
|
|
|
@ -58,10 +58,18 @@ export class HomeComponent implements OnInit {
|
|
|
|
|
public worklistNotifications: any;
|
|
|
|
|
public totalRequestCount = 0;
|
|
|
|
|
public newWorkListResponse = [];
|
|
|
|
|
public showFormattedData = {};
|
|
|
|
|
public showFormattedData = [];
|
|
|
|
|
public allFormattedData = [];
|
|
|
|
|
public selectedFilter = 'ALL';
|
|
|
|
|
public showSearchButton = false;
|
|
|
|
|
public itemType = '';
|
|
|
|
|
|
|
|
|
|
public totalHR = 0;
|
|
|
|
|
public totalPO = 0;
|
|
|
|
|
public totalPR = 0;
|
|
|
|
|
public totalMR = 0;
|
|
|
|
|
|
|
|
|
|
public showChart = false;
|
|
|
|
|
public options = {
|
|
|
|
|
cutoutPercentage: 80,
|
|
|
|
|
tooltips: { enabled: false },
|
|
|
|
|
@ -153,11 +161,9 @@ export class HomeComponent implements OnInit {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
|
// this.direction = TranslatorService.getCurrentDirection();
|
|
|
|
|
this.worklistNotifications = this.common.sharedService.getSharedData('worklistNotifications', false);
|
|
|
|
|
this.Details();
|
|
|
|
|
this.Count();
|
|
|
|
|
this.assignDataToFilters();
|
|
|
|
|
this.getAllPushNotificationFun();
|
|
|
|
|
this.totalRequestCount = this.worklistNotifications.P_OPEN_NTF_NUMBER;
|
|
|
|
|
}
|
|
|
|
|
@ -165,42 +171,38 @@ export class HomeComponent implements OnInit {
|
|
|
|
|
assignDataToFilters() {
|
|
|
|
|
this.filters[0].value = this.worklistNotifications.P_OPEN_NTF_NUMBER;
|
|
|
|
|
const openNotificationsArray = this.worklistNotifications.GetOpenNotificationsList;
|
|
|
|
|
|
|
|
|
|
for (const notification of openNotificationsArray) {
|
|
|
|
|
if (notification.ITEM_TYPE === 'HRSSA') {
|
|
|
|
|
this.filters[1].value = notification.OPEN_NTF_NUMBER;
|
|
|
|
|
this.filters[1].value = this.totalHR;
|
|
|
|
|
this.data.datasets[0].data[0] = notification.OPEN_NTF_NUMBER;
|
|
|
|
|
} else if (notification.ITEM_TYPE === 'POAPPRV') {
|
|
|
|
|
this.filters[2].value = notification.OPEN_NTF_NUMBER;
|
|
|
|
|
this.filters[2].value = this.totalPO;
|
|
|
|
|
this.data.datasets[0].data[1] = notification.OPEN_NTF_NUMBER;
|
|
|
|
|
} else if (notification.ITEM_TYPE === 'REQAPPRV') {
|
|
|
|
|
this.filters[3].value = notification.OPEN_NTF_NUMBER;
|
|
|
|
|
this.filters[3].value = this.totalPR;
|
|
|
|
|
this.data.datasets[0].data[2] = notification.OPEN_NTF_NUMBER;
|
|
|
|
|
} else if (notification.ITEM_TYPE === 'INVMOA') {
|
|
|
|
|
this.filters[4].value = notification.OPEN_NTF_NUMBER;
|
|
|
|
|
this.filters[4].value = this.totalMR;
|
|
|
|
|
this.data.datasets[0].data[3] = notification.OPEN_NTF_NUMBER;
|
|
|
|
|
} else if (notification.ITEM_TYPE === 'ITG') {
|
|
|
|
|
this.filters[5].value = notification.OPEN_NTF_NUMBER;
|
|
|
|
|
this.data.datasets[0].data[4] = notification.OPEN_NTF_NUMBER;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.showChart = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
activeFilter(index: number) {
|
|
|
|
|
if (this.currentActiveIndex !== index) {
|
|
|
|
|
this.showFormattedData = {};
|
|
|
|
|
this.previousActiveIndex = this.currentActiveIndex;
|
|
|
|
|
this.currentActiveIndex = index;
|
|
|
|
|
this.filters[this.previousActiveIndex].active = false;
|
|
|
|
|
this.filters[this.currentActiveIndex].active = true;
|
|
|
|
|
if (this.filters[this.currentActiveIndex].value !== 0) {
|
|
|
|
|
const selectedKey = this.filters[this.currentActiveIndex].key;
|
|
|
|
|
this.resetData();
|
|
|
|
|
this.itemType = (selectedKey !== 'ITG' && selectedKey !== 'ALL') ? this.filters[this.currentActiveIndex].key : '';
|
|
|
|
|
this.getAllPushNotificationFun();
|
|
|
|
|
}
|
|
|
|
|
this.selectedFilter = this.filters[this.currentActiveIndex].key;
|
|
|
|
|
if (this.selectedFilter !== 'ITG') {
|
|
|
|
|
this.getFilteredData(this.selectedFilter);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -230,13 +232,13 @@ export class HomeComponent implements OnInit {
|
|
|
|
|
async openSearchModal() {
|
|
|
|
|
const modal = await this.modalController.create({
|
|
|
|
|
component: WorklistAdvancedSearchComponent,
|
|
|
|
|
cssClass: 'advanced-search-modal',
|
|
|
|
|
cssClass: 'advanced-search-modal-custom',
|
|
|
|
|
backdropDismiss: false,
|
|
|
|
|
componentProps: {}
|
|
|
|
|
});
|
|
|
|
|
modal.onDidDismiss().then(result => {
|
|
|
|
|
if (result.data) {
|
|
|
|
|
if (result.data.notificationType !== '' || result.data.selectedValue !== '' || result.data.itemType !== '') {
|
|
|
|
|
if (result.data.notificationType !== '' || result.data.selectedValue !== '' || result.data.itemType !== '') {
|
|
|
|
|
this.showSearchButton = true;
|
|
|
|
|
this.itemType = result.data.itemType;
|
|
|
|
|
this.notificationType = result.data.notificationType;
|
|
|
|
|
@ -245,7 +247,7 @@ export class HomeComponent implements OnInit {
|
|
|
|
|
this.inputSearch = result.data.inputSearch;
|
|
|
|
|
this.WorkListObj.P_PAGE_NUM = 1;
|
|
|
|
|
this.newWorkListResponse = [];
|
|
|
|
|
this.showFormattedData = {};
|
|
|
|
|
this.showFormattedData = [];
|
|
|
|
|
this.selectedFilter = 'ALL';
|
|
|
|
|
this.filters[this.currentActiveIndex].active = false;
|
|
|
|
|
this.currentActiveIndex = 0;
|
|
|
|
|
@ -268,7 +270,7 @@ export class HomeComponent implements OnInit {
|
|
|
|
|
this.WorkListObj.P_SEARCH_SUBJECT = this.selectedValue === '2' ? this.inputSearch : '';
|
|
|
|
|
this.WorkListObj.P_SEARCH_SENT_DATE = (this.inputDate && this.selectedValue === '3')
|
|
|
|
|
? moment(this.inputDate).format('DD-MMM-YYYY') : '';
|
|
|
|
|
this.WorkListObj.P_SEARCH_ITEM_TYPE_DSP_NAME = this.selectedValue === '4' ? this.inputSearch : ''; ;
|
|
|
|
|
this.WorkListObj.P_SEARCH_ITEM_TYPE_DSP_NAME = this.selectedValue === '4' ? this.inputSearch : '';
|
|
|
|
|
this.WorkListObj.P_ITEM_TYPE = this.itemType !== '' ? this.itemType : '';
|
|
|
|
|
this.WorkListObj.P_NOTIFICATION_TYPE = this.notificationType !== '' ? this.notificationType : '1';
|
|
|
|
|
if (this.selectedValue === '5') {
|
|
|
|
|
@ -277,7 +279,6 @@ export class HomeComponent implements OnInit {
|
|
|
|
|
this.WorkListObj.P_SEARCH_SENT_DATE = '';
|
|
|
|
|
this.WorkListObj.P_SEARCH_SUBJECT = '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.WorklistService.getWorkList(this.WorkListObj).subscribe((result) => {
|
|
|
|
|
if (this.common.validResponse(result)) {
|
|
|
|
|
this.handleWorkListResult(result.GetWorkList);
|
|
|
|
|
@ -286,24 +287,82 @@ export class HomeComponent implements OnInit {
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
categorizeData(arrayToCategorize: any) {
|
|
|
|
|
const datePipe = new DatePipe('en-US');
|
|
|
|
|
const formattedData = {};
|
|
|
|
|
for (const workList of arrayToCategorize) {
|
|
|
|
|
workList.FORMATTED_DATE = datePipe.transform(new Date(workList.BEGIN_DATE), 'MMMM dd, y');
|
|
|
|
|
if (!(workList.FORMATTED_DATE in formattedData)) {
|
|
|
|
|
formattedData[workList.FORMATTED_DATE] = new Array();
|
|
|
|
|
formattedData[workList.FORMATTED_DATE].push(workList);
|
|
|
|
|
} else {
|
|
|
|
|
formattedData[workList.FORMATTED_DATE].push(workList);
|
|
|
|
|
getFilteredData(filter: string) {
|
|
|
|
|
if (filter === 'ALL') {
|
|
|
|
|
this.showFormattedData = this.allFormattedData;
|
|
|
|
|
} else {
|
|
|
|
|
let arrayToFilter;
|
|
|
|
|
arrayToFilter = this.newWorkListResponse.filter((workList) => {
|
|
|
|
|
return workList.ITEM_TYPE === filter;
|
|
|
|
|
});
|
|
|
|
|
this.showFormattedData = this.categorizeData(arrayToFilter);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
checkDateExistance(currentDate: any, formattedData: any) {
|
|
|
|
|
let existsBefore = false;
|
|
|
|
|
let index = 0;
|
|
|
|
|
for (let i = 0; i < formattedData.length; i++) {
|
|
|
|
|
if (formattedData[i].date === currentDate) {
|
|
|
|
|
existsBefore = true;
|
|
|
|
|
index = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return {
|
|
|
|
|
exists: existsBefore,
|
|
|
|
|
indexNumber: index
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
addCountInFilters(workList: any) {
|
|
|
|
|
if (workList.ITEM_TYPE === 'HRSSA') {
|
|
|
|
|
this.totalHR = this.totalHR + 1;
|
|
|
|
|
} else if (workList.ITEM_TYPE === 'POAPPRV') {
|
|
|
|
|
this.totalPO = this.totalPO + 1;
|
|
|
|
|
} else if (workList.ITEM_TYPE === 'REQAPPRV') {
|
|
|
|
|
this.totalPR = this.totalPR + 1;
|
|
|
|
|
} else if (workList.ITEM_TYPE === 'INVMOA') {
|
|
|
|
|
this.totalMR = this.totalMR + 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
categorizeData(arrayToCategorize: any) {
|
|
|
|
|
this.totalHR = 0;
|
|
|
|
|
this.totalPO = 0;
|
|
|
|
|
this.totalPR = 0;
|
|
|
|
|
this.totalMR = 0;
|
|
|
|
|
|
|
|
|
|
const datePipe = new DatePipe('en-US');
|
|
|
|
|
const formattedData = [];
|
|
|
|
|
for (const workList of arrayToCategorize) {
|
|
|
|
|
this.addCountInFilters(workList);
|
|
|
|
|
const currentDate = datePipe.transform(new Date(workList.BEGIN_DATE), 'MMMM dd, y');
|
|
|
|
|
const currentObject = {
|
|
|
|
|
date: '',
|
|
|
|
|
data: []
|
|
|
|
|
};
|
|
|
|
|
if (formattedData.length === 0) {
|
|
|
|
|
currentObject.date = currentDate;
|
|
|
|
|
currentObject.data.push(workList);
|
|
|
|
|
formattedData.push(currentObject);
|
|
|
|
|
} else {
|
|
|
|
|
const existsBefore = this.checkDateExistance(currentDate, formattedData);
|
|
|
|
|
if (existsBefore.exists) {
|
|
|
|
|
formattedData[existsBefore.indexNumber].data.push(workList);
|
|
|
|
|
} else {
|
|
|
|
|
currentObject.date = currentDate;
|
|
|
|
|
currentObject.data.push(workList);
|
|
|
|
|
formattedData.push(currentObject);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return formattedData;
|
|
|
|
|
return formattedData;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sortArray(arrayToSort: any) {
|
|
|
|
|
return arrayToSort.sort((a: any, b: any) =>
|
|
|
|
|
new Date(b.BEGIN_DATE).getTime() - new Date(a.BEGIN_DATE).getTime()
|
|
|
|
|
new Date(b.date).getTime() - new Date(a.date).getTime()
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -330,9 +389,10 @@ export class HomeComponent implements OnInit {
|
|
|
|
|
} else {
|
|
|
|
|
this.newWorkListResponse = this.newWorkListResponse.concat(result);
|
|
|
|
|
}
|
|
|
|
|
this.newWorkListResponse = this.sortArray(this.newWorkListResponse);
|
|
|
|
|
console.log(this.newWorkListResponse);
|
|
|
|
|
this.showFormattedData = this.categorizeData(this.newWorkListResponse);
|
|
|
|
|
const categorizedWorkListResponse = this.categorizeData(this.newWorkListResponse);
|
|
|
|
|
this.assignDataToFilters();
|
|
|
|
|
this.showFormattedData = this.sortArray(categorizedWorkListResponse);
|
|
|
|
|
this.allFormattedData = this.showFormattedData;
|
|
|
|
|
this.common.sharedService.setSharedData(this.newWorkListResponse, HomeComponent.NOTIFICATION_ARR);
|
|
|
|
|
} else {
|
|
|
|
|
this.newWorkListResponse = [];
|
|
|
|
|
@ -352,10 +412,6 @@ export class HomeComponent implements OnInit {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
isEmptyObject() {
|
|
|
|
|
return (this.showFormattedData && (Object.keys(this.showFormattedData).length > 0) || this.ITGItem.length > 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resetData() {
|
|
|
|
|
if (this.infiniteScroll) {
|
|
|
|
|
this.infiniteScroll.complete();
|
|
|
|
|
@ -366,7 +422,8 @@ export class HomeComponent implements OnInit {
|
|
|
|
|
this.inputDate = '';
|
|
|
|
|
this.inputSearch = '';
|
|
|
|
|
this.newWorkListResponse = [];
|
|
|
|
|
this.showFormattedData = {};
|
|
|
|
|
this.showFormattedData = [];
|
|
|
|
|
this.allFormattedData = [];
|
|
|
|
|
this.WorkListObj.P_SEARCH_FROM_USER = '';
|
|
|
|
|
this.WorkListObj.P_SEARCH_ITEM_TYPE_DSP_NAME = '';
|
|
|
|
|
this.WorkListObj.P_SEARCH_SENT_DATE = '';
|
|
|
|
|
@ -413,13 +470,13 @@ export class HomeComponent implements OnInit {
|
|
|
|
|
Details() {
|
|
|
|
|
this.workListService.getITGDetails()
|
|
|
|
|
.subscribe((result: any) => {
|
|
|
|
|
this.ITGCount = result.TotalCount;
|
|
|
|
|
this.totalRequestCount = this.totalRequestCount + result.TotalCount;
|
|
|
|
|
this.filters[5].value = result.TotalCount;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ITGNotification() {
|
|
|
|
|
// this.Details();
|
|
|
|
|
this.isAll = false;
|
|
|
|
|
this.isPR = false;
|
|
|
|
|
this.isPO = false;
|
|
|
|
|
|