From faad878c8719a66a88259d1dd062624dca40d072 Mon Sep 17 00:00:00 2001 From: Sultan Khan Date: Wed, 17 Jul 2019 11:07:34 +0300 Subject: [PATCH] worklist main page added --- Mohem/src/app/app-routing.module.ts | 53 +-- Mohem/src/app/app.component.ts | 3 +- Mohem/src/app/app.module.ts | 3 +- .../app/notification/notification.module.ts | 16 +- .../worklist-main.component.html | 8 +- .../worklist-main/worklist-main.component.ts | 331 +++++++++++++++++- Mohem/src/assets/localization/i18n.json | 66 ++++ Mohem/src/theme/styles.scss | 2 +- 8 files changed, 422 insertions(+), 60 deletions(-) diff --git a/Mohem/src/app/app-routing.module.ts b/Mohem/src/app/app-routing.module.ts index c36f4a97..e531d005 100644 --- a/Mohem/src/app/app-routing.module.ts +++ b/Mohem/src/app/app-routing.module.ts @@ -1,28 +1,29 @@ -import { NgModule } from '@angular/core'; -import { PreloadAllModules, RouterModule, Routes } from '@angular/router'; - -const routes: Routes = [ - { path: '', redirectTo: 'authentication/login', pathMatch: 'full' }, - { - path: 'authentication', loadChildren: './authentication/authentication.module#AuthenticationPageModule', - data: { preload: true, delay: 1000 } - }, - { path: 'home', loadChildren: './home/home.module#HomePageModule' }, - { path: 'profile', loadChildren: './profile/profile.module#ProfilePageModule' }, - { path: 'vacation-rule', loadChildren: './vacation-rule/vacation-rule.module#VacationRulePageModule' }, - { path: 'accrual-balances', loadChildren: './accrual-balances/accrual-balances.module#AccrualBalancesPageModule' }, - { path: 'my-team', loadChildren: './my-team/my-team.module#MyTeamPageModule' }, - { path: 'attendance', loadChildren: './attendance/attendance.module#AttendancePageModule' }, - { path: 'eit', loadChildren: './eit/eit.module#EITPageModule' }, { path: 'absence', loadChildren: './absence/absence.module#AbsencePageModule' }, +import { NgModule } from '@angular/core'; +import { PreloadAllModules, RouterModule, Routes } from '@angular/router'; + + +const routes: Routes = [ + { path: '', redirectTo: 'authentication/login', pathMatch: 'full' }, + { + path: 'authentication', loadChildren: './authentication/authentication.module#AuthenticationPageModule', + data: { preload: true, delay: 1000 } + }, + { path: 'home', loadChildren: './home/home.module#HomePageModule' }, + { path: 'profile', loadChildren: './profile/profile.module#ProfilePageModule' }, + { path: 'vacation-rule', loadChildren: './vacation-rule/vacation-rule.module#VacationRulePageModule' }, + { path: 'accrual-balances', loadChildren: './accrual-balances/accrual-balances.module#AccrualBalancesPageModule' }, + { path: 'my-team', loadChildren: './my-team/my-team.module#MyTeamPageModule' }, + { path: 'attendance', loadChildren: './attendance/attendance.module#AttendancePageModule' }, + { path: 'eit', loadChildren: './eit/eit.module#EITPageModule' }, + { path: 'absence', loadChildren: './absence/absence.module#AbsencePageModule' }, { path: 'notification', loadChildren: './notification/notification.module#NotificationPageModule' } - -]; - -@NgModule({ - imports: [ - RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules }) - ], - exports: [RouterModule] -}) -export class AppRoutingModule { } +]; + +@NgModule({ + imports: [ + RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules}), + ], + exports: [RouterModule] +}) +export class AppRoutingModule { } diff --git a/Mohem/src/app/app.component.ts b/Mohem/src/app/app.component.ts index 4bc82b92..9040df11 100644 --- a/Mohem/src/app/app.component.ts +++ b/Mohem/src/app/app.component.ts @@ -6,7 +6,6 @@ import { AuthenticationService } from "./hmg-common/services/authentication/auth import { AuthenticatedUser } from "./hmg-common/services/authentication/models/authenticated-user"; import { TabsBarComponent } from "./hmg-common/ui/tabs-bar/tabs-bar.component"; import { KeyboardService } from "./hmg-common/services/keyboard/keyboard.service"; - import { SMSCheckResponse } from "src/app/hmg-common/services/authentication/models/smscheck.response"; import { LazyLoadingService } from "./hmg-common/services/lazy-loading/lazy-loading.service"; @@ -36,7 +35,7 @@ export class AppComponent implements OnInit, AfterViewInit { private events: Events, private keyboardService: KeyboardService, private menu: MenuController, - private authService: AuthenticationService + private authService: AuthenticationService, ) {} ngOnInit() { this.initializeApp(); diff --git a/Mohem/src/app/app.module.ts b/Mohem/src/app/app.module.ts index 26ba2d6e..1eb960c3 100644 --- a/Mohem/src/app/app.module.ts +++ b/Mohem/src/app/app.module.ts @@ -12,6 +12,7 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { ZBar } from '@ionic-native/zbar/ngx'; import { Geolocation } from '@ionic-native/geolocation/ngx'; + @NgModule({ declarations: [AppComponent], entryComponents: [], @@ -19,7 +20,7 @@ import { Geolocation } from '@ionic-native/geolocation/ngx'; BrowserModule, BrowserAnimationsModule, IonicModule.forRoot({ - hardwareBackButton: true + hardwareBackButton: true, }), AppRoutingModule, HmgCommonModule diff --git a/Mohem/src/app/notification/notification.module.ts b/Mohem/src/app/notification/notification.module.ts index 6f02872d..a5af9540 100644 --- a/Mohem/src/app/notification/notification.module.ts +++ b/Mohem/src/app/notification/notification.module.ts @@ -9,8 +9,8 @@ import { IonicModule } from '@ionic/angular'; import { NotificationPage } from './notification.page'; import { PipesModule } from '../pipes/pipes.module'; import { WorklistService } from './service/worklist.service'; -// import { WorklistMainComponent } from './worklist-main/worklist-main.component'; - +import { WorklistMainComponent } from './worklist-main/worklist-main.component'; +import { WorklistMainService } from './service/work-list.main.service'; const routes: Routes = [ { @@ -25,10 +25,10 @@ const routes: Routes = [ path: 'work-list-attach-view', component: WorkListAttachViewComponent }, - // { - // path:'worklist-main', - // component:WorklistMainComponent - // } + { + path:'worklist-main', + component:WorklistMainComponent + } ] } ]; @@ -45,8 +45,8 @@ const routes: Routes = [ declarations: [ NotificationPage, HomeComponent, - // WorklistMainComponent + WorklistMainComponent ], - providers:[WorklistService] + providers:[WorklistService,WorklistMainService] }) export class NotificationPageModule {} diff --git a/Mohem/src/app/notification/worklist-main/worklist-main.component.html b/Mohem/src/app/notification/worklist-main/worklist-main.component.html index a4bda127..3129aba0 100644 --- a/Mohem/src/app/notification/worklist-main/worklist-main.component.html +++ b/Mohem/src/app/notification/worklist-main/worklist-main.component.html @@ -110,19 +110,19 @@
- - +
{{'worklistMain.action' | translate}} - {{notificationButtons.BUTTON_LABEL}} + {{notificationButtons.BUTTON_LABEL}}
- + {{ts.trPK('general','submit')}}
\ 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 4d329f4b..9c840da1 100644 --- a/Mohem/src/app/notification/worklist-main/worklist-main.component.ts +++ b/Mohem/src/app/notification/worklist-main/worklist-main.component.ts @@ -1,28 +1,323 @@ -import { Component, OnInit } from '@angular/core'; -import { CommonService } from 'src/app/hmg-common/services/common/common.service'; -import { TranslatorService } from 'src/app/hmg-common/services/translator/translator.service'; -import {WorkListBodyRequest} from '../models/NotificationBodyReq'; -import {EITNotificatonBodyResponse} from '../models/EITNotificationBodyRes'; -import {AbsenceNotificatonBodyResponse} from '../models/AbsenceNotificationBodyRes'; -import {NotificatonButtonResponse} from '../models/NotificationButtonRes'; -import {WorkListActionRequest} from '../models/NotificationActionReq'; -import { WorkListButtonRequest } from '../models/NotificationButtonReq'; +import { Component, OnInit } from "@angular/core"; +import { CommonService } from "src/app/hmg-common/services/common/common.service"; +import { TranslatorService } from "src/app/hmg-common/services/translator/translator.service"; +import { WorkListBodyRequest } from "../models/NotificationBodyReq"; +import { EITNotificatonBodyResponse } from "../models/EITNotificationBodyRes"; +import { AbsenceNotificatonBodyResponse } from "../models/AbsenceNotificationBodyRes"; +import { NotificatonButtonResponse } from "../models/NotificationButtonRes"; +import { WorkListActionRequest } from "../models/NotificationActionReq"; +import { WorkListButtonRequest } from "../models/NotificationButtonReq"; // import { isDate } from 'angular6-json-schema-form'; -import { MenuResponse } from 'src/app/hmg-common/services/menu/models/menu-response'; -import { LoginRequest } from 'src/app/hmg-common/services/authentication/models/login.request'; -import { WorklistMainService } from '../service/work-list.main.service'; +import { MenuResponse } from "src/app/hmg-common/services/menu/models/menu-response"; +import { LoginRequest } from "src/app/hmg-common/services/authentication/models/login.request"; +import { WorklistMainService } from "../service/work-list.main.service"; +import { HomeComponent } from 'src/app/notification/home/home.component'; @Component({ - selector: 'app-worklist-main', - templateUrl: './worklist-main.component.html', - styleUrls: ['./worklist-main.component.scss'], + selector: "app-worklist-main", + templateUrl: "./worklist-main.component.html", + styleUrls: ["./worklist-main.component.scss"] }) export class WorklistMainComponent implements OnInit { - + private WorkListBodyObj: WorkListBodyRequest; + private WorkListButtonsObj: WorkListButtonRequest; + private WorkListActionObj: WorkListActionRequest; + getPassNotificationDetails: any; + TransactionID: number = -999; + notificationBodyRes: any; + actionHistoryRes: any; + notificationButtonRes: any; + actionMode: any; + pInformation: string = ""; + pQuestion: string = ""; + RespondAttributesListRes: any; + schemaNotific: any; + NotRespondAttributeList: any; + Resp2_val: any; + notExampleJsonObject: any; + hideForwordEmployee: any; + exampleJsonObject: any; + dataOfAttr: any; + P_RESPOND_ATTRIBUTES_TBL: any; + selEmployeeID: any; + actionType: string = ""; constructor( public common: CommonService, public ts: TranslatorService, - ) { } + public worklistMainService: WorklistMainService + ) {} + + ngOnInit() { + this.getPassNotificationDetails = this.common.sharedService.getSharedData(HomeComponent.NOTIFICATION_DATA, false); + this.WorkListBodyObj = new WorkListBodyRequest(); + this.WorkListButtonsObj = new WorkListButtonRequest(); + + this.WorkListActionObj = new WorkListActionRequest(); + + this.WorkListBodyObj.P_TRANSACTION_ID = this.TransactionID; + this.WorkListBodyObj.P_NOTIFICATION_ID = this.getPassNotificationDetails.NOTIFICATION_ID; + + this.WorkListButtonsObj.P_NOTIFICATION_ID = this.getPassNotificationDetails.NOTIFICATION_ID; + + this.WorkListActionObj.P_NOTIFICATION_ID = this.getPassNotificationDetails.NOTIFICATION_ID; + this.WorkListActionObj.P_FORWARD_TO_USER_NAME = ""; + this.WorkListActionObj.P_ACTION_MODE = ""; + this.WorkListActionObj.P_COMMENTS = ""; + this.WorkListActionObj.P_APPROVER_INDEX = null; + this.getNotificationButtons(this.WorkListButtonsObj); + this.getNotificationResAttr(this.WorkListButtonsObj); + + if (this.getPassNotificationDetails.REQUEST_TYPE == "EIT") { + this.getEITNotificationDetails(this.WorkListBodyObj); + } else if (this.getPassNotificationDetails.REQUEST_TYPE == "ABSENCE") { + this.getAbsenceNotificationDetails(this.WorkListBodyObj); + } + } + + getEITNotificationDetails(notificationBodyObj) { + this.worklistMainService.getEITNotificationBody( + notificationBodyObj + ).subscribe((result: EITNotificatonBodyResponse) => { + this.handleWorkListBodyResult(result, "EIT"); + }); + } + + getAbsenceNotificationDetails(notificationBodyObj) { + this.worklistMainService.getAbsencesNotificationBody( + notificationBodyObj + ).subscribe((result: AbsenceNotificatonBodyResponse) => { + this.handleWorkListBodyResult(result, "ABSENCE"); + }); + } + + handleWorkListBodyResult(result, Type) { + this.notificationBodyRes = {}; + if (this.common.validResponse(result)) { + this.pInformation = result.P_INFORMATION; + this.pQuestion = result.P_QUESTION; + if (Type == "EIT") { + if (result.GetEITCollectionNotificationBodyList) { + this.notificationBodyRes = + result.GetEITCollectionNotificationBodyList; + } + } else if (Type == "ABSENCE") { + if (result.GetAbsenceCollectionNotificationBodyList) { + this.notificationBodyRes = + result.GetAbsenceCollectionNotificationBodyList; + } + } + } + } //End handleWorkListBodyResult + + getNotificationButtons(notificationButtonsObj) { + this.worklistMainService.getNotificationButtons( + notificationButtonsObj + ).subscribe((result: NotificatonButtonResponse) => { + this.handleWorkListButtonsResult(result); + }); + } + + handleWorkListButtonsResult(result) { + if (this.common.validResponse(result)) { + // this.sharedData.setSharedData(result, WorKListResponse.SHARED_DATA); + if (result.GetNotificationButtonsList != null) { + this.notificationButtonRes = result.GetNotificationButtonsList; + } // if result == null + } // valid it + } // End handleWorkListButtonsResult + + + applyAction(WorkListActionObj) { + this.worklistMainService.actionButton(WorkListActionObj).subscribe( + (result: any) => { + this.handleApplayActionResult(result); + } + ); + } + + handleApplayActionResult(result) { + if (this.common.validResponse(result)) { + if (result.MessageStatus == 1) { + + // this.navCtrl.push("HomePage"); + } + } // valid it + } + + actionButton() { + let ButtonAction: string = this.actionType; + var responseAttrDic = this.notExampleJsonObject; + this.P_RESPOND_ATTRIBUTES_TBL = []; + for (let key in responseAttrDic) { + // let obj: any = {}; + // obj.ATTRIBUTE_NAME = key; + // if (typeof responseAttrDic[key] === "number") { + // obj.ATTRIBUTE_NUMBER_VALUE = responseAttrDic[key]; + // } else if (isDate(responseAttrDic[key])) { + // obj.ATTRIBUTE_DATE_VALUE = responseAttrDic[key]; + // } else { + // obj.ATTRIBUTE_TEXT_VALUE = responseAttrDic[key]; + // } + // this.P_RESPOND_ATTRIBUTES_TBL.push(obj); + } + let repUserName = this.selEmployeeID; + if (this.hideForwordEmployee && this.hideForwordEmployee.ATTRIBUTE_NAME) { + let obj: any = {}; + repUserName = ""; + obj.ATTRIBUTE_NAME = this.hideForwordEmployee.ATTRIBUTE_NAME; + obj.ATTRIBUTE_TEXT_VALUE = this.selEmployeeID; + this.P_RESPOND_ATTRIBUTES_TBL.push(obj); + } + if ( + ButtonAction == "APPROVED" || + ButtonAction == "REJECTED" || + ButtonAction == "DEL" || + ButtonAction == "CLOSE" + ) { + + this.WorkListActionObj.P_FORWARD_TO_USER_NAME = ""; + this.WorkListActionObj.P_ACTION_MODE = ButtonAction; + this.WorkListActionObj.P_COMMENTS = ""; + this.WorkListActionObj.RespondAttributeList = this.P_RESPOND_ATTRIBUTES_TBL; + this.applyAction(this.WorkListActionObj); + } + + if (ButtonAction == "RFC") { + // alert("Return For Correction"); + this.WorkListActionObj.P_ACTION_MODE = ButtonAction; + // this.navCtrl.push("WorkListRfcPage", { + // passNotificationInfo: this.getPassNotificationDetails, + // passActionMode: ButtonAction, + // passResAttr: this.P_RESPOND_ATTRIBUTES_TBL + // }); + } else if (ButtonAction == "ANSWER_INFO") { + // this.navCtrl.push("WorkListReplacmentRollPage", { + // pQuestion: this.pQuestion, + // passNotificationInfo: this.getPassNotificationDetails, + // passActionMode: ButtonAction, + // passResAttr: this.P_RESPOND_ATTRIBUTES_TBL + // }); + } else if ( + ButtonAction == "DELEGATE" || + ButtonAction == "REQUEST_INFO" || + ButtonAction == "TRANSFER" || + ButtonAction == "TRANSFER_INFO" + ) { + // alert("multi option: "+ ButtonAction); + this.WorkListActionObj.P_ACTION_MODE = ButtonAction; + // this.navCtrl.push("WorkListReplacmentRollPage", { + // passNotificationInfo: this.getPassNotificationDetails, + // passActionMode: ButtonAction, + // passResAttr: this.P_RESPOND_ATTRIBUTES_TBL + // }); + } else if ( + ButtonAction == "UPDATE_ACTION" || + ButtonAction == "CONTINUE_ACTION" + ) { + + + if (this.getPassNotificationDetails.REQUEST_TYPE == "EIT") { + this.common.sharedService.setSharedData( + this.notificationBodyRes, + EITNotificatonBodyResponse.SHARED_DATA + ); + this.common.sharedService.setSharedData( + this.getPassNotificationDetails, + EITNotificatonBodyResponse.NOT_WORKLIST + ); + // this.navCtrl.push("EitUpdateListPage"); + } else if (this.getPassNotificationDetails.REQUEST_TYPE == "ABSENCE") { + this.common.sharedService.setSharedData( + this.notificationBodyRes, + AbsenceNotificatonBodyResponse.SHARED_DATA + ); + this.common.sharedService.setSharedData( + this.getPassNotificationDetails, + AbsenceNotificatonBodyResponse.NOT_WORKLIST + ); + // this.navCtrl.push("SubmitAbsencePage", { + // dirfromNotificationPage: true, + // submitAbsObjList: this.notificationBodyRes[0].Collection_Notification + // }); + + } + } + // else if (this.notificationButtonRes.length > 0 && !ButtonAction) { + // (this.elementRef.nativeElement.querySelectorAll( + // "ion-item" + // ) as HTMLElement[]).forEach(x => { + // if (x.classList.contains("requiredItem")) { + // x.classList.add("ng-touched"); + // x.classList.remove("ng-untouched"); + // } + // }); + // this.common.showAlert( + // this.translate.translate("worklistMain.actionRequird") + // ); + // } else { + // this.navCtrl.pop(); + // } + + } + + openActionHistory() { + // this.navCtrl.push("WorkListActionHistoryPage", { + // passNotificationInfo: this.getPassNotificationDetails + // }); + } + + openSupportDocuments() { + // this.navCtrl.push("WorkListAttachPage", { + // passNotificationInfo: this.getPassNotificationDetails + // }); + } + + getNotificationResAttr(notificationButtonsObj) { + this.worklistMainService.notificationResponseAttr( + notificationButtonsObj + ).subscribe((result: NotificatonButtonResponse) => { + this.handleNotificationResAttrResult(result); + }); + } + + handleNotificationResAttrResult(result) { + if (this.common.validResponse(result)) { + // this.sharedData.setSharedData(result, WorKListResponse.SHARED_DATA); + this.NotRespondAttributeList = + result.NotificationGetRespondAttributesList; + if ( + result.NotificationRespondRolesList != "" && + result.NotificationRespondRolesList[0].ATTRIBUTE_NAME != null && + result.NotificationRespondRolesList[0].ATTRIBUTE_NAME != undefined + ) { + this.Resp2_val = result.NotificationRespondRolesList[0].ATTRIBUTE_NAME; + this.hideForwordEmployee = result.NotificationRespondRolesList[0]; + } - ngOnInit() {} + if (result.P_Schema) this.schemaNotific = JSON.parse(result.P_Schema); + } // valid it + } // End handleWorkListButtonsResult + openNotificationBody() { + if (this.getPassNotificationDetails.REQUEST_TYPE == "EIT") { + this.common.sharedService.setSharedData( + this.notificationBodyRes, + EITNotificatonBodyResponse.SHARED_DATA + ); + this.common.sharedService.setSharedData( + this.getPassNotificationDetails, + EITNotificatonBodyResponse.NOT_WORKLIST + ); + // this.navCtrl.push("WorkListDetailsPage", { NotBodyType: "EIT" }); + } else if (this.getPassNotificationDetails.REQUEST_TYPE == "ABSENCE") { + this.common.sharedService.setSharedData( + this.notificationBodyRes, + AbsenceNotificatonBodyResponse.SHARED_DATA + ); + this.common.sharedService.setSharedData( + this.getPassNotificationDetails, + AbsenceNotificatonBodyResponse.NOT_WORKLIST + ); + //this.navCtrl.push("WorkListDetailsPage", { NotBodyType: "ABSENCE" }); + } + } } diff --git a/Mohem/src/assets/localization/i18n.json b/Mohem/src/assets/localization/i18n.json index d8e232d7..a7f6ca2c 100644 --- a/Mohem/src/assets/localization/i18n.json +++ b/Mohem/src/assets/localization/i18n.json @@ -1477,5 +1477,71 @@ "en":"Search", "ar":"بحث" } + }, + "worklistMain": { + "title":{ + "en": "Details", + "ar":"التفاصيل" + }, + "from": { + "en":"From:", + "ar":"من:" + }, + "to":{ + "en": "To:", + "ar":"إلى:" + }, + "sent":{ + "en":"Sent:", + "ar":"أرسلت:" + }, + "empInfo": { + "en":"Employee Information", + "ar": "معلومات الموظف" + }, + "info":{ + "en": "Information", + "ar":"تفاصيل" + }, + "notfDetails":{ + "en": "Notification Details", + "ar":"تفاصيل العرض" + }, + "actionHis": { + "en":"Action History", + "ar":"تاريخ الإجراء" + }, + "suppDoc": { + "en":"Support Documents", + "ar":"المرفقات" + }, + "closed":{ + "en":"Closed:", + "ar":"أغلقت:" + }, + "id":{ + "en":"ID:", + "ar":"الرقم:" + }, + "responder":{ + "en":"Responder:", + "ar":"المرسل:" + }, + "subject":{ + "en":"Subject:", + "ar":"الموضوع:" + }, + "rfc":{ + "en":"Return for correction", + "ar":"عودة للتصحيح" + }, + "action":{ + "en":"Action", + "ar":"الحركة" + }, + "actionRequird":{ + "en":"Action is required", + "ar":"اختر حركة" + } } } \ No newline at end of file diff --git a/Mohem/src/theme/styles.scss b/Mohem/src/theme/styles.scss index 97d1f3c9..ff62af4c 100644 --- a/Mohem/src/theme/styles.scss +++ b/Mohem/src/theme/styles.scss @@ -744,6 +744,6 @@ color: var(--dark); .progress-loading-page .loading-gif { margin-top: 0.42cm; width:100%; - margin-left: 0.4cm; + } .centerDiv .button{width:200px;} \ No newline at end of file