diff --git a/Mohem/src/app/notification/home/home.component.html b/Mohem/src/app/notification/home/home.component.html index 0fc2a591..697439cc 100644 --- a/Mohem/src/app/notification/home/home.component.html +++ b/Mohem/src/app/notification/home/home.component.html @@ -4,9 +4,6 @@ WORK LIST - @@ -46,10 +43,11 @@ Advanced Search - - + - +
{{data.key}} @@ -62,8 +60,8 @@ No Data Available
- - + + diff --git a/Mohem/src/app/notification/home/home.component.scss b/Mohem/src/app/notification/home/home.component.scss index da327bdb..b81f5e3f 100644 --- a/Mohem/src/app/notification/home/home.component.scss +++ b/Mohem/src/app/notification/home/home.component.scss @@ -390,3 +390,9 @@ ion-content { pointer-events: none; opacity: .3; } +.total-result { + margin-top: 55px; + padding-left: 20px; + color: #888; + font-size: 15px; +} diff --git a/Mohem/src/app/notification/home/home.component.ts b/Mohem/src/app/notification/home/home.component.ts index 59c10f87..6a0a863e 100644 --- a/Mohem/src/app/notification/home/home.component.ts +++ b/Mohem/src/app/notification/home/home.component.ts @@ -4,12 +4,10 @@ import { CommonService } from 'src/app/hmg-common/services/common/common.service import { TranslatorService } from 'src/app/hmg-common/services/translator/translator.service'; import { WorkListRequest } from '../models/workListRequest'; import * as moment from 'moment'; -import { WorKListResponse } from '../models/workListResponse'; import { WorklistService } from '../service/worklist.service'; import { IonInfiniteScroll } from '@ionic/angular'; import { WorklistMainService } from '../service/work-list.main.service'; import { WorklistAdvancedSearchComponent } from '../worklist-advanced-search/worklist-advanced-search.component'; -import { AuthenticatedUser } from 'src/app/hmg-common/services/authentication/models/authenticated-user'; import { DatePipe } from '@angular/common'; @Component({ @@ -35,13 +33,8 @@ export class HomeComponent implements OnInit { inputSearch = ''; inputDate: string; filteredNotificationList: any; - IsReachEnd = false; + isReachEnd = false; public noData = false; - public isAll = true; - public isPR = false; - public isPO = false; - public isMR = false; - public isHR = false; public isITG = false; public isSearch = false; public direction = 'ltr'; @@ -51,7 +44,6 @@ export class HomeComponent implements OnInit { public worklistNotifications: any; public totalRequestCount = 0; public newWorkListResponse = []; - public allFormattedData = {}; public showFormattedData = {}; public selectedFilter = 'ALL'; public showSearchButton = false; @@ -174,27 +166,23 @@ export class HomeComponent implements OnInit { } } - 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); - } - } + activeFilter(index: number) { - this.showFormattedData = {}; - this.previousActiveIndex = this.currentActiveIndex; - this.currentActiveIndex = index; - this.filters[this.previousActiveIndex].active = false; - this.filters[this.currentActiveIndex].active = true; - - this.selectedFilter = this.filters[this.currentActiveIndex].key; - this.getFilteredData(this.selectedFilter); + 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; + } } openProfilePage() { @@ -207,7 +195,7 @@ export class HomeComponent implements OnInit { filter.disable = false; filter.active = true; this.selectedFilter = filter.name; - } else if (this.itemType === 'none') { + } else if (this.itemType === '') { filter.disable = false; filter.active = false; } else { @@ -215,7 +203,7 @@ export class HomeComponent implements OnInit { filter.active = false; } } - if (this.itemType === 'none') { + if (this.itemType === '') { this.filters[0].active = true; } } @@ -239,17 +227,16 @@ export class HomeComponent implements OnInit { this.inputSearch = result.data.inputSearch; this.WorkListObj.P_PAGE_NUM = 1; this.newWorkListResponse = []; - this.allFormattedData = {}; this.showFormattedData = {}; this.selectedFilter = 'ALL'; this.filters[this.currentActiveIndex].active = false; this.currentActiveIndex = 0; this.previousActiveIndex = 0; this.filters[this.currentActiveIndex].active = true; - this.getAllPushNotificationFun(); if (this.itemType !== '') { this.disableFilters(); } + this.getAllPushNotificationFun(); } } }); @@ -258,12 +245,14 @@ export class HomeComponent implements OnInit { getAllPushNotificationFun() { this.WorkListObj.P_PAGE_NUM = 1; - this.IsReachEnd = false; + this.isReachEnd = false; 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 : '';; + this.WorkListObj.P_ITEM_TYPE = this.itemType !== '' ? this.itemType : ''; + this.WorkListObj.P_NOTIFICATION_TYPE = this.notificationType !== '' ? this.notificationType : '1'; if (this.selectedValue === '5') { this.WorkListObj.P_SEARCH_FROM_USER = ''; this.WorkListObj.P_SEARCH_ITEM_TYPE_DSP_NAME = ''; @@ -305,11 +294,15 @@ export class HomeComponent implements OnInit { const lastitem = result[lastItemIndex]; if (lastitem) { if (lastitem.NO_OF_ROWS === lastitem.ROW_NUM) { - this.IsReachEnd = true; - this.infiniteScroll.complete(); + this.isReachEnd = true; + if (this.infiniteScroll) { + this.infiniteScroll.complete(); + } } else { - this.IsReachEnd = false; - this.infiniteScroll.complete(); + this.isReachEnd = false; + if (this.infiniteScroll) { + this.infiniteScroll.complete(); + } } } if (this.common.hasData(result)) { @@ -321,8 +314,7 @@ export class HomeComponent implements OnInit { } this.newWorkListResponse = this.sortArray(this.newWorkListResponse); console.log(this.newWorkListResponse); - this.allFormattedData = this.categorizeData(this.newWorkListResponse); - this.showFormattedData = this.allFormattedData; + this.showFormattedData = this.categorizeData(this.newWorkListResponse); this.common.sharedService.setSharedData(this.newWorkListResponse, HomeComponent.NOTIFICATION_ARR); } else { this.newWorkListResponse = []; @@ -332,7 +324,6 @@ export class HomeComponent implements OnInit { openNotificationDetail(obj) { console.log(obj); this.common.sharedService.setSharedData(obj[0], HomeComponent.NOTIFICATION_DATA); - // this.common.openWorklistMainPage(); if (obj.REQUEST_TYPE === 'PR') { this.common.openWorklistMainPRPage(); } else if (obj[0].REQUEST_TYPE === 'PO') { @@ -341,7 +332,6 @@ export class HomeComponent implements OnInit { this.common.openWorklistMainMRPage(); } else { this.common.openWorklistMainPage(); - } } @@ -349,43 +339,40 @@ export class HomeComponent implements OnInit { return (this.showFormattedData && (Object.keys(this.showFormattedData).length > 0)); } - clearSearch() { - this.itemType = 'none'; - this.disableFilters(); + resetData() { + if (this.infiniteScroll) { + this.infiniteScroll.complete(); + } this.showSearchButton = false; - this.notificationType = ''; + this.notificationType = '1'; this.selectedValue = ''; this.inputDate = ''; this.inputSearch = ''; - this.WorkListObj.P_PAGE_NUM = 1; this.newWorkListResponse = []; - this.allFormattedData = {}; this.showFormattedData = {}; - this.selectedFilter = 'ALL'; - this.filters[this.currentActiveIndex].active = false; - this.currentActiveIndex = 0; - this.previousActiveIndex = 0; - this.filters[this.currentActiveIndex].active = true; 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.getAllPushNotificationFun(); } - onChangeView(selectedValue: any) { - this.WorkListObj.P_NOTIFICATION_TYPE = selectedValue.detail.value; + clearSearch() { + this.itemType = ''; + this.selectedFilter = 'ALL'; + this.disableFilters(); + this.resetData(); + this.getAllPushNotificationFun(); } doInfinite(infiniteScroll) { - if (!this.IsReachEnd && this.selectedFilter === 'ALL') { + if (!this.isReachEnd && this.selectedFilter !== 'ITG') { this.WorklistService.getWorkList(this.WorkListObj).subscribe((result) => { if (this.common.validResponse(result)) { this.handleWorkListResult(result.GetWorkList); } }); } else { - if (this.infiniteScroll && this.selectedFilter === 'ALL') { + if (this.infiniteScroll) { this.infiniteScroll.complete(); } } @@ -399,41 +386,6 @@ export class HomeComponent implements OnInit { }); } - // 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) => { @@ -441,18 +393,4 @@ export class HomeComponent implements OnInit { console.log(result); }); } - - ITGNotification() { - // this.Details(); - this.isAll = false; - this.isPR = false; - this.isPO = false; - this.isMR = false; - this.isHR = false; - this.isITG = true; - } - - searchBtn() { - this.isSearch = !this.isSearch; - } } diff --git a/Mohem/src/app/notification/models/workListRequest.ts b/Mohem/src/app/notification/models/workListRequest.ts index 5f0efad2..1885e441 100644 --- a/Mohem/src/app/notification/models/workListRequest.ts +++ b/Mohem/src/app/notification/models/workListRequest.ts @@ -9,4 +9,5 @@ export class WorkListRequest extends Request{ public P_SEARCH_ITEM_TYPE_DSP_NAME: string; public P_PAGE_NUM: number; public P_PAGE_LIMIT: number; + public P_ITEM_TYPE : string; } \ No newline at end of file