added worklist filters logic

master
umasoodch 6 years ago
parent 96971a6b68
commit 5208584999

@ -26,7 +26,7 @@
<ion-row class="filters-row">
<ion-slides [options]="slideOptsOne">
<ion-slide *ngFor="let filter of filters; let i=index">
<ion-slide *ngFor="let filter of filters; let i=index" [ngClass]="filter.disable === true ? 'disable-filter' : ''">
<app-card-filter
[value]="filter.value"
[text]="filter.name"
@ -39,7 +39,7 @@
</ion-row>
<ion-row class="search-container">
<ion-col style="float: left;" size=[6] *ngIf="showSearchButton && selectedFilter === 'ALL'" (click)="clearSearch()">
<ion-col style="float: left;" size=[6] *ngIf="showSearchButton" (click)="clearSearch()">
<span style="margin-left: 5px;">Clear Search</span>
<ion-icon name="close" ></ion-icon>
</ion-col>

@ -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;
}
}
.disable-filter {
pointer-events: none;
opacity: .3;
}

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

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

@ -46,14 +46,13 @@
</div>
<ion-item lines="none">
<ion-label>Request Type</ion-label>
<ion-label>Item Type</ion-label>
<ion-select okText="{{ts.trPK('general','ok')}}" cancelText="{{ts.trPK('general','cancel')}}"
[(ngModel)]="requestType">
<ion-select-option value="1">{{ts.trPK('worklist','from')}}</ion-select-option>
<ion-select-option value="2">{{ts.trPK('worklist','subject')}}</ion-select-option>
<ion-select-option value="3">{{ts.trPK('worklist','sent')}}</ion-select-option>
<ion-select-option value="4">{{ts.trPK('worklist','itemType')}}</ion-select-option>
<ion-select-option value="5">{{ts.trPK('worklist','none')}}</ion-select-option>
[(ngModel)]="itemType">
<ion-select-option value="HRSSA">HR</ion-select-option>
<ion-select-option value="POAPPRV">PO</ion-select-option>
<ion-select-option value="REQAPPRV">PR</ion-select-option>
<ion-select-option value="INVMOA">MR</ion-select-option>
</ion-select>
</ion-item>

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

Loading…
Cancel
Save