@masterteam/system-settings 0.0.13 → 0.0.14

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.
@@ -18,28 +18,34 @@ import { Card } from '@masterteam/components/card';
18
18
  import { MultiSelectField } from '@masterteam/components/multi-select-field';
19
19
  import { SelectField } from '@masterteam/components/select-field';
20
20
  import { RadioCardsField } from '@masterteam/components/radio-cards-field';
21
+ import { ToggleField } from '@masterteam/components/toggle-field';
21
22
  import { ModalRef } from '@masterteam/components/dialog';
22
23
  import { DateField } from '@masterteam/components/date-field';
23
24
  import { TextField } from '@masterteam/components/text-field';
24
25
  import { Table } from '@masterteam/components/table';
25
26
  import { NumberField } from '@masterteam/components/number-field';
26
27
  import { TextareaField } from '@masterteam/components/textarea-field';
27
- import { ToggleField } from '@masterteam/components/toggle-field';
28
28
 
29
29
  /**
30
- * "General Configuration" — product-wide application behaviour that is not tied
31
- * to a specific feature area. Currently holds the explore landing view; more
32
- * entries are expected to land in this card.
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
33
  */
34
34
  class SystemSettingsGeneralConfigSection {
35
35
  generalConfigurationForm = input.required(...(ngDevMode ? [{ debugName: "generalConfigurationForm" }] : /* istanbul ignore next */ []));
36
36
  exploreDefaultViewOptions = input([], ...(ngDevMode ? [{ debugName: "exploreDefaultViewOptions" }] : /* istanbul ignore next */ []));
37
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'\">\n <mt-card class=\"block\">\n <div [formGroup]=\"generalConfigurationForm()\" class=\"space-y-5\">\n <div class=\"space-y-1\">\n <h4 class=\"text-base font-semibold text-neutral-900\">\n {{ t(\"general-configuration-title\") }}\n </h4>\n <p class=\"text-sm text-neutral-600\">\n {{ t(\"general-configuration-description\") }}\n </p>\n </div>\n\n <mt-radio-cards-field\n formControlName=\"defaultExploreView\"\n [options]=\"exploreDefaultViewOptions()\"\n [optionLabel]=\"'name'\"\n [optionValue]=\"'id'\"\n [label]=\"t('explore-default-view')\"\n [hint]=\"t('explore-default-view-hint')\"\n [required]=\"true\"\n size=\"small\"\n />\n </div>\n </mt-card>\n</ng-container>\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"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
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'\">\n <mt-card class=\"block\">\n <div [formGroup]=\"generalConfigurationForm()\" class=\"space-y-5\">\n <div class=\"space-y-1\">\n <h4 class=\"text-base font-semibold text-neutral-900\">\n {{ t(\"general-configuration-title\") }}\n </h4>\n <p class=\"text-sm text-neutral-600\">\n {{ t(\"general-configuration-description\") }}\n </p>\n </div>\n\n <mt-radio-cards-field\n formControlName=\"defaultExploreView\"\n [options]=\"exploreDefaultViewOptions()\"\n [optionLabel]=\"'name'\"\n [optionValue]=\"'id'\"\n [label]=\"t('explore-default-view')\"\n [hint]=\"t('explore-default-view-hint')\"\n [required]=\"true\"\n size=\"small\"\n />\n\n <div class=\"space-y-1\">\n <mt-toggle-field\n formControlName=\"showDesignSwitcher\"\n [label]=\"t('design-switcher')\"\n />\n <p class=\"text-sm text-neutral-600\">\n {{ t(\"design-switcher-hint\") }}\n </p>\n </div>\n </div>\n </mt-card>\n</ng-container>\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
39
  }
40
40
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: SystemSettingsGeneralConfigSection, decorators: [{
41
41
  type: Component,
42
- args: [{ selector: 'mt-system-settings-general-config-section', imports: [ReactiveFormsModule, TranslocoDirective, Card, RadioCardsField], changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-container *transloco=\"let t; prefix: 'system-settings'\">\n <mt-card class=\"block\">\n <div [formGroup]=\"generalConfigurationForm()\" class=\"space-y-5\">\n <div class=\"space-y-1\">\n <h4 class=\"text-base font-semibold text-neutral-900\">\n {{ t(\"general-configuration-title\") }}\n </h4>\n <p class=\"text-sm text-neutral-600\">\n {{ t(\"general-configuration-description\") }}\n </p>\n </div>\n\n <mt-radio-cards-field\n formControlName=\"defaultExploreView\"\n [options]=\"exploreDefaultViewOptions()\"\n [optionLabel]=\"'name'\"\n [optionValue]=\"'id'\"\n [label]=\"t('explore-default-view')\"\n [hint]=\"t('explore-default-view-hint')\"\n [required]=\"true\"\n size=\"small\"\n />\n </div>\n </mt-card>\n</ng-container>\n", styles: [":host{display:block;height:100%}mt-card{height:100%}\n"] }]
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'\">\n <mt-card class=\"block\">\n <div [formGroup]=\"generalConfigurationForm()\" class=\"space-y-5\">\n <div class=\"space-y-1\">\n <h4 class=\"text-base font-semibold text-neutral-900\">\n {{ t(\"general-configuration-title\") }}\n </h4>\n <p class=\"text-sm text-neutral-600\">\n {{ t(\"general-configuration-description\") }}\n </p>\n </div>\n\n <mt-radio-cards-field\n formControlName=\"defaultExploreView\"\n [options]=\"exploreDefaultViewOptions()\"\n [optionLabel]=\"'name'\"\n [optionValue]=\"'id'\"\n [label]=\"t('explore-default-view')\"\n [hint]=\"t('explore-default-view-hint')\"\n [required]=\"true\"\n size=\"small\"\n />\n\n <div class=\"space-y-1\">\n <mt-toggle-field\n formControlName=\"showDesignSwitcher\"\n [label]=\"t('design-switcher')\"\n />\n <p class=\"text-sm text-neutral-600\">\n {{ t(\"design-switcher-hint\") }}\n </p>\n </div>\n </div>\n </mt-card>\n</ng-container>\n", styles: [":host{display:block;height:100%}mt-card{height:100%}\n"] }]
43
49
  }], propDecorators: { generalConfigurationForm: [{ type: i0.Input, args: [{ isSignal: true, alias: "generalConfigurationForm", required: true }] }], exploreDefaultViewOptions: [{ type: i0.Input, args: [{ isSignal: true, alias: "exploreDefaultViewOptions", required: false }] }] } });
44
50
 
45
51
  class SystemSettingsGeneralSection {
@@ -267,6 +273,7 @@ const EXPLORE_DEFAULT_VIEW_OPTIONS = [
267
273
  ];
268
274
  const DEFAULT_GENERAL_CONFIGURATION = {
269
275
  defaultExploreView: 'cards',
276
+ showDesignSwitcher: false,
270
277
  };
271
278
  const DEFAULT_DATE_FORMAT_OPTIONS = [
272
279
  {
@@ -404,6 +411,9 @@ class SystemSettings {
404
411
  nonNullable: true,
405
412
  validators: [Validators.required],
406
413
  }),
414
+ showDesignSwitcher: new FormControl(false, {
415
+ nonNullable: true,
416
+ }),
407
417
  }),
408
418
  timezone: new FormGroup({
409
419
  regionId: new FormControl(null, Validators.required),
@@ -786,6 +796,7 @@ class SystemSettings {
786
796
  this.holidayItems.set(holidays.data);
787
797
  this.form.controls.generalConfiguration.setValue({
788
798
  defaultExploreView: generalConfiguration.defaultExploreView,
799
+ showDesignSwitcher: generalConfiguration.showDesignSwitcher,
789
800
  });
790
801
  this.form.controls.timezone.setValue({
791
802
  regionId: timezone.region?.id ?? null,
@@ -896,6 +907,8 @@ class SystemSettings {
896
907
  return {
897
908
  defaultExploreView: normalizeExploreDefaultView(this.form.controls.generalConfiguration.controls.defaultExploreView
898
909
  .value),
910
+ showDesignSwitcher: this.form.controls.generalConfiguration.controls.showDesignSwitcher
911
+ .value === true,
899
912
  };
900
913
  }
901
914
  buildWeekendValue() {
@@ -936,6 +949,8 @@ class SystemSettings {
936
949
  return {
937
950
  defaultExploreView: normalizeExploreDefaultView(setting.value['defaultExploreView'] ??
938
951
  setting.value['DefaultExploreView']),
952
+ showDesignSwitcher: normalizeShowDesignSwitcher(setting.value['showDesignSwitcher'] ??
953
+ setting.value['ShowDesignSwitcher']),
939
954
  };
940
955
  }
941
956
  extractHolidaysValue(setting) {
@@ -1087,6 +1102,7 @@ class SystemSettings {
1087
1102
  normalizeGeneralConfigurationSnapshot(value) {
1088
1103
  return {
1089
1104
  defaultExploreView: normalizeExploreDefaultView(value.defaultExploreView),
1105
+ showDesignSwitcher: normalizeShowDesignSwitcher(value.showDesignSwitcher),
1090
1106
  };
1091
1107
  }
1092
1108
  normalizeTimezoneSnapshot(value) {
@@ -1413,6 +1429,13 @@ function getNumberArray(value) {
1413
1429
  .map((item) => (typeof item === 'number' ? item : Number(item)))
1414
1430
  .filter((item) => Number.isInteger(item));
1415
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
+ }
1416
1439
  function normalizeExploreDefaultView(value) {
1417
1440
  return EXPLORE_DEFAULT_VIEW_OPTIONS.some((option) => option.id === value)
1418
1441
  ? value