|
|
@@ -34,75 +34,76 @@ export class LeaveNotificationDecorator<T> extends DecoratorSubject<T> {
|
|
|
}
|
|
|
|
|
|
private async onReceiveNotification(notif) {
|
|
|
- const OPERATION = notif.data?.data?.NotificationMicroserviceData?.uiMessage?.NotificationData?.Operation;
|
|
|
- const DOCID = +notif.data?.data?.NotificationMicroserviceData?.uiMessage?.NotificationData?.ID;
|
|
|
- const CODE = notif.data?.data?.NotificationMicroserviceData?.uiMessage?.NotificationData?.Code;
|
|
|
+ const OPERATION = notif.data?.data?.NotificationMicroserviceData?.uiMessage?.NotificationData?.Operation
|
|
|
+ || notif.data?.data?.NotificationMicroserviceData?.uiMessage?.NotificationModuleData?.extendedProperties?.operation;
|
|
|
+ const DOC_CODE = notif.data?.data?.NotificationMicroserviceData?.uiMessage?.NotificationData?.Code
|
|
|
+ || notif.data?.data?.NotificationMicroserviceData?.uiMessage?.NotificationModuleData?.extendedProperties?.docRefNo;
|
|
|
let leave;
|
|
|
let applicant;
|
|
|
await firstValueFrom(this.messaging.GetData({
|
|
|
- serviceId: 'Leave Application Data',
|
|
|
- parameter: `__clearSearchValue__=true,caching=false,code=${CODE}`
|
|
|
+ serviceId: 'Leave Application Data',
|
|
|
+ parameter: `__clearSearchValue__=true,caching=false`
|
|
|
},{liveResponsesOnly:true}).pipe(skipUndefined(),debounceNotification(100))).then(res => {
|
|
|
- leave = res.GenericFisData?.data?.DataService?.rows?.row[0]?.column;
|
|
|
+ leave = res.GenericFisData?.data?.DataService?.rows?.row?.find(x => x.column.ps_doc_header_ps_doc_ref_no === DOC_CODE)?.column;
|
|
|
}).catch(error => console.error(error));
|
|
|
if (leave) {
|
|
|
- await firstValueFrom(this.messaging.GetData({
|
|
|
- serviceId: 'Employee Role Data',
|
|
|
- parameter: `roleId=${leave?.ps_doc_leave_emp_role_id},__clearSearchValue__=true,caching=false`
|
|
|
- }).pipe(skipUndefined())).then(res => {
|
|
|
- applicant = res.GenericFisData?.data?.DataService?.rows?.row[0]?.column || res.data?.GenericFisData?.data?.DataService?.rows?.row[0]?.column;
|
|
|
- }).catch(error => console.error(error));
|
|
|
- switch (OPERATION?.toLowerCase()) {
|
|
|
- case 'new': {
|
|
|
- this.notification.notify({
|
|
|
- message:{
|
|
|
- title:{key:'new_leave_applied',default:'New Leave Applied'},
|
|
|
- desc: `${applicant?.pers_name}`,
|
|
|
- timestamp: new Date(),
|
|
|
- },
|
|
|
- action: () => {this.component.cs.navigate('/leave/approval')}
|
|
|
- });
|
|
|
- break;
|
|
|
- }
|
|
|
- case 'modify': {
|
|
|
- this.notification.notify({
|
|
|
- message:{
|
|
|
- title: {key:'leave_modified',default:'Leave Modified'},
|
|
|
- desc: `${applicant?.pers_name}`,
|
|
|
- timestamp: new Date(),
|
|
|
- },
|
|
|
- action: () => {this.component.cs.navigate('/leave/approval')}
|
|
|
- });
|
|
|
- break;
|
|
|
+ await firstValueFrom(this.messaging.GetData({
|
|
|
+ serviceId: 'Employee Role Data',
|
|
|
+ parameter: `roleId=${leave?.ps_doc_leave_emp_role_id},__clearSearchValue__=true,caching=false`
|
|
|
+ }).pipe(skipUndefined())).then(res => {
|
|
|
+ applicant = res.GenericFisData?.data?.DataService?.rows?.row[0]?.column || res.data?.GenericFisData?.data?.DataService?.rows?.row[0]?.column;
|
|
|
+ }).catch(error => console.error(error));
|
|
|
+ switch (OPERATION?.toLowerCase()) {
|
|
|
+ case 'new': {
|
|
|
+ this.notification.notify({
|
|
|
+ message:{
|
|
|
+ title:{key:'new_leave_applied',default:'New Leave Applied'},
|
|
|
+ desc: `${applicant?.pers_name}`,
|
|
|
+ timestamp: new Date(),
|
|
|
+ },
|
|
|
+ action: () => {this.component.cs.navigate('/leave/approval')}
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 'modify': {
|
|
|
+ this.notification.notify({
|
|
|
+ message:{
|
|
|
+ title: {key:'leave_modified',default:'Leave Modified'},
|
|
|
+ desc: `${applicant?.pers_name}`,
|
|
|
+ timestamp: new Date(),
|
|
|
+ },
|
|
|
+ action: () => {this.component.cs.navigate('/leave/approval')}
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 'post': {
|
|
|
+ if (leave?.ps_doc_leave_emp_role_id !== this.empRoleId) break;
|
|
|
+ const DATE_FROM = formatDate(adjustISOTimezoneOffset(leave.ps_doc_leave_ps_dt_from),'yyyy-MM-dd EEE',this.component.cs.appSettings.locale);
|
|
|
+ this.notification.notify({
|
|
|
+ message:{
|
|
|
+ title: {key:'leave_approved',default:'Leave Approved'},
|
|
|
+ desc: {key:`#{leave_date_from}: ${DATE_FROM}`,default:''},
|
|
|
+ timestamp: new Date(),
|
|
|
+ },
|
|
|
+ action: () => {this.component.cs.navigate('/leave',{type:'view',detailsTabIndex:1})}
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 'cancel': {
|
|
|
+ if (leave?.ps_doc_leave_emp_role_id !== this.empRoleId) break;
|
|
|
+ const DATE_FROM = formatDate(adjustISOTimezoneOffset(leave.ps_doc_leave_ps_dt_from),'yyyy-MM-dd EEE',this.component.cs.appSettings.locale);
|
|
|
+ this.notification.notify({
|
|
|
+ message:{
|
|
|
+ title: {key:'leave_cancelled',default:'Leave Cancelled'},
|
|
|
+ desc: {key:`#{leave_date_from}: ${DATE_FROM}`,default:''},
|
|
|
+ timestamp: new Date(),
|
|
|
+ },
|
|
|
+ action: () => {this.component.cs.navigate('/leave',{type:'view',detailsTabIndex:2})}
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ default: break;
|
|
|
}
|
|
|
- case 'post': {
|
|
|
- if (leave?.ps_doc_leave_emp_role_id !== this.empRoleId) break;
|
|
|
- const DATE_FROM = formatDate(adjustISOTimezoneOffset(leave.ps_doc_leave_ps_dt_from),'yyyy-MM-dd EEE',this.component.cs.appSettings.locale);
|
|
|
- this.notification.notify({
|
|
|
- message:{
|
|
|
- title: {key:'leave_approved',default:'Leave Approved'},
|
|
|
- desc: {key:`#{leave_date_from}: ${DATE_FROM}`,default:''},
|
|
|
- timestamp: new Date(),
|
|
|
- },
|
|
|
- action: () => {this.component.cs.navigate('/leave',{type:'view',detailsTabIndex:1})}
|
|
|
- });
|
|
|
- break;
|
|
|
- }
|
|
|
- case 'cancel': {
|
|
|
- if (leave?.ps_doc_leave_emp_role_id !== this.empRoleId) break;
|
|
|
- const DATE_FROM = formatDate(adjustISOTimezoneOffset(leave.ps_doc_leave_ps_dt_from),'yyyy-MM-dd EEE',this.component.cs.appSettings.locale);
|
|
|
- this.notification.notify({
|
|
|
- message:{
|
|
|
- title: {key:'leave_cancelled',default:'Leave Cancelled'},
|
|
|
- desc: {key:`#{leave_date_from}: ${DATE_FROM}`,default:''},
|
|
|
- timestamp: new Date(),
|
|
|
- },
|
|
|
- action: () => {this.component.cs.navigate('/leave',{type:'view',detailsTabIndex:2})}
|
|
|
- });
|
|
|
- break;
|
|
|
- }
|
|
|
- default: break;
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
}
|