@masterteam/system-settings 0.0.21 → 0.0.22

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.
@@ -489,7 +489,7 @@ class SystemSettings {
489
489
  nonNullable: true,
490
490
  validators: GLOBAL_WORKING_HOURS_WORKING_DAYS_VALIDATORS,
491
491
  }),
492
- hoursPerDay: new FormControl(8, GLOBAL_WORKING_HOURS_HOURS_PER_DAY_VALIDATORS),
492
+ hoursPerDay: new FormControl(8, this.buildHoursPerDayValidators()),
493
493
  holidaysCsv: new FormControl('', { nonNullable: true }),
494
494
  }),
495
495
  }, maxDailyHoursGteHoursPerDay(() => this.hideTimeSheet()));
@@ -1013,6 +1013,21 @@ class SystemSettings {
1013
1013
  holidays: parseCsv(globalForm.holidaysCsv),
1014
1014
  };
1015
1015
  }
1016
+ /**
1017
+ * Built via a method (not a module-level constant like the other
1018
+ * GlobalWorkingHours/TimeSheet validator arrays) because
1019
+ * `greaterThanZeroValidator` needs `this.transloco` to resolve its message
1020
+ * - safe to call from the `form` field initializer since `transloco` is
1021
+ * declared and `inject()`-ed earlier in the class body and field
1022
+ * initializers run in declaration order.
1023
+ */
1024
+ buildHoursPerDayValidators() {
1025
+ return [
1026
+ Validators.required,
1027
+ greaterThanZeroValidator(() => this.transloco.translate('system-settings.daily-working-hours-min-message')),
1028
+ Validators.max(24),
1029
+ ];
1030
+ }
1016
1031
  findSettingByKey(key) {
1017
1032
  const normalizedKey = key.trim().toLowerCase();
1018
1033
  return (this.settings()?.find((setting) => setting.key.trim().toLowerCase() === normalizedKey) ?? null);
@@ -1618,11 +1633,32 @@ const TIME_SHEET_SUBMISSION_DEADLINE_VALIDATORS = [
1618
1633
  ];
1619
1634
  const GLOBAL_WORKING_HOURS_TIMEZONE_VALIDATORS = [Validators.required];
1620
1635
  const GLOBAL_WORKING_HOURS_WORKING_DAYS_VALIDATORS = [Validators.required];
1621
- const GLOBAL_WORKING_HOURS_HOURS_PER_DAY_VALIDATORS = [
1622
- Validators.required,
1623
- Validators.min(0),
1624
- Validators.max(24),
1625
- ];
1636
+ /**
1637
+ * `hoursPerDay` ("Daily Working Hours") needs an *exclusive* lower bound -
1638
+ * `0` itself must be rejected, unlike every other range on this page which
1639
+ * uses Angular's inclusive `Validators.min`. There's no built-in "greater
1640
+ * than" validator, and reusing `Validators.min(0)`'s error would render the
1641
+ * wrong message ("must be at least 0" on a control that just rejected 0), so
1642
+ * this returns a distinct `dailyWorkingHoursMin` error carrying its own
1643
+ * pre-translated `.message` - `ErrorMessagePipe` prefers a `.message` on the
1644
+ * error object over its generic per-key translations (see
1645
+ * `field-validation/error-message.pipe.ts`), so no changes are needed there
1646
+ * or to its shared i18n keys.
1647
+ *
1648
+ * Mirrors `Validators.min`'s own null-handling: an empty control is left to
1649
+ * `Validators.required` rather than also failing this check.
1650
+ */
1651
+ function greaterThanZeroValidator(message) {
1652
+ return (control) => {
1653
+ const value = control.value;
1654
+ if (value === null || value === undefined || value === '') {
1655
+ return null;
1656
+ }
1657
+ return typeof value === 'number' && value > 0
1658
+ ? null
1659
+ : { dailyWorkingHoursMin: { min: 0, message: message() } };
1660
+ };
1661
+ }
1626
1662
  /**
1627
1663
  * Cross-field validator comparing `timeSheetPolicy.maxDailyHours` against
1628
1664
  * `globalWorkingHours.hoursPerDay`. Takes the `hideTimeSheet` input as a
@@ -2853,7 +2889,7 @@ function isTestRequestConflict(error) {
2853
2889
  const EMAIL_DELIVERY_ROUTES = [
2854
2890
  {
2855
2891
  path: '',
2856
- loadComponent: () => import('./masterteam-system-settings-email-delivery-shell-CR2wsIif.mjs').then((module) => module.EmailDeliveryShell),
2892
+ loadComponent: () => import('./masterteam-system-settings-email-delivery-shell-oTWOzKWj.mjs').then((module) => module.EmailDeliveryShell),
2857
2893
  },
2858
2894
  { path: '**', redirectTo: '' },
2859
2895
  ];
@@ -2863,4 +2899,4 @@ const EMAIL_DELIVERY_ROUTES = [
2863
2899
  */
2864
2900
 
2865
2901
  export { DEFAULT_GENERAL_CONFIGURATION as D, EmailDeliveryFacade as E, FIXED_CURRENCIES as F, GENERAL_CONFIGURATION_SETTING_KEY as G, RATE_SOURCE_OPTIONS as R, SystemSettings as S, TIMESHEET_FREQUENCY_OPTIONS as T, WEEKEND_DAY_DEFINITIONS as W, EmailDeliveryStatus as a, EMAIL_DELIVERY_ATTEMPT_STATUSES as b, createEmailTestRequestId as c, areEmailTestRecipientsValid as d, isEmailTestRequestPending as e, EMAIL_DELIVERY_PERMISSIONS as f, getEmailDeliveryStatusMap as g, EXPLORE_DEFAULT_VIEW_OPTIONS as h, isConnectionTestAttempt as i, DEFAULT_DATE_FORMAT_OPTIONS as j, DEFAULT_TIME_FORMAT_OPTIONS as k, DOTNET_DAY_DEFINITIONS as l, SCHEDULE_ITEM_TYPE_OPTIONS as m, SystemSettingsHolidayEditor as n, DEFAULT_EMAIL_DELIVERY_OPTIONS as o, parseEmailTestRecipients as p, EMAIL_DELIVERY_OPTIONS as q, provideEmailDelivery as r, EmailDeliveryAccessService as s, collectEmailTemplatePlaceholders as t, buildEmailTemplatePlaceholderFields as u, EmailUserTestDialog as v, EMAIL_USER_INITIATED_TEST_OPERATION_KIND as w, EMAIL_DELIVERY_ROUTES as x };
2866
- //# sourceMappingURL=masterteam-system-settings-masterteam-system-settings-DBy-LQB0.mjs.map
2902
+ //# sourceMappingURL=masterteam-system-settings-masterteam-system-settings-7I4TfgwP.mjs.map