diff --git a/Mohem/src/app/notification/worklist-main-mr/worklist-main-mr.component.ts b/Mohem/src/app/notification/worklist-main-mr/worklist-main-mr.component.ts index 82084a7b..1674519f 100644 --- a/Mohem/src/app/notification/worklist-main-mr/worklist-main-mr.component.ts +++ b/Mohem/src/app/notification/worklist-main-mr/worklist-main-mr.component.ts @@ -33,6 +33,8 @@ import { WorkListReplacementRollComponent } from '../work-list-replacement-roll/ import { WorkListRfcComponent } from '../work-list-rfc/work-list-rfc.component'; import { MOItemHistoryRes } from '../models/MOItemHistoryRes'; import { MOItemHistoryReq } from '../models/MOItemHistoryReq'; +import { GetOpenNotificationsResponse } from 'src/app/hmg-common/services/dashbored/models/GetOpenNotificationsResponse'; +import { DashboredService } from 'src/app/hmg-common/services/dashbored/dashbored.service'; @Component({ selector: 'app-worklist-main-mr', @@ -105,9 +107,12 @@ export class WorklistMainMRComponent implements OnInit { moreDisabled: boolean = true; direction: string; defaultSegment = ''; - + public isPostNoLoad = true; + public worklistNotifications: any; + public totalRequestCount = 0; constructor( + public common: CommonService, public ts: TranslatorService, public worklistMainService: WorklistMainService, @@ -116,7 +121,8 @@ export class WorklistMainMRComponent implements OnInit { public events: Events, public worklistAttachService: WorklistAttachService, private modalCtrl: ModalController, - public worklistService: WorklistService + public worklistService: WorklistService, + public dashboredService: DashboredService, ) { this.direction = TranslatorService.getCurrentLanguageName() //this.getPassNotificationDetails = this.common.sharedService.getSharedData('passNotificationInfo'); @@ -307,7 +313,7 @@ export class WorklistMainMRComponent implements OnInit { setTimeout(() => { this.messageSuccess = false; - this.getNotificationCountAfterSubmit(); + this.openNotificationsDashboard(); this.nextNotfification(); }, 5000); @@ -643,19 +649,19 @@ export class WorklistMainMRComponent implements OnInit { } } - getNotificationCountAfterSubmit() { - const req: any = {}; - this.menuService.getNotificationCount(req).subscribe((result: any) => { - if (this.common.validResponse(result)) { - this.notificationCount = - result.GetOpenNotificationsNumList.P_OPEN_NOTIFICATIONS_NUM; - if (this.notificationCount <= 0) { - this.notificationCount = null; - } - this.events.publish('getNotCount', this.notificationCount); - } - }); - } + // getNotificationCountAfterSubmit() { + // const req: any = {}; + // this.menuService.getNotificationCount(req).subscribe((result: any) => { + // if (this.common.validResponse(result)) { + // this.notificationCount = + // result.GetOpenNotificationsNumList.P_OPEN_NOTIFICATIONS_NUM; + // if (this.notificationCount <= 0) { + // this.notificationCount = null; + // } + // this.events.publish('getNotCount', this.notificationCount); + // } + // }); + // } @@ -1000,7 +1006,7 @@ export class WorklistMainMRComponent implements OnInit { if (data.data == 'cancel' || data.data == undefined) { return; } else if (data.data == 'Success') { - this.getNotificationCountAfterSubmit(); + this.openNotificationsDashboard(); this.nextNotfification(); } @@ -1032,7 +1038,7 @@ export class WorklistMainMRComponent implements OnInit { if (data.data == 'cancel' || data.data == undefined) { return; } else if (data.data == 'Success') { - this.getNotificationCountAfterSubmit(); + this.openNotificationsDashboard(); this.nextNotfification(); } @@ -1089,7 +1095,15 @@ export class WorklistMainMRComponent implements OnInit { } - + openNotificationsDashboard() { + this.dashboredService.getOpenNotifications('', '', this.isPostNoLoad).subscribe((result: GetOpenNotificationsResponse) => { + if (this.common.validResponse(result)) { + this.worklistNotifications = result; + this.totalRequestCount = this.worklistNotifications.P_OPEN_NTF_NUMBER; + this.common.sharedService.setSharedData(result, 'worklistNotifications'); + } + }); + } } diff --git a/Mohem/src/app/notification/worklist-main-po/worklist-main-po.component.ts b/Mohem/src/app/notification/worklist-main-po/worklist-main-po.component.ts index e877615c..50056319 100644 --- a/Mohem/src/app/notification/worklist-main-po/worklist-main-po.component.ts +++ b/Mohem/src/app/notification/worklist-main-po/worklist-main-po.component.ts @@ -35,6 +35,7 @@ import { QuotationAnalysisRequest } from '../models/quotationAnalysisReq'; import { MoreActionModalComponent } from '../more-action-modal/more-action-modal.component' import { WorkListReplacementRollComponent } from '../work-list-replacement-roll/work-list-replacement-roll.component'; import { WorkListRfcComponent } from '../work-list-rfc/work-list-rfc.component'; +import { DashboredService } from 'src/app/hmg-common/services/dashbored/dashbored.service'; @Component({ selector: 'app-worklist-main-po', @@ -54,7 +55,9 @@ export class WorklistMainPoComponent implements OnInit { public static PASS_PO_HEADER_ID = "passPOHeader"; public static PASS_ACTION_MODE = "passActionMode"; public static PASS_ACTION_MORE = "passActioMore"; - + public isPostNoLoad = true; + public worklistNotifications: any; + public totalRequestCount = 0; getPassNotificationDetails: any; public static PASS_RES_ATTR = "passResAttr"; TransactionID: number = -999; @@ -129,6 +132,8 @@ export class WorklistMainPoComponent implements OnInit { public worklistAttachService: WorklistAttachService, private modalCtrl: ModalController, public worklistService: WorklistService, + public dashboredService: DashboredService, + ) { this.direction = TranslatorService.getCurrentLanguageName() this.WorkListActionHistoryObj = new WorkListActionHistoryRequest(); @@ -340,7 +345,7 @@ export class WorklistMainPoComponent implements OnInit { setTimeout(() => { this.messageSuccess = false; - this.getNotificationCountAfterSubmit(); + this.openNotificationsDashboard(); this.nextNotfification(); }, 5000); @@ -679,19 +684,19 @@ export class WorklistMainPoComponent implements OnInit { } } - getNotificationCountAfterSubmit() { - const req: any = {}; - this.menuService.getNotificationCount(req).subscribe((result: any) => { - if (this.common.validResponse(result)) { - this.notificationCount = - result.GetOpenNotificationsNumList.P_OPEN_NOTIFICATIONS_NUM; - if (this.notificationCount <= 0) { - this.notificationCount = null; - } - this.events.publish("getNotCount", this.notificationCount); - } - }); - } + // getNotificationCountAfterSubmit() { + // const req: any = {}; + // this.menuService.getNotificationCount(req).subscribe((result: any) => { + // if (this.common.validResponse(result)) { + // this.notificationCount = + // result.GetOpenNotificationsNumList.P_OPEN_NOTIFICATIONS_NUM; + // if (this.notificationCount <= 0) { + // this.notificationCount = null; + // } + // this.events.publish("getNotCount", this.notificationCount); + // } + // }); + // } @@ -1068,7 +1073,7 @@ export class WorklistMainPoComponent implements OnInit { if (data.data == "cancel" || data.data == undefined) { return; } else if (data.data == "Success") { - this.getNotificationCountAfterSubmit(); + this.openNotificationsDashboard(); this.nextNotfification(); } @@ -1112,4 +1117,15 @@ export class WorklistMainPoComponent implements OnInit { } + openNotificationsDashboard() { + this.dashboredService.getOpenNotifications('', '', this.isPostNoLoad).subscribe((result: GetOpenNotificationsResponse) => { + if (this.common.validResponse(result)) { + this.worklistNotifications = result; + this.totalRequestCount = this.worklistNotifications.P_OPEN_NTF_NUMBER; + this.common.sharedService.setSharedData(result, 'worklistNotifications'); + } + }); + } + + } diff --git a/Mohem/src/app/notification/worklist-main-pr/worklist-main-pr.component.ts b/Mohem/src/app/notification/worklist-main-pr/worklist-main-pr.component.ts index 6b436ab0..9797a8d1 100644 --- a/Mohem/src/app/notification/worklist-main-pr/worklist-main-pr.component.ts +++ b/Mohem/src/app/notification/worklist-main-pr/worklist-main-pr.component.ts @@ -31,6 +31,8 @@ import { ApplyActionModalComponent } from '../apply-action-modal/apply-action-mo import { MoreActionModalComponent } from '../more-action-modal/more-action-modal.component'; import { WorkListReplacementRollComponent } from '../work-list-replacement-roll/work-list-replacement-roll.component'; import { WorkListRfcComponent } from '../work-list-rfc/work-list-rfc.component'; +import { DashboredService } from 'src/app/hmg-common/services/dashbored/dashbored.service'; +import { GetOpenNotificationsResponse } from 'src/app/hmg-common/services/dashbored/models/GetOpenNotificationsResponse'; @Component({ selector: 'app-worklist-main-pr', @@ -38,7 +40,9 @@ import { WorkListRfcComponent } from '../work-list-rfc/work-list-rfc.component'; styleUrls: ['./worklist-main-pr.component.scss'], }) export class WorklistMainPRComponent implements OnInit { - + public isPostNoLoad = true; + public worklistNotifications: any; + public totalRequestCount = 0; private WorkListBodyObj: WorkListBodyRequest; private WorkListButtonsObj: WorkListButtonRequest; private WorkListActionObj: WorkListActionRequest; @@ -106,6 +110,7 @@ export class WorklistMainPRComponent implements OnInit { constructor( + public dashboredService: DashboredService, public common: CommonService, public ts: TranslatorService, public worklistMainService: WorklistMainService, @@ -340,7 +345,7 @@ export class WorklistMainPRComponent implements OnInit { this.messageSuccess = false; }, 5000); - this.getNotificationCountAfterSubmit(); + this.openNotificationsDashboard(); this.nextNotfification(); } } // valid it @@ -677,19 +682,19 @@ export class WorklistMainPRComponent implements OnInit { } } - getNotificationCountAfterSubmit() { - const req: any = {}; - this.menuService.getNotificationCount(req).subscribe((result: any) => { - if (this.common.validResponse(result)) { - this.notificationCount = - result.GetOpenNotificationsNumList.P_OPEN_NOTIFICATIONS_NUM; - if (this.notificationCount <= 0) { - this.notificationCount = null; - } - this.events.publish('getNotCount', this.notificationCount); - } - }); - } + // getNotificationCountAfterSubmit() { + // const req: any = {}; + // this.menuService.getNotificationCount(req).subscribe((result: any) => { + // if (this.common.validResponse(result)) { + // this.notificationCount = + // result.GetOpenNotificationsNumList.P_OPEN_NOTIFICATIONS_NUM; + // if (this.notificationCount <= 0) { + // this.notificationCount = null; + // } + // this.events.publish('getNotCount', this.notificationCount); + // } + // }); + // } @@ -1000,7 +1005,7 @@ export class WorklistMainPRComponent implements OnInit { if (data.data == 'cancel' || data.data == undefined) { return; } else if (data.data == 'Success') { - this.getNotificationCountAfterSubmit(); + this.openNotificationsDashboard(); this.nextNotfification(); } @@ -1043,4 +1048,14 @@ export class WorklistMainPRComponent implements OnInit { } + openNotificationsDashboard() { + this.dashboredService.getOpenNotifications('', '', this.isPostNoLoad).subscribe((result: GetOpenNotificationsResponse) => { + if (this.common.validResponse(result)) { + this.worklistNotifications = result; + this.totalRequestCount = this.worklistNotifications.P_OPEN_NTF_NUMBER; + this.common.sharedService.setSharedData(result, 'worklistNotifications'); + } + }); + } + } \ No newline at end of file diff --git a/Mohem/src/app/notification/worklist-main/worklist-main.component.ts b/Mohem/src/app/notification/worklist-main/worklist-main.component.ts index 972712cd..7bdf179c 100644 --- a/Mohem/src/app/notification/worklist-main/worklist-main.component.ts +++ b/Mohem/src/app/notification/worklist-main/worklist-main.component.ts @@ -35,6 +35,7 @@ import { WorkListSubmitterInfoRequest } from '../models/WorklistsubmitterInfoReq import { WorkListReplacementRollComponent } from '../work-list-replacement-roll/work-list-replacement-roll.component'; import { WorkListRfcComponent } from '../work-list-rfc/work-list-rfc.component'; import { ApplyActionModalComponent } from '../apply-action-modal/apply-action-modal.component'; +import { GetOpenNotificationsResponse } from 'src/app/hmg-common/services/dashbored/models/GetOpenNotificationsResponse'; @@ -97,6 +98,9 @@ export class WorklistMainComponent implements OnInit { dirfromNotificationPage: boolean = false; direction: string; defaultSegment = ''; + public isPostNoLoad = true; + public worklistNotifications: any; + public totalRequestCount = 0; constructor( public worklistService: WorklistService, @@ -350,7 +354,7 @@ export class WorklistMainComponent implements OnInit { setTimeout(() => { this.messageSuccess = false; - this.getNotificationCountAfterSubmit(); + this.openNotificationsDashboard(); this.nextNotfification(); }, 5000); @@ -363,21 +367,34 @@ export class WorklistMainComponent implements OnInit { //let itemExist = false; let itemNo = this.getPassNotificationDetails.ROW_NUM; itemNo += 1; - if (itemNo > this.notificationArray.length) { - this.common.openNotificationPage(); - } else { - for (let i = 0; i < this.notificationArray.length; i++) { - if (this.notificationArray[i].ROW_NUM == itemNo) { - this.common.sharedService.setSharedData(this.notificationArray[i], HomeComponent.NOTIFICATION_DATA); - // itemExist = true; - this.intializeNotificationDetail(); - break; - } - } - // if(itemExist==false){ - // this.nextNotfification(); - // } - } + console.log( this.notificationArray); + let sortArr =this.sortArray(this.notificationArray); + console.log( sortArr); + + const sortedActivities = this.notificationArray.slice().sort((a, b) => b.BEGIN_DATE - a.BEGIN_DATE) + console.log(sortedActivities); + // if (itemNo > this.notificationArray.length) { + // this.common.openNotificationPage(); + // } else { + // for (let i = 0; i < this.notificationArray.length; i++) { + // if (this.notificationArray[i].ROW_NUM == itemNo) { + // this.common.sharedService.setSharedData(this.notificationArray[i], HomeComponent.NOTIFICATION_DATA); + // // itemExist = true; + // this.intializeNotificationDetail(); + // break; + // } + // } + // // if(itemExist==false){ + // // this.nextNotfification(); + // // } + // } + } + + + sortArray(arrayToSort: any) { + return arrayToSort.sort((a: any, b: any) => + new Date(b.BEGIN_DATE).getTime() - new Date(a.BEGIN_DATE).getTime() + ); } actionButton(action) { @@ -687,19 +704,19 @@ export class WorklistMainComponent implements OnInit { } } - getNotificationCountAfterSubmit() { - const req: any = {}; - this.menuService.getNotificationCount(req).subscribe((result: any) => { - if (this.common.validResponse(result)) { - this.notificationCount = - result.GetOpenNotificationsNumList.P_OPEN_NOTIFICATIONS_NUM; - if (this.notificationCount <= 0) { - this.notificationCount = null; - } - this.events.publish("getNotCount", this.notificationCount); - } - }); - } + // getNotificationCountAfterSubmit() { + // const req: any = {}; + // this.menuService.getNotificationCount(req).subscribe((result: any) => { + // if (this.common.validResponse(result)) { + // this.notificationCount = + // result.GetOpenNotificationsNumList.P_OPEN_NOTIFICATIONS_NUM; + // if (this.notificationCount <= 0) { + // this.notificationCount = null; + // } + // this.events.publish("getNotCount", this.notificationCount); + // } + // }); + // } getAttachmentNotification(WorkListAttachObj) { @@ -904,7 +921,7 @@ export class WorklistMainComponent implements OnInit { if (data.data == "cancel" || data.data == undefined) { return; } else if (data.data == "Success") { - this.getNotificationCountAfterSubmit(); + this.openNotificationsDashboard(); this.nextNotfification(); } @@ -936,7 +953,7 @@ export class WorklistMainComponent implements OnInit { if (data.data == "cancel" || data.data == undefined) { return; } else if (data.data == "Success") { - this.getNotificationCountAfterSubmit(); + this.openNotificationsDashboard(); this.nextNotfification(); } @@ -1017,4 +1034,15 @@ export class WorklistMainComponent implements OnInit { } }//end infiniteScroll + + openNotificationsDashboard() { + this.dashboredService.getOpenNotifications('', '', this.isPostNoLoad).subscribe((result: GetOpenNotificationsResponse) => { + if (this.common.validResponse(result)) { + this.worklistNotifications = result; + this.totalRequestCount = this.worklistNotifications.P_OPEN_NTF_NUMBER; + this.common.sharedService.setSharedData(result, 'worklistNotifications'); + } + }); + } + }