@masterteam/system-settings 0.0.16 → 0.0.18

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.
@@ -1,1589 +1,2 @@
1
- import { CommonModule } from '@angular/common';
2
- import { HttpClient } from '@angular/common/http';
3
- import * as i0 from '@angular/core';
4
- import { input, ChangeDetectionStrategy, Component, inject, computed, effect, output, signal, InjectionToken, makeEnvironmentProviders } from '@angular/core';
5
- import { toSignal } from '@angular/core/rxjs-interop';
6
- import * as i1 from '@angular/forms';
7
- import { ReactiveFormsModule, FormGroup, FormControl, Validators } from '@angular/forms';
8
- import { Router } from '@angular/router';
9
- import { TranslocoDirective, TranslocoService } from '@jsverse/transloco';
10
- import { Breadcrumb } from '@masterteam/components/breadcrumb';
11
- import { Button } from '@masterteam/components/button';
12
- import { Page } from '@masterteam/components/page';
13
- import { ModalService } from '@masterteam/components/modal';
14
- import { ToastService } from '@masterteam/components/toast';
15
- import * as i1$1 from 'primeng/skeleton';
16
- import { SkeletonModule } from 'primeng/skeleton';
17
- import { Card } from '@masterteam/components/card';
18
- import { MultiSelectField } from '@masterteam/components/multi-select-field';
19
- import { SelectField } from '@masterteam/components/select-field';
20
- import { RadioCardsField } from '@masterteam/components/radio-cards-field';
21
- import { ToggleField } from '@masterteam/components/toggle-field';
22
- import { ModalRef } from '@masterteam/components/dialog';
23
- import { DateField } from '@masterteam/components/date-field';
24
- import { TextField } from '@masterteam/components/text-field';
25
- import { Table } from '@masterteam/components/table';
26
- import { NumberField } from '@masterteam/components/number-field';
27
- import { TextareaField } from '@masterteam/components/textarea-field';
28
-
29
- /**
30
- * "Experience & Appearance" — product-wide application behaviour that is not
31
- * tied to a specific feature area: the explore landing view and whether the
32
- * topbar design switcher is offered. More entries are expected here.
33
- */
34
- class SystemSettingsGeneralConfigSection {
35
- generalConfigurationForm = input.required(...(ngDevMode ? [{ debugName: "generalConfigurationForm" }] : /* istanbul ignore next */ []));
36
- exploreDefaultViewOptions = input([], ...(ngDevMode ? [{ debugName: "exploreDefaultViewOptions" }] : /* istanbul ignore next */ []));
37
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: SystemSettingsGeneralConfigSection, deps: [], target: i0.ɵɵFactoryTarget.Component });
38
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.8", type: SystemSettingsGeneralConfigSection, isStandalone: true, selector: "mt-system-settings-general-config-section", inputs: { generalConfigurationForm: { classPropertyName: "generalConfigurationForm", publicName: "generalConfigurationForm", isSignal: true, isRequired: true, transformFunction: null }, exploreDefaultViewOptions: { classPropertyName: "exploreDefaultViewOptions", publicName: "exploreDefaultViewOptions", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<ng-container *transloco=\"let t; prefix: 'system-settings'\">\r\n <mt-card class=\"block\">\r\n <div [formGroup]=\"generalConfigurationForm()\" class=\"space-y-5\">\r\n <div class=\"space-y-1\">\r\n <h4 class=\"text-base font-semibold text-neutral-900\">\r\n {{ t(\"general-configuration-title\") }}\r\n </h4>\r\n <p class=\"text-sm text-neutral-600\">\r\n {{ t(\"general-configuration-description\") }}\r\n </p>\r\n </div>\r\n\r\n <mt-radio-cards-field\r\n formControlName=\"defaultExploreView\"\r\n [options]=\"exploreDefaultViewOptions()\"\r\n [optionLabel]=\"'name'\"\r\n [optionValue]=\"'id'\"\r\n [label]=\"t('explore-default-view')\"\r\n [hint]=\"t('explore-default-view-hint')\"\r\n [required]=\"true\"\r\n size=\"small\"\r\n />\r\n\r\n <div class=\"space-y-1\">\r\n <mt-toggle-field\r\n formControlName=\"showDesignSwitcher\"\r\n [label]=\"t('design-switcher')\"\r\n />\r\n <p class=\"text-sm text-neutral-600\">\r\n {{ t(\"design-switcher-hint\") }}\r\n </p>\r\n </div>\r\n </div>\r\n </mt-card>\r\n</ng-container>\r\n", styles: [":host{display:block;height:100%}mt-card{height:100%}\n"], dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "directive", type: TranslocoDirective, selector: "[transloco]", inputs: ["transloco", "translocoParams", "translocoScope", "translocoRead", "translocoPrefix", "translocoLang", "translocoLoadingTpl"] }, { kind: "component", type: Card, selector: "mt-card", inputs: ["class", "title", "paddingless"] }, { kind: "component", type: RadioCardsField, selector: "mt-radio-cards-field", inputs: ["circle", "label", "hint", "readonly", "required", "color", "size", "optionLabel", "optionValue", "options"] }, { kind: "component", type: ToggleField, selector: "mt-toggle-field", inputs: ["label", "inputId", "labelPosition", "placeholder", "readonly", "pInputs", "required", "toggleShape", "size", "icon", "descriptionCard"], outputs: ["onChange"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
39
- }
40
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: SystemSettingsGeneralConfigSection, decorators: [{
41
- type: Component,
42
- args: [{ selector: 'mt-system-settings-general-config-section', imports: [
43
- ReactiveFormsModule,
44
- TranslocoDirective,
45
- Card,
46
- RadioCardsField,
47
- ToggleField,
48
- ], changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-container *transloco=\"let t; prefix: 'system-settings'\">\r\n <mt-card class=\"block\">\r\n <div [formGroup]=\"generalConfigurationForm()\" class=\"space-y-5\">\r\n <div class=\"space-y-1\">\r\n <h4 class=\"text-base font-semibold text-neutral-900\">\r\n {{ t(\"general-configuration-title\") }}\r\n </h4>\r\n <p class=\"text-sm text-neutral-600\">\r\n {{ t(\"general-configuration-description\") }}\r\n </p>\r\n </div>\r\n\r\n <mt-radio-cards-field\r\n formControlName=\"defaultExploreView\"\r\n [options]=\"exploreDefaultViewOptions()\"\r\n [optionLabel]=\"'name'\"\r\n [optionValue]=\"'id'\"\r\n [label]=\"t('explore-default-view')\"\r\n [hint]=\"t('explore-default-view-hint')\"\r\n [required]=\"true\"\r\n size=\"small\"\r\n />\r\n\r\n <div class=\"space-y-1\">\r\n <mt-toggle-field\r\n formControlName=\"showDesignSwitcher\"\r\n [label]=\"t('design-switcher')\"\r\n />\r\n <p class=\"text-sm text-neutral-600\">\r\n {{ t(\"design-switcher-hint\") }}\r\n </p>\r\n </div>\r\n </div>\r\n </mt-card>\r\n</ng-container>\r\n", styles: [":host{display:block;height:100%}mt-card{height:100%}\n"] }]
49
- }], propDecorators: { generalConfigurationForm: [{ type: i0.Input, args: [{ isSignal: true, alias: "generalConfigurationForm", required: true }] }], exploreDefaultViewOptions: [{ type: i0.Input, args: [{ isSignal: true, alias: "exploreDefaultViewOptions", required: false }] }] } });
50
-
51
- class SystemSettingsGeneralSection {
52
- generalConfigurationForm = input.required(...(ngDevMode ? [{ debugName: "generalConfigurationForm" }] : /* istanbul ignore next */ []));
53
- timezoneForm = input.required(...(ngDevMode ? [{ debugName: "timezoneForm" }] : /* istanbul ignore next */ []));
54
- currencyForm = input.required(...(ngDevMode ? [{ debugName: "currencyForm" }] : /* istanbul ignore next */ []));
55
- weekendForm = input.required(...(ngDevMode ? [{ debugName: "weekendForm" }] : /* istanbul ignore next */ []));
56
- exploreDefaultViewOptions = input([], ...(ngDevMode ? [{ debugName: "exploreDefaultViewOptions" }] : /* istanbul ignore next */ []));
57
- dateFormatOptions = input([], ...(ngDevMode ? [{ debugName: "dateFormatOptions" }] : /* istanbul ignore next */ []));
58
- timeFormatOptions = input([], ...(ngDevMode ? [{ debugName: "timeFormatOptions" }] : /* istanbul ignore next */ []));
59
- currencyOptions = input([], ...(ngDevMode ? [{ debugName: "currencyOptions" }] : /* istanbul ignore next */ []));
60
- currencyFormatOptions = input([], ...(ngDevMode ? [{ debugName: "currencyFormatOptions" }] : /* istanbul ignore next */ []));
61
- weekendOptions = input([], ...(ngDevMode ? [{ debugName: "weekendOptions" }] : /* istanbul ignore next */ []));
62
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: SystemSettingsGeneralSection, deps: [], target: i0.ɵɵFactoryTarget.Component });
63
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.8", type: SystemSettingsGeneralSection, isStandalone: true, selector: "mt-system-settings-general-section", inputs: { generalConfigurationForm: { classPropertyName: "generalConfigurationForm", publicName: "generalConfigurationForm", isSignal: true, isRequired: true, transformFunction: null }, timezoneForm: { classPropertyName: "timezoneForm", publicName: "timezoneForm", isSignal: true, isRequired: true, transformFunction: null }, currencyForm: { classPropertyName: "currencyForm", publicName: "currencyForm", isSignal: true, isRequired: true, transformFunction: null }, weekendForm: { classPropertyName: "weekendForm", publicName: "weekendForm", isSignal: true, isRequired: true, transformFunction: null }, exploreDefaultViewOptions: { classPropertyName: "exploreDefaultViewOptions", publicName: "exploreDefaultViewOptions", isSignal: true, isRequired: false, transformFunction: null }, dateFormatOptions: { classPropertyName: "dateFormatOptions", publicName: "dateFormatOptions", isSignal: true, isRequired: false, transformFunction: null }, timeFormatOptions: { classPropertyName: "timeFormatOptions", publicName: "timeFormatOptions", isSignal: true, isRequired: false, transformFunction: null }, currencyOptions: { classPropertyName: "currencyOptions", publicName: "currencyOptions", isSignal: true, isRequired: false, transformFunction: null }, currencyFormatOptions: { classPropertyName: "currencyFormatOptions", publicName: "currencyFormatOptions", isSignal: true, isRequired: false, transformFunction: null }, weekendOptions: { classPropertyName: "weekendOptions", publicName: "weekendOptions", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<ng-container *transloco=\"let t; prefix: 'system-settings'\">\n <div class=\"grid gap-6 xl:grid-cols-3\">\n <mt-card class=\"block\">\n <div class=\"space-y-4\">\n <div class=\"space-y-1\">\n <h4 class=\"text-base font-semibold text-neutral-900\">\n {{ t(\"date-time-weekend-title\") }}\n </h4>\n <p class=\"text-sm text-neutral-600\">\n {{ t(\"date-time-weekend-description\") }}\n </p>\n </div>\n\n <div [formGroup]=\"timezoneForm()\" class=\"grid gap-4 md:grid-cols-2\">\n <mt-select-field\n formControlName=\"dateFormat\"\n [options]=\"dateFormatOptions()\"\n [optionLabel]=\"'name'\"\n [optionValue]=\"'id'\"\n [label]=\"t('date-format')\"\n [placeholder]=\"t('date-format-placeholder')\"\n [required]=\"true\"\n />\n\n <mt-select-field\n formControlName=\"timeFormat\"\n [options]=\"timeFormatOptions()\"\n [optionLabel]=\"'name'\"\n [optionValue]=\"'id'\"\n [label]=\"t('time-format')\"\n [placeholder]=\"t('time-format-placeholder')\"\n [required]=\"true\"\n />\n </div>\n\n <div [formGroup]=\"weekendForm()\">\n <mt-multi-select-field\n formControlName=\"days\"\n [options]=\"weekendOptions()\"\n [optionLabel]=\"'name'\"\n [optionValue]=\"'dayNumber'\"\n [label]=\"t('weekend-days')\"\n [placeholder]=\"t('weekend-placeholder')\"\n [display]=\"'chip'\"\n [filter]=\"false\"\n [showClear]=\"true\"\n [maxSelectedLabels]=\"3\"\n />\n </div>\n </div>\n </mt-card>\n\n <mt-card class=\"block\">\n <div [formGroup]=\"currencyForm()\" class=\"space-y-4\">\n <div class=\"space-y-1\">\n <h4 class=\"text-base font-semibold text-neutral-900\">\n {{ t(\"currency-title\") }}\n </h4>\n <p class=\"text-sm text-neutral-600\">\n {{ t(\"currency-description\") }}\n </p>\n </div>\n\n <mt-select-field\n formControlName=\"code\"\n [options]=\"currencyOptions()\"\n [optionLabel]=\"'name'\"\n [optionValue]=\"'id'\"\n [label]=\"t('currency')\"\n [placeholder]=\"t('currency-placeholder')\"\n [required]=\"true\"\n />\n\n <mt-select-field\n formControlName=\"format\"\n [options]=\"currencyFormatOptions()\"\n [optionLabel]=\"'name'\"\n [optionValue]=\"'id'\"\n [label]=\"t('currency-format')\"\n [placeholder]=\"t('currency-format-placeholder')\"\n [required]=\"true\"\n />\n </div>\n </mt-card>\n\n <mt-system-settings-general-config-section\n class=\"block\"\n [generalConfigurationForm]=\"generalConfigurationForm()\"\n [exploreDefaultViewOptions]=\"exploreDefaultViewOptions()\"\n />\n </div>\n</ng-container>\n", styles: [":host{display:block}\n"], dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "directive", type: TranslocoDirective, selector: "[transloco]", inputs: ["transloco", "translocoParams", "translocoScope", "translocoRead", "translocoPrefix", "translocoLang", "translocoLoadingTpl"] }, { kind: "component", type: Card, selector: "mt-card", inputs: ["class", "title", "paddingless"] }, { kind: "component", type: SelectField, selector: "mt-select-field", inputs: ["field", "hint", "label", "placeholder", "hasPlaceholderPrefix", "class", "readonly", "pInputs", "options", "optionValue", "optionLabel", "filter", "filterBy", "dataKey", "showClear", "clearAfterSelect", "required", "group", "size", "optionGroupLabel", "optionGroupChildren", "loading", "optionIcon", "optionIconColor", "optionIconShape", "optionAvatarShape", "optionGroupIcon", "optionGroupIconColor", "optionGroupIconShape", "optionGroupAvatarShape", "markCurrentUser"], outputs: ["onChange"] }, { kind: "component", type: MultiSelectField, selector: "mt-multi-select-field", inputs: ["field", "label", "placeholder", "class", "readonly", "pInputs", "options", "optionValue", "optionLabel", "filter", "filterBy", "dataKey", "showClear", "display", "required", "maxSelectedLabels", "group", "virtualScroll", "virtualScrollItemSize", "optionGroupLabel", "optionGroupChildren", "optionIcon", "optionIconColor", "optionIconShape", "optionAvatarShape", "optionGroupIcon", "optionGroupIconColor", "optionGroupIconShape", "optionGroupAvatarShape"], outputs: ["onChange"] }, { kind: "component", type: SystemSettingsGeneralConfigSection, selector: "mt-system-settings-general-config-section", inputs: ["generalConfigurationForm", "exploreDefaultViewOptions"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
64
- }
65
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: SystemSettingsGeneralSection, decorators: [{
66
- type: Component,
67
- args: [{ selector: 'mt-system-settings-general-section', imports: [
68
- ReactiveFormsModule,
69
- TranslocoDirective,
70
- Card,
71
- SelectField,
72
- MultiSelectField,
73
- SystemSettingsGeneralConfigSection,
74
- ], changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-container *transloco=\"let t; prefix: 'system-settings'\">\n <div class=\"grid gap-6 xl:grid-cols-3\">\n <mt-card class=\"block\">\n <div class=\"space-y-4\">\n <div class=\"space-y-1\">\n <h4 class=\"text-base font-semibold text-neutral-900\">\n {{ t(\"date-time-weekend-title\") }}\n </h4>\n <p class=\"text-sm text-neutral-600\">\n {{ t(\"date-time-weekend-description\") }}\n </p>\n </div>\n\n <div [formGroup]=\"timezoneForm()\" class=\"grid gap-4 md:grid-cols-2\">\n <mt-select-field\n formControlName=\"dateFormat\"\n [options]=\"dateFormatOptions()\"\n [optionLabel]=\"'name'\"\n [optionValue]=\"'id'\"\n [label]=\"t('date-format')\"\n [placeholder]=\"t('date-format-placeholder')\"\n [required]=\"true\"\n />\n\n <mt-select-field\n formControlName=\"timeFormat\"\n [options]=\"timeFormatOptions()\"\n [optionLabel]=\"'name'\"\n [optionValue]=\"'id'\"\n [label]=\"t('time-format')\"\n [placeholder]=\"t('time-format-placeholder')\"\n [required]=\"true\"\n />\n </div>\n\n <div [formGroup]=\"weekendForm()\">\n <mt-multi-select-field\n formControlName=\"days\"\n [options]=\"weekendOptions()\"\n [optionLabel]=\"'name'\"\n [optionValue]=\"'dayNumber'\"\n [label]=\"t('weekend-days')\"\n [placeholder]=\"t('weekend-placeholder')\"\n [display]=\"'chip'\"\n [filter]=\"false\"\n [showClear]=\"true\"\n [maxSelectedLabels]=\"3\"\n />\n </div>\n </div>\n </mt-card>\n\n <mt-card class=\"block\">\n <div [formGroup]=\"currencyForm()\" class=\"space-y-4\">\n <div class=\"space-y-1\">\n <h4 class=\"text-base font-semibold text-neutral-900\">\n {{ t(\"currency-title\") }}\n </h4>\n <p class=\"text-sm text-neutral-600\">\n {{ t(\"currency-description\") }}\n </p>\n </div>\n\n <mt-select-field\n formControlName=\"code\"\n [options]=\"currencyOptions()\"\n [optionLabel]=\"'name'\"\n [optionValue]=\"'id'\"\n [label]=\"t('currency')\"\n [placeholder]=\"t('currency-placeholder')\"\n [required]=\"true\"\n />\n\n <mt-select-field\n formControlName=\"format\"\n [options]=\"currencyFormatOptions()\"\n [optionLabel]=\"'name'\"\n [optionValue]=\"'id'\"\n [label]=\"t('currency-format')\"\n [placeholder]=\"t('currency-format-placeholder')\"\n [required]=\"true\"\n />\n </div>\n </mt-card>\n\n <mt-system-settings-general-config-section\n class=\"block\"\n [generalConfigurationForm]=\"generalConfigurationForm()\"\n [exploreDefaultViewOptions]=\"exploreDefaultViewOptions()\"\n />\n </div>\n</ng-container>\n", styles: [":host{display:block}\n"] }]
75
- }], propDecorators: { generalConfigurationForm: [{ type: i0.Input, args: [{ isSignal: true, alias: "generalConfigurationForm", required: true }] }], timezoneForm: [{ type: i0.Input, args: [{ isSignal: true, alias: "timezoneForm", required: true }] }], currencyForm: [{ type: i0.Input, args: [{ isSignal: true, alias: "currencyForm", required: true }] }], weekendForm: [{ type: i0.Input, args: [{ isSignal: true, alias: "weekendForm", required: true }] }], exploreDefaultViewOptions: [{ type: i0.Input, args: [{ isSignal: true, alias: "exploreDefaultViewOptions", required: false }] }], dateFormatOptions: [{ type: i0.Input, args: [{ isSignal: true, alias: "dateFormatOptions", required: false }] }], timeFormatOptions: [{ type: i0.Input, args: [{ isSignal: true, alias: "timeFormatOptions", required: false }] }], currencyOptions: [{ type: i0.Input, args: [{ isSignal: true, alias: "currencyOptions", required: false }] }], currencyFormatOptions: [{ type: i0.Input, args: [{ isSignal: true, alias: "currencyFormatOptions", required: false }] }], weekendOptions: [{ type: i0.Input, args: [{ isSignal: true, alias: "weekendOptions", required: false }] }] } });
76
-
77
- class SystemSettingsHolidayEditor {
78
- ref = inject(ModalRef);
79
- modal = inject(ModalService);
80
- holiday = input(null, ...(ngDevMode ? [{ debugName: "holiday" }] : /* istanbul ignore next */ []));
81
- isEditMode = input(false, ...(ngDevMode ? [{ debugName: "isEditMode" }] : /* istanbul ignore next */ []));
82
- form = new FormGroup({
83
- label: new FormControl('', {
84
- nonNullable: true,
85
- validators: [Validators.required],
86
- }),
87
- from: new FormControl(null, {
88
- validators: [Validators.required],
89
- }),
90
- to: new FormControl(null, {
91
- validators: [Validators.required],
92
- }),
93
- }, {
94
- validators: [holidayRangeValidator()],
95
- });
96
- actionLabel = computed(() => this.isEditMode() ? 'update-holiday' : 'add-holiday', ...(ngDevMode ? [{ debugName: "actionLabel" }] : /* istanbul ignore next */ []));
97
- fromValue = toSignal(this.form.controls.from.valueChanges, {
98
- initialValue: this.form.controls.from.value,
99
- });
100
- toPickerInputs = computed(() => {
101
- const from = this.fromValue();
102
- return from instanceof Date ? { minDate: from } : {};
103
- }, ...(ngDevMode ? [{ debugName: "toPickerInputs" }] : /* istanbul ignore next */ []));
104
- constructor() {
105
- effect(() => {
106
- const holiday = this.holiday();
107
- this.form.reset({
108
- label: holiday?.label ?? '',
109
- from: holiday?.from ?? null,
110
- to: holiday?.to ?? null,
111
- }, { emitEvent: false });
112
- this.form.markAsPristine();
113
- this.form.markAsUntouched();
114
- });
115
- }
116
- onSave() {
117
- this.form.markAllAsTouched();
118
- if (this.form.invalid) {
119
- return;
120
- }
121
- const value = this.form.getRawValue();
122
- if (!(value.from instanceof Date) || !(value.to instanceof Date)) {
123
- return;
124
- }
125
- this.ref.close({
126
- label: value.label.trim(),
127
- from: value.from,
128
- to: value.to,
129
- });
130
- }
131
- onCancel() {
132
- this.ref.close(null);
133
- }
134
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: SystemSettingsHolidayEditor, deps: [], target: i0.ɵɵFactoryTarget.Component });
135
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: SystemSettingsHolidayEditor, isStandalone: true, selector: "mt-system-settings-holiday-editor", inputs: { holiday: { classPropertyName: "holiday", publicName: "holiday", isSignal: true, isRequired: false, transformFunction: null }, isEditMode: { classPropertyName: "isEditMode", publicName: "isEditMode", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<ng-container *transloco=\"let t; prefix: 'system-settings'\">\n <div [class]=\"' ' + (modal.contentClass || '')\">\n <form [formGroup]=\"form\" class=\"space-y-4 p-3\" (ngSubmit)=\"onSave()\">\n <mt-text-field\n formControlName=\"label\"\n [label]=\"t('holiday-name')\"\n [placeholder]=\"t('holiday-name-placeholder')\"\n [required]=\"true\"\n />\n\n <div class=\"grid gap-4 md:grid-cols-2\">\n <div class=\"grid gap-1\">\n <mt-date-field\n formControlName=\"from\"\n [label]=\"t('from-date')\"\n [placeholder]=\"t('from-date')\"\n [showIcon]=\"true\"\n [required]=\"true\"\n />\n </div>\n\n <div class=\"grid gap-1\">\n <mt-date-field\n formControlName=\"to\"\n [label]=\"t('to-date')\"\n [placeholder]=\"t('to-date')\"\n [showIcon]=\"true\"\n [required]=\"true\"\n [pInputs]=\"toPickerInputs()\"\n />\n </div>\n </div>\n\n @if (form.errors?.[\"invalidRange\"] && (form.dirty || form.touched)) {\n <div class=\"text-sm text-red-600\">\n {{ t(\"holiday-range-error\") }}\n </div>\n }\n </form>\n </div>\n <div [class]=\"modal.footerClass\">\n <mt-button\n [label]=\"t('cancel')\"\n variant=\"outlined\"\n type=\"button\"\n (onClick)=\"onCancel()\"\n />\n <mt-button [label]=\"t(actionLabel())\" type=\"button\" (onClick)=\"onSave()\" />\n </div>\n</ng-container>\n", styles: [":host{display:block}\n"], dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "directive", type: TranslocoDirective, selector: "[transloco]", inputs: ["transloco", "translocoParams", "translocoScope", "translocoRead", "translocoPrefix", "translocoLang", "translocoLoadingTpl"] }, { kind: "component", type: Button, selector: "mt-button", inputs: ["icon", "label", "tooltip", "class", "type", "styleClass", "severity", "badge", "variant", "badgeSeverity", "size", "iconPos", "autofocus", "fluid", "raised", "rounded", "text", "plain", "outlined", "link", "disabled", "loading", "pInputs", "ariaLabel"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "component", type: DateField, selector: "mt-date-field", inputs: ["field", "hint", "label", "placeholder", "class", "readonly", "showIcon", "showOnFocus", "showClear", "showTime", "timeOnly", "minDate", "maxDate", "pInputs", "required"] }, { kind: "component", type: TextField, selector: "mt-text-field", inputs: ["field", "hint", "label", "placeholder", "class", "type", "readonly", "pInputs", "required", "maxLength", "icon", "iconPosition"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
136
- }
137
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: SystemSettingsHolidayEditor, decorators: [{
138
- type: Component,
139
- args: [{ selector: 'mt-system-settings-holiday-editor', imports: [
140
- ReactiveFormsModule,
141
- TranslocoDirective,
142
- Button,
143
- DateField,
144
- TextField,
145
- ], changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-container *transloco=\"let t; prefix: 'system-settings'\">\n <div [class]=\"' ' + (modal.contentClass || '')\">\n <form [formGroup]=\"form\" class=\"space-y-4 p-3\" (ngSubmit)=\"onSave()\">\n <mt-text-field\n formControlName=\"label\"\n [label]=\"t('holiday-name')\"\n [placeholder]=\"t('holiday-name-placeholder')\"\n [required]=\"true\"\n />\n\n <div class=\"grid gap-4 md:grid-cols-2\">\n <div class=\"grid gap-1\">\n <mt-date-field\n formControlName=\"from\"\n [label]=\"t('from-date')\"\n [placeholder]=\"t('from-date')\"\n [showIcon]=\"true\"\n [required]=\"true\"\n />\n </div>\n\n <div class=\"grid gap-1\">\n <mt-date-field\n formControlName=\"to\"\n [label]=\"t('to-date')\"\n [placeholder]=\"t('to-date')\"\n [showIcon]=\"true\"\n [required]=\"true\"\n [pInputs]=\"toPickerInputs()\"\n />\n </div>\n </div>\n\n @if (form.errors?.[\"invalidRange\"] && (form.dirty || form.touched)) {\n <div class=\"text-sm text-red-600\">\n {{ t(\"holiday-range-error\") }}\n </div>\n }\n </form>\n </div>\n <div [class]=\"modal.footerClass\">\n <mt-button\n [label]=\"t('cancel')\"\n variant=\"outlined\"\n type=\"button\"\n (onClick)=\"onCancel()\"\n />\n <mt-button [label]=\"t(actionLabel())\" type=\"button\" (onClick)=\"onSave()\" />\n </div>\n</ng-container>\n", styles: [":host{display:block}\n"] }]
146
- }], ctorParameters: () => [], propDecorators: { holiday: [{ type: i0.Input, args: [{ isSignal: true, alias: "holiday", required: false }] }], isEditMode: [{ type: i0.Input, args: [{ isSignal: true, alias: "isEditMode", required: false }] }] } });
147
- function holidayRangeValidator() {
148
- return (control) => {
149
- const from = control.get('from')?.value;
150
- const to = control.get('to')?.value;
151
- if (!from || !to) {
152
- return null;
153
- }
154
- return from <= to ? null : { invalidRange: true };
155
- };
156
- }
157
-
158
- class SystemSettingsHolidaysSection {
159
- transloco = inject(TranslocoService);
160
- holidays = input([], ...(ngDevMode ? [{ debugName: "holidays" }] : /* istanbul ignore next */ []));
161
- addHoliday = output();
162
- editHoliday = output();
163
- deleteHoliday = output();
164
- columns = computed(() => [
165
- {
166
- key: 'label',
167
- label: this.transloco.translate('system-settings.holiday-name'),
168
- },
169
- {
170
- key: 'from',
171
- label: this.transloco.translate('system-settings.from-date'),
172
- },
173
- {
174
- key: 'to',
175
- label: this.transloco.translate('system-settings.to-date'),
176
- },
177
- ], ...(ngDevMode ? [{ debugName: "columns" }] : /* istanbul ignore next */ []));
178
- rowActions = computed(() => [
179
- {
180
- icon: 'general.edit-01',
181
- tooltip: this.transloco.translate('system-settings.edit-holiday'),
182
- color: 'secondary',
183
- variant: 'outlined',
184
- action: (row) => this.editHoliday.emit(row.rowIndex),
185
- },
186
- {
187
- icon: 'general.trash-01',
188
- tooltip: this.transloco.translate('system-settings.remove-holiday'),
189
- color: 'danger',
190
- variant: 'outlined',
191
- action: (row) => this.deleteHoliday.emit(row.rowIndex),
192
- },
193
- ], ...(ngDevMode ? [{ debugName: "rowActions" }] : /* istanbul ignore next */ []));
194
- hasHolidays = computed(() => this.holidays().length > 0, ...(ngDevMode ? [{ debugName: "hasHolidays" }] : /* istanbul ignore next */ []));
195
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: SystemSettingsHolidaysSection, deps: [], target: i0.ɵɵFactoryTarget.Component });
196
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: SystemSettingsHolidaysSection, isStandalone: true, selector: "mt-system-settings-holidays-section", inputs: { holidays: { classPropertyName: "holidays", publicName: "holidays", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { addHoliday: "addHoliday", editHoliday: "editHoliday", deleteHoliday: "deleteHoliday" }, ngImport: i0, template: "<ng-container *transloco=\"let t; prefix: 'system-settings'\">\n <mt-card class=\"block\">\n <div class=\"space-y-6\">\n <div\n class=\"flex flex-col gap-4 md:flex-row md:items-start md:justify-between\"\n >\n <div class=\"space-y-1\">\n <h4 class=\"text-base font-semibold text-neutral-900\">\n {{ t(\"holidays-title\") }}\n </h4>\n <p class=\"text-sm text-neutral-600\">\n {{ t(\"holidays-description\") }}\n </p>\n </div>\n\n <mt-button\n [label]=\"t('add-holiday')\"\n icon=\"general.plus\"\n (onClick)=\"addHoliday.emit()\"\n />\n </div>\n\n @if (hasHolidays()) {\n <mt-table\n noCard\n [data]=\"holidays()\"\n [columns]=\"columns()\"\n [rowActions]=\"rowActions()\"\n [generalSearch]=\"false\"\n [showFilters]=\"false\"\n [dataKey]=\"'rowKey'\"\n storageKey=\"admin-system-settings-holidays-table\"\n >\n </mt-table>\n } @else {\n <div\n class=\"rounded-xl border border-dashed border-neutral-300 bg-neutral-50 px-6 py-10 text-center\"\n >\n <h5 class=\"text-base font-semibold text-neutral-900\">\n {{ t(\"no-holidays-title\") }}\n </h5>\n <p class=\"mt-2 text-sm text-neutral-600\">\n {{ t(\"no-holidays-description\") }}\n </p>\n </div>\n }\n </div>\n </mt-card>\n</ng-container>\n", styles: [":host{display:block}\n"], dependencies: [{ kind: "directive", type: TranslocoDirective, selector: "[transloco]", inputs: ["transloco", "translocoParams", "translocoScope", "translocoRead", "translocoPrefix", "translocoLang", "translocoLoadingTpl"] }, { kind: "component", type: Button, selector: "mt-button", inputs: ["icon", "label", "tooltip", "class", "type", "styleClass", "severity", "badge", "variant", "badgeSeverity", "size", "iconPos", "autofocus", "fluid", "raised", "rounded", "text", "plain", "outlined", "link", "disabled", "loading", "pInputs", "ariaLabel"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "component", type: Card, selector: "mt-card", inputs: ["class", "title", "paddingless"] }, { kind: "component", type: Table, selector: "mt-table", inputs: ["filters", "data", "columns", "rowActions", "size", "showGridlines", "stripedRows", "selectableRows", "clickableRows", "generalSearch", "lazyLocalSearch", "showFilters", "filterMode", "loading", "updating", "lazy", "lazyLocalSort", "lazyTotalRecords", "reorderableColumns", "reorderableRows", "dataKey", "storageKey", "storageMode", "persistStateExclude", "exportable", "printable", "groupable", "groupCountMap", "cellClickFilter", "freezeActions", "virtualScroll", "virtualScrollItemSize", "scrollHeight", "printTitle", "exportFilename", "actionShape", "rowActionsLoadingFn", "tableLayout", "noCard", "tabs", "tabsOptionLabel", "tabsOptionValue", "activeTab", "actions", "captionStartTemplate", "captionEndTemplate", "emptyTitle", "emptyDescription", "emptyActionLabel", "emptyActionIcon", "paginatorPosition", "alwaysShowPaginator", "rowsPerPageOptions", "pageSize", "currentPage", "first", "filterTerm", "groupBy", "sortField", "sortDirection"], outputs: ["selectionChange", "cellChange", "lazyLoad", "columnReorder", "rowReorder", "rowClick", "emptyAction", "rowActionsRequested", "filtersChange", "activeTabChange", "onTabChange", "pageSizeChange", "currentPageChange", "firstChange", "filterTermChange", "groupByChange", "sortFieldChange", "sortDirectionChange"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
197
- }
198
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: SystemSettingsHolidaysSection, decorators: [{
199
- type: Component,
200
- args: [{ selector: 'mt-system-settings-holidays-section', imports: [TranslocoDirective, Button, Card, Table], changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-container *transloco=\"let t; prefix: 'system-settings'\">\n <mt-card class=\"block\">\n <div class=\"space-y-6\">\n <div\n class=\"flex flex-col gap-4 md:flex-row md:items-start md:justify-between\"\n >\n <div class=\"space-y-1\">\n <h4 class=\"text-base font-semibold text-neutral-900\">\n {{ t(\"holidays-title\") }}\n </h4>\n <p class=\"text-sm text-neutral-600\">\n {{ t(\"holidays-description\") }}\n </p>\n </div>\n\n <mt-button\n [label]=\"t('add-holiday')\"\n icon=\"general.plus\"\n (onClick)=\"addHoliday.emit()\"\n />\n </div>\n\n @if (hasHolidays()) {\n <mt-table\n noCard\n [data]=\"holidays()\"\n [columns]=\"columns()\"\n [rowActions]=\"rowActions()\"\n [generalSearch]=\"false\"\n [showFilters]=\"false\"\n [dataKey]=\"'rowKey'\"\n storageKey=\"admin-system-settings-holidays-table\"\n >\n </mt-table>\n } @else {\n <div\n class=\"rounded-xl border border-dashed border-neutral-300 bg-neutral-50 px-6 py-10 text-center\"\n >\n <h5 class=\"text-base font-semibold text-neutral-900\">\n {{ t(\"no-holidays-title\") }}\n </h5>\n <p class=\"mt-2 text-sm text-neutral-600\">\n {{ t(\"no-holidays-description\") }}\n </p>\n </div>\n }\n </div>\n </mt-card>\n</ng-container>\n", styles: [":host{display:block}\n"] }]
201
- }], propDecorators: { holidays: [{ type: i0.Input, args: [{ isSignal: true, alias: "holidays", required: false }] }], addHoliday: [{ type: i0.Output, args: ["addHoliday"] }], editHoliday: [{ type: i0.Output, args: ["editHoliday"] }], deleteHoliday: [{ type: i0.Output, args: ["deleteHoliday"] }] } });
202
-
203
- class SystemSettingsTimeSheetSection {
204
- policyForm = input.required(...(ngDevMode ? [{ debugName: "policyForm" }] : /* istanbul ignore next */ []));
205
- globalWorkingHoursForm = input.required(...(ngDevMode ? [{ debugName: "globalWorkingHoursForm" }] : /* istanbul ignore next */ []));
206
- dayOptions = input([], ...(ngDevMode ? [{ debugName: "dayOptions" }] : /* istanbul ignore next */ []));
207
- frequencyOptions = input([], ...(ngDevMode ? [{ debugName: "frequencyOptions" }] : /* istanbul ignore next */ []));
208
- timezoneOptions = input([], ...(ngDevMode ? [{ debugName: "timezoneOptions" }] : /* istanbul ignore next */ []));
209
- maxDailyBelowDaily = input(false, ...(ngDevMode ? [{ debugName: "maxDailyBelowDaily" }] : /* istanbul ignore next */ []));
210
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: SystemSettingsTimeSheetSection, deps: [], target: i0.ɵɵFactoryTarget.Component });
211
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.8", type: SystemSettingsTimeSheetSection, isStandalone: true, selector: "mt-system-settings-timesheet-section", inputs: { policyForm: { classPropertyName: "policyForm", publicName: "policyForm", isSignal: true, isRequired: true, transformFunction: null }, globalWorkingHoursForm: { classPropertyName: "globalWorkingHoursForm", publicName: "globalWorkingHoursForm", isSignal: true, isRequired: true, transformFunction: null }, dayOptions: { classPropertyName: "dayOptions", publicName: "dayOptions", isSignal: true, isRequired: false, transformFunction: null }, frequencyOptions: { classPropertyName: "frequencyOptions", publicName: "frequencyOptions", isSignal: true, isRequired: false, transformFunction: null }, timezoneOptions: { classPropertyName: "timezoneOptions", publicName: "timezoneOptions", isSignal: true, isRequired: false, transformFunction: null }, maxDailyBelowDaily: { classPropertyName: "maxDailyBelowDaily", publicName: "maxDailyBelowDaily", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<ng-container *transloco=\"let t; prefix: 'system-settings'\">\n <div class=\"grid gap-6 xl:grid-cols-2 mb-6\">\n <mt-card class=\"block\">\n <div [formGroup]=\"policyForm()\" class=\"space-y-5\">\n <div class=\"space-y-1\">\n <h4 class=\"text-base font-semibold text-neutral-900\">\n {{ t(\"general-card-title\") }}\n </h4>\n <p class=\"text-sm text-neutral-600\">\n {{ t(\"general-card-description\") }}\n </p>\n </div>\n\n <div class=\"grid gap-4 md:grid-cols-2\">\n <mt-select-field\n formControlName=\"frequency\"\n [options]=\"frequencyOptions()\"\n [optionLabel]=\"'name'\"\n [optionValue]=\"'id'\"\n [label]=\"t('frequency')\"\n [placeholder]=\"t('frequency-placeholder')\"\n [required]=\"true\"\n />\n\n <mt-number-field\n formControlName=\"maxDailyHours\"\n [label]=\"t('max-daily-hours')\"\n [placeholder]=\"t('max-daily-hours-placeholder')\"\n [min]=\"1\"\n [max]=\"24\"\n [required]=\"true\"\n [hint]=\"maxDailyBelowDaily() ? t('max-daily-below-daily') : ''\"\n />\n\n <mt-number-field\n formControlName=\"submissionDeadlineDays\"\n [label]=\"t('submission-deadline-days')\"\n [placeholder]=\"t('submission-deadline-days-placeholder')\"\n [min]=\"0\"\n [max]=\"90\"\n [required]=\"true\"\n [hint]=\"t('submission-deadline-hint')\"\n />\n </div>\n\n <div class=\"grid gap-3 md:grid-cols-2\">\n <mt-toggle-field\n formControlName=\"requireDescription\"\n [label]=\"t('require-description')\"\n />\n <mt-toggle-field\n formControlName=\"allowFutureEntry\"\n [label]=\"t('allow-future-entry')\"\n />\n <mt-toggle-field\n formControlName=\"allowBackdatedEntry\"\n [label]=\"t('allow-backdated-entry')\"\n />\n <mt-toggle-field\n formControlName=\"autoLockOnApprove\"\n [label]=\"t('auto-lock-on-approve')\"\n />\n </div>\n </div>\n </mt-card>\n\n <mt-card class=\"block\">\n <div [formGroup]=\"globalWorkingHoursForm()\" class=\"space-y-5\">\n <div class=\"space-y-1\">\n <h4 class=\"text-base font-semibold text-neutral-900\">\n {{ t(\"working-hours-card-title\") }}\n </h4>\n <p class=\"text-sm text-neutral-600\">\n {{ t(\"working-hours-card-description\") }}\n </p>\n </div>\n\n <div class=\"grid gap-4 md:grid-cols-2\">\n <mt-select-field\n class=\"md:col-span-2\"\n formControlName=\"timeZoneId\"\n [options]=\"timezoneOptions()\"\n [optionLabel]=\"'name'\"\n [optionValue]=\"'id'\"\n [label]=\"t('global-timezone')\"\n [placeholder]=\"t('global-timezone-placeholder')\"\n [filter]=\"true\"\n [required]=\"true\"\n />\n\n <mt-multi-select-field\n class=\"md:col-span-2\"\n formControlName=\"workingDays\"\n [options]=\"dayOptions()\"\n [optionLabel]=\"'name'\"\n [optionValue]=\"'dayNumber'\"\n [label]=\"t('working-days')\"\n [placeholder]=\"t('working-days-placeholder')\"\n [display]=\"'chip'\"\n [required]=\"true\"\n [showClear]=\"true\"\n />\n\n <mt-number-field\n class=\"md:col-span-2\"\n formControlName=\"hoursPerDay\"\n [label]=\"t('daily-working-hours')\"\n [placeholder]=\"t('daily-working-hours-placeholder')\"\n [min]=\"0\"\n [max]=\"24\"\n [required]=\"true\"\n />\n\n <mt-textarea-field\n class=\"md:col-span-2\"\n formControlName=\"holidaysCsv\"\n [label]=\"t('global-holidays')\"\n [placeholder]=\"t('global-holidays-placeholder')\"\n rows=\"3\"\n />\n </div>\n </div>\n </mt-card>\n </div>\n</ng-container>\n", dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "directive", type: TranslocoDirective, selector: "[transloco]", inputs: ["transloco", "translocoParams", "translocoScope", "translocoRead", "translocoPrefix", "translocoLang", "translocoLoadingTpl"] }, { kind: "component", type: Card, selector: "mt-card", inputs: ["class", "title", "paddingless"] }, { kind: "component", type: MultiSelectField, selector: "mt-multi-select-field", inputs: ["field", "label", "placeholder", "class", "readonly", "pInputs", "options", "optionValue", "optionLabel", "filter", "filterBy", "dataKey", "showClear", "display", "required", "maxSelectedLabels", "group", "virtualScroll", "virtualScrollItemSize", "optionGroupLabel", "optionGroupChildren", "optionIcon", "optionIconColor", "optionIconShape", "optionAvatarShape", "optionGroupIcon", "optionGroupIconColor", "optionGroupIconShape", "optionGroupAvatarShape"], outputs: ["onChange"] }, { kind: "component", type: NumberField, selector: "mt-number-field", inputs: ["field", "hint", "label", "placeholder", "class", "readonly", "pInputs", "format", "useGrouping", "maxFractionDigits", "min", "max", "required"] }, { kind: "component", type: SelectField, selector: "mt-select-field", inputs: ["field", "hint", "label", "placeholder", "hasPlaceholderPrefix", "class", "readonly", "pInputs", "options", "optionValue", "optionLabel", "filter", "filterBy", "dataKey", "showClear", "clearAfterSelect", "required", "group", "size", "optionGroupLabel", "optionGroupChildren", "loading", "optionIcon", "optionIconColor", "optionIconShape", "optionAvatarShape", "optionGroupIcon", "optionGroupIconColor", "optionGroupIconShape", "optionGroupAvatarShape", "markCurrentUser"], outputs: ["onChange"] }, { kind: "component", type: TextareaField, selector: "mt-textarea-field", inputs: ["field", "hint", "label", "placeholder", "class", "readonly", "noErrorStyle", "pInputs", "rows", "required", "maxLength"] }, { kind: "component", type: ToggleField, selector: "mt-toggle-field", inputs: ["label", "inputId", "labelPosition", "placeholder", "readonly", "pInputs", "required", "toggleShape", "size", "icon", "descriptionCard"], outputs: ["onChange"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
212
- }
213
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: SystemSettingsTimeSheetSection, decorators: [{
214
- type: Component,
215
- args: [{ selector: 'mt-system-settings-timesheet-section', imports: [
216
- ReactiveFormsModule,
217
- TranslocoDirective,
218
- Card,
219
- MultiSelectField,
220
- NumberField,
221
- SelectField,
222
- TextareaField,
223
- ToggleField,
224
- ], changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-container *transloco=\"let t; prefix: 'system-settings'\">\n <div class=\"grid gap-6 xl:grid-cols-2 mb-6\">\n <mt-card class=\"block\">\n <div [formGroup]=\"policyForm()\" class=\"space-y-5\">\n <div class=\"space-y-1\">\n <h4 class=\"text-base font-semibold text-neutral-900\">\n {{ t(\"general-card-title\") }}\n </h4>\n <p class=\"text-sm text-neutral-600\">\n {{ t(\"general-card-description\") }}\n </p>\n </div>\n\n <div class=\"grid gap-4 md:grid-cols-2\">\n <mt-select-field\n formControlName=\"frequency\"\n [options]=\"frequencyOptions()\"\n [optionLabel]=\"'name'\"\n [optionValue]=\"'id'\"\n [label]=\"t('frequency')\"\n [placeholder]=\"t('frequency-placeholder')\"\n [required]=\"true\"\n />\n\n <mt-number-field\n formControlName=\"maxDailyHours\"\n [label]=\"t('max-daily-hours')\"\n [placeholder]=\"t('max-daily-hours-placeholder')\"\n [min]=\"1\"\n [max]=\"24\"\n [required]=\"true\"\n [hint]=\"maxDailyBelowDaily() ? t('max-daily-below-daily') : ''\"\n />\n\n <mt-number-field\n formControlName=\"submissionDeadlineDays\"\n [label]=\"t('submission-deadline-days')\"\n [placeholder]=\"t('submission-deadline-days-placeholder')\"\n [min]=\"0\"\n [max]=\"90\"\n [required]=\"true\"\n [hint]=\"t('submission-deadline-hint')\"\n />\n </div>\n\n <div class=\"grid gap-3 md:grid-cols-2\">\n <mt-toggle-field\n formControlName=\"requireDescription\"\n [label]=\"t('require-description')\"\n />\n <mt-toggle-field\n formControlName=\"allowFutureEntry\"\n [label]=\"t('allow-future-entry')\"\n />\n <mt-toggle-field\n formControlName=\"allowBackdatedEntry\"\n [label]=\"t('allow-backdated-entry')\"\n />\n <mt-toggle-field\n formControlName=\"autoLockOnApprove\"\n [label]=\"t('auto-lock-on-approve')\"\n />\n </div>\n </div>\n </mt-card>\n\n <mt-card class=\"block\">\n <div [formGroup]=\"globalWorkingHoursForm()\" class=\"space-y-5\">\n <div class=\"space-y-1\">\n <h4 class=\"text-base font-semibold text-neutral-900\">\n {{ t(\"working-hours-card-title\") }}\n </h4>\n <p class=\"text-sm text-neutral-600\">\n {{ t(\"working-hours-card-description\") }}\n </p>\n </div>\n\n <div class=\"grid gap-4 md:grid-cols-2\">\n <mt-select-field\n class=\"md:col-span-2\"\n formControlName=\"timeZoneId\"\n [options]=\"timezoneOptions()\"\n [optionLabel]=\"'name'\"\n [optionValue]=\"'id'\"\n [label]=\"t('global-timezone')\"\n [placeholder]=\"t('global-timezone-placeholder')\"\n [filter]=\"true\"\n [required]=\"true\"\n />\n\n <mt-multi-select-field\n class=\"md:col-span-2\"\n formControlName=\"workingDays\"\n [options]=\"dayOptions()\"\n [optionLabel]=\"'name'\"\n [optionValue]=\"'dayNumber'\"\n [label]=\"t('working-days')\"\n [placeholder]=\"t('working-days-placeholder')\"\n [display]=\"'chip'\"\n [required]=\"true\"\n [showClear]=\"true\"\n />\n\n <mt-number-field\n class=\"md:col-span-2\"\n formControlName=\"hoursPerDay\"\n [label]=\"t('daily-working-hours')\"\n [placeholder]=\"t('daily-working-hours-placeholder')\"\n [min]=\"0\"\n [max]=\"24\"\n [required]=\"true\"\n />\n\n <mt-textarea-field\n class=\"md:col-span-2\"\n formControlName=\"holidaysCsv\"\n [label]=\"t('global-holidays')\"\n [placeholder]=\"t('global-holidays-placeholder')\"\n rows=\"3\"\n />\n </div>\n </div>\n </mt-card>\n </div>\n</ng-container>\n" }]
225
- }], propDecorators: { policyForm: [{ type: i0.Input, args: [{ isSignal: true, alias: "policyForm", required: true }] }], globalWorkingHoursForm: [{ type: i0.Input, args: [{ isSignal: true, alias: "globalWorkingHoursForm", required: true }] }], dayOptions: [{ type: i0.Input, args: [{ isSignal: true, alias: "dayOptions", required: false }] }], frequencyOptions: [{ type: i0.Input, args: [{ isSignal: true, alias: "frequencyOptions", required: false }] }], timezoneOptions: [{ type: i0.Input, args: [{ isSignal: true, alias: "timezoneOptions", required: false }] }], maxDailyBelowDaily: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxDailyBelowDaily", required: false }] }] } });
226
-
227
- /** The settings record General Configuration fields live in. */
228
- const GENERAL_CONFIGURATION_SETTING_KEY = 'Identity';
229
- const FIXED_CURRENCIES = [
230
- {
231
- code: 'SAR',
232
- englishLabel: 'Saudi Riyal (SAR)',
233
- arabicLabel: 'ريال سعودي (SAR)',
234
- unit: {
235
- en: 'SAR',
236
- ar: 'ريال سعودي',
237
- },
238
- },
239
- {
240
- code: 'OMR',
241
- englishLabel: 'Omani Rial (OMR)',
242
- arabicLabel: 'ريال عماني (OMR)',
243
- unit: {
244
- en: 'OMR',
245
- ar: 'ريال عماني',
246
- },
247
- },
248
- {
249
- code: 'AED',
250
- englishLabel: 'UAE Dirham (AED)',
251
- arabicLabel: 'درهم إماراتي (AED)',
252
- unit: {
253
- en: 'AED',
254
- ar: 'درهم إماراتي',
255
- },
256
- },
257
- ];
258
- /**
259
- * Explore landing views, mirroring the app-client explore header switcher
260
- * (same icons) so the configured default reads as the same choice.
261
- */
262
- const EXPLORE_DEFAULT_VIEW_OPTIONS = [
263
- {
264
- id: 'cards',
265
- translationKey: 'explore-default-view-cards',
266
- icon: 'layout.grid-01',
267
- },
268
- {
269
- id: 'timeline',
270
- translationKey: 'explore-default-view-timeline',
271
- icon: 'time.clock',
272
- },
273
- ];
274
- const DEFAULT_GENERAL_CONFIGURATION = {
275
- defaultExploreView: 'cards',
276
- showDesignSwitcher: false,
277
- };
278
- const DEFAULT_DATE_FORMAT_OPTIONS = [
279
- {
280
- key: 'MM/dd/yyyy',
281
- sample: 'MM/dd/yyyy [01/20/2023]',
282
- isSelected: true,
283
- },
284
- {
285
- key: 'yyyy/MM/dd',
286
- sample: 'yyyy/MM/dd [2023/01/20]',
287
- isSelected: false,
288
- },
289
- {
290
- key: 'dd-MM-yyyy',
291
- sample: 'dd-MM-yyyy [20-01-2023]',
292
- isSelected: false,
293
- },
294
- {
295
- key: 'yyyy-MM-dd',
296
- sample: 'yyyy-MM-dd [2023-01-20]',
297
- isSelected: false,
298
- },
299
- ];
300
- const DEFAULT_TIME_FORMAT_OPTIONS = [
301
- {
302
- key: 'hh:mm tt',
303
- sample: 'hh:mm tt [03:00 PM]',
304
- isSelected: true,
305
- },
306
- {
307
- key: 'HH:mm',
308
- sample: 'HH:mm [15:00]',
309
- isSelected: false,
310
- },
311
- {
312
- key: 'H:mm:ss',
313
- sample: 'H:mm:ss [15:00:00]',
314
- isSelected: false,
315
- },
316
- {
317
- key: 'hh:mm:ss',
318
- sample: 'hh:mm:ss [03:00:00]',
319
- isSelected: false,
320
- },
321
- ];
322
- const WEEKEND_DAY_DEFINITIONS = [
323
- { dayNumber: 1, translationKey: 'monday' },
324
- { dayNumber: 2, translationKey: 'tuesday' },
325
- { dayNumber: 3, translationKey: 'wednesday' },
326
- { dayNumber: 4, translationKey: 'thursday' },
327
- { dayNumber: 5, translationKey: 'friday' },
328
- { dayNumber: 6, translationKey: 'saturday' },
329
- { dayNumber: 7, translationKey: 'sunday' },
330
- ];
331
- const DOTNET_DAY_DEFINITIONS = [
332
- { dayNumber: 0, translationKey: 'sunday' },
333
- { dayNumber: 1, translationKey: 'monday' },
334
- { dayNumber: 2, translationKey: 'tuesday' },
335
- { dayNumber: 3, translationKey: 'wednesday' },
336
- { dayNumber: 4, translationKey: 'thursday' },
337
- { dayNumber: 5, translationKey: 'friday' },
338
- { dayNumber: 6, translationKey: 'saturday' },
339
- ];
340
- const TIMESHEET_FREQUENCY_OPTIONS = [
341
- { id: 'Daily', translationKey: 'frequency-daily' },
342
- { id: 'Weekly', translationKey: 'frequency-weekly' },
343
- { id: 'BiWeekly', translationKey: 'frequency-biweekly' },
344
- { id: 'Monthly', translationKey: 'frequency-monthly' },
345
- ];
346
- const SCHEDULE_ITEM_TYPE_OPTIONS = [
347
- { itemType: 'Task', translationKey: 'schedule-item-task' },
348
- { itemType: 'Milestone', translationKey: 'schedule-item-milestone' },
349
- { itemType: 'Deliverable', translationKey: 'schedule-item-deliverable' },
350
- ];
351
- const RATE_SOURCE_OPTIONS = [
352
- { id: 'UserHourlyRate', translationKey: 'rate-source-user-hourly-rate' },
353
- { id: 'None', translationKey: 'rate-source-none' },
354
- ];
355
-
356
- const SYSTEM_SETTINGS_STORAGE_KEY = 'systemSettings.settings';
357
- function serializeSystemSettings(settings) {
358
- return JSON.stringify(settings);
359
- }
360
- /**
361
- * Persists the canonical settings array consumed by host-level formatters.
362
- * Storage failures must not turn a successful API request into a UI failure.
363
- */
364
- function synchronizeSystemSettingsStorage(storage, settings) {
365
- if (!storage) {
366
- return false;
367
- }
368
- try {
369
- storage.setItem(SYSTEM_SETTINGS_STORAGE_KEY, serializeSystemSettings(settings));
370
- return true;
371
- }
372
- catch {
373
- return false;
374
- }
375
- }
376
- function resolveBrowserLocalStorage() {
377
- try {
378
- return globalThis.localStorage ?? null;
379
- }
380
- catch {
381
- return null;
382
- }
383
- }
384
-
385
- class SystemSettings {
386
- http = inject(HttpClient);
387
- router = inject(Router);
388
- transloco = inject(TranslocoService);
389
- modal = inject(ModalService);
390
- toast = inject(ToastService);
391
- apiBasePath = input('settings', ...(ngDevMode ? [{ debugName: "apiBasePath" }] : /* istanbul ignore next */ []));
392
- backRoute = input('/control-panel/product-settings', ...(ngDevMode ? [{ debugName: "backRoute" }] : /* istanbul ignore next */ []));
393
- formatSchema = input(null, ...(ngDevMode ? [{ debugName: "formatSchema" }] : /* istanbul ignore next */ []));
394
- breadcrumbItems = [
395
- {
396
- label: '',
397
- icon: 'general.home-line',
398
- routerLink: '/control-panel/workspaces',
399
- },
400
- {
401
- label: this.transloco.translate('product-settings.product-settings'),
402
- routerLink: '/control-panel/product-settings',
403
- },
404
- {
405
- label: this.transloco.translate('system-settings.page-title'),
406
- },
407
- ];
408
- form = new FormGroup({
409
- generalConfiguration: new FormGroup({
410
- defaultExploreView: new FormControl('cards', {
411
- nonNullable: true,
412
- validators: [Validators.required],
413
- }),
414
- showDesignSwitcher: new FormControl(false, {
415
- nonNullable: true,
416
- }),
417
- }),
418
- timezone: new FormGroup({
419
- regionId: new FormControl(null, Validators.required),
420
- dateFormat: new FormControl(null, Validators.required),
421
- timeFormat: new FormControl(null, Validators.required),
422
- }),
423
- currency: new FormGroup({
424
- code: new FormControl(null, Validators.required),
425
- format: new FormControl(null, Validators.required),
426
- }),
427
- weekend: new FormGroup({
428
- days: new FormControl([], { nonNullable: true }),
429
- }),
430
- timeSheetPolicy: new FormGroup({
431
- frequency: new FormControl('Weekly', Validators.required),
432
- maxDailyHours: new FormControl(24, [
433
- Validators.required,
434
- Validators.min(1),
435
- Validators.max(24),
436
- ]),
437
- requireDescription: new FormControl(false, { nonNullable: true }),
438
- allowFutureEntry: new FormControl(false, { nonNullable: true }),
439
- allowBackdatedEntry: new FormControl(true, { nonNullable: true }),
440
- autoLockOnApprove: new FormControl(true, { nonNullable: true }),
441
- submissionDeadlineDays: new FormControl(3, [
442
- Validators.required,
443
- Validators.min(0),
444
- Validators.max(90),
445
- ]),
446
- }),
447
- globalWorkingHours: new FormGroup({
448
- timeZoneId: new FormControl(null, Validators.required),
449
- workingDays: new FormControl([0, 1, 2, 3, 4], {
450
- nonNullable: true,
451
- validators: [Validators.required],
452
- }),
453
- hoursPerDay: new FormControl(8, [
454
- Validators.required,
455
- Validators.min(0),
456
- Validators.max(24),
457
- ]),
458
- holidaysCsv: new FormControl('', { nonNullable: true }),
459
- }),
460
- }, maxDailyHoursGteHoursPerDay);
461
- settings = signal(null, ...(ngDevMode ? [{ debugName: "settings" }] : /* istanbul ignore next */ []));
462
- settingsLoading = signal(false, ...(ngDevMode ? [{ debugName: "settingsLoading" }] : /* istanbul ignore next */ []));
463
- settingsError = signal(null, ...(ngDevMode ? [{ debugName: "settingsError" }] : /* istanbul ignore next */ []));
464
- settingsLastUpdated = signal(null, ...(ngDevMode ? [{ debugName: "settingsLastUpdated" }] : /* istanbul ignore next */ []));
465
- updating = signal(false, ...(ngDevMode ? [{ debugName: "updating" }] : /* istanbul ignore next */ []));
466
- updateError = signal(null, ...(ngDevMode ? [{ debugName: "updateError" }] : /* istanbul ignore next */ []));
467
- timezones = signal([], ...(ngDevMode ? [{ debugName: "timezones" }] : /* istanbul ignore next */ []));
468
- timezonesLoading = signal(false, ...(ngDevMode ? [{ debugName: "timezonesLoading" }] : /* istanbul ignore next */ []));
469
- timezonesError = signal(null, ...(ngDevMode ? [{ debugName: "timezonesError" }] : /* istanbul ignore next */ []));
470
- holidayItems = signal([], ...(ngDevMode ? [{ debugName: "holidayItems" }] : /* istanbul ignore next */ []));
471
- initialSnapshot = signal(null, ...(ngDevMode ? [{ debugName: "initialSnapshot" }] : /* istanbul ignore next */ []));
472
- hydrationVersion = signal(null, ...(ngDevMode ? [{ debugName: "hydrationVersion" }] : /* istanbul ignore next */ []));
473
- activeLang = toSignal(this.transloco.langChanges$, {
474
- initialValue: this.transloco.getActiveLang(),
475
- });
476
- formStatus = toSignal(this.form.statusChanges, {
477
- initialValue: this.form.status,
478
- });
479
- selectedDateFormat = toSignal(this.form.controls.timezone.controls.dateFormat.valueChanges, {
480
- initialValue: this.form.controls.timezone.controls.dateFormat.value,
481
- });
482
- selectedTimeFormat = toSignal(this.form.controls.timezone.controls.timeFormat.valueChanges, {
483
- initialValue: this.form.controls.timezone.controls.timeFormat.value,
484
- });
485
- selectedCurrencyCode = toSignal(this.form.controls.currency.controls.code.valueChanges, {
486
- initialValue: this.form.controls.currency.controls.code.value,
487
- });
488
- formValue = toSignal(this.form.valueChanges, {
489
- initialValue: this.form.getRawValue(),
490
- });
491
- /**
492
- * The `Identity` record. It is shared with `@masterteam/brand-display`, which
493
- * owns every other field in it — we only read/write the General Configuration
494
- * slice and must preserve the rest verbatim.
495
- */
496
- generalConfigurationSetting = computed(() => this.findSettingByKey(GENERAL_CONFIGURATION_SETTING_KEY), ...(ngDevMode ? [{ debugName: "generalConfigurationSetting" }] : /* istanbul ignore next */ []));
497
- holidaysSetting = computed(() => this.findSettingByKey('Holidays'), ...(ngDevMode ? [{ debugName: "holidaysSetting" }] : /* istanbul ignore next */ []));
498
- timezoneSetting = computed(() => this.findSettingByKey('Timezone'), ...(ngDevMode ? [{ debugName: "timezoneSetting" }] : /* istanbul ignore next */ []));
499
- currencySetting = computed(() => this.findSettingByKey('Currency'), ...(ngDevMode ? [{ debugName: "currencySetting" }] : /* istanbul ignore next */ []));
500
- weekendSetting = computed(() => this.findSettingByKey('Weekend'), ...(ngDevMode ? [{ debugName: "weekendSetting" }] : /* istanbul ignore next */ []));
501
- timeSheetPolicySetting = computed(() => this.findSettingByKey('TimeSheetPolicy'), ...(ngDevMode ? [{ debugName: "timeSheetPolicySetting" }] : /* istanbul ignore next */ []));
502
- globalWorkingHoursSetting = computed(() => this.findSettingByKey('GlobalWorkingHours'), ...(ngDevMode ? [{ debugName: "globalWorkingHoursSetting" }] : /* istanbul ignore next */ []));
503
- resolvedFormatSchema = computed(() => {
504
- const schema = this.formatSchema();
505
- return {
506
- dateFormats: schema?.dateFormats ?? DEFAULT_DATE_FORMAT_OPTIONS,
507
- timeFormats: schema?.timeFormats ?? DEFAULT_TIME_FORMAT_OPTIONS,
508
- };
509
- }, ...(ngDevMode ? [{ debugName: "resolvedFormatSchema" }] : /* istanbul ignore next */ []));
510
- timezoneOptions = computed(() => this.timezones().map((timezone) => ({
511
- ...timezone,
512
- name: timezone.name ?? timezone.displayName,
513
- })), ...(ngDevMode ? [{ debugName: "timezoneOptions" }] : /* istanbul ignore next */ []));
514
- dateFormatOptions = computed(() => this.mapFormatOptions(this.resolvedFormatSchema().dateFormats, this.selectedDateFormat()), ...(ngDevMode ? [{ debugName: "dateFormatOptions" }] : /* istanbul ignore next */ []));
515
- timeFormatOptions = computed(() => this.mapFormatOptions(this.resolvedFormatSchema().timeFormats, this.selectedTimeFormat()), ...(ngDevMode ? [{ debugName: "timeFormatOptions" }] : /* istanbul ignore next */ []));
516
- currencyOptions = computed(() => {
517
- const lang = this.activeLang();
518
- return FIXED_CURRENCIES.map((currency) => ({
519
- id: currency.code,
520
- name: lang === 'ar' ? currency.arabicLabel : currency.englishLabel,
521
- }));
522
- }, ...(ngDevMode ? [{ debugName: "currencyOptions" }] : /* istanbul ignore next */ []));
523
- currencyFormatOptions = computed(() => {
524
- const currency = FIXED_CURRENCIES.find((item) => item.code === this.selectedCurrencyCode());
525
- return this.buildCurrencyFormatOptions(currency);
526
- }, ...(ngDevMode ? [{ debugName: "currencyFormatOptions" }] : /* istanbul ignore next */ []));
527
- weekendOptions = computed(() => {
528
- this.activeLang();
529
- return WEEKEND_DAY_DEFINITIONS.map((day) => ({
530
- id: `${day.dayNumber}`,
531
- dayNumber: day.dayNumber,
532
- name: this.transloco.translate(`system-settings.${day.translationKey}`),
533
- }));
534
- }, ...(ngDevMode ? [{ debugName: "weekendOptions" }] : /* istanbul ignore next */ []));
535
- dotnetDayOptions = computed(() => {
536
- this.activeLang();
537
- return DOTNET_DAY_DEFINITIONS.map((day) => ({
538
- id: `${day.dayNumber}`,
539
- dayNumber: day.dayNumber,
540
- name: this.transloco.translate(`system-settings.${day.translationKey}`),
541
- }));
542
- }, ...(ngDevMode ? [{ debugName: "dotnetDayOptions" }] : /* istanbul ignore next */ []));
543
- exploreDefaultViewOptions = computed(() => {
544
- this.activeLang();
545
- return EXPLORE_DEFAULT_VIEW_OPTIONS.map((option) => ({
546
- id: option.id,
547
- name: this.transloco.translate(`system-settings.${option.translationKey}`),
548
- icon: option.icon,
549
- }));
550
- }, ...(ngDevMode ? [{ debugName: "exploreDefaultViewOptions" }] : /* istanbul ignore next */ []));
551
- frequencyOptions = computed(() => {
552
- this.activeLang();
553
- return TIMESHEET_FREQUENCY_OPTIONS.map((item) => ({
554
- id: item.id,
555
- name: this.transloco.translate(`system-settings.${item.translationKey}`),
556
- }));
557
- }, ...(ngDevMode ? [{ debugName: "frequencyOptions" }] : /* istanbul ignore next */ []));
558
- isReady = computed(() => this.hydrationVersion() !== null && this.initialSnapshot() !== null, ...(ngDevMode ? [{ debugName: "isReady" }] : /* istanbul ignore next */ []));
559
- isLoading = computed(() => this.settingsLoading() || this.timezonesLoading() || !this.isReady(), ...(ngDevMode ? [{ debugName: "isLoading" }] : /* istanbul ignore next */ []));
560
- hasChanges = computed(() => {
561
- this.formValue();
562
- this.holidayItems();
563
- const initial = this.initialSnapshot();
564
- if (!initial) {
565
- return false;
566
- }
567
- const current = this.buildCurrentSnapshot();
568
- if (!current) {
569
- return false;
570
- }
571
- return (!this.areEqual(initial.generalConfiguration, current.generalConfiguration) ||
572
- !this.areEqual(initial.holidays, current.holidays) ||
573
- !this.areEqual(initial.timezone, current.timezone) ||
574
- !this.areEqual(initial.currency, current.currency) ||
575
- !this.areEqual(initial.weekend, current.weekend) ||
576
- !this.areEqual(initial.timeSheetPolicy, current.timeSheetPolicy) ||
577
- !this.areEqual(initial.globalWorkingHours, current.globalWorkingHours));
578
- }, ...(ngDevMode ? [{ debugName: "hasChanges" }] : /* istanbul ignore next */ []));
579
- canSaveSettings = computed(() => !this.isLoading() &&
580
- !this.updating() &&
581
- this.formStatus() === 'VALID' &&
582
- this.hasChanges(), ...(ngDevMode ? [{ debugName: "canSaveSettings" }] : /* istanbul ignore next */ []));
583
- holidayTableRows = computed(() => this.holidayItems().map((holiday, index) => ({
584
- rowKey: `${index}`,
585
- rowIndex: index,
586
- label: holiday.label,
587
- from: formatDateOnly(holiday.from),
588
- to: formatDateOnly(holiday.to),
589
- })), ...(ngDevMode ? [{ debugName: "holidayTableRows" }] : /* istanbul ignore next */ []));
590
- constructor() {
591
- effect(() => {
592
- const version = [
593
- this.settingsLastUpdated() ?? 'none',
594
- this.settingsError() ?? 'none',
595
- this.timezonesError() ?? 'none',
596
- String(this.timezones().length),
597
- JSON.stringify(this.resolvedFormatSchema()),
598
- ].join('::');
599
- if (this.settingsLoading() || this.timezonesLoading()) {
600
- return;
601
- }
602
- if (version === this.hydrationVersion()) {
603
- return;
604
- }
605
- this.hydrateForm(this.generalConfigurationSetting() ??
606
- this.createFallbackSetting(GENERAL_CONFIGURATION_SETTING_KEY), this.holidaysSetting() ?? this.createFallbackSetting('Holidays'), this.timezoneSetting() ?? this.createFallbackSetting('Timezone'), this.currencySetting() ?? this.createFallbackSetting('Currency'), this.weekendSetting() ?? this.createFallbackSetting('Weekend'), this.timeSheetPolicySetting() ??
607
- this.createFallbackSetting('TimeSheetPolicy'), this.globalWorkingHoursSetting() ??
608
- this.createFallbackSetting('GlobalWorkingHours'));
609
- this.hydrationVersion.set(version);
610
- });
611
- }
612
- ngOnInit() {
613
- this.loadSettings();
614
- this.loadTimezones();
615
- }
616
- goBack() {
617
- const backRoute = this.backRoute();
618
- if (!backRoute) {
619
- return;
620
- }
621
- this.router.navigateByUrl(backRoute);
622
- }
623
- openAddHoliday() {
624
- const modalRef = this.modal.openModal(SystemSettingsHolidayEditor, 'dialog', {
625
- header: this.transloco.translate('system-settings.add-holiday'),
626
- width: '42rem',
627
- appendTo: 'body',
628
- dismissableMask: true,
629
- dismissible: true,
630
- inputValues: {
631
- holiday: null,
632
- isEditMode: false,
633
- },
634
- });
635
- modalRef.onClose.subscribe((result) => {
636
- if (!result) {
637
- return;
638
- }
639
- this.holidayItems.update((items) => [...items, result]);
640
- });
641
- }
642
- editHoliday(index) {
643
- const holiday = this.holidayItems()[index];
644
- if (!holiday) {
645
- return;
646
- }
647
- const modalRef = this.modal.openModal(SystemSettingsHolidayEditor, 'drawer', {
648
- header: this.transloco.translate('system-settings.edit-holiday'),
649
- styleClass: '!w-[30rem] !absolute !shadow-none',
650
- position: 'end',
651
- appendTo: 'page-content',
652
- dismissible: true,
653
- inputValues: {
654
- holiday,
655
- isEditMode: true,
656
- },
657
- });
658
- modalRef.onClose.subscribe((result) => {
659
- if (!result) {
660
- return;
661
- }
662
- this.holidayItems.update((items) => items.map((item, itemIndex) => (itemIndex === index ? result : item)));
663
- });
664
- }
665
- deleteHoliday(index) {
666
- this.holidayItems.update((items) => items.filter((_, itemIndex) => itemIndex !== index));
667
- }
668
- onSave() {
669
- this.form.markAllAsTouched();
670
- const nextSnapshot = this.buildCurrentSnapshot();
671
- const initialSnapshot = this.initialSnapshot();
672
- if (!nextSnapshot || !initialSnapshot) {
673
- return;
674
- }
675
- const values = [];
676
- if (!this.areEqual(initialSnapshot.generalConfiguration, nextSnapshot.generalConfiguration)) {
677
- // `Identity` is shared with brand-display and is saved by full
678
- // replacement, so merge our slice onto the record as last loaded instead
679
- // of sending it alone — sending only our fields would wipe the branding.
680
- values.push({
681
- key: GENERAL_CONFIGURATION_SETTING_KEY,
682
- value: {
683
- ...this.getIdentityRecord(),
684
- ...nextSnapshot.generalConfiguration,
685
- },
686
- });
687
- }
688
- if (!this.areEqual(initialSnapshot.holidays, nextSnapshot.holidays)) {
689
- values.push({
690
- key: 'Holidays',
691
- value: this.serializeHolidaysValue(nextSnapshot.holidays),
692
- });
693
- }
694
- if (!this.areEqual(initialSnapshot.timezone, nextSnapshot.timezone)) {
695
- values.push({
696
- key: 'Timezone',
697
- value: nextSnapshot.timezone,
698
- });
699
- }
700
- if (!this.areEqual(initialSnapshot.currency, nextSnapshot.currency)) {
701
- values.push({
702
- key: 'Currency',
703
- value: nextSnapshot.currency,
704
- });
705
- }
706
- if (!this.areEqual(initialSnapshot.weekend, nextSnapshot.weekend)) {
707
- values.push({
708
- key: 'Weekend',
709
- value: nextSnapshot.weekend,
710
- });
711
- }
712
- if (!this.areEqual(initialSnapshot.timeSheetPolicy, nextSnapshot.timeSheetPolicy)) {
713
- values.push({
714
- key: 'TimeSheetPolicy',
715
- value: nextSnapshot.timeSheetPolicy,
716
- });
717
- }
718
- if (!this.areEqual(initialSnapshot.globalWorkingHours, nextSnapshot.globalWorkingHours)) {
719
- values.push({
720
- key: 'GlobalWorkingHours',
721
- value: nextSnapshot.globalWorkingHours,
722
- });
723
- }
724
- if (!values.length) {
725
- this.toast.info(this.transloco.translate('system-settings.no-changes-message'));
726
- return;
727
- }
728
- this.updateSettings(values);
729
- }
730
- loadSettings() {
731
- this.settingsLoading.set(true);
732
- this.settingsError.set(null);
733
- this.http
734
- .get(this.buildEndpoint('getsystemsettings'))
735
- .subscribe({
736
- next: (response) => {
737
- const settings = response.data ?? [];
738
- this.settings.set(settings);
739
- synchronizeSystemSettingsStorage(resolveBrowserLocalStorage(), settings);
740
- this.settingsLoading.set(false);
741
- this.settingsLastUpdated.set(new Date().toISOString());
742
- },
743
- error: (error) => {
744
- this.settingsLoading.set(false);
745
- this.settingsError.set(error?.message ?? 'Failed to load system settings');
746
- this.settingsLastUpdated.set(new Date().toISOString());
747
- },
748
- });
749
- }
750
- loadTimezones() {
751
- this.timezonesLoading.set(true);
752
- this.timezonesError.set(null);
753
- this.http
754
- .get(this.buildEndpoint('timezones'))
755
- .subscribe({
756
- next: (response) => {
757
- this.timezones.set(response.data ?? []);
758
- this.timezonesLoading.set(false);
759
- },
760
- error: (error) => {
761
- this.timezonesLoading.set(false);
762
- this.timezonesError.set(error?.message ?? 'Failed to load timezone options');
763
- },
764
- });
765
- }
766
- updateSettings(values) {
767
- this.updating.set(true);
768
- this.updateError.set(null);
769
- this.http
770
- .put(this.buildEndpoint('updatesystemsettings'), {
771
- values,
772
- })
773
- .subscribe({
774
- next: () => {
775
- const nextSettings = this.applyUpdatedSettings(this.settings() ?? [], values);
776
- this.settings.set(nextSettings);
777
- synchronizeSystemSettingsStorage(resolveBrowserLocalStorage(), nextSettings);
778
- this.updating.set(false);
779
- this.updateError.set(null);
780
- this.settingsLastUpdated.set(new Date().toISOString());
781
- },
782
- error: (error) => {
783
- this.updating.set(false);
784
- this.updateError.set(error?.message ?? 'Failed to update system settings');
785
- },
786
- });
787
- }
788
- hydrateForm(generalConfigurationSetting, holidaysSetting, timezoneSetting, currencySetting, weekendSetting, timeSheetPolicySetting, globalWorkingHoursSetting) {
789
- const generalConfiguration = this.normalizeGeneralConfigurationSnapshot(this.extractGeneralConfigurationValue(generalConfigurationSetting));
790
- const holidays = this.extractHolidaysValue(holidaysSetting);
791
- const timezone = this.normalizeTimezoneSnapshot(this.extractTimezoneValue(timezoneSetting));
792
- const currency = this.normalizeCurrencySnapshot(this.extractCurrencyValue(currencySetting));
793
- const weekend = this.normalizeWeekendSnapshot(this.extractWeekendValue(weekendSetting));
794
- const globalWorkingHours = this.normalizeGlobalWorkingHoursSnapshot(this.extractGlobalWorkingHoursValue(globalWorkingHoursSetting));
795
- const timeSheetPolicy = this.normalizeTimeSheetPolicySnapshot(this.extractTimeSheetPolicyValue(timeSheetPolicySetting), globalWorkingHours.hoursPerDay);
796
- this.holidayItems.set(holidays.data);
797
- this.form.controls.generalConfiguration.setValue({
798
- defaultExploreView: generalConfiguration.defaultExploreView,
799
- showDesignSwitcher: generalConfiguration.showDesignSwitcher,
800
- });
801
- this.form.controls.timezone.setValue({
802
- regionId: timezone.region?.id ?? null,
803
- dateFormat: timezone.dateFormat,
804
- timeFormat: timezone.timeFormat,
805
- });
806
- this.form.controls.currency.setValue({
807
- code: this.resolveCurrencyCode(currency),
808
- format: currency.format,
809
- });
810
- this.form.controls.weekend.setValue({
811
- days: weekend.days,
812
- });
813
- this.form.controls.timeSheetPolicy.setValue({
814
- frequency: timeSheetPolicy.frequency,
815
- maxDailyHours: timeSheetPolicy.maxDailyHours,
816
- requireDescription: timeSheetPolicy.requireDescription,
817
- allowFutureEntry: timeSheetPolicy.allowFutureEntry,
818
- allowBackdatedEntry: timeSheetPolicy.allowBackdatedEntry,
819
- autoLockOnApprove: timeSheetPolicy.autoLockOnApprove,
820
- submissionDeadlineDays: timeSheetPolicy.submissionDeadlineDays,
821
- });
822
- this.form.controls.globalWorkingHours.setValue({
823
- timeZoneId: globalWorkingHours.timeZoneId,
824
- workingDays: globalWorkingHours.workingDays,
825
- hoursPerDay: globalWorkingHours.hoursPerDay,
826
- holidaysCsv: globalWorkingHours.holidays.join(', '),
827
- });
828
- this.form.markAsPristine();
829
- this.form.markAsUntouched();
830
- this.initialSnapshot.set({
831
- generalConfiguration,
832
- holidays,
833
- timezone,
834
- currency,
835
- weekend,
836
- timeSheetPolicy,
837
- globalWorkingHours,
838
- });
839
- }
840
- buildCurrentSnapshot() {
841
- const timezone = this.buildTimezoneValue();
842
- const currency = this.buildCurrencyValue();
843
- if (!timezone || !currency || this.form.invalid) {
844
- return null;
845
- }
846
- return {
847
- generalConfiguration: this.buildGeneralConfigurationValue(),
848
- holidays: {
849
- data: this.holidayItems().map((item) => ({
850
- label: item.label.trim(),
851
- from: item.from,
852
- to: item.to,
853
- })),
854
- },
855
- timezone,
856
- currency,
857
- weekend: this.buildWeekendValue(),
858
- timeSheetPolicy: this.buildTimeSheetPolicyValue(),
859
- globalWorkingHours: this.buildGlobalWorkingHoursValue(),
860
- };
861
- }
862
- buildTimezoneValue() {
863
- const timezoneForm = this.form.controls.timezone.getRawValue();
864
- if (!timezoneForm.regionId ||
865
- !timezoneForm.dateFormat ||
866
- !timezoneForm.timeFormat) {
867
- return null;
868
- }
869
- const region = this.timezones().find((item) => item.id === timezoneForm.regionId);
870
- if (!region) {
871
- return null;
872
- }
873
- return {
874
- region: {
875
- ...region,
876
- name: region.name ?? region.displayName,
877
- },
878
- dateFormat: timezoneForm.dateFormat,
879
- timeFormat: timezoneForm.timeFormat,
880
- };
881
- }
882
- buildCurrencyValue() {
883
- const currencyForm = this.form.controls.currency.getRawValue();
884
- if (!currencyForm.code || !currencyForm.format) {
885
- return null;
886
- }
887
- const currency = FIXED_CURRENCIES.find((item) => item.code === currencyForm.code);
888
- if (!currency) {
889
- return null;
890
- }
891
- return {
892
- name: currency.code,
893
- unit: currency.unit,
894
- format: currencyForm.format,
895
- };
896
- }
897
- /**
898
- * The `Identity` value exactly as last returned by the API (or written by a
899
- * previous save in this session), used as the base every save merges onto so
900
- * branding fields this page does not model survive round-trips.
901
- */
902
- getIdentityRecord() {
903
- const value = this.generalConfigurationSetting()?.value;
904
- return isRecord(value) ? value : {};
905
- }
906
- buildGeneralConfigurationValue() {
907
- return {
908
- defaultExploreView: normalizeExploreDefaultView(this.form.controls.generalConfiguration.controls.defaultExploreView
909
- .value),
910
- showDesignSwitcher: this.form.controls.generalConfiguration.controls.showDesignSwitcher
911
- .value === true,
912
- };
913
- }
914
- buildWeekendValue() {
915
- return {
916
- days: normalizeWeekendDays(this.form.controls.weekend.controls.days.value),
917
- };
918
- }
919
- buildTimeSheetPolicyValue() {
920
- const policyForm = this.form.controls.timeSheetPolicy.getRawValue();
921
- const hoursPerDay = clampNumber(this.form.controls.globalWorkingHours.controls.hoursPerDay.value ?? 8, 0, 24);
922
- return {
923
- frequency: normalizeFrequency(policyForm.frequency),
924
- maxDailyHours: Math.max(hoursPerDay, clampNumber(policyForm.maxDailyHours ?? 24, 1, 24)),
925
- requireDescription: policyForm.requireDescription,
926
- allowFutureEntry: policyForm.allowFutureEntry,
927
- allowBackdatedEntry: policyForm.allowBackdatedEntry,
928
- autoLockOnApprove: policyForm.autoLockOnApprove,
929
- submissionDeadlineDays: clampNumber(policyForm.submissionDeadlineDays ?? 0, 0, 90),
930
- };
931
- }
932
- buildGlobalWorkingHoursValue() {
933
- const globalForm = this.form.controls.globalWorkingHours.getRawValue();
934
- return {
935
- timeZoneId: globalForm.timeZoneId ?? 'UTC',
936
- workingDays: normalizeDotnetDays(globalForm.workingDays),
937
- hoursPerDay: clampNumber(globalForm.hoursPerDay ?? 8, 0, 24),
938
- holidays: parseCsv(globalForm.holidaysCsv),
939
- };
940
- }
941
- findSettingByKey(key) {
942
- const normalizedKey = key.trim().toLowerCase();
943
- return (this.settings()?.find((setting) => setting.key.trim().toLowerCase() === normalizedKey) ?? null);
944
- }
945
- extractGeneralConfigurationValue(setting) {
946
- if (!isRecord(setting.value)) {
947
- return { ...DEFAULT_GENERAL_CONFIGURATION };
948
- }
949
- return {
950
- defaultExploreView: normalizeExploreDefaultView(setting.value['defaultExploreView'] ??
951
- setting.value['DefaultExploreView']),
952
- showDesignSwitcher: normalizeShowDesignSwitcher(setting.value['showDesignSwitcher'] ??
953
- setting.value['ShowDesignSwitcher']),
954
- };
955
- }
956
- extractHolidaysValue(setting) {
957
- if (!isRecord(setting.value)) {
958
- return { data: [] };
959
- }
960
- const rawData = setting.value['data'];
961
- if (!Array.isArray(rawData)) {
962
- return { data: [] };
963
- }
964
- return {
965
- data: rawData
966
- .map((item) => this.normalizeHolidayItem(item))
967
- .filter((item) => item !== null),
968
- };
969
- }
970
- extractTimezoneValue(setting) {
971
- if (!isRecord(setting.value)) {
972
- return {
973
- region: null,
974
- dateFormat: null,
975
- timeFormat: null,
976
- };
977
- }
978
- return {
979
- region: this.normalizeTimezoneRegion(setting.value['region'] ?? setting.value['Region']),
980
- dateFormat: getNullableString(setting.value['dateFormat'] ??
981
- setting.value['DateFormat'] ??
982
- setting.value['dateformat']),
983
- timeFormat: getNullableString(setting.value['timeFormat'] ??
984
- setting.value['TimeFormat'] ??
985
- setting.value['timeformat']),
986
- };
987
- }
988
- extractCurrencyValue(setting) {
989
- if (!isRecord(setting.value)) {
990
- return this.getDefaultCurrencyValue();
991
- }
992
- return {
993
- name: getString(setting.value['name']) ?? FIXED_CURRENCIES[0].code,
994
- unit: this.normalizeCurrencyUnit(setting.value['unit']),
995
- format: getNullableString(setting.value['format']),
996
- };
997
- }
998
- extractWeekendValue(setting) {
999
- if (!isRecord(setting.value)) {
1000
- return { days: [] };
1001
- }
1002
- return {
1003
- days: normalizeWeekendDays(setting.value['days'] ?? setting.value['Days']),
1004
- };
1005
- }
1006
- extractTimeSheetPolicyValue(setting) {
1007
- if (!isRecord(setting.value)) {
1008
- return this.getDefaultTimeSheetPolicyValue();
1009
- }
1010
- const value = setting.value;
1011
- const defaults = this.getDefaultTimeSheetPolicyValue();
1012
- return {
1013
- frequency: normalizeFrequency(value['frequency'] ?? value['Frequency']),
1014
- maxDailyHours: getNumber(value['maxDailyHours'] ?? value['MaxDailyHours']) ??
1015
- defaults.maxDailyHours,
1016
- requireDescription: getBoolean(value['requireDescription'] ?? value['RequireDescription']) ?? defaults.requireDescription,
1017
- allowFutureEntry: getBoolean(value['allowFutureEntry'] ?? value['AllowFutureEntry']) ??
1018
- defaults.allowFutureEntry,
1019
- allowBackdatedEntry: getBoolean(value['allowBackdatedEntry'] ?? value['AllowBackdatedEntry']) ?? defaults.allowBackdatedEntry,
1020
- autoLockOnApprove: getBoolean(value['autoLockOnApprove'] ?? value['AutoLockOnApprove']) ??
1021
- defaults.autoLockOnApprove,
1022
- submissionDeadlineDays: getNumber(value['submissionDeadlineDays'] ?? value['SubmissionDeadlineDays']) ?? defaults.submissionDeadlineDays,
1023
- };
1024
- }
1025
- extractGlobalWorkingHoursValue(setting) {
1026
- if (!isRecord(setting.value)) {
1027
- return this.getDefaultGlobalWorkingHoursValue();
1028
- }
1029
- const value = setting.value;
1030
- const defaults = this.getDefaultGlobalWorkingHoursValue();
1031
- return {
1032
- timeZoneId: getString(value['timeZoneId'] ?? value['TimeZoneId']) ??
1033
- defaults.timeZoneId,
1034
- workingDays: getNumberArray(value['workingDays'] ?? value['WorkingDays']) ??
1035
- defaults.workingDays,
1036
- hoursPerDay: getNumber(value['hoursPerDay'] ?? value['HoursPerDay']) ??
1037
- defaults.hoursPerDay,
1038
- holidays: getStringArray(value['holidays'] ?? value['Holidays']) ??
1039
- defaults.holidays,
1040
- };
1041
- }
1042
- normalizeHolidayItem(value) {
1043
- if (!isRecord(value)) {
1044
- return null;
1045
- }
1046
- const label = getString(value['label'] ?? value['name']);
1047
- const from = normalizeDateInput(value['from']);
1048
- const to = normalizeDateInput(value['to']);
1049
- if (!label || !from || !to) {
1050
- return null;
1051
- }
1052
- return { label, from, to };
1053
- }
1054
- normalizeTimezoneRegion(value) {
1055
- if (typeof value === 'string' && value.trim()) {
1056
- const normalizedValue = value.trim().toLowerCase();
1057
- const region = this.timezones().find((item) => item.id.trim().toLowerCase() === normalizedValue) ?? null;
1058
- return region
1059
- ? {
1060
- ...region,
1061
- name: region.name ?? region.displayName,
1062
- }
1063
- : null;
1064
- }
1065
- if (!isRecord(value)) {
1066
- return null;
1067
- }
1068
- const id = getString(value['id'] ?? value['Id']);
1069
- if (!id) {
1070
- return null;
1071
- }
1072
- const matchedRegion = this.timezones().find((item) => item.id.trim().toLowerCase() === id.trim().toLowerCase());
1073
- if (matchedRegion) {
1074
- return {
1075
- ...matchedRegion,
1076
- name: getString(value['name'] ?? value['Name']) ??
1077
- matchedRegion.name ??
1078
- matchedRegion.displayName,
1079
- };
1080
- }
1081
- const standardName = getString(value['standardName'] ?? value['StandardName']) ?? id;
1082
- const displayName = getString(value['displayName'] ?? value['DisplayName']) ?? id;
1083
- return {
1084
- id,
1085
- baseUtcOffset: getString(value['baseUtcOffset'] ?? value['BaseUtcOffset']) ?? '',
1086
- standardName,
1087
- displayName,
1088
- daylightName: getString(value['daylightName'] ?? value['DaylightName']) ??
1089
- standardName,
1090
- name: getString(value['name'] ?? value['Name']) ?? displayName,
1091
- };
1092
- }
1093
- normalizeCurrencyUnit(value) {
1094
- if (!isRecord(value)) {
1095
- return FIXED_CURRENCIES[0].unit;
1096
- }
1097
- return {
1098
- en: getString(value['en']) ?? FIXED_CURRENCIES[0].unit.en,
1099
- ar: getString(value['ar']) ?? FIXED_CURRENCIES[0].unit.ar,
1100
- };
1101
- }
1102
- normalizeGeneralConfigurationSnapshot(value) {
1103
- return {
1104
- defaultExploreView: normalizeExploreDefaultView(value.defaultExploreView),
1105
- showDesignSwitcher: normalizeShowDesignSwitcher(value.showDesignSwitcher),
1106
- };
1107
- }
1108
- normalizeTimezoneSnapshot(value) {
1109
- const defaults = this.getDefaultTimezoneValue();
1110
- return {
1111
- region: value.region ?? defaults.region,
1112
- dateFormat: value.dateFormat ?? defaults.dateFormat,
1113
- timeFormat: value.timeFormat ?? defaults.timeFormat,
1114
- };
1115
- }
1116
- normalizeCurrencySnapshot(value) {
1117
- const code = this.resolveCurrencyCode(value);
1118
- const currency = FIXED_CURRENCIES.find((item) => item.code === code) ??
1119
- FIXED_CURRENCIES[0];
1120
- const defaultFormat = this.buildCurrencyFormatOptions(currency)[0]?.id ?? null;
1121
- return {
1122
- name: currency.code,
1123
- unit: currency.unit,
1124
- format: value.format ?? defaultFormat,
1125
- };
1126
- }
1127
- normalizeWeekendSnapshot(value) {
1128
- return {
1129
- days: normalizeWeekendDays(value.days),
1130
- };
1131
- }
1132
- normalizeTimeSheetPolicySnapshot(value, hoursPerDay) {
1133
- return {
1134
- frequency: normalizeFrequency(value.frequency),
1135
- maxDailyHours: Math.max(clampNumber(hoursPerDay, 0, 24), clampNumber(value.maxDailyHours, 1, 24)),
1136
- requireDescription: value.requireDescription,
1137
- allowFutureEntry: value.allowFutureEntry,
1138
- allowBackdatedEntry: value.allowBackdatedEntry,
1139
- autoLockOnApprove: value.autoLockOnApprove,
1140
- submissionDeadlineDays: clampNumber(value.submissionDeadlineDays, 0, 90),
1141
- };
1142
- }
1143
- normalizeGlobalWorkingHoursSnapshot(value) {
1144
- const defaults = this.getDefaultGlobalWorkingHoursValue();
1145
- return {
1146
- timeZoneId: value.timeZoneId || defaults.timeZoneId,
1147
- workingDays: normalizeDotnetDays(value.workingDays),
1148
- hoursPerDay: clampNumber(value.hoursPerDay, 0, 24),
1149
- holidays: value.holidays,
1150
- };
1151
- }
1152
- createFallbackSetting(key) {
1153
- switch (key) {
1154
- case 'Identity':
1155
- return {
1156
- key,
1157
- label: key,
1158
- description: key,
1159
- value: { ...DEFAULT_GENERAL_CONFIGURATION },
1160
- };
1161
- case 'Holidays':
1162
- return { key, label: key, description: key, value: { data: [] } };
1163
- case 'Timezone':
1164
- return {
1165
- key,
1166
- label: key,
1167
- description: key,
1168
- value: this.getDefaultTimezoneValue(),
1169
- };
1170
- case 'Currency':
1171
- return {
1172
- key,
1173
- label: key,
1174
- description: key,
1175
- value: this.getDefaultCurrencyValue(),
1176
- };
1177
- case 'Weekend':
1178
- return { key, label: key, description: key, value: { days: [] } };
1179
- case 'TimeSheetPolicy':
1180
- return {
1181
- key,
1182
- label: key,
1183
- description: key,
1184
- value: this.getDefaultTimeSheetPolicyValue(),
1185
- };
1186
- case 'GlobalWorkingHours':
1187
- return {
1188
- key,
1189
- label: key,
1190
- description: key,
1191
- value: this.getDefaultGlobalWorkingHoursValue(),
1192
- };
1193
- }
1194
- }
1195
- getDefaultTimezoneValue() {
1196
- const region = this.timezones()[0] ?? null;
1197
- const defaultDateFormat = this.dateFormatOptions().find((option) => option.isSelected)?.id ??
1198
- this.dateFormatOptions()[0]?.id ??
1199
- null;
1200
- const defaultTimeFormat = this.timeFormatOptions().find((option) => option.isSelected)?.id ??
1201
- this.timeFormatOptions()[0]?.id ??
1202
- null;
1203
- return {
1204
- region: region
1205
- ? {
1206
- ...region,
1207
- name: region.name ?? region.displayName,
1208
- }
1209
- : null,
1210
- dateFormat: defaultDateFormat,
1211
- timeFormat: defaultTimeFormat,
1212
- };
1213
- }
1214
- getDefaultCurrencyValue() {
1215
- const currency = FIXED_CURRENCIES[0];
1216
- return {
1217
- name: currency.code,
1218
- unit: currency.unit,
1219
- format: this.buildCurrencyFormatOptions(currency)[0]?.id ?? null,
1220
- };
1221
- }
1222
- getDefaultTimeSheetPolicyValue() {
1223
- return {
1224
- frequency: 'Weekly',
1225
- maxDailyHours: 24,
1226
- requireDescription: false,
1227
- allowFutureEntry: false,
1228
- allowBackdatedEntry: true,
1229
- autoLockOnApprove: true,
1230
- submissionDeadlineDays: 3,
1231
- };
1232
- }
1233
- getDefaultGlobalWorkingHoursValue() {
1234
- return {
1235
- timeZoneId: this.timezones()[0]?.id ?? 'UTC',
1236
- workingDays: [0, 1, 2, 3, 4],
1237
- hoursPerDay: 8,
1238
- holidays: [],
1239
- };
1240
- }
1241
- resolveCurrencyCode(value) {
1242
- const candidates = [value.name, value.unit.en, value.unit.ar].filter((candidate) => !!candidate);
1243
- for (const candidate of candidates) {
1244
- const normalizedCandidate = candidate.trim().toLowerCase();
1245
- const extractedCode = candidate.match(/\(([A-Za-z]{3})\)/)?.[1]?.toUpperCase() ?? null;
1246
- if (extractedCode) {
1247
- const directCodeMatch = FIXED_CURRENCIES.find((item) => item.code === extractedCode);
1248
- if (directCodeMatch) {
1249
- return directCodeMatch.code;
1250
- }
1251
- }
1252
- const match = FIXED_CURRENCIES.find((item) => item.code.toLowerCase() === normalizedCandidate ||
1253
- item.englishLabel.toLowerCase() === normalizedCandidate ||
1254
- item.arabicLabel.toLowerCase() === normalizedCandidate ||
1255
- item.unit.en.toLowerCase() === normalizedCandidate ||
1256
- item.unit.ar.toLowerCase() === normalizedCandidate);
1257
- if (match) {
1258
- return match.code;
1259
- }
1260
- }
1261
- return FIXED_CURRENCIES[0].code;
1262
- }
1263
- mapFormatOptions(options, selectedKey) {
1264
- // Read active language so the label re-translates on language switch.
1265
- this.activeLang();
1266
- return options.map((option) => ({
1267
- id: option.key,
1268
- name: this.formatOptionLabel(option.key),
1269
- isSelected: selectedKey ? option.key === selectedKey : option.isSelected,
1270
- }));
1271
- }
1272
- /**
1273
- * Builds a localized, human-readable label for a date/time format key by
1274
- * translating each format token (e.g. `dd-MM-yyyy` → `يوم-شهر-سنة`) while
1275
- * preserving the original separators. Unknown characters are left as-is.
1276
- */
1277
- formatOptionLabel(formatKey) {
1278
- const tokenKeyByLetter = {
1279
- y: 'format-token-year',
1280
- M: 'format-token-month',
1281
- d: 'format-token-day',
1282
- H: 'format-token-hour',
1283
- h: 'format-token-hour',
1284
- m: 'format-token-minute',
1285
- s: 'format-token-second',
1286
- t: 'format-token-period',
1287
- };
1288
- return formatKey.replace(/y+|M+|d+|H+|h+|m+|s+|t+/g, (token) => {
1289
- const translationKey = tokenKeyByLetter[token[0]];
1290
- return translationKey
1291
- ? this.transloco.translate(`system-settings.${translationKey}`)
1292
- : token;
1293
- });
1294
- }
1295
- serializeHolidaysValue(value) {
1296
- return {
1297
- data: value.data.map((item) => ({
1298
- label: item.label,
1299
- from: formatDateOnly(item.from),
1300
- to: formatDateOnly(item.to),
1301
- })),
1302
- };
1303
- }
1304
- buildCurrencyFormatOptions(currency) {
1305
- const unitLabel = this.getCurrencyFormatLabel(currency);
1306
- return [
1307
- { id: '{0:0}', name: `1000 ${unitLabel}` },
1308
- { id: '{0:0.0}', name: `1000.0 ${unitLabel}` },
1309
- { id: '{0:0.00}', name: `1000.00 ${unitLabel}` },
1310
- { id: '{0:#,0}', name: `1,000 ${unitLabel}` },
1311
- { id: '{0:#,0.0}', name: `1,000.0 ${unitLabel}` },
1312
- { id: '{0:#,0.00}', name: `1,000.00 ${unitLabel}` },
1313
- { id: '{0:#,0, K}', name: `1 K ${unitLabel}` },
1314
- { id: '{0:N3}', name: `1,000 N3 ${unitLabel}` },
1315
- ];
1316
- }
1317
- getCurrencyFormatLabel(currency) {
1318
- if (!currency) {
1319
- return '';
1320
- }
1321
- return this.activeLang() === 'ar' ? currency.unit.ar : currency.unit.en;
1322
- }
1323
- buildEndpoint(path) {
1324
- return `${this.apiBasePath().replace(/\/$/, '')}/${path}`;
1325
- }
1326
- applyUpdatedSettings(settings, values) {
1327
- const valueMap = new Map(values.map((item) => [item.key, item.value]));
1328
- const nextSettings = settings.map((setting) => {
1329
- if (!valueMap.has(setting.key)) {
1330
- return setting;
1331
- }
1332
- return {
1333
- ...setting,
1334
- value: valueMap.get(setting.key),
1335
- };
1336
- });
1337
- const existingKeys = new Set(nextSettings.map((setting) => setting.key));
1338
- for (const item of values) {
1339
- if (existingKeys.has(item.key)) {
1340
- continue;
1341
- }
1342
- nextSettings.push({
1343
- key: item.key,
1344
- label: item.key,
1345
- description: item.key,
1346
- value: item.value,
1347
- });
1348
- }
1349
- return nextSettings.sort((left, right) => left.key.localeCompare(right.key));
1350
- }
1351
- areEqual(left, right) {
1352
- return JSON.stringify(left) === JSON.stringify(right);
1353
- }
1354
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: SystemSettings, deps: [], target: i0.ɵɵFactoryTarget.Component });
1355
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: SystemSettings, isStandalone: true, selector: "mt-system-settings", inputs: { apiBasePath: { classPropertyName: "apiBasePath", publicName: "apiBasePath", isSignal: true, isRequired: false, transformFunction: null }, backRoute: { classPropertyName: "backRoute", publicName: "backRoute", isSignal: true, isRequired: false, transformFunction: null }, formatSchema: { classPropertyName: "formatSchema", publicName: "formatSchema", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<ng-container *transloco=\"let t; prefix: 'system-settings'\">\r\n <mt-page\r\n [title]=\"t('page-title')\"\r\n [avatarIcon]=\"'general.settings-02'\"\r\n [avatarStyle]=\"{\r\n '--p-avatar-background': 'var(--p-emerald-100)',\r\n '--p-avatar-color': 'var(--p-emerald-700)',\r\n }\"\r\n (backButtonClick)=\"goBack()\"\r\n backButton\r\n >\r\n <div class=\"flex flex-col gap-3\">\r\n <div\r\n class=\"flex flex-col gap-4 md:flex-row md:items-end md:justify-between\"\r\n >\r\n <div>\r\n <h3 class=\"text-lg font-bold text-neutral-900\">\r\n {{ t(\"page-title\") }}\r\n </h3>\r\n <mt-breadcrumb\r\n [items]=\"breadcrumbItems\"\r\n [styleClass]=\"'flex justify-start mx-1'\"\r\n />\r\n </div>\r\n\r\n <mt-button\r\n [label]=\"t('save')\"\r\n icon=\"general.save-01\"\r\n [tooltip]=\"t('save-tooltip')\"\r\n [badge]=\"hasChanges() ? '!' : ''\"\r\n badgeSeverity=\"warn\"\r\n [loading]=\"updating()\"\r\n [disabled]=\"!canSaveSettings()\"\r\n (onClick)=\"onSave()\"\r\n />\r\n </div>\r\n\r\n @if (isLoading()) {\r\n <div class=\"space-y-4\">\r\n <p-skeleton width=\"100%\" height=\"12rem\" borderRadius=\"0.75rem\" />\r\n <p-skeleton width=\"100%\" height=\"18rem\" borderRadius=\"0.75rem\" />\r\n <p-skeleton width=\"100%\" height=\"14rem\" borderRadius=\"0.75rem\" />\r\n </div>\r\n } @else {\r\n <!--\r\n BE/HTTP errors (timezonesError, settingsError, updateError) are already\r\n surfaced as toasts by the HTTP interceptor, so they are intentionally\r\n not rendered as top-of-page banners here to avoid duplicate messaging.\r\n -->\r\n <div class=\"space-y-6\">\r\n <mt-system-settings-general-section\r\n [generalConfigurationForm]=\"form.controls.generalConfiguration\"\r\n [timezoneForm]=\"form.controls.timezone\"\r\n [currencyForm]=\"form.controls.currency\"\r\n [weekendForm]=\"form.controls.weekend\"\r\n [exploreDefaultViewOptions]=\"exploreDefaultViewOptions()\"\r\n [dateFormatOptions]=\"dateFormatOptions()\"\r\n [timeFormatOptions]=\"timeFormatOptions()\"\r\n [currencyOptions]=\"currencyOptions()\"\r\n [currencyFormatOptions]=\"currencyFormatOptions()\"\r\n [weekendOptions]=\"weekendOptions()\"\r\n />\r\n\r\n <mt-system-settings-timesheet-section\r\n [policyForm]=\"form.controls.timeSheetPolicy\"\r\n [globalWorkingHoursForm]=\"form.controls.globalWorkingHours\"\r\n [dayOptions]=\"dotnetDayOptions()\"\r\n [frequencyOptions]=\"frequencyOptions()\"\r\n [timezoneOptions]=\"timezoneOptions()\"\r\n [maxDailyBelowDaily]=\"form.errors?.['maxDailyBelowDaily'] ?? false\"\r\n />\r\n\r\n <mt-system-settings-holidays-section\r\n [holidays]=\"holidayTableRows()\"\r\n (addHoliday)=\"openAddHoliday()\"\r\n (editHoliday)=\"editHoliday($event)\"\r\n (deleteHoliday)=\"deleteHoliday($event)\"\r\n />\r\n </div>\r\n }\r\n </div>\r\n </mt-page>\r\n</ng-container>\r\n", styles: [":host{display:block}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: TranslocoDirective, selector: "[transloco]", inputs: ["transloco", "translocoParams", "translocoScope", "translocoRead", "translocoPrefix", "translocoLang", "translocoLoadingTpl"] }, { kind: "component", type: Page, selector: "mt-page", inputs: ["backButton", "backButtonIcon", "avatarIcon", "avatarStyle", "avatarShape", "title", "tabs", "activeTab", "contentClass", "contentId"], outputs: ["backButtonClick", "tabChange"] }, { kind: "component", type: Button, selector: "mt-button", inputs: ["icon", "label", "tooltip", "class", "type", "styleClass", "severity", "badge", "variant", "badgeSeverity", "size", "iconPos", "autofocus", "fluid", "raised", "rounded", "text", "plain", "outlined", "link", "disabled", "loading", "pInputs", "ariaLabel"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "component", type: Breadcrumb, selector: "mt-breadcrumb", inputs: ["items", "styleClass"], outputs: ["onItemClick"] }, { kind: "ngmodule", type: SkeletonModule }, { kind: "component", type: i1$1.Skeleton, selector: "p-skeleton", inputs: ["styleClass", "shape", "animation", "borderRadius", "size", "width", "height"] }, { kind: "component", type: SystemSettingsHolidaysSection, selector: "mt-system-settings-holidays-section", inputs: ["holidays"], outputs: ["addHoliday", "editHoliday", "deleteHoliday"] }, { kind: "component", type: SystemSettingsGeneralSection, selector: "mt-system-settings-general-section", inputs: ["generalConfigurationForm", "timezoneForm", "currencyForm", "weekendForm", "exploreDefaultViewOptions", "dateFormatOptions", "timeFormatOptions", "currencyOptions", "currencyFormatOptions", "weekendOptions"] }, { kind: "component", type: SystemSettingsTimeSheetSection, selector: "mt-system-settings-timesheet-section", inputs: ["policyForm", "globalWorkingHoursForm", "dayOptions", "frequencyOptions", "timezoneOptions", "maxDailyBelowDaily"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1356
- }
1357
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: SystemSettings, decorators: [{
1358
- type: Component,
1359
- args: [{ selector: 'mt-system-settings', imports: [
1360
- CommonModule,
1361
- ReactiveFormsModule,
1362
- TranslocoDirective,
1363
- Page,
1364
- Button,
1365
- Breadcrumb,
1366
- SkeletonModule,
1367
- SystemSettingsHolidaysSection,
1368
- SystemSettingsGeneralSection,
1369
- SystemSettingsTimeSheetSection,
1370
- ], changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-container *transloco=\"let t; prefix: 'system-settings'\">\r\n <mt-page\r\n [title]=\"t('page-title')\"\r\n [avatarIcon]=\"'general.settings-02'\"\r\n [avatarStyle]=\"{\r\n '--p-avatar-background': 'var(--p-emerald-100)',\r\n '--p-avatar-color': 'var(--p-emerald-700)',\r\n }\"\r\n (backButtonClick)=\"goBack()\"\r\n backButton\r\n >\r\n <div class=\"flex flex-col gap-3\">\r\n <div\r\n class=\"flex flex-col gap-4 md:flex-row md:items-end md:justify-between\"\r\n >\r\n <div>\r\n <h3 class=\"text-lg font-bold text-neutral-900\">\r\n {{ t(\"page-title\") }}\r\n </h3>\r\n <mt-breadcrumb\r\n [items]=\"breadcrumbItems\"\r\n [styleClass]=\"'flex justify-start mx-1'\"\r\n />\r\n </div>\r\n\r\n <mt-button\r\n [label]=\"t('save')\"\r\n icon=\"general.save-01\"\r\n [tooltip]=\"t('save-tooltip')\"\r\n [badge]=\"hasChanges() ? '!' : ''\"\r\n badgeSeverity=\"warn\"\r\n [loading]=\"updating()\"\r\n [disabled]=\"!canSaveSettings()\"\r\n (onClick)=\"onSave()\"\r\n />\r\n </div>\r\n\r\n @if (isLoading()) {\r\n <div class=\"space-y-4\">\r\n <p-skeleton width=\"100%\" height=\"12rem\" borderRadius=\"0.75rem\" />\r\n <p-skeleton width=\"100%\" height=\"18rem\" borderRadius=\"0.75rem\" />\r\n <p-skeleton width=\"100%\" height=\"14rem\" borderRadius=\"0.75rem\" />\r\n </div>\r\n } @else {\r\n <!--\r\n BE/HTTP errors (timezonesError, settingsError, updateError) are already\r\n surfaced as toasts by the HTTP interceptor, so they are intentionally\r\n not rendered as top-of-page banners here to avoid duplicate messaging.\r\n -->\r\n <div class=\"space-y-6\">\r\n <mt-system-settings-general-section\r\n [generalConfigurationForm]=\"form.controls.generalConfiguration\"\r\n [timezoneForm]=\"form.controls.timezone\"\r\n [currencyForm]=\"form.controls.currency\"\r\n [weekendForm]=\"form.controls.weekend\"\r\n [exploreDefaultViewOptions]=\"exploreDefaultViewOptions()\"\r\n [dateFormatOptions]=\"dateFormatOptions()\"\r\n [timeFormatOptions]=\"timeFormatOptions()\"\r\n [currencyOptions]=\"currencyOptions()\"\r\n [currencyFormatOptions]=\"currencyFormatOptions()\"\r\n [weekendOptions]=\"weekendOptions()\"\r\n />\r\n\r\n <mt-system-settings-timesheet-section\r\n [policyForm]=\"form.controls.timeSheetPolicy\"\r\n [globalWorkingHoursForm]=\"form.controls.globalWorkingHours\"\r\n [dayOptions]=\"dotnetDayOptions()\"\r\n [frequencyOptions]=\"frequencyOptions()\"\r\n [timezoneOptions]=\"timezoneOptions()\"\r\n [maxDailyBelowDaily]=\"form.errors?.['maxDailyBelowDaily'] ?? false\"\r\n />\r\n\r\n <mt-system-settings-holidays-section\r\n [holidays]=\"holidayTableRows()\"\r\n (addHoliday)=\"openAddHoliday()\"\r\n (editHoliday)=\"editHoliday($event)\"\r\n (deleteHoliday)=\"deleteHoliday($event)\"\r\n />\r\n </div>\r\n }\r\n </div>\r\n </mt-page>\r\n</ng-container>\r\n", styles: [":host{display:block}\n"] }]
1371
- }], ctorParameters: () => [], propDecorators: { apiBasePath: [{ type: i0.Input, args: [{ isSignal: true, alias: "apiBasePath", required: false }] }], backRoute: [{ type: i0.Input, args: [{ isSignal: true, alias: "backRoute", required: false }] }], formatSchema: [{ type: i0.Input, args: [{ isSignal: true, alias: "formatSchema", required: false }] }] } });
1372
- function isRecord(value) {
1373
- return typeof value === 'object' && value !== null && !Array.isArray(value);
1374
- }
1375
- function getString(value) {
1376
- if (typeof value !== 'string') {
1377
- return null;
1378
- }
1379
- const normalizedValue = value.trim();
1380
- return normalizedValue ? normalizedValue : null;
1381
- }
1382
- function getNullableString(value) {
1383
- if (typeof value !== 'string') {
1384
- return null;
1385
- }
1386
- return value.trim() || null;
1387
- }
1388
- function getNullableNumber(value) {
1389
- if (typeof value === 'number' && !Number.isNaN(value)) {
1390
- return value;
1391
- }
1392
- if (typeof value === 'string' && value.trim()) {
1393
- const parsedValue = Number(value);
1394
- return Number.isNaN(parsedValue) ? null : parsedValue;
1395
- }
1396
- return null;
1397
- }
1398
- function getNumber(value) {
1399
- return getNullableNumber(value);
1400
- }
1401
- function getBoolean(value) {
1402
- if (typeof value === 'boolean') {
1403
- return value;
1404
- }
1405
- if (typeof value === 'string') {
1406
- const normalizedValue = value.trim().toLowerCase();
1407
- if (normalizedValue === 'true') {
1408
- return true;
1409
- }
1410
- if (normalizedValue === 'false') {
1411
- return false;
1412
- }
1413
- }
1414
- return null;
1415
- }
1416
- function getStringArray(value) {
1417
- if (!Array.isArray(value)) {
1418
- return null;
1419
- }
1420
- return value
1421
- .map((item) => (typeof item === 'string' ? item.trim() : ''))
1422
- .filter(Boolean);
1423
- }
1424
- function getNumberArray(value) {
1425
- if (!Array.isArray(value)) {
1426
- return null;
1427
- }
1428
- return value
1429
- .map((item) => (typeof item === 'number' ? item : Number(item)))
1430
- .filter((item) => Number.isInteger(item));
1431
- }
1432
- /**
1433
- * The design switcher is opt-in, so anything that is not an explicit `true`
1434
- * (or the string a settings record may round-trip it as) reads as hidden.
1435
- */
1436
- function normalizeShowDesignSwitcher(value) {
1437
- return value === true || value === 'true' || value === 'True';
1438
- }
1439
- function normalizeExploreDefaultView(value) {
1440
- return EXPLORE_DEFAULT_VIEW_OPTIONS.some((option) => option.id === value)
1441
- ? value
1442
- : DEFAULT_GENERAL_CONFIGURATION.defaultExploreView;
1443
- }
1444
- function normalizeWeekendDays(value) {
1445
- if (!Array.isArray(value)) {
1446
- return [];
1447
- }
1448
- return value
1449
- .map((item) => (typeof item === 'number' ? item : Number(item)))
1450
- .filter((item) => Number.isInteger(item) && item >= 1 && item <= 7)
1451
- .sort((left, right) => left - right);
1452
- }
1453
- function normalizeDotnetDays(value) {
1454
- if (!Array.isArray(value)) {
1455
- return [];
1456
- }
1457
- return Array.from(new Set(value
1458
- .map((item) => (typeof item === 'number' ? item : Number(item)))
1459
- .filter((item) => Number.isInteger(item) && item >= 0 && item <= 6))).sort((left, right) => left - right);
1460
- }
1461
- function clampNumber(value, min, max) {
1462
- if (!Number.isFinite(value)) {
1463
- return min;
1464
- }
1465
- return Math.min(Math.max(value, min), max);
1466
- }
1467
- const TIMESHEET_FREQUENCIES = [
1468
- 'Daily',
1469
- 'Weekly',
1470
- 'BiWeekly',
1471
- 'Monthly',
1472
- ];
1473
- function normalizeFrequency(value) {
1474
- return typeof value === 'string' &&
1475
- TIMESHEET_FREQUENCIES.includes(value)
1476
- ? value
1477
- : 'Weekly';
1478
- }
1479
- function maxDailyHoursGteHoursPerDay(group) {
1480
- const maxDailyHours = group.get('timeSheetPolicy.maxDailyHours')?.value;
1481
- const hoursPerDay = group.get('globalWorkingHours.hoursPerDay')?.value;
1482
- if (typeof maxDailyHours === 'number' &&
1483
- typeof hoursPerDay === 'number' &&
1484
- maxDailyHours < hoursPerDay) {
1485
- return { maxDailyBelowDaily: true };
1486
- }
1487
- return null;
1488
- }
1489
- function parseCsv(value) {
1490
- return value
1491
- .split(',')
1492
- .map((item) => item.trim())
1493
- .filter(Boolean);
1494
- }
1495
- function normalizeDateInput(value) {
1496
- if (value instanceof Date) {
1497
- if (Number.isNaN(value.getTime())) {
1498
- return null;
1499
- }
1500
- return createLocalDate(value.getFullYear(), value.getMonth() + 1, value.getDate());
1501
- }
1502
- if (typeof value !== 'string') {
1503
- return null;
1504
- }
1505
- const normalizedValue = value.trim();
1506
- if (!normalizedValue) {
1507
- return null;
1508
- }
1509
- const dateOnlyMatch = normalizedValue.match(/^(\d{4})[-/](\d{2})[-/](\d{2})/);
1510
- if (dateOnlyMatch) {
1511
- const [, year, month, day] = dateOnlyMatch;
1512
- return createLocalDate(Number(year), Number(month), Number(day));
1513
- }
1514
- const parsedDate = new Date(normalizedValue);
1515
- if (Number.isNaN(parsedDate.getTime())) {
1516
- return null;
1517
- }
1518
- return createLocalDate(parsedDate.getFullYear(), parsedDate.getMonth() + 1, parsedDate.getDate());
1519
- }
1520
- function createLocalDate(year, month, day) {
1521
- return new Date(year, month - 1, day, 12, 0, 0, 0);
1522
- }
1523
- function formatDateOnly(value) {
1524
- const year = value.getFullYear();
1525
- const month = String(value.getMonth() + 1).padStart(2, '0');
1526
- const day = String(value.getDate()).padStart(2, '0');
1527
- return `${year}-${month}-${day}`;
1528
- }
1529
-
1530
- const EMAIL_DELIVERY_PERMISSIONS = {
1531
- controlPanel: 'CONTROL_PANEL',
1532
- };
1533
- const EMAIL_DELIVERY_ATTEMPT_STATUSES = [
1534
- 'Reserved',
1535
- 'ProviderInvocationStarted',
1536
- 'ProviderInvocationDefinitivelyNotAccepted',
1537
- 'ProviderResultReconciliation',
1538
- 'ProviderResultPending',
1539
- 'Blocked',
1540
- 'RetryScheduled',
1541
- 'Accepted',
1542
- 'OutcomeUnknown',
1543
- 'FailedPermanent',
1544
- 'DeadLettered',
1545
- ];
1546
- /**
1547
- * Activity rows the backend writes for an operator-run controlled test. They
1548
- * carry `templateId: 0`, the caller's original `testRequestId`, and a
1549
- * non-reversible recipient fingerprint instead of any real address. They are
1550
- * presented as "Connection test" and are never replayable — resending a test is
1551
- * an explicit operator action from the connection, not a replay.
1552
- */
1553
- const EMAIL_USER_INITIATED_TEST_OPERATION_KIND = 'UserInitiatedTest';
1554
- function isConnectionTestAttempt(attempt) {
1555
- return attempt.operationKind === EMAIL_USER_INITIATED_TEST_OPERATION_KIND;
1556
- }
1557
-
1558
- const DEFAULT_EMAIL_DELIVERY_OPTIONS = {
1559
- apiBasePath: 'control-panel/email-delivery',
1560
- notificationApiBasePath: 'Notifications',
1561
- permissionKeys: [EMAIL_DELIVERY_PERMISSIONS.controlPanel],
1562
- };
1563
- const EMAIL_DELIVERY_OPTIONS = new InjectionToken('EMAIL_DELIVERY_OPTIONS', {
1564
- providedIn: 'root',
1565
- factory: () => DEFAULT_EMAIL_DELIVERY_OPTIONS,
1566
- });
1567
- function provideEmailDelivery(options = {}) {
1568
- return makeEnvironmentProviders([
1569
- {
1570
- provide: EMAIL_DELIVERY_OPTIONS,
1571
- useValue: { ...DEFAULT_EMAIL_DELIVERY_OPTIONS, ...options },
1572
- },
1573
- ]);
1574
- }
1575
-
1576
- const EMAIL_DELIVERY_ROUTES = [
1577
- {
1578
- path: '',
1579
- loadComponent: () => import('./masterteam-system-settings-email-delivery-shell-Co2SifYp.mjs').then((module) => module.EmailDeliveryShell),
1580
- },
1581
- { path: '**', redirectTo: '' },
1582
- ];
1583
-
1584
- /**
1585
- * Generated bundle index. Do not edit.
1586
- */
1587
-
1588
- export { DEFAULT_DATE_FORMAT_OPTIONS, DEFAULT_EMAIL_DELIVERY_OPTIONS, DEFAULT_GENERAL_CONFIGURATION, DEFAULT_TIME_FORMAT_OPTIONS, DOTNET_DAY_DEFINITIONS, EMAIL_DELIVERY_ATTEMPT_STATUSES, EMAIL_DELIVERY_OPTIONS, EMAIL_DELIVERY_PERMISSIONS, EMAIL_DELIVERY_ROUTES, EMAIL_USER_INITIATED_TEST_OPERATION_KIND, EXPLORE_DEFAULT_VIEW_OPTIONS, FIXED_CURRENCIES, GENERAL_CONFIGURATION_SETTING_KEY, RATE_SOURCE_OPTIONS, SCHEDULE_ITEM_TYPE_OPTIONS, SystemSettings, SystemSettingsHolidayEditor, TIMESHEET_FREQUENCY_OPTIONS, WEEKEND_DAY_DEFINITIONS, isConnectionTestAttempt, provideEmailDelivery };
1
+ export { j as DEFAULT_DATE_FORMAT_OPTIONS, o as DEFAULT_EMAIL_DELIVERY_OPTIONS, D as DEFAULT_GENERAL_CONFIGURATION, k as DEFAULT_TIME_FORMAT_OPTIONS, l as DOTNET_DAY_DEFINITIONS, b as EMAIL_DELIVERY_ATTEMPT_STATUSES, q as EMAIL_DELIVERY_OPTIONS, f as EMAIL_DELIVERY_PERMISSIONS, x as EMAIL_DELIVERY_ROUTES, w as EMAIL_USER_INITIATED_TEST_OPERATION_KIND, h as EXPLORE_DEFAULT_VIEW_OPTIONS, s as EmailDeliveryAccessService, v as EmailUserTestDialog, F as FIXED_CURRENCIES, G as GENERAL_CONFIGURATION_SETTING_KEY, R as RATE_SOURCE_OPTIONS, m as SCHEDULE_ITEM_TYPE_OPTIONS, S as SystemSettings, n as SystemSettingsHolidayEditor, T as TIMESHEET_FREQUENCY_OPTIONS, W as WEEKEND_DAY_DEFINITIONS, d as areEmailTestRecipientsValid, u as buildEmailTemplatePlaceholderFields, t as collectEmailTemplatePlaceholders, c as createEmailTestRequestId, i as isConnectionTestAttempt, e as isEmailTestRequestPending, p as parseEmailTestRecipients, r as provideEmailDelivery } from './masterteam-system-settings-masterteam-system-settings-CO-XTJOi.mjs';
1589
2
  //# sourceMappingURL=masterteam-system-settings.mjs.map