added notification service for worklist

enad-Q3
enadhilal 4 years ago
parent d5dfc27004
commit f7c23eb8d4

@ -0,0 +1,6 @@
export class UserItemTypes extends Request {
public P_ITEM_TYPE: string;
public P_FYA_ENABLED_FALG: string;
public P_FYI_ENABLED_FLAG: string;
public ItemID: number;
}

@ -20,6 +20,7 @@ import { QuotationAnalysisResponse } from '../models/quotationAnalysisRes';
import { Request } from 'src/app/hmg-common/services/models/request';
import { LoginModel } from '../../authentication/models/LoginModel';
import { itgRequest } from '../models/itgFormDetailsRequest';
import { UserItemTypes } from "../models/userItemTypeRequest";
@Injectable()
export class WorklistMainService {
@ -395,18 +396,17 @@ export class WorklistMainService {
}
public updateWorklistNotifications(
requestData: any,
onError?: any,
errorLabel?: string
): Observable<any> {
const request = new Request();
this.authService.authenticateRequest(request);
this.authService.authenticateRequest(requestData);
return this.api.post(
WorklistMainService.updateWorklistNotificationURL,
request,
requestData,
onError,
errorLabel
);
}
}

@ -16,18 +16,26 @@
<br>
<ion-list>
<ion-item>
<ion-label>
<p *ngIf="direction == 'ltr'" style="color: black; padding: 5px; font-size: 16px; font-family: 'Poppins'; font-weight: bolder;">item type</p>
</ion-label>
<p *ngIf="direction == 'ltr'" style="color: black; padding: 5px; font-size: 16px; font-family: 'Poppins'; font-weight: bolder;">FYA</p>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<p *ngIf="direction == 'ltr'" style="color: black; padding: 5px; font-size: 16px; font-family: 'Poppins'; font-weight: bolder;">FYI</p>
</ion-item>
<ion-item *ngFor="let data of notificationList">
<ion-label>
<p *ngIf="direction == 'ltr'" style="color: black; padding: 5px; font-size: 16px; font-family: 'Poppins'; padding-bottom: 10px;">{{data.ITEM_TYPE}}</p>
</ion-label>
<ion-toggle (onchange)="chnageToggle()" [checked]="data.FYA_ENABLED_FALG === 'Y'"></ion-toggle>
<ion-toggle (ionChange)="chnageToggle(data, 'FYA', data.FYA_ENABLED_FALG)" [checked]="data.FYA_ENABLED_FALG === 'Y'"></ion-toggle>
&nbsp;&nbsp;&nbsp;
<ion-toggle (onchange)="chnageToggle()" [checked]="data.FYI_ENABLED_FLAG === 'Y'"></ion-toggle>
<ion-toggle (ionChange)="chnageToggle(data, 'FYI', data.FYI_ENABLED_FLAG)" [checked]="data.FYI_ENABLED_FLAG === 'Y'"></ion-toggle>
</ion-item>
<br>
</ion-list>
</ion-content>
<ion-footer>
<ion-button style="font-size: 16px !important; width:371px; --background: #259CB8; background: white;" expand="block" (click)='dismiss()'>{{ 'worklist, save-changes' | translate}}</ion-button>
<ion-button (click)="saveChanges()" style="font-size: 16px !important; width:371px; --background: #259CB8; background: white;" expand="block">{{ 'worklist, save-changes' | translate}}</ion-button>
</ion-footer>

@ -2,6 +2,7 @@ import { Component, OnInit } from '@angular/core';
import { ModalController } from '@ionic/angular';
import { CommonService } from 'src/app/hmg-common/services/common/common.service';
import { TranslatorService } from 'src/app/hmg-common/services/translator/translator.service';
import { UserItemTypes } from '../models/userItemTypeRequest';
import { WorklistMainService } from '../service/work-list.main.service';
@Component({
@ -12,6 +13,8 @@ import { WorklistMainService } from '../service/work-list.main.service';
export class WorklistSettingComponent implements OnInit {
notificationList = [];
request = [];
isChange = false;
public direction: string;
@ -19,30 +22,67 @@ export class WorklistSettingComponent implements OnInit {
public modalController: ModalController,
public ts: TranslatorService,
public common: CommonService,
public workListService: WorklistMainService,) { }
public workListService: WorklistMainService) {}
ionViewWillEnter() {
ngOnInit() {
this.direction = TranslatorService.getCurrentDirection();
this.workListService.getWorklistNotifications()
.subscribe((result: any) => {
result.GetUserItemTypesList.forEach(element => {
this.notificationList.push(element);
});
this.notificationList = result.GetUserItemTypesList;
for (let i = 0; i < this.notificationList.length; i++) {
this.request[i] = {
P_FYA_ENABLED_FALG: this.notificationList[i].FYA_ENABLED_FALG,
P_FYI_ENABLED_FLAG: this.notificationList[i].FYI_ENABLED_FLAG,
P_ITEM_TYPE: this.notificationList[i].ITEM_TYPE,
ItemID: i
};
}
});
}
ngOnInit() {
this.direction = TranslatorService.getCurrentDirection();
// list.forEach(element => {
// this.notificationList.push(element);
// });
// console.log(this.notificationList);
dismiss() {
this.modalController.dismiss({
dismissed: true
});
}
chnageToggle(toggleValue, type, val) {
if ( val === 'Y') {
val = 'N';
} else if ( val === 'N') {
val = 'Y';
}
this.notificationList.forEach((el, index) => {
if ( el.ITEM_TYPE === toggleValue.ITEM_TYPE) {
if (type === 'FYI') {
this.request[index].P_FYI_ENABLED_FLAG = val;
} else if (type === 'FYA') {
this.request[index].P_FYA_ENABLED_FALG = val;
}
this.request[index].ItemID = index;
}
this.request[index].P_ITEM_TYPE = el.ITEM_TYPE;
});
}
dismiss() {
this.modalController.dismiss({
'dismissed': true
saveChanges() {
const body = {
UpdateItemTypeList: this.request
};
this.workListService.updateWorklistNotifications(body)
.subscribe((result: any) => {
if (result.UpdateItemTypeSuccessList) {
if (result.UpdateUserItemTypesList) {
this.common.greenToastPK('worklist', 'save-successfully');
this.dismiss();
} else {
this.common.redToastPK('worklist', 'save-error');
}
} else {
this.common.redToastPK('worklist', 'save-error');
}
});
}

@ -2551,6 +2551,14 @@
"loading":{
"en":"Loading",
"ar":"يتم التحميل"
},
"save-successfully":{
"ar":"تم حفظ التغيير بنجاح",
"en":"Your change has been saved successfully"
},
"save-error":{
"ar":"هناك شئ خاطئ، يرجى المحاولة فى وقت لاحق",
"en":"Something went wrong please try again later"
}
},
"worklistMain": {

Loading…
Cancel
Save