added item-type in search

master
umasoodch 6 years ago
parent 2c5c0599d8
commit 14e1c27591

@ -4,9 +4,6 @@
<nav-buttons backLink="/home"></nav-buttons>
</ion-buttons>
<ion-title>WORK LIST</ion-title>
<!-- <div class="profile-image-container" (click)="openProfilePage()">
<img [src]="userImage"/>
</div> -->
</ion-toolbar>
</ion-header>
@ -46,10 +43,11 @@
<ion-col style="float: right;" size=[6] (click)="openSearchModal()" *ngIf="selectedFilter === 'ALL'">
<ion-icon name="search" ></ion-icon>
<span>Advanced Search</span>
</ion-col>
</ion-col>
</ion-row>
<!-- <div class="total-result" *ngIf="isEmptyObject() && selectedFilter === 'ALL' && showSearchButton === false">
<span>showing {{newWorkListResponse.length}} of {{filters[0].value}}</span>
</div> -->
<div [ngClass]="isEmptyObject() ? 'work-list-container' : ''">
<div *ngFor="let data of showFormattedData | keyvalue; let i = index">
<span class="date-span">{{data.key}}</span>
@ -62,8 +60,8 @@
<span>No Data Available</span>
</div>
</div>
<ion-infinite-scroll *ngIf="selectedFilter === 'ALL'" (ionInfinite)="doInfinite($event)">
<ion-infinite-scroll (ionInfinite)="doInfinite($event)">
<ion-infinite-scroll-content></ion-infinite-scroll-content>
</ion-infinite-scroll>

@ -390,3 +390,9 @@ ion-content {
pointer-events: none;
opacity: .3;
}
.total-result {
margin-top: 55px;
padding-left: 20px;
color: #888;
font-size: 15px;
}

@ -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;
}
}

@ -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;
}
Loading…
Cancel
Save