From 52085849999743b338c6bc8f5e40247bfa477057 Mon Sep 17 00:00:00 2001 From: umasoodch Date: Wed, 12 Feb 2020 11:44:43 +0300 Subject: [PATCH] added worklist filters logic --- .../app/notification/home/home.component.html | 4 +- .../app/notification/home/home.component.scss | 9 +- .../app/notification/home/home.component.ts | 250 +++++++----------- .../notification/models/workListRequest.ts | 20 +- .../worklist-advanced-search.component.html | 13 +- .../worklist-advanced-search.component.ts | 27 +- 6 files changed, 127 insertions(+), 196 deletions(-) diff --git a/Mohem/src/app/notification/home/home.component.html b/Mohem/src/app/notification/home/home.component.html index 09f904d0..1ab21604 100644 --- a/Mohem/src/app/notification/home/home.component.html +++ b/Mohem/src/app/notification/home/home.component.html @@ -26,7 +26,7 @@ - + - + Clear Search diff --git a/Mohem/src/app/notification/home/home.component.scss b/Mohem/src/app/notification/home/home.component.scss index 0686c9fa..da327bdb 100644 --- a/Mohem/src/app/notification/home/home.component.scss +++ b/Mohem/src/app/notification/home/home.component.scss @@ -221,9 +221,6 @@ ion-input ,ion-datetime{ ///////////////////////////////////////////NEW DESIGN///////////////////////////////////// -.header-toolbar-new{ - --background: #22c6b3; -} .profile-image-container{ position: relative; z-index: 999; @@ -388,4 +385,8 @@ ion-content { left: 50%; margin-left: -100px; margin-top: 100px; -} \ No newline at end of file +} +.disable-filter { + pointer-events: none; + opacity: .3; +} diff --git a/Mohem/src/app/notification/home/home.component.ts b/Mohem/src/app/notification/home/home.component.ts index a8fa91a7..1021547f 100644 --- a/Mohem/src/app/notification/home/home.component.ts +++ b/Mohem/src/app/notification/home/home.component.ts @@ -33,8 +33,6 @@ export class HomeComponent implements OnInit { SentDate = ''; Subject = ''; inputSearch = ''; - // HideDateInput = false; - // HideTextInput = false; inputDate: string; filteredNotificationList: any; IsReachEnd = false; @@ -47,7 +45,7 @@ export class HomeComponent implements OnInit { public isITG = false; public isSearch = false; public direction = 'ltr'; - ///// New ///////////// + public currentActiveIndex = 0; public previousActiveIndex = 0; public worklistNotifications: any; @@ -57,6 +55,7 @@ export class HomeComponent implements OnInit { public showFormattedData = {}; public selectedFilter = 'ALL'; public showSearchButton = false; + public itemType = ''; public options = { cutoutPercentage: 80, tooltips: { enabled: false }, @@ -82,42 +81,48 @@ export class HomeComponent implements OnInit { name: 'All', active: true, color: '#124375', - key: 'ALL' + key: 'ALL', + disable: false }, { value: 0, name: 'HR', active: false, color: '#18a169', - key: 'HRSSA' + key: 'HRSSA', + disable: false }, { value: 0, name: 'PO', active: false, color: '#38c9b3', - key: 'POAPPRV' + key: 'POAPPRV', + disable: false }, { value: 0, name: 'PR', active: false, color: '#114475', - key: 'REQAPPRV' + key: 'REQAPPRV', + disable: false }, { value: 0, name: 'MR', active: false, color: '#3cb9d5', - key: 'INVMOA' + key: 'INVMOA', + disable: false }, { value: 0, name: 'ITG', active: false, color: '#cc3232', - key: 'ITG' + key: 'ITG', + disable: false } ]; public slideOptsOne = { @@ -168,9 +173,9 @@ export class HomeComponent implements OnInit { } } } - + getFilteredData(filter: string) { - if(filter === 'ALL') { + if (filter === 'ALL') { this.showFormattedData = this.allFormattedData; } else { let arrayToFilter; @@ -196,6 +201,25 @@ export class HomeComponent implements OnInit { this.common.openProfile(); } + disableFilters() { + for (const filter of this.filters) { + if (filter.key === this.itemType) { + filter.disable = false; + filter.active = true; + this.selectedFilter = filter.name; + } else if (this.itemType === 'none') { + filter.disable = false; + filter.active = false; + } else { + filter.disable = true; + filter.active = false; + } + } + if (this.itemType === 'none') { + this.filters[0].active = true; + } + } + async openSearchModal() { const modal = await this.modalController.create({ component: WorklistAdvancedSearchComponent, @@ -205,9 +229,10 @@ export class HomeComponent implements OnInit { }); modal.onDidDismiss().then(result => { console.log(result.data); - if(result.data){ - if(result.data.notificationType !== '' || result.data.selectedValue){ + if (result.data) { + if (result.data.notificationType !== '' || result.data.selectedValue !== '' || result.data.itemType !== '') { this.showSearchButton = true; + this.itemType = result.data.itemType; this.notificationType = result.data.notificationType; this.selectedValue = result.data.selectedValue; this.inputDate = result.data.inputDate; @@ -222,58 +247,24 @@ export class HomeComponent implements OnInit { this.previousActiveIndex = 0; this.filters[this.currentActiveIndex].active = true; this.getAllPushNotificationFun(); + if (this.itemType !== '') { + this.disableFilters(); + } } } - }); return await modal.present(); } - ionViewDidLoad() { - // this.navBar.backButtonClick = () => { - // // you can set a full custom history here if you want - // let pages = [ - // { - // page: "HomePage" - // } - // ]; - // this.navCtrl.setPages(pages); - // }; - } - - ionViewWillEnter() { - // this.getAllPushNotificationFun(); //filter with item type - } - getAllPushNotificationFun() { this.WorkListObj.P_PAGE_NUM = 1; this.IsReachEnd = false; - - if (this.selectedValue === '1') { - this.WorkListObj.P_SEARCH_FROM_USER = this.inputSearch; - this.WorkListObj.P_SEARCH_ITEM_TYPE_DSP_NAME = ''; - this.WorkListObj.P_SEARCH_SENT_DATE = ''; - this.WorkListObj.P_SEARCH_SUBJECT = ''; - } else if (this.selectedValue === '2') { - this.WorkListObj.P_SEARCH_FROM_USER = ''; - this.WorkListObj.P_SEARCH_ITEM_TYPE_DSP_NAME = ''; - this.WorkListObj.P_SEARCH_SENT_DATE = ''; - this.WorkListObj.P_SEARCH_SUBJECT = this.inputSearch; - } else if (this.selectedValue === '3') { - this.WorkListObj.P_SEARCH_FROM_USER = ''; - this.WorkListObj.P_SEARCH_ITEM_TYPE_DSP_NAME = ''; - if (this.inputDate) { - this.WorkListObj.P_SEARCH_SENT_DATE = moment(this.inputDate).format( - 'DD-MMM-YYYY' - ); - } else { this.WorkListObj.P_SEARCH_SENT_DATE = ''; } - this.WorkListObj.P_SEARCH_SUBJECT = ''; - } else if (this.selectedValue === '4') { - this.WorkListObj.P_SEARCH_FROM_USER = ''; - this.WorkListObj.P_SEARCH_ITEM_TYPE_DSP_NAME = this.inputSearch; - this.WorkListObj.P_SEARCH_SENT_DATE = ''; - this.WorkListObj.P_SEARCH_SUBJECT = ''; - } else if (this.selectedValue === '5') { + this.WorkListObj.P_SEARCH_FROM_USER = this.selectedValue === '1' ? this.inputSearch : ''; + 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 : '';; + if (this.selectedValue === '5') { this.WorkListObj.P_SEARCH_FROM_USER = ''; this.WorkListObj.P_SEARCH_ITEM_TYPE_DSP_NAME = ''; this.WorkListObj.P_SEARCH_SENT_DATE = ''; @@ -290,10 +281,10 @@ export class HomeComponent implements OnInit { categorizeData(arrayToCategorize: any) { const datePipe = new DatePipe('en-US'); - let formattedData = {}; + 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)) { + if (!(workList.FORMATTED_DATE in formattedData)) { formattedData[workList.FORMATTED_DATE] = new Array(); formattedData[workList.FORMATTED_DATE].push(workList); } else { @@ -323,7 +314,7 @@ export class HomeComponent implements OnInit { } if (this.common.hasData(result)) { this.WorkListObj.P_PAGE_NUM++; - if(this.newWorkListResponse.length === 0) { + if (this.newWorkListResponse.length === 0) { this.newWorkListResponse = result; } else { this.newWorkListResponse = this.newWorkListResponse.concat(result); @@ -342,22 +333,16 @@ export class HomeComponent implements OnInit { console.log(obj); this.common.sharedService.setSharedData(obj, HomeComponent.NOTIFICATION_DATA); // this.common.openWorklistMainPage(); - if(obj.REQUEST_TYPE == 'PR'){ + if (obj.REQUEST_TYPE === 'PR') { this.common.openWorklistMainPRPage(); - } - else if(obj.REQUEST_TYPE == 'PO'){ + } else if (obj.REQUEST_TYPE === 'PO') { this.common.openWorklistMainPOPage(); - } - else if(obj.REQUEST_TYPE == 'MO'){ + } else if (obj.REQUEST_TYPE === 'MO') { this.common.openWorklistMainMRPage(); - } - - else{ + } else { this.common.openWorklistMainPage(); } - - // this.navCtrl.push("WorkListMainPage", { passNotificationList: obj }); } isEmptyObject() { @@ -365,6 +350,8 @@ export class HomeComponent implements OnInit { } clearSearch() { + this.itemType = 'none'; + this.disableFilters(); this.showSearchButton = false; this.notificationType = ''; this.selectedValue = ''; @@ -398,7 +385,7 @@ export class HomeComponent implements OnInit { } }); } else { - if (this.infiniteScroll && this.selectedFilter === 'ALL') { + if (this.infiniteScroll && this.selectedFilter === 'ALL') { this.infiniteScroll.complete(); } } @@ -407,105 +394,54 @@ export class HomeComponent implements OnInit { Count() { this.workListService.getITGCount() .subscribe((result: any) => { - console.log('ENAD ITG COUNT:') + console.log('ENAD ITG COUNT:'); console.log(result); }); } - filterNotificationByRequestType(reqType) { - let filterdType = []; - if (reqType == 'All') { - this.filteredNotificationList = this.WorkListResObj; - if (this.filteredNotificationList == [] || this.filteredNotificationList == null || this.filteredNotificationList == '') { - this.noData = true; - return false; - } else { - this.noData = false; - return false; - } - } - for (let i = 0; i < this.WorkListResObj.length; i++) { - if(reqType=='HR'){ - if ('EIT' == this.WorkListResObj[i].REQUEST_TYPE || 'ABSENCE' == this.WorkListResObj[i].REQUEST_TYPE) { - filterdType.push(this.WorkListResObj[i]); - } - }else{ - if (reqType == this.WorkListResObj[i].REQUEST_TYPE) { - filterdType.push(this.WorkListResObj[i]); - } - } - - } - - this.filteredNotificationList = filterdType; - if (this.filteredNotificationList == [] || this.filteredNotificationList == null || this.filteredNotificationList == '') { - this.noData = true; - return false; - } else { - this.noData = false; - return false; - } - } + // filterNotificationByRequestType(reqType) { + // const filterdType = []; + // if (reqType === 'All') { + // this.filteredNotificationList = this.WorkListResObj; + // if (this.filteredNotificationList === [] || this.filteredNotificationList == null || this.filteredNotificationList === '') { + // this.noData = true; + // return false; + // } else { + // this.noData = false; + // return false; + // } + // } + // for (let i = 0; i < this.WorkListResObj.length; i++) { + // if (reqType === 'HR') { + // if ('EIT' === this.WorkListResObj[i].REQUEST_TYPE || 'ABSENCE' === this.WorkListResObj[i].REQUEST_TYPE) { + // filterdType.push(this.WorkListResObj[i]); + // } + // } else { + // if (reqType === this.WorkListResObj[i].REQUEST_TYPE) { + // filterdType.push(this.WorkListResObj[i]); + // } + // } + + // } + + // this.filteredNotificationList = filterdType; + // if (this.filteredNotificationList === [] || this.filteredNotificationList == null || this.filteredNotificationList === '') { + // this.noData = true; + // return false; + // } else { + // this.noData = false; + // return false; + // } + // } Details() { this.workListService.getITGDetails() .subscribe((result: any) => { - console.log('ENAD ITG Details:') + console.log('ENAD ITG Details:'); console.log(result); }); } - AllNotification() { - this.filterNotificationByRequestType('All'); - this.isAll = true; - this.isPR = false; - this.isPO = false; - this.isMR = false; - this.isHR = false; - this.isITG = false; - } - - PRNotification() { - this.filterNotificationByRequestType('PR'); - this.isAll = false; - this.isPR = true; - this.isPO = false; - this.isMR = false; - this.isHR = false; - this.isITG = false; - } - - PONotification() { - this.filterNotificationByRequestType('PO'); - this.isAll = false; - this.isPR = false; - this.isPO = true; - this.isMR = false; - this.isHR = false; - this.isITG = false; - - } - - MRNotification() { - this.filterNotificationByRequestType('MO'); - this.isAll = false; - this.isPR = false; - this.isPO = false; - this.isMR = true; - this.isHR = false; - this.isITG = false; - } - - HRNotification() { - this.filterNotificationByRequestType('HR'); - this.isAll = false; - this.isPR = false; - this.isPO = false; - this.isMR = false; - this.isHR = true; - this.isITG = false; - } - ITGNotification() { // this.Details(); this.isAll = false; diff --git a/Mohem/src/app/notification/models/workListRequest.ts b/Mohem/src/app/notification/models/workListRequest.ts index 018942ab..5f0efad2 100644 --- a/Mohem/src/app/notification/models/workListRequest.ts +++ b/Mohem/src/app/notification/models/workListRequest.ts @@ -1,18 +1,12 @@ -// import { Request } from './request'; import { Request } from 'src/app/hmg-common/services/models/request'; export class WorkListRequest extends Request{ public static SHARED_DATA = 'login-request'; - // Channel: Channel, //channel - // LanguageID: LanguageID,//langlist - // P_USER_NAME:userName,//string - // P_SESSION_ID:sessionID,//number - public P_NOTIFICATION_TYPE: string;//string - public P_SEARCH_FROM_USER:string;//string - public P_SEARCH_SUBJECT:string;//string - public P_SEARCH_SENT_DATE:string;//string - public P_SEARCH_ITEM_TYPE_DSP_NAME:string;//string - public P_PAGE_NUM:number;//number - public P_PAGE_LIMIT:number;//number - + public P_NOTIFICATION_TYPE: string; + public P_SEARCH_FROM_USER: string; + public P_SEARCH_SUBJECT: string; + public P_SEARCH_SENT_DATE: string; + public P_SEARCH_ITEM_TYPE_DSP_NAME: string; + public P_PAGE_NUM: number; + public P_PAGE_LIMIT: number; } \ No newline at end of file diff --git a/Mohem/src/app/notification/worklist-advanced-search/worklist-advanced-search.component.html b/Mohem/src/app/notification/worklist-advanced-search/worklist-advanced-search.component.html index b02442bf..e0b313d3 100644 --- a/Mohem/src/app/notification/worklist-advanced-search/worklist-advanced-search.component.html +++ b/Mohem/src/app/notification/worklist-advanced-search/worklist-advanced-search.component.html @@ -46,14 +46,13 @@ - Request Type + Item Type - {{ts.trPK('worklist','from')}} - {{ts.trPK('worklist','subject')}} - {{ts.trPK('worklist','sent')}} - {{ts.trPK('worklist','itemType')}} - {{ts.trPK('worklist','none')}} + [(ngModel)]="itemType"> + HR + PO + PR + MR diff --git a/Mohem/src/app/notification/worklist-advanced-search/worklist-advanced-search.component.ts b/Mohem/src/app/notification/worklist-advanced-search/worklist-advanced-search.component.ts index 1f8c1d95..5f393e89 100644 --- a/Mohem/src/app/notification/worklist-advanced-search/worklist-advanced-search.component.ts +++ b/Mohem/src/app/notification/worklist-advanced-search/worklist-advanced-search.component.ts @@ -9,12 +9,13 @@ import { TranslatorService } from 'src/app/hmg-common/services/translator/transl }) export class WorklistAdvancedSearchComponent implements OnInit { - public hideDateInput: boolean = false; - public hideTextInput: boolean = false; - public inputDate: string = ''; - public inputSearch: string = ''; - public selectedValue: string = ''; - public notificationType: string = ''; + public hideDateInput = false; + public hideTextInput = false; + public inputDate = ''; + public inputSearch = ''; + public selectedValue = ''; + public notificationType = ''; + public itemType = ''; constructor( public modalController: ModalController, @@ -28,11 +29,13 @@ export class WorklistAdvancedSearchComponent implements OnInit { } public search() { + console.log(this.itemType); this.modalController.dismiss({ notificationType: this.notificationType, selectedValue: this.selectedValue, inputDate: this.inputDate, inputSearch: this.inputSearch, + itemType: this.itemType }); } @@ -42,23 +45,21 @@ export class WorklistAdvancedSearchComponent implements OnInit { getValueSelected(value) { this.selectedValue = value.detail.value; - if (this.selectedValue == '1') { + if (this.selectedValue === '1') { this.hideDateInput = false; this.hideTextInput = true; - } else if (this.selectedValue == '2') { + } else if (this.selectedValue === '2') { this.hideDateInput = false; this.hideTextInput = true; - } else if (this.selectedValue == '3') { + } else if (this.selectedValue === '3') { this.hideDateInput = true; this.hideTextInput = false; - } else if (this.selectedValue == '4') { + } else if (this.selectedValue === '4') { this.hideDateInput = false; this.hideTextInput = true; - } else if (this.selectedValue == '5') { + } else if (this.selectedValue === '5') { this.hideDateInput = false; this.hideTextInput = false; } } - - }