@mis-wis/common 0.1.9 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2020/lib/components/create-non-shift-modal/create-non-shift-modal.component.mjs +233 -0
- package/esm2020/lib/constants/assets.constants.mjs +8 -0
- package/esm2020/lib/models/env.model.mjs +1 -1
- package/esm2020/lib/models/session.model.mjs +2 -0
- package/esm2020/lib/services/http.service.mjs +29 -9
- package/esm2020/lib/services/session.errors.mjs +28 -0
- package/esm2020/lib/services/session.service.mjs +148 -0
- package/esm2020/lib/wis-common.module.mjs +13 -8
- package/esm2020/public-api.mjs +5 -1
- package/fesm2015/mis-wis-common.mjs +459 -25
- package/fesm2015/mis-wis-common.mjs.map +1 -1
- package/fesm2020/mis-wis-common.mjs +451 -25
- package/fesm2020/mis-wis-common.mjs.map +1 -1
- package/lib/components/create-non-shift-modal/create-non-shift-modal.component.d.ts +56 -0
- package/lib/constants/assets.constants.d.ts +7 -0
- package/lib/models/env.model.d.ts +1 -0
- package/lib/models/session.model.d.ts +21 -0
- package/lib/services/http.service.d.ts +16 -5
- package/lib/services/session.errors.d.ts +15 -0
- package/lib/services/session.service.d.ts +49 -0
- package/lib/wis-common.module.d.ts +9 -4
- package/mis-wis-common-0.2.0.tgz +0 -0
- package/package.json +3 -2
- package/public-api.d.ts +4 -0
- package/src/assets/calendar.svg +7 -0
- package/src/assets/images/icons/Wis-icon.svg +4 -0
- package/src/assets/images/icons/brand.png +0 -0
- package/src/assets/images/icons/broascast.svg +3 -0
- package/src/assets/images/icons/bulk-upload.svg +3 -0
- package/src/assets/images/icons/desk-mgmt.svg +6 -0
- package/src/assets/images/icons/employees-sidebar.svg +3 -0
- package/src/assets/images/icons/help-section.svg +4 -0
- package/src/assets/images/icons/home.svg +3 -0
- package/src/assets/images/icons/logout.svg +4 -0
- package/src/assets/images/icons/manage-premise.svg +3 -0
- package/src/assets/images/icons/meeting-room.svg +7 -0
- package/src/assets/images/icons/mis-icon.svg +3 -0
- package/src/assets/images/icons/my-bookings.svg +5 -0
- package/src/assets/images/icons/profile.svg +3 -0
- package/src/assets/images/icons/reception.svg +14 -0
- package/src/assets/images/icons/report.svg +3 -0
- package/src/assets/images/icons/resource-group.svg +3 -0
- package/src/assets/images/icons/roles.svg +3 -0
- package/src/assets/images/icons/sanitize.svg +10 -0
- package/src/assets/images/icons/seat-mgmt.svg +3 -0
- package/src/assets/images/icons/settings-sidebar.svg +3 -0
- package/src/assets/images/icons/signout.svg +4 -0
- package/src/assets/images/icons/user-group.svg +6 -0
- package/src/assets/images/icons/user-permission.svg +5 -0
- package/src/assets/images/icons/utilisation.svg +3 -0
- package/src/assets/images/icons/vaccine_approval.svg +8 -0
- package/src/assets/images/icons/vaccine_upload.png +0 -0
- package/src/assets/images/icons/work-planner-sidebar.svg +3 -0
- package/src/assets/images/icons/workInSyncText.svg +14 -0
|
@@ -1,18 +1,28 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { Injectable, NgModule, Component, Inject } from '@angular/core';
|
|
3
|
-
import * as
|
|
3
|
+
import * as i5 from '@angular/common';
|
|
4
4
|
import { CommonModule } from '@angular/common';
|
|
5
|
-
import * as i1$
|
|
6
|
-
import { HttpErrorResponse } from '@angular/common/http';
|
|
7
|
-
import { tap } from 'rxjs/operators';
|
|
5
|
+
import * as i1$2 from '@angular/common/http';
|
|
6
|
+
import { HttpErrorResponse, HttpClientModule } from '@angular/common/http';
|
|
7
|
+
import { tap, finalize } from 'rxjs/operators';
|
|
8
8
|
import * as i1 from '@angular/router';
|
|
9
9
|
import * as i2 from 'mis-crystal-design-system/toast';
|
|
10
|
-
import * as i1$
|
|
10
|
+
import * as i1$1 from '@angular/cdk/overlay';
|
|
11
11
|
import { OverlayConfig, OverlayModule } from '@angular/cdk/overlay';
|
|
12
12
|
import { ComponentPortal } from '@angular/cdk/portal';
|
|
13
13
|
import * as i2$1 from 'mis-crystal-design-system/loader';
|
|
14
14
|
import { LoaderModule } from 'mis-crystal-design-system/loader';
|
|
15
|
-
import { ReplaySubject } from 'rxjs';
|
|
15
|
+
import { map, forkJoin, ReplaySubject } from 'rxjs';
|
|
16
|
+
import * as i2$2 from '@angular/forms';
|
|
17
|
+
import { Validators, ReactiveFormsModule } from '@angular/forms';
|
|
18
|
+
import { parseZone } from 'moment';
|
|
19
|
+
import * as i1$3 from 'mis-design-system/mis-modal';
|
|
20
|
+
import { MODAL_DATA_VAR } from 'mis-design-system/mis-modal';
|
|
21
|
+
import * as i6 from 'mis-crystal-design-system/dropdown';
|
|
22
|
+
import { DropdownModule } from 'mis-crystal-design-system/dropdown';
|
|
23
|
+
import * as i7 from 'mis-crystal-design-system/datepicker_v2';
|
|
24
|
+
import { DatepickerModuleV2 } from 'mis-crystal-design-system/datepicker_v2';
|
|
25
|
+
import jwtDecode from 'jwt-decode';
|
|
16
26
|
|
|
17
27
|
class AuthService {
|
|
18
28
|
constructor() { }
|
|
@@ -145,7 +155,7 @@ class LoaderComponent {
|
|
|
145
155
|
ngOnInit() { }
|
|
146
156
|
}
|
|
147
157
|
LoaderComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: LoaderComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
148
|
-
LoaderComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: LoaderComponent, selector: "mis-common-loader", ngImport: i0, template: "<div class=\"message-wrapper\" *ngIf=\"message; else noMessageLoader\">\n <span><mis-loader type=\"block\"></mis-loader></span>\n <p>{{ message }}</p>\n</div>\n<ng-template #noMessageLoader>\n <mis-loader></mis-loader>\n</ng-template>\n", styles: [".message-wrapper{max-width:343px;background-color:#fff;display:flex;flex-wrap:nowrap;align-items:center;padding:20px 16px;border-radius:6px}.message-wrapper span{position:relative;background-color:#fff;display:inline-block;width:40px;height:40px;margin-right:16px}.message-wrapper p{margin:0}\n"], dependencies: [{ kind: "directive", type:
|
|
158
|
+
LoaderComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: LoaderComponent, selector: "mis-common-loader", ngImport: i0, template: "<div class=\"message-wrapper\" *ngIf=\"message; else noMessageLoader\">\n <span><mis-loader type=\"block\"></mis-loader></span>\n <p>{{ message }}</p>\n</div>\n<ng-template #noMessageLoader>\n <mis-loader></mis-loader>\n</ng-template>\n", styles: [".message-wrapper{max-width:343px;background-color:#fff;display:flex;flex-wrap:nowrap;align-items:center;padding:20px 16px;border-radius:6px}.message-wrapper span{position:relative;background-color:#fff;display:inline-block;width:40px;height:40px;margin-right:16px}.message-wrapper p{margin:0}\n"], dependencies: [{ kind: "directive", type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i2$1.LoaderComponent, selector: "mis-loader", inputs: ["mobileView"] }] });
|
|
149
159
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: LoaderComponent, decorators: [{
|
|
150
160
|
type: Component,
|
|
151
161
|
args: [{ selector: "mis-common-loader", template: "<div class=\"message-wrapper\" *ngIf=\"message; else noMessageLoader\">\n <span><mis-loader type=\"block\"></mis-loader></span>\n <p>{{ message }}</p>\n</div>\n<ng-template #noMessageLoader>\n <mis-loader></mis-loader>\n</ng-template>\n", styles: [".message-wrapper{max-width:343px;background-color:#fff;display:flex;flex-wrap:nowrap;align-items:center;padding:20px 16px;border-radius:6px}.message-wrapper span{position:relative;background-color:#fff;display:inline-block;width:40px;height:40px;margin-right:16px}.message-wrapper p{margin:0}\n"] }]
|
|
@@ -199,14 +209,14 @@ class LoaderService {
|
|
|
199
209
|
return { positionStrategy, width, backdropClass, hasMessage };
|
|
200
210
|
}
|
|
201
211
|
}
|
|
202
|
-
LoaderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: LoaderService, deps: [{ token: i1$
|
|
212
|
+
LoaderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: LoaderService, deps: [{ token: i1$1.Overlay }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
203
213
|
LoaderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: LoaderService, providedIn: "root" });
|
|
204
214
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: LoaderService, decorators: [{
|
|
205
215
|
type: Injectable,
|
|
206
216
|
args: [{
|
|
207
217
|
providedIn: "root"
|
|
208
218
|
}]
|
|
209
|
-
}], ctorParameters: function () { return [{ type: i1$
|
|
219
|
+
}], ctorParameters: function () { return [{ type: i1$1.Overlay }]; } });
|
|
210
220
|
|
|
211
221
|
/** @format */
|
|
212
222
|
const CONSTANTS_LOGGER = {
|
|
@@ -264,7 +274,7 @@ class LoggerService {
|
|
|
264
274
|
this.logRequest(Object.assign(Object.assign({}, data), { componentName, serviceUrl }), "error");
|
|
265
275
|
}
|
|
266
276
|
}
|
|
267
|
-
LoggerService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: LoggerService, deps: [{ token: i1$
|
|
277
|
+
LoggerService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: LoggerService, deps: [{ token: i1$2.HttpClient }, { token: CONSTANTS_LOGGER.APP_NAME }, { token: CONSTANTS_LOGGER.ENV_VAR }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
268
278
|
LoggerService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: LoggerService, providedIn: "root" });
|
|
269
279
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: LoggerService, decorators: [{
|
|
270
280
|
type: Injectable,
|
|
@@ -272,7 +282,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImpor
|
|
|
272
282
|
providedIn: "root"
|
|
273
283
|
}]
|
|
274
284
|
}], ctorParameters: function () {
|
|
275
|
-
return [{ type: i1$
|
|
285
|
+
return [{ type: i1$2.HttpClient }, { type: undefined, decorators: [{
|
|
276
286
|
type: Inject,
|
|
277
287
|
args: [CONSTANTS_LOGGER.APP_NAME]
|
|
278
288
|
}] }, { type: undefined, decorators: [{
|
|
@@ -326,16 +336,36 @@ const API_URLS = {
|
|
|
326
336
|
CONFIGURATIONS: "configurations"
|
|
327
337
|
};
|
|
328
338
|
class HttpService {
|
|
329
|
-
constructor(env,
|
|
339
|
+
constructor(env, http) {
|
|
330
340
|
this.env = env;
|
|
331
|
-
this.auth = auth;
|
|
332
341
|
this.http = http;
|
|
333
342
|
}
|
|
334
|
-
|
|
335
|
-
return this.http.get(`${this.env.
|
|
343
|
+
getProperties(Porperties) {
|
|
344
|
+
return this.http.get(`${this.env.ets}/ets/apis/properties/${Porperties.join(",")}`).pipe(map((res) => {
|
|
345
|
+
return res.reduce((acc, item) => {
|
|
346
|
+
acc[item.propertyName] = item.propertyValue === "true" ? true : item.propertyValue === "false" ? false : item.propertyValue;
|
|
347
|
+
return acc;
|
|
348
|
+
}, {});
|
|
349
|
+
}));
|
|
350
|
+
}
|
|
351
|
+
getOffices(nonce) {
|
|
352
|
+
const body = `CSRF_NONCE=${nonce}&method=getOfficeList`;
|
|
353
|
+
return this.http.post(`${this.env.ets}/Locality_Servlet`, body, { headers: { "Content-Type": "application/x-www-form-urlencoded" } });
|
|
354
|
+
}
|
|
355
|
+
listTransportLocalities(nonce) {
|
|
356
|
+
const body = `CSRF_NONCE=${nonce}&method=listTransportLocalities`;
|
|
357
|
+
return this.http.post(`${this.env.ets}/Locality_Servlet`, body, { headers: { "Content-Type": "application/x-www-form-urlencoded" } });
|
|
358
|
+
}
|
|
359
|
+
createEmptyIrregularTripSheet(nonce, direction) {
|
|
360
|
+
const body = `CSRF_NONCE=${nonce}&method=createEmptyIrregularTripSheet&direction=${direction}`;
|
|
361
|
+
return this.http.post(`${this.env.ets}/Tripsheet_Edit_Servlet`, body, { headers: { "Content-Type": "application/x-www-form-urlencoded" } });
|
|
362
|
+
}
|
|
363
|
+
addEmployeeToTripSheet(nonce, params) {
|
|
364
|
+
const body = `CSRF_NONCE=${nonce}&method=addEmployeeToTripSheet&tripsheet=${encodeURIComponent(JSON.stringify(params.tripsheet))}&employee=${encodeURIComponent(JSON.stringify(params.employee))}&pickupLoc=${encodeURIComponent(JSON.stringify(params.pickupLoc))}&dropLoc=${encodeURIComponent(JSON.stringify(params.dropLoc))}&pickUpTime="${params.pickUpTime}"&dropTime="${params.dropTime}"&position=${params.position}${params.routeSource ? "&routeSource=" + params.routeSource : ""}${params.assetList ? "&assetList=" + encodeURIComponent(JSON.stringify(params.assetList)) : ""}`;
|
|
365
|
+
return this.http.post(`${this.env.ets}/Tripsheet_Edit_Servlet`, body, { headers: { "Content-Type": "application/x-www-form-urlencoded" } });
|
|
336
366
|
}
|
|
337
367
|
}
|
|
338
|
-
HttpService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: HttpService, deps: [{ token: CONSTANTS_WIS_COMMON }, { token:
|
|
368
|
+
HttpService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: HttpService, deps: [{ token: CONSTANTS_WIS_COMMON }, { token: i1$2.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
339
369
|
HttpService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: HttpService });
|
|
340
370
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: HttpService, decorators: [{
|
|
341
371
|
type: Injectable
|
|
@@ -343,7 +373,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImpor
|
|
|
343
373
|
return [{ type: undefined, decorators: [{
|
|
344
374
|
type: Inject,
|
|
345
375
|
args: [CONSTANTS_WIS_COMMON]
|
|
346
|
-
}] }, { type:
|
|
376
|
+
}] }, { type: i1$2.HttpClient }];
|
|
347
377
|
} });
|
|
348
378
|
|
|
349
379
|
class SidenavComponent {
|
|
@@ -357,24 +387,256 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImpor
|
|
|
357
387
|
args: [{ selector: "wis-common-sidenav", template: "<div class=\"wis-sidenav-wrapper\">\n <div class=\"wis-sidenav-header\">\n <div class=\"wis-sidenav-header-logo\">\n <img src=\"assets/sidenav/assets/Wis-icon.svg\" alt=\"\" />\n </div>\n <div class=\"wis-sidenav-header-title\">\n <h1>WIS</h1>\n </div>\n </div>\n <div class=\"wis-sidenav-body\">\n <div class=\"wis-sidenav-body-item\">\n <div class=\"wis-sidenav-body-item-icon\">\n <i class=\"fas fa-home\"></i>\n </div>\n <div class=\"wis-sidenav-body-item-text\">\n <h3>Home</h3>\n </div>\n </div>\n <div class=\"wis-sidenav-body-item\">\n <div class=\"wis-sidenav-body-item-icon\">\n <i class=\"fas fa-user\"></i>\n </div>\n <div class=\"wis-sidenav-body-item-text\">\n <h3>Profile</h3>\n </div>\n </div>\n <div class=\"wis-sidenav-body-item\">\n <div class=\"wis-sidenav-body-item-icon\">\n <i class=\"fas fa-users\"></i>\n </div>\n <div class=\"wis-sidenav-body-item-text\">\n <h3>Users</h3>\n </div>\n </div>\n <div class=\"wis-sidenav-body-item\">\n <div class=\"wis-sidenav-body-item-icon\">\n <i class=\"fas fa-cog\"></i>\n </div>\n <div class=\"wis-sidenav-body-item-text\">\n <h3>Settings</h3>\n </div>\n </div>\n </div>\n</div>\n", styles: [".wis-sidenav-wrapper{width:72px;border-right:1px solid #e0e0e0}\n"] }]
|
|
358
388
|
}], ctorParameters: function () { return []; } });
|
|
359
389
|
|
|
390
|
+
/** @format */
|
|
391
|
+
const CONSTANTS_ASSETS_WIS_COMMON = {
|
|
392
|
+
IMAGES: {
|
|
393
|
+
CALENDAR_ICON: "assets/libraries/wis-common/calendar.svg"
|
|
394
|
+
},
|
|
395
|
+
ICONS: {}
|
|
396
|
+
};
|
|
397
|
+
|
|
398
|
+
const PROPERTIES = ["NON_SHIFT_TRIPS_CATEGORIES", "USE_VALID_OFFICE_FOR_IRREGULAR_TRIPS"];
|
|
399
|
+
class CreateNonShiftModalComponent {
|
|
400
|
+
constructor(modalData, modalRef, fb, http, toast) {
|
|
401
|
+
this.modalData = modalData;
|
|
402
|
+
this.modalRef = modalRef;
|
|
403
|
+
this.fb = fb;
|
|
404
|
+
this.http = http;
|
|
405
|
+
this.toast = toast;
|
|
406
|
+
this.CONSTANTS_ASSETS_WIS_COMMON = CONSTANTS_ASSETS_WIS_COMMON;
|
|
407
|
+
this.dateConfig = {
|
|
408
|
+
minDate: parseZone().format("DD/MM/YYYY"),
|
|
409
|
+
format: "DD/MM/YYYY"
|
|
410
|
+
};
|
|
411
|
+
this.offices = [];
|
|
412
|
+
this.locationDropdownData = [];
|
|
413
|
+
this.categoryDropdownData = [];
|
|
414
|
+
this.hoursDropdownData = [];
|
|
415
|
+
this.minutesDropdownData = [];
|
|
416
|
+
this.showOtherAddress = false;
|
|
417
|
+
this.loading = false;
|
|
418
|
+
this.isSubmitting = false;
|
|
419
|
+
this.TYPE_OFFICE = 6;
|
|
420
|
+
this.TYPE_TRANSPORT = 3;
|
|
421
|
+
this.TYPE_OTHER = 4;
|
|
422
|
+
this.properties = {};
|
|
423
|
+
}
|
|
424
|
+
ngOnInit() {
|
|
425
|
+
this.loading = true;
|
|
426
|
+
const $office = this.http.getOffices(this.modalData.nonce);
|
|
427
|
+
const $properties = this.http.getProperties(PROPERTIES);
|
|
428
|
+
forkJoin([$office, $properties])
|
|
429
|
+
.pipe(finalize(() => (this.loading = false)))
|
|
430
|
+
.subscribe({
|
|
431
|
+
next: ([offices, properties]) => {
|
|
432
|
+
this.properties = properties;
|
|
433
|
+
this.initializeForm();
|
|
434
|
+
this.initializeDropdownData(offices);
|
|
435
|
+
this.setupFormListeners();
|
|
436
|
+
},
|
|
437
|
+
error: error => {
|
|
438
|
+
console.error("Error loading form data:", error);
|
|
439
|
+
this.modalRef.close();
|
|
440
|
+
}
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
initializeForm() {
|
|
444
|
+
var _a, _b, _c;
|
|
445
|
+
const currentTime = (_b = (_a = this.modalData) === null || _a === void 0 ? void 0 : _a.date) !== null && _b !== void 0 ? _b : parseZone().format("DD/MM/YYYY");
|
|
446
|
+
this.createTripsheetForm = this.fb.group({
|
|
447
|
+
direction: [((_c = this.modalData) === null || _c === void 0 ? void 0 : _c.shiftType) === "logout" ? "OUT" : "IN", Validators.required],
|
|
448
|
+
location: [{ label: "", value: "" }],
|
|
449
|
+
otherAddress: "",
|
|
450
|
+
tripCategory: [{ label: "", value: "" }],
|
|
451
|
+
date: [currentTime, Validators.required],
|
|
452
|
+
hours: [{ label: "", value: "" }],
|
|
453
|
+
mins: [{ label: "", value: "" }]
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
initializeDropdownData(offices) {
|
|
457
|
+
var _a, _b, _c;
|
|
458
|
+
this.locationDropdownData = offices.map((office) => ({
|
|
459
|
+
label: office.address,
|
|
460
|
+
value: { type: this.TYPE_OFFICE, office: office || null }
|
|
461
|
+
}));
|
|
462
|
+
(_a = this.createTripsheetForm.get("location")) === null || _a === void 0 ? void 0 : _a.setValue(this.locationDropdownData[0]);
|
|
463
|
+
if (!((_b = this.properties) === null || _b === void 0 ? void 0 : _b["USE_VALID_OFFICE_FOR_IRREGULAR_TRIPS"])) {
|
|
464
|
+
this.locationDropdownData.push({ label: "Airport", value: { type: this.TYPE_TRANSPORT, office: null } }, { label: "Other", value: { type: this.TYPE_OTHER, office: null } });
|
|
465
|
+
}
|
|
466
|
+
// Initialize category dropdown
|
|
467
|
+
const categoriesString = (_c = this.properties) === null || _c === void 0 ? void 0 : _c["NON_SHIFT_TRIPS_CATEGORIES"];
|
|
468
|
+
if (categoriesString && typeof categoriesString === "string") {
|
|
469
|
+
const categories = categoriesString.split(",").filter(cat => cat && cat.trim());
|
|
470
|
+
if (categories.length > 0) {
|
|
471
|
+
this.categoryDropdownData = categories.map(category => ({
|
|
472
|
+
label: category.trim(),
|
|
473
|
+
value: category.trim()
|
|
474
|
+
}));
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
const currentHour = new Date().getHours();
|
|
478
|
+
this.hoursDropdownData = Array.from({ length: 24 }, (_, i) => ({
|
|
479
|
+
label: this.padZero(i),
|
|
480
|
+
value: this.padZero(i)
|
|
481
|
+
}));
|
|
482
|
+
this.createTripsheetForm.patchValue({ hours: this.hoursDropdownData[currentHour] });
|
|
483
|
+
const currentMinute = new Date().getMinutes();
|
|
484
|
+
this.minutesDropdownData = Array.from({ length: 60 }, (_, i) => ({
|
|
485
|
+
label: this.padZero(i),
|
|
486
|
+
value: this.padZero(i)
|
|
487
|
+
}));
|
|
488
|
+
this.createTripsheetForm.patchValue({ mins: this.minutesDropdownData[currentMinute] });
|
|
489
|
+
}
|
|
490
|
+
setupFormListeners() {
|
|
491
|
+
var _a;
|
|
492
|
+
(_a = this.createTripsheetForm) === null || _a === void 0 ? void 0 : _a.valueChanges.subscribe(value => {
|
|
493
|
+
var _a, _b, _c, _d, _e, _f;
|
|
494
|
+
const { location } = (_a = this.createTripsheetForm) === null || _a === void 0 ? void 0 : _a.value;
|
|
495
|
+
if (this.showOtherAddress !== (((_b = location === null || location === void 0 ? void 0 : location.value) === null || _b === void 0 ? void 0 : _b.type) === this.TYPE_OTHER)) {
|
|
496
|
+
this.showOtherAddress = ((_c = location === null || location === void 0 ? void 0 : location.value) === null || _c === void 0 ? void 0 : _c.type) === this.TYPE_OTHER;
|
|
497
|
+
if (this.showOtherAddress) {
|
|
498
|
+
(_d = this.createTripsheetForm.get("otherAddress")) === null || _d === void 0 ? void 0 : _d.setValidators([Validators.required]);
|
|
499
|
+
}
|
|
500
|
+
else {
|
|
501
|
+
(_e = this.createTripsheetForm.get("otherAddress")) === null || _e === void 0 ? void 0 : _e.clearValidators();
|
|
502
|
+
}
|
|
503
|
+
(_f = this.createTripsheetForm.get("otherAddress")) === null || _f === void 0 ? void 0 : _f.updateValueAndValidity();
|
|
504
|
+
}
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
padZero(num) {
|
|
508
|
+
return num.toString().padStart(2, "0");
|
|
509
|
+
}
|
|
510
|
+
onCancel() {
|
|
511
|
+
this.modalRef.close();
|
|
512
|
+
}
|
|
513
|
+
onSubmit() {
|
|
514
|
+
var _a, _b;
|
|
515
|
+
if (this.createTripsheetForm.invalid) {
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
const formValue = this.createTripsheetForm.value;
|
|
519
|
+
const pickupTime = `${formValue.date} ${formValue.hours.value}/${formValue.mins.value}/00`;
|
|
520
|
+
const pickupTimeDate = parseZone(pickupTime).toDate();
|
|
521
|
+
if (this.isDateAndTimeFromPast(pickupTimeDate)) {
|
|
522
|
+
this.toast.displayMsg("Please select a future date and time.");
|
|
523
|
+
return;
|
|
524
|
+
}
|
|
525
|
+
if (this.categoryDropdownData.length > 0 && (!formValue.tripCategory || !formValue.tripCategory.value)) {
|
|
526
|
+
this.toast.displayMsg("Please provide a trip category.");
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
529
|
+
if (((_b = (_a = formValue.location) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.type) === this.TYPE_OTHER) {
|
|
530
|
+
if (!formValue.otherAddress || formValue.otherAddress.trim() === "") {
|
|
531
|
+
this.toast.displayMsg("Please provide the address.");
|
|
532
|
+
return;
|
|
533
|
+
}
|
|
534
|
+
if (formValue.otherAddress.includes(",")) {
|
|
535
|
+
this.toast.displayMsg("Special character (,) not allowed in address.");
|
|
536
|
+
return;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
this.isSubmitting = true;
|
|
540
|
+
this.http.createEmptyIrregularTripSheet(this.modalData.nonce, formValue.direction).subscribe({
|
|
541
|
+
next: routeTripSheet => {
|
|
542
|
+
const pickupLoc = routeTripSheet.dir === "IN" ? this.modalData.employee.home : this.getLocation(formValue);
|
|
543
|
+
const dropLoc = routeTripSheet.dir === "OUT" ? this.modalData.employee.home : this.getLocation(formValue);
|
|
544
|
+
const pickupTimeFormatted = pickupTime;
|
|
545
|
+
const dropTimeFormatted = pickupTime;
|
|
546
|
+
const employee = Object.assign(Object.assign({}, this.modalData.employee), { employee_status: 1 });
|
|
547
|
+
const addEmployeeParams = {
|
|
548
|
+
tripsheet: routeTripSheet,
|
|
549
|
+
employee: employee,
|
|
550
|
+
pickupLoc: pickupLoc,
|
|
551
|
+
dropLoc: dropLoc,
|
|
552
|
+
pickUpTime: pickupTimeFormatted,
|
|
553
|
+
dropTime: dropTimeFormatted,
|
|
554
|
+
position: 0,
|
|
555
|
+
routeSource: this.modalData.routeSource,
|
|
556
|
+
assetList: this.modalData.assetList
|
|
557
|
+
};
|
|
558
|
+
this.http.addEmployeeToTripSheet(this.modalData.nonce, addEmployeeParams).subscribe({
|
|
559
|
+
next: updatedTripSheet => {
|
|
560
|
+
var _a;
|
|
561
|
+
if (!updatedTripSheet.customMap) {
|
|
562
|
+
updatedTripSheet.customMap = {};
|
|
563
|
+
}
|
|
564
|
+
updatedTripSheet.customMap.tripCategory = ((_a = formValue.tripCategory) === null || _a === void 0 ? void 0 : _a.value) || "";
|
|
565
|
+
this.modalRef.close({
|
|
566
|
+
success: true,
|
|
567
|
+
tripsheet: updatedTripSheet
|
|
568
|
+
});
|
|
569
|
+
},
|
|
570
|
+
error: error => {
|
|
571
|
+
console.error("Error adding employee to tripsheet:", error);
|
|
572
|
+
this.toast.displayMsg("Failed to add employee to tripsheet. Please try again.");
|
|
573
|
+
this.isSubmitting = false;
|
|
574
|
+
}
|
|
575
|
+
});
|
|
576
|
+
},
|
|
577
|
+
error: error => {
|
|
578
|
+
console.error("Error creating tripsheet:", error);
|
|
579
|
+
this.toast.displayMsg("Failed to create tripsheet. Please try again.");
|
|
580
|
+
this.isSubmitting = false;
|
|
581
|
+
}
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
isDateAndTimeFromPast(date) {
|
|
585
|
+
const now = new Date();
|
|
586
|
+
return date < now;
|
|
587
|
+
}
|
|
588
|
+
getLocation(formValue) {
|
|
589
|
+
var _a;
|
|
590
|
+
const location = (_a = formValue.location) === null || _a === void 0 ? void 0 : _a.value;
|
|
591
|
+
if (!location) {
|
|
592
|
+
return null;
|
|
593
|
+
}
|
|
594
|
+
const locType = location.type;
|
|
595
|
+
switch (locType) {
|
|
596
|
+
case this.TYPE_OFFICE:
|
|
597
|
+
return location.office;
|
|
598
|
+
case this.TYPE_TRANSPORT:
|
|
599
|
+
return {
|
|
600
|
+
id: null,
|
|
601
|
+
type: this.TYPE_TRANSPORT,
|
|
602
|
+
address: "Airport",
|
|
603
|
+
geoCord: null
|
|
604
|
+
};
|
|
605
|
+
case this.TYPE_OTHER:
|
|
606
|
+
return Object.assign(Object.assign({}, location.office), { address: formValue.otherAddress || "" });
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
CreateNonShiftModalComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: CreateNonShiftModalComponent, deps: [{ token: MODAL_DATA_VAR }, { token: i1$3.ModalRef }, { token: i2$2.FormBuilder }, { token: HttpService }, { token: i2.ToastService }], target: i0.ɵɵFactoryTarget.Component });
|
|
611
|
+
CreateNonShiftModalComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: CreateNonShiftModalComponent, selector: "app-create-non-shift-modal", ngImport: i0, template: "<div class=\"createTripsheet\">\n <h2 class=\"modal-header\">Create Non-Shift Tripsheet</h2>\n\n <div *ngIf=\"loading\" class=\"loading-container\">\n <div class=\"spinner\"></div>\n <p>Loading...</p>\n </div>\n\n <form\n *ngIf=\"!loading && createTripsheetForm\"\n [formGroup]=\"createTripsheetForm\"\n (ngSubmit)=\"onSubmit()\"\n class=\"createTripsheetForm\"\n id=\"createTripsheetForm\"\n >\n <div class=\"form-content\">\n <!-- Radio buttons row -->\n <div [ngClass]=\"{ 'radio-row': true, disabled: modalData?.shiftSelectionDisabled }\">\n <label class=\"radio-label\">\n <input class=\"modern-checkbox\" type=\"radio\" formControlName=\"direction\" value=\"OUT\" id=\"startLoc\" />\n <span>Start Location Fixed (Logout)</span>\n </label>\n <label class=\"radio-label\">\n <input class=\"modern-checkbox\" type=\"radio\" formControlName=\"direction\" value=\"IN\" id=\"endLoc\" />\n <span>End Location Fixed (Login)</span>\n </label>\n </div>\n\n <!-- Location field -->\n <div class=\"form-field\">\n <div class=\"label-cell\">\n <label class=\"locText\">Location</label>\n </div>\n <div class=\"input-cell\">\n <mis-dropdown\n [searchEnabled]=\"true\"\n [width]=\"'100%'\"\n [height]=\"'40px'\"\n [data]=\"locationDropdownData\"\n [selectedItem]=\"createTripsheetForm.get('location')?.value\"\n [label]=\"'Select location...'\"\n (onChange)=\"createTripsheetForm.get('location')?.setValue($event)\"\n ></mis-dropdown>\n </div>\n </div>\n\n <!-- Other address field -->\n <div class=\"form-field otherAddress\" *ngIf=\"showOtherAddress\">\n <div class=\"label-cell\">\n <label>Pick/Drop point <sup>*</sup></label>\n </div>\n <div class=\"input-cell\">\n <input type=\"text\" formControlName=\"otherAddress\" class=\"modern-input\" />\n </div>\n </div>\n\n <!-- Trip category field -->\n <div class=\"form-field\" *ngIf=\"categoryDropdownData.length > 0\">\n <div class=\"label-cell\">\n <label>Trip Category</label>\n </div>\n <div class=\"input-cell\">\n <mis-dropdown\n [searchEnabled]=\"false\"\n [width]=\"'250px'\"\n [height]=\"'40px'\"\n [data]=\"categoryDropdownData\"\n [selectedItem]=\"createTripsheetForm.get('tripCategory')?.value\"\n [label]=\"'Select category...'\"\n (onChange)=\"createTripsheetForm.get('tripCategory')?.setValue($event)\"\n ></mis-dropdown>\n </div>\n </div>\n\n <!-- Time field -->\n <div class=\"form-field\">\n <div class=\"label-cell\">\n <label class=\"fixedTimeText\">Time</label>\n </div>\n <div class=\"input-cell modern-date-container\">\n <div class=\"date-select\">\n <input\n misTzDp\n readonly\n [dpConfig]=\"dateConfig\"\n [formControl]=\"createTripsheetForm.get('date')\"\n style=\"height: 44px !important; font-size: 16px !important; cursor: pointer; vertical-align: middle !important\"\n />\n <img [src]=\"CONSTANTS_ASSETS_WIS_COMMON.IMAGES.CALENDAR_ICON\" alt=\"Calendar Icon\" class=\"date-icon data-picker-icon\" />\n </div>\n\n <mis-dropdown\n [searchEnabled]=\"false\"\n [width]=\"'5rem'\"\n [height]=\"'40px'\"\n [data]=\"hoursDropdownData\"\n [selectedItem]=\"createTripsheetForm.get('hours')?.value\"\n [label]=\"'HH'\"\n (onChange)=\"createTripsheetForm.get('hours')?.setValue($event)\"\n ></mis-dropdown>\n\n <mis-dropdown\n [searchEnabled]=\"false\"\n [width]=\"'5rem'\"\n [height]=\"'40px'\"\n [data]=\"minutesDropdownData\"\n [selectedItem]=\"createTripsheetForm.get('mins')?.value\"\n [label]=\"'MM'\"\n (onChange)=\"createTripsheetForm.get('mins')?.setValue($event)\"\n ></mis-dropdown>\n </div>\n </div>\n </div>\n\n <div class=\"form-actions\">\n <button mis-button type=\"outline\" (click)=\"onCancel()\" [disabled]=\"isSubmitting\">Cancel</button>\n <button mis-button type=\"primary\" [disabled]=\"isSubmitting || createTripsheetForm?.invalid\">\n {{ isSubmitting ? \"Creating...\" : \"Create\" }}\n </button>\n </div>\n </form>\n</div>\n", styles: [".createTripsheet{width:40rem;margin:auto;background:#fff;border-radius:.5rem;padding:1.25rem}.createTripsheet .modal-header{font-size:1.25rem;font-weight:600;color:#333;margin:0 0 1.25rem;padding-bottom:.9375rem;border-bottom:.0625rem solid #e0e0e0}.createTripsheet .loading-container{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:3.75rem 1.25rem;min-height:12.5rem}.createTripsheet .loading-container .spinner{border:.1875rem solid #f3f3f3;border-top:.1875rem solid #007bff;border-radius:50%;width:2.5rem;height:2.5rem;animation:spin 1s linear infinite}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.createTripsheet .createTripsheetForm .form-content{display:flex;flex-direction:column}.createTripsheet .createTripsheetForm .form-field{display:flex;align-items:flex-start;gap:1.25rem;padding:.9375rem 0}.createTripsheet .createTripsheetForm .form-field .label-cell{flex:0 0 30%;padding-top:.5rem}.createTripsheet .createTripsheetForm .form-field .label-cell label{font-size:.875rem;font-weight:500;color:#333}.createTripsheet .createTripsheetForm .form-field .input-cell{flex:1;display:flex}.createTripsheet .createTripsheetForm .radio-row{display:flex;gap:1.25rem;padding:.9375rem 0}.createTripsheet .createTripsheetForm .radio-label{font-size:.875rem;display:flex;align-items:center;cursor:pointer;margin:0}.createTripsheet .createTripsheetForm .radio-label .modern-checkbox{margin-right:.625rem;vertical-align:sub;cursor:pointer;width:1rem;height:1rem;accent-color:#007bff}.createTripsheet .createTripsheetForm .radio-label span{-webkit-user-select:none;user-select:none;white-space:nowrap}.createTripsheet .createTripsheetForm .modern-input{width:100%;padding:.5rem .75rem;border:.0625rem solid #ddd;border-radius:.25rem;font-size:.875rem;transition:border-color .3s}.createTripsheet .createTripsheetForm .modern-input:focus{outline:none;border-color:#007bff;box-shadow:0 0 0 .2rem #007bff40}.createTripsheet .createTripsheetForm .modern-input:disabled{background-color:#f5f5f5;cursor:not-allowed}.createTripsheet .createTripsheetForm sup{color:#dc3545}.createTripsheet .createTripsheetForm ::ng-deep mis-dropdown{display:block;width:100%}.createTripsheet .createTripsheetForm .modern-date-container{position:inherit;float:inherit;display:flex;align-items:center;gap:.625rem}.createTripsheet .createTripsheetForm .ng-invalid{border:.0625rem solid #dc3545}.createTripsheet .createTripsheetForm .form-actions{text-align:right;margin:.625rem;border-top:.0625rem solid #e0e0e0;padding:.625rem;display:flex;justify-content:flex-end;gap:.625rem;margin-bottom:0}.createTripsheet .createTripsheetForm .form-actions button{padding:.625rem 1.5rem;font-size:.875rem;font-weight:500;border-radius:.375rem;border:none;cursor:pointer;transition:all .3s ease;min-width:6.25rem}.createTripsheet .createTripsheetForm .form-actions button[type=primary]{background-color:#0937b2;color:#fff;border:.0625rem solid #0937b2}.createTripsheet .createTripsheetForm .form-actions button[type=outline]{background-color:transparent;color:#6c757d;border:.0625rem solid #ddd}.createTripsheet .createTripsheetForm .form-actions button:disabled{opacity:.6;cursor:not-allowed;box-shadow:none}.date-select{height:2.5rem;border:.0625rem solid #e0e0e0;padding:0;border-radius:.375rem;display:flex;flex-wrap:nowrap;justify-content:space-between;align-items:center;position:relative;overflow:hidden;left:-.5%;flex-shrink:0}.date-select input{background-color:transparent;display:inline-block;padding:.25rem 0 .25rem .75rem;width:100%;border:none;outline:none;cursor:pointer;font-size:.875rem}.date-select img{position:relative;right:1rem}.radio-row.disabled{pointer-events:none;opacity:.5}\n"], dependencies: [{ kind: "directive", type: i5.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i6.DropdownComponent, selector: "mis-dropdown", inputs: ["data", "height", "ariaLabel", "width", "label", "itemSizeForCdk", "showOnlyIcon", "higlightSelectedValue", "dropdownListHeight", "dropdownListWidth", "dropdownListPosition", "config", "searchEnabled", "selectedItem", "noDataMessage", "multiLine", "additionalInfoMessage", "scrollIntoView", "searchLabel", "customStyles", "activeItem"], outputs: ["onChange"] }, { kind: "directive", type: i2$2.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i2$2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i2$2.RadioControlValueAccessor, selector: "input[type=radio][formControlName],input[type=radio][formControl],input[type=radio][ngModel]", inputs: ["name", "formControlName", "value"] }, { kind: "directive", type: i2$2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2$2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i2$2.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: i2$2.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i2$2.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "directive", type: i7.TzDatepickerDirective, selector: "input[misTzDp]", inputs: ["dpConfig", "selectedDate", "datesDisabled", "dateMessages", "positionX", "positionY", "offsetX", "offsetY", "allowBookingOnDisabledDay", "disableBoxShadow", "disableOverLay", "openElement"], outputs: ["dateChange"] }] });
|
|
612
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: CreateNonShiftModalComponent, decorators: [{
|
|
613
|
+
type: Component,
|
|
614
|
+
args: [{ selector: "app-create-non-shift-modal", template: "<div class=\"createTripsheet\">\n <h2 class=\"modal-header\">Create Non-Shift Tripsheet</h2>\n\n <div *ngIf=\"loading\" class=\"loading-container\">\n <div class=\"spinner\"></div>\n <p>Loading...</p>\n </div>\n\n <form\n *ngIf=\"!loading && createTripsheetForm\"\n [formGroup]=\"createTripsheetForm\"\n (ngSubmit)=\"onSubmit()\"\n class=\"createTripsheetForm\"\n id=\"createTripsheetForm\"\n >\n <div class=\"form-content\">\n <!-- Radio buttons row -->\n <div [ngClass]=\"{ 'radio-row': true, disabled: modalData?.shiftSelectionDisabled }\">\n <label class=\"radio-label\">\n <input class=\"modern-checkbox\" type=\"radio\" formControlName=\"direction\" value=\"OUT\" id=\"startLoc\" />\n <span>Start Location Fixed (Logout)</span>\n </label>\n <label class=\"radio-label\">\n <input class=\"modern-checkbox\" type=\"radio\" formControlName=\"direction\" value=\"IN\" id=\"endLoc\" />\n <span>End Location Fixed (Login)</span>\n </label>\n </div>\n\n <!-- Location field -->\n <div class=\"form-field\">\n <div class=\"label-cell\">\n <label class=\"locText\">Location</label>\n </div>\n <div class=\"input-cell\">\n <mis-dropdown\n [searchEnabled]=\"true\"\n [width]=\"'100%'\"\n [height]=\"'40px'\"\n [data]=\"locationDropdownData\"\n [selectedItem]=\"createTripsheetForm.get('location')?.value\"\n [label]=\"'Select location...'\"\n (onChange)=\"createTripsheetForm.get('location')?.setValue($event)\"\n ></mis-dropdown>\n </div>\n </div>\n\n <!-- Other address field -->\n <div class=\"form-field otherAddress\" *ngIf=\"showOtherAddress\">\n <div class=\"label-cell\">\n <label>Pick/Drop point <sup>*</sup></label>\n </div>\n <div class=\"input-cell\">\n <input type=\"text\" formControlName=\"otherAddress\" class=\"modern-input\" />\n </div>\n </div>\n\n <!-- Trip category field -->\n <div class=\"form-field\" *ngIf=\"categoryDropdownData.length > 0\">\n <div class=\"label-cell\">\n <label>Trip Category</label>\n </div>\n <div class=\"input-cell\">\n <mis-dropdown\n [searchEnabled]=\"false\"\n [width]=\"'250px'\"\n [height]=\"'40px'\"\n [data]=\"categoryDropdownData\"\n [selectedItem]=\"createTripsheetForm.get('tripCategory')?.value\"\n [label]=\"'Select category...'\"\n (onChange)=\"createTripsheetForm.get('tripCategory')?.setValue($event)\"\n ></mis-dropdown>\n </div>\n </div>\n\n <!-- Time field -->\n <div class=\"form-field\">\n <div class=\"label-cell\">\n <label class=\"fixedTimeText\">Time</label>\n </div>\n <div class=\"input-cell modern-date-container\">\n <div class=\"date-select\">\n <input\n misTzDp\n readonly\n [dpConfig]=\"dateConfig\"\n [formControl]=\"createTripsheetForm.get('date')\"\n style=\"height: 44px !important; font-size: 16px !important; cursor: pointer; vertical-align: middle !important\"\n />\n <img [src]=\"CONSTANTS_ASSETS_WIS_COMMON.IMAGES.CALENDAR_ICON\" alt=\"Calendar Icon\" class=\"date-icon data-picker-icon\" />\n </div>\n\n <mis-dropdown\n [searchEnabled]=\"false\"\n [width]=\"'5rem'\"\n [height]=\"'40px'\"\n [data]=\"hoursDropdownData\"\n [selectedItem]=\"createTripsheetForm.get('hours')?.value\"\n [label]=\"'HH'\"\n (onChange)=\"createTripsheetForm.get('hours')?.setValue($event)\"\n ></mis-dropdown>\n\n <mis-dropdown\n [searchEnabled]=\"false\"\n [width]=\"'5rem'\"\n [height]=\"'40px'\"\n [data]=\"minutesDropdownData\"\n [selectedItem]=\"createTripsheetForm.get('mins')?.value\"\n [label]=\"'MM'\"\n (onChange)=\"createTripsheetForm.get('mins')?.setValue($event)\"\n ></mis-dropdown>\n </div>\n </div>\n </div>\n\n <div class=\"form-actions\">\n <button mis-button type=\"outline\" (click)=\"onCancel()\" [disabled]=\"isSubmitting\">Cancel</button>\n <button mis-button type=\"primary\" [disabled]=\"isSubmitting || createTripsheetForm?.invalid\">\n {{ isSubmitting ? \"Creating...\" : \"Create\" }}\n </button>\n </div>\n </form>\n</div>\n", styles: [".createTripsheet{width:40rem;margin:auto;background:#fff;border-radius:.5rem;padding:1.25rem}.createTripsheet .modal-header{font-size:1.25rem;font-weight:600;color:#333;margin:0 0 1.25rem;padding-bottom:.9375rem;border-bottom:.0625rem solid #e0e0e0}.createTripsheet .loading-container{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:3.75rem 1.25rem;min-height:12.5rem}.createTripsheet .loading-container .spinner{border:.1875rem solid #f3f3f3;border-top:.1875rem solid #007bff;border-radius:50%;width:2.5rem;height:2.5rem;animation:spin 1s linear infinite}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.createTripsheet .createTripsheetForm .form-content{display:flex;flex-direction:column}.createTripsheet .createTripsheetForm .form-field{display:flex;align-items:flex-start;gap:1.25rem;padding:.9375rem 0}.createTripsheet .createTripsheetForm .form-field .label-cell{flex:0 0 30%;padding-top:.5rem}.createTripsheet .createTripsheetForm .form-field .label-cell label{font-size:.875rem;font-weight:500;color:#333}.createTripsheet .createTripsheetForm .form-field .input-cell{flex:1;display:flex}.createTripsheet .createTripsheetForm .radio-row{display:flex;gap:1.25rem;padding:.9375rem 0}.createTripsheet .createTripsheetForm .radio-label{font-size:.875rem;display:flex;align-items:center;cursor:pointer;margin:0}.createTripsheet .createTripsheetForm .radio-label .modern-checkbox{margin-right:.625rem;vertical-align:sub;cursor:pointer;width:1rem;height:1rem;accent-color:#007bff}.createTripsheet .createTripsheetForm .radio-label span{-webkit-user-select:none;user-select:none;white-space:nowrap}.createTripsheet .createTripsheetForm .modern-input{width:100%;padding:.5rem .75rem;border:.0625rem solid #ddd;border-radius:.25rem;font-size:.875rem;transition:border-color .3s}.createTripsheet .createTripsheetForm .modern-input:focus{outline:none;border-color:#007bff;box-shadow:0 0 0 .2rem #007bff40}.createTripsheet .createTripsheetForm .modern-input:disabled{background-color:#f5f5f5;cursor:not-allowed}.createTripsheet .createTripsheetForm sup{color:#dc3545}.createTripsheet .createTripsheetForm ::ng-deep mis-dropdown{display:block;width:100%}.createTripsheet .createTripsheetForm .modern-date-container{position:inherit;float:inherit;display:flex;align-items:center;gap:.625rem}.createTripsheet .createTripsheetForm .ng-invalid{border:.0625rem solid #dc3545}.createTripsheet .createTripsheetForm .form-actions{text-align:right;margin:.625rem;border-top:.0625rem solid #e0e0e0;padding:.625rem;display:flex;justify-content:flex-end;gap:.625rem;margin-bottom:0}.createTripsheet .createTripsheetForm .form-actions button{padding:.625rem 1.5rem;font-size:.875rem;font-weight:500;border-radius:.375rem;border:none;cursor:pointer;transition:all .3s ease;min-width:6.25rem}.createTripsheet .createTripsheetForm .form-actions button[type=primary]{background-color:#0937b2;color:#fff;border:.0625rem solid #0937b2}.createTripsheet .createTripsheetForm .form-actions button[type=outline]{background-color:transparent;color:#6c757d;border:.0625rem solid #ddd}.createTripsheet .createTripsheetForm .form-actions button:disabled{opacity:.6;cursor:not-allowed;box-shadow:none}.date-select{height:2.5rem;border:.0625rem solid #e0e0e0;padding:0;border-radius:.375rem;display:flex;flex-wrap:nowrap;justify-content:space-between;align-items:center;position:relative;overflow:hidden;left:-.5%;flex-shrink:0}.date-select input{background-color:transparent;display:inline-block;padding:.25rem 0 .25rem .75rem;width:100%;border:none;outline:none;cursor:pointer;font-size:.875rem}.date-select img{position:relative;right:1rem}.radio-row.disabled{pointer-events:none;opacity:.5}\n"] }]
|
|
615
|
+
}], ctorParameters: function () {
|
|
616
|
+
return [{ type: undefined, decorators: [{
|
|
617
|
+
type: Inject,
|
|
618
|
+
args: [MODAL_DATA_VAR]
|
|
619
|
+
}] }, { type: i1$3.ModalRef }, { type: i2$2.FormBuilder }, { type: HttpService }, { type: i2.ToastService }];
|
|
620
|
+
} });
|
|
621
|
+
|
|
360
622
|
class WisCommonModule {
|
|
361
623
|
static forRoot(env) {
|
|
362
624
|
return {
|
|
363
625
|
ngModule: WisCommonModule,
|
|
364
|
-
providers: [{ provide: CONSTANTS_WIS_COMMON, useValue: env }, ConfigurationService, LoaderService]
|
|
626
|
+
providers: [HttpService, { provide: CONSTANTS_WIS_COMMON, useValue: env }, ConfigurationService, LoaderService]
|
|
365
627
|
};
|
|
366
628
|
}
|
|
367
629
|
}
|
|
368
630
|
WisCommonModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: WisCommonModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
369
|
-
WisCommonModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.3.0", ngImport: i0, type: WisCommonModule, declarations: [LoaderComponent, SidenavComponent], imports: [CommonModule, OverlayModule, LoaderModule], exports: [SidenavComponent] });
|
|
370
|
-
WisCommonModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: WisCommonModule,
|
|
631
|
+
WisCommonModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.3.0", ngImport: i0, type: WisCommonModule, declarations: [LoaderComponent, SidenavComponent, CreateNonShiftModalComponent], imports: [CommonModule, HttpClientModule, OverlayModule, LoaderModule, DropdownModule, ReactiveFormsModule, DatepickerModuleV2], exports: [SidenavComponent, CreateNonShiftModalComponent] });
|
|
632
|
+
WisCommonModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: WisCommonModule, imports: [CommonModule, HttpClientModule, OverlayModule, LoaderModule, DropdownModule, ReactiveFormsModule, DatepickerModuleV2] });
|
|
371
633
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: WisCommonModule, decorators: [{
|
|
372
634
|
type: NgModule,
|
|
373
635
|
args: [{
|
|
374
|
-
declarations: [LoaderComponent, SidenavComponent],
|
|
375
|
-
imports: [CommonModule, OverlayModule, LoaderModule],
|
|
376
|
-
providers: [
|
|
377
|
-
exports: [SidenavComponent]
|
|
636
|
+
declarations: [LoaderComponent, SidenavComponent, CreateNonShiftModalComponent],
|
|
637
|
+
imports: [CommonModule, HttpClientModule, OverlayModule, LoaderModule, DropdownModule, ReactiveFormsModule, DatepickerModuleV2,],
|
|
638
|
+
providers: [],
|
|
639
|
+
exports: [SidenavComponent, CreateNonShiftModalComponent]
|
|
378
640
|
}]
|
|
379
641
|
}] });
|
|
380
642
|
|
|
@@ -404,6 +666,178 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImpor
|
|
|
404
666
|
}]
|
|
405
667
|
}], ctorParameters: function () { return []; } });
|
|
406
668
|
|
|
669
|
+
class SessionError extends Error {
|
|
670
|
+
}
|
|
671
|
+
class SessionTokenNotFoundError extends SessionError {
|
|
672
|
+
constructor() {
|
|
673
|
+
super('Session token was not found.');
|
|
674
|
+
this.name = 'SessionTokenNotFoundError';
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
class SessionTokenExpiredError extends SessionError {
|
|
678
|
+
constructor() {
|
|
679
|
+
super('Session token has expired.');
|
|
680
|
+
this.name = 'SessionTokenExpiredError';
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
class SessionTokenInvalidError extends SessionError {
|
|
684
|
+
constructor() {
|
|
685
|
+
super('Session token could not be decoded.');
|
|
686
|
+
this.name = 'SessionTokenInvalidError';
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
class SessionClaimNotFoundError extends SessionError {
|
|
690
|
+
constructor(claim) {
|
|
691
|
+
super(`Session claim "${claim}" was not found in the token.`);
|
|
692
|
+
this.claim = claim;
|
|
693
|
+
this.name = 'SessionClaimNotFoundError';
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
const DEFAULT_SESSION_TOKEN_PREFIX = 'sso-wis-token';
|
|
698
|
+
const DEFAULT_SESSION_TOKEN_FALLBACK_KEY = 'x-wis-token';
|
|
699
|
+
const DEFAULT_VET_TOKEN_PREFIX = 'x-vet-token';
|
|
700
|
+
const LAUNCH_SOURCE_VET = 'VET';
|
|
701
|
+
class SessionService {
|
|
702
|
+
constructor() {
|
|
703
|
+
this.config = {};
|
|
704
|
+
this.cachedToken = null;
|
|
705
|
+
this.cachedState = null;
|
|
706
|
+
}
|
|
707
|
+
init(config) {
|
|
708
|
+
this.config = Object.assign({}, config);
|
|
709
|
+
this.cachedToken = null;
|
|
710
|
+
this.cachedState = null;
|
|
711
|
+
}
|
|
712
|
+
/**
|
|
713
|
+
* Runs `handlers.next` and returns its result, or `handlers.error(error)` if it throws a `SessionError`.
|
|
714
|
+
* Centralizes the try/catch mechanics; the caller still supplies the actual handling logic.
|
|
715
|
+
*/
|
|
716
|
+
read(handlers) {
|
|
717
|
+
try {
|
|
718
|
+
return handlers.next(this);
|
|
719
|
+
}
|
|
720
|
+
catch (e) {
|
|
721
|
+
if (e instanceof SessionError) {
|
|
722
|
+
return handlers.error(e);
|
|
723
|
+
}
|
|
724
|
+
throw e;
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
/**
|
|
728
|
+
* Statement-style variant of `read` for blocks of assignments/side effects with no return value.
|
|
729
|
+
*/
|
|
730
|
+
run(handlers) {
|
|
731
|
+
this.read({
|
|
732
|
+
next: s => { handlers.next(s); return undefined; },
|
|
733
|
+
error: err => { handlers.error(err); return undefined; }
|
|
734
|
+
});
|
|
735
|
+
}
|
|
736
|
+
get isVET() {
|
|
737
|
+
return this.state.isVET;
|
|
738
|
+
}
|
|
739
|
+
get sub() { return this.getClaim('sub'); }
|
|
740
|
+
get empGuid() { return this.getClaim('employeeGUID'); }
|
|
741
|
+
get internalSsoRole() { return this.getClaim('internal_sso_role'); }
|
|
742
|
+
get roles() { return this.getClaim('roles'); }
|
|
743
|
+
get sessionId() { return this.getClaim('sessionId'); }
|
|
744
|
+
get loggedInUser() { return this.getClaim('loggedInUser'); }
|
|
745
|
+
get exp() { return this.getClaim('exp'); }
|
|
746
|
+
get iat() { return this.getClaim('iat'); }
|
|
747
|
+
get businessUnitId() { return this.getClaim('businessUnitId'); }
|
|
748
|
+
get allowedBuids() { return this.getClaim('ALLOWED_BUIDS'); }
|
|
749
|
+
get vetUserEmailId() { return this.getClaim('vetUserEmailId'); }
|
|
750
|
+
get vetUserId() { return this.getClaim('vetUserId'); }
|
|
751
|
+
get source() { return this.getClaim('source'); }
|
|
752
|
+
get roleId() {
|
|
753
|
+
var _a, _b, _c;
|
|
754
|
+
const claims = this.getClaims();
|
|
755
|
+
const raw = ((_a = claims.internal_sso_role) === null || _a === void 0 ? void 0 : _a.trim()) || ((_c = (_b = claims.roles) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.trim());
|
|
756
|
+
if (!raw || !/^\d+$/.test(raw)) {
|
|
757
|
+
throw new SessionClaimNotFoundError('roleId');
|
|
758
|
+
}
|
|
759
|
+
return Number(raw);
|
|
760
|
+
}
|
|
761
|
+
getClaims() {
|
|
762
|
+
const state = this.state;
|
|
763
|
+
if (state.status === 'ok') {
|
|
764
|
+
return state.claims;
|
|
765
|
+
}
|
|
766
|
+
if (state.status === 'not-found') {
|
|
767
|
+
throw new SessionTokenNotFoundError();
|
|
768
|
+
}
|
|
769
|
+
if (state.status === 'expired') {
|
|
770
|
+
throw new SessionTokenExpiredError();
|
|
771
|
+
}
|
|
772
|
+
throw new SessionTokenInvalidError();
|
|
773
|
+
}
|
|
774
|
+
getClaim(key) {
|
|
775
|
+
const claims = this.getClaims();
|
|
776
|
+
const value = claims[key];
|
|
777
|
+
const isEmptyString = typeof value === 'string' && value.trim() === '';
|
|
778
|
+
if (value === undefined || value === null || isEmptyString) {
|
|
779
|
+
throw new SessionClaimNotFoundError(key);
|
|
780
|
+
}
|
|
781
|
+
return (typeof value === 'string' ? value.trim() : value);
|
|
782
|
+
}
|
|
783
|
+
get state() {
|
|
784
|
+
const { token, isVET } = this.findToken();
|
|
785
|
+
if (!this.cachedState || token !== this.cachedToken) {
|
|
786
|
+
this.cachedToken = token;
|
|
787
|
+
this.cachedState = this.build(token, isVET);
|
|
788
|
+
}
|
|
789
|
+
return this.cachedState;
|
|
790
|
+
}
|
|
791
|
+
build(token, isVET) {
|
|
792
|
+
if (!token) {
|
|
793
|
+
return { status: 'not-found', isVET };
|
|
794
|
+
}
|
|
795
|
+
let claims;
|
|
796
|
+
try {
|
|
797
|
+
claims = jwtDecode(token);
|
|
798
|
+
}
|
|
799
|
+
catch (_a) {
|
|
800
|
+
return { status: 'invalid', isVET };
|
|
801
|
+
}
|
|
802
|
+
if (this.isExpired(claims)) {
|
|
803
|
+
return { status: 'expired', isVET };
|
|
804
|
+
}
|
|
805
|
+
return { status: 'ok', claims, isVET };
|
|
806
|
+
}
|
|
807
|
+
isExpired(claims) {
|
|
808
|
+
return typeof claims.exp === 'number' && claims.exp * 1000 <= Date.now();
|
|
809
|
+
}
|
|
810
|
+
isVETSource() {
|
|
811
|
+
return getQueryParam('source') === LAUNCH_SOURCE_VET;
|
|
812
|
+
}
|
|
813
|
+
resolveBuid() {
|
|
814
|
+
return getQueryParam('buid') || getCookie('buid') || null;
|
|
815
|
+
}
|
|
816
|
+
findToken() {
|
|
817
|
+
var _a;
|
|
818
|
+
const buid = this.resolveBuid();
|
|
819
|
+
if (this.isVETSource()) {
|
|
820
|
+
const vetKey = (_a = this.config.vetTokenCookieKey) !== null && _a !== void 0 ? _a : (buid ? `${DEFAULT_VET_TOKEN_PREFIX}-${buid}` : null);
|
|
821
|
+
const vetToken = (vetKey ? getCookie(vetKey) : '') || '';
|
|
822
|
+
if (vetToken) {
|
|
823
|
+
return { token: vetToken, isVET: true };
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
const sessionToken = this.config.sessionTokenCookieKey
|
|
827
|
+
? getCookie(this.config.sessionTokenCookieKey)
|
|
828
|
+
: (buid ? getCookie(`${DEFAULT_SESSION_TOKEN_PREFIX}-${buid}`) : '') || getCookie(DEFAULT_SESSION_TOKEN_FALLBACK_KEY);
|
|
829
|
+
return { token: sessionToken || '', isVET: false };
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
SessionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: SessionService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
833
|
+
SessionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: SessionService, providedIn: 'root' });
|
|
834
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: SessionService, decorators: [{
|
|
835
|
+
type: Injectable,
|
|
836
|
+
args: [{
|
|
837
|
+
providedIn: 'root'
|
|
838
|
+
}]
|
|
839
|
+
}] });
|
|
840
|
+
|
|
407
841
|
/*
|
|
408
842
|
* Public API Surface of wis-common
|
|
409
843
|
*/
|
|
@@ -412,5 +846,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImpor
|
|
|
412
846
|
* Generated bundle index. Do not edit.
|
|
413
847
|
*/
|
|
414
848
|
|
|
415
|
-
export { AuthInterceptor, AuthModule, AuthService, ConfigurationService, LoaderService, LoggerModule, LoggerService, MfeCommunicationService, SidenavComponent, WisCommonModule, filterNavList, getCookie, getQueryParam, removeCookie, setCookie };
|
|
849
|
+
export { AuthInterceptor, AuthModule, AuthService, ConfigurationService, CreateNonShiftModalComponent, LoaderService, LoggerModule, LoggerService, MfeCommunicationService, SessionClaimNotFoundError, SessionError, SessionService, SessionTokenExpiredError, SessionTokenInvalidError, SessionTokenNotFoundError, SidenavComponent, WisCommonModule, filterNavList, getCookie, getQueryParam, removeCookie, setCookie };
|
|
416
850
|
//# sourceMappingURL=mis-wis-common.mjs.map
|