@dative-gpi/foundation-shared-components 1.0.36 → 1.0.37-report-v1

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.
Files changed (271) hide show
  1. package/components/FSBreadcrumbs.vue +21 -12
  2. package/components/FSButton.vue +10 -10
  3. package/components/FSCalendar.vue +52 -14
  4. package/components/FSCalendarTwin.vue +96 -40
  5. package/components/FSCard.vue +28 -7
  6. package/components/FSCardPlaceholder.vue +8 -5
  7. package/components/FSChip.vue +12 -2
  8. package/components/FSClickable.vue +12 -13
  9. package/components/FSClock.vue +16 -7
  10. package/components/FSColorIcon.vue +23 -5
  11. package/components/FSDialog.vue +2 -1
  12. package/components/FSDialogContent.vue +12 -11
  13. package/components/FSDialogForm.vue +22 -2
  14. package/components/FSDialogFormBody.vue +47 -28
  15. package/components/FSDialogMenu.vue +17 -8
  16. package/components/FSDialogMultiFormBody.vue +77 -54
  17. package/components/FSDialogRemove.vue +8 -8
  18. package/components/FSDialogSubmit.vue +17 -8
  19. package/components/FSEditImage.vue +1 -1
  20. package/components/FSEditImageUI.vue +20 -10
  21. package/components/FSFadeOut.vue +53 -21
  22. package/components/FSForm.vue +10 -8
  23. package/components/FSGrid.vue +1 -1
  24. package/components/FSIcon.vue +2 -1
  25. package/components/FSIconCard.vue +47 -7
  26. package/components/FSImage.vue +12 -4
  27. package/components/FSImageUI.vue +8 -15
  28. package/components/FSInstantPicker.vue +266 -0
  29. package/components/FSLink.vue +25 -9
  30. package/components/FSLoader.vue +28 -11
  31. package/components/FSOptionGroup.vue +51 -3
  32. package/components/FSPlayButtons.vue +72 -0
  33. package/components/FSProgressBar.vue +94 -0
  34. package/components/FSRouterLink.vue +42 -0
  35. package/components/FSSlideGroup.vue +19 -5
  36. package/components/FSSpan.vue +17 -7
  37. package/components/FSSwitch.vue +57 -27
  38. package/components/FSTab.vue +15 -13
  39. package/components/FSTabs.vue +32 -7
  40. package/components/FSTag.vue +14 -3
  41. package/components/FSTagGroup.vue +1 -1
  42. package/components/FSText.vue +11 -7
  43. package/components/FSWindow.vue +128 -4
  44. package/components/FSWrapGroup.vue +13 -1
  45. package/components/agenda/FSAgenda.vue +223 -0
  46. package/components/agenda/FSAgendaDialogCalendar.vue +76 -0
  47. package/components/agenda/FSAgendaHeader.vue +215 -0
  48. package/components/agenda/FSAgendaHorizontalEvent.vue +174 -0
  49. package/components/agenda/FSAgendaHorizontalTimeLineMarker.vue +46 -0
  50. package/components/agenda/FSAgendaHoursCol.vue +103 -0
  51. package/components/agenda/FSAgendaHoursRow.vue +164 -0
  52. package/components/agenda/FSAgendaVerticalEvent.vue +160 -0
  53. package/components/agenda/FSAgendaVerticalTimeLineMarker.vue +46 -0
  54. package/components/agenda/FSDayAgenda.vue +199 -0
  55. package/components/agenda/FSMonthAgenda.vue +252 -0
  56. package/components/agenda/FSSelectAgendaMode.vue +54 -0
  57. package/components/agenda/FSWeekAgenda.vue +323 -0
  58. package/components/autocompletes/FSAutoCompleteAddress.vue +22 -20
  59. package/components/autocompletes/FSAutocompleteLanguage.vue +7 -1
  60. package/components/autocompletes/FSAutocompleteTimeZone.vue +7 -1
  61. package/components/buttons/FSButtonAdd.vue +1 -1
  62. package/components/buttons/FSButtonAddLabel.vue +1 -1
  63. package/components/buttons/FSButtonCancel.vue +1 -1
  64. package/components/buttons/FSButtonCancelLabel.vue +1 -1
  65. package/components/buttons/FSButtonCopy.vue +1 -1
  66. package/components/buttons/FSButtonCopyLabel.vue +1 -1
  67. package/components/buttons/FSButtonDragIcon.vue +27 -0
  68. package/components/buttons/FSButtonDuplicate.vue +1 -1
  69. package/components/buttons/FSButtonDuplicateLabel.vue +1 -1
  70. package/components/buttons/FSButtonEdit.vue +1 -1
  71. package/components/buttons/FSButtonEditLabel.vue +1 -1
  72. package/components/buttons/FSButtonFile.vue +1 -1
  73. package/components/buttons/FSButtonFileLabel.vue +1 -1
  74. package/components/buttons/FSButtonNext.vue +1 -1
  75. package/components/buttons/FSButtonNextLabel.vue +1 -1
  76. package/components/buttons/FSButtonPrevious.vue +1 -1
  77. package/components/buttons/FSButtonPreviousLabel.vue +1 -1
  78. package/components/buttons/FSButtonRedo.vue +1 -1
  79. package/components/buttons/FSButtonRedoLabel.vue +1 -1
  80. package/components/buttons/FSButtonRemove.vue +1 -1
  81. package/components/buttons/FSButtonRemoveLabel.vue +1 -1
  82. package/components/buttons/FSButtonSave.vue +1 -1
  83. package/components/buttons/FSButtonSaveLabel.vue +1 -1
  84. package/components/buttons/FSButtonSearch.vue +1 -1
  85. package/components/buttons/FSButtonSearchLabel.vue +1 -1
  86. package/components/buttons/FSButtonUndo.vue +1 -1
  87. package/components/buttons/FSButtonUndoLabel.vue +1 -1
  88. package/components/buttons/FSButtonUpdate.vue +1 -1
  89. package/components/buttons/FSButtonUpdateLabel.vue +1 -1
  90. package/components/buttons/FSButtonValidate.vue +1 -1
  91. package/components/buttons/FSButtonValidateLabel.vue +1 -1
  92. package/components/calendar/FSSimpleCalendar.vue +145 -0
  93. package/components/calendar/FSSimpleCalendarHeader.vue +60 -0
  94. package/components/calendar/FSSimpleMonthSelector.vue +138 -0
  95. package/components/deviceOrganisations/FSConnectivity.vue +11 -1
  96. package/components/deviceOrganisations/FSConnectivityCard.vue +19 -47
  97. package/components/deviceOrganisations/FSStatus.vue +11 -1
  98. package/components/deviceOrganisations/FSStatusCard.vue +35 -61
  99. package/components/deviceOrganisations/FSStatusesCarousel.vue +1 -0
  100. package/components/deviceOrganisations/FSStatusesRow.vue +9 -3
  101. package/components/deviceOrganisations/FSWorstAlert.vue +30 -37
  102. package/components/deviceOrganisations/FSWorstAlertCard.vue +36 -85
  103. package/components/fields/FSAutocompleteField.vue +445 -463
  104. package/components/fields/FSAutocompleteTag.vue +1 -1
  105. package/components/fields/FSBaseField.vue +44 -27
  106. package/components/fields/FSColorField.vue +42 -39
  107. package/components/fields/FSCommentField.vue +105 -0
  108. package/components/fields/FSDateField.vue +3 -2
  109. package/components/fields/FSDateRangeField.vue +3 -2
  110. package/components/fields/FSDateTimeField.vue +4 -3
  111. package/components/fields/FSDateTimeRangeField.vue +8 -6
  112. package/components/fields/FSEntityFieldUI.vue +271 -0
  113. package/components/fields/FSGradientField.vue +27 -33
  114. package/components/fields/FSIconField.vue +0 -1
  115. package/components/fields/FSMagicConfigField.vue +10 -3
  116. package/components/fields/FSMagicField.vue +9 -4
  117. package/components/fields/FSNumberField.vue +6 -1
  118. package/components/fields/FSRichTextField.vue +102 -52
  119. package/components/fields/FSSearchField.vue +9 -115
  120. package/components/fields/FSSelectField.vue +477 -252
  121. package/components/fields/FSTagField.vue +1 -1
  122. package/components/fields/FSTermField.vue +42 -17
  123. package/components/fields/FSTextArea.vue +26 -7
  124. package/components/fields/FSTextField.vue +8 -3
  125. package/components/fields/FSTimeRangeField.vue +304 -0
  126. package/components/fields/FSTimeStepField.vue +3 -3
  127. package/components/fields/FSTranslateField.vue +4 -3
  128. package/components/fields/FSTranslateRichTextField.vue +32 -12
  129. package/components/fields/FSTranslateTextArea.vue +233 -0
  130. package/components/fields/periodicField/FSPeriodicDailyField.vue +2 -2
  131. package/components/fields/periodicField/FSPeriodicField.vue +8 -8
  132. package/components/fields/periodicField/FSPeriodicMonthlyField.vue +8 -8
  133. package/components/fields/periodicField/FSPeriodicWeeklyField.vue +23 -13
  134. package/components/fields/periodicField/FSPeriodicYearlyField.vue +6 -6
  135. package/components/lists/FSDataTableUI.vue +173 -103
  136. package/components/lists/FSDraggable.vue +2 -2
  137. package/components/lists/FSFilterButton.vue +7 -11
  138. package/components/lists/FSHeaderButton.vue +4 -4
  139. package/components/lists/FSHiddenButton.vue +3 -5
  140. package/components/lists/FSLoadDataTable.vue +10 -7
  141. package/components/lists/FSSimpleList.vue +234 -0
  142. package/components/lists/FSSimpleListItem.vue +132 -0
  143. package/components/map/FSMap.vue +83 -33
  144. package/components/map/FSMapFeatureGroup.vue +2 -2
  145. package/components/map/FSMapLayerButton.vue +3 -3
  146. package/components/map/FSMapMarker.vue +11 -7
  147. package/components/map/FSMapMarkerClusterGroup.vue +8 -3
  148. package/components/map/FSMapOverlay.vue +37 -20
  149. package/components/map/FSMapPolygon.vue +5 -5
  150. package/components/map/FSMapTileLayer.vue +2 -2
  151. package/components/map/keys.ts +3 -3
  152. package/components/selects/FSSelectAutoRefresh.vue +9 -9
  153. package/components/selects/FSSelectDashboardVariableType.vue +5 -4
  154. package/components/selects/FSSelectDateSetting.vue +3 -2
  155. package/components/selects/FSSelectDays.vue +9 -9
  156. package/components/selects/FSSelectListMode.vue +51 -0
  157. package/components/selects/FSSelectMonths.vue +14 -14
  158. package/components/selects/chartSelectors/FSAggregationSelector.vue +52 -0
  159. package/components/selects/chartSelectors/FSAxisTypeSelector.vue +49 -0
  160. package/components/selects/chartSelectors/FSDisplayAsSelector.vue +53 -0
  161. package/components/selects/chartSelectors/FSFilterTypeSelector.vue +54 -0
  162. package/components/selects/chartSelectors/FSHeatmapRuleSelector.vue +54 -0
  163. package/components/selects/chartSelectors/FSOperationOnSelector.vue +53 -0
  164. package/components/selects/chartSelectors/FSPlanningTypeSelector.vue +53 -0
  165. package/components/selects/chartSelectors/FSPlotPerSelector.vue +52 -0
  166. package/components/selects/chartSelectors/FSSelectEntityType.vue +59 -0
  167. package/components/selects/chartSelectors/FSSerieTypeSelector.vue +53 -0
  168. package/components/tiles/FSAlertTileUI.vue +90 -0
  169. package/components/tiles/FSChartTileUI.vue +111 -0
  170. package/components/tiles/FSCommentTileUI.vue +174 -0
  171. package/components/tiles/FSDeviceOrganisationTileUI.vue +6 -0
  172. package/components/tiles/FSGroupTileUI.vue +2 -2
  173. package/components/tiles/FSLoadTile.vue +2 -0
  174. package/components/tiles/FSLocationTileUI.vue +192 -0
  175. package/components/tiles/FSModelTileUI.vue +18 -0
  176. package/components/tiles/FSSimpleTileUI.vue +9 -4
  177. package/components/tiles/FSTile.vue +93 -74
  178. package/components/tiles/FSUserOrganisationTileUI.vue +1 -1
  179. package/components/toggleSets/FSToggleSetPosition.vue +2 -2
  180. package/components/views/FSBaseView.vue +64 -0
  181. package/components/views/FSEntityView.vue +12 -140
  182. package/components/views/FSSimpleView.vue +29 -0
  183. package/components/views/desktop/FSBaseDefaultDesktopView.vue +135 -0
  184. package/components/views/desktop/FSBaseDesktopView.vue +53 -0
  185. package/components/views/desktop/FSBaseEntityDesktopView.vue +209 -0
  186. package/components/views/mobile/FSBaseDefaultMobileView.vue +133 -0
  187. package/components/views/mobile/FSBaseEntityMobileView.vue +199 -0
  188. package/components/views/mobile/FSBaseMobileView.vue +53 -0
  189. package/composables/useBreakpoints.ts +39 -3
  190. package/composables/useColors.ts +3 -2
  191. package/composables/useMagicFieldProvider.ts +1 -0
  192. package/composables/useSlots.ts +2 -1
  193. package/models/agenda.ts +9 -0
  194. package/models/deviceAlerts.ts +1 -1
  195. package/models/deviceConnectivities.ts +1 -1
  196. package/models/index.ts +1 -0
  197. package/models/magicFields.ts +1 -0
  198. package/models/map.ts +2 -2
  199. package/models/rules.ts +8 -5
  200. package/models/tables.ts +5 -2
  201. package/models/variableNode.ts +8 -5
  202. package/package.json +5 -5
  203. package/styles/components/fs_agenda.scss +36 -0
  204. package/styles/components/fs_agenda_event.scss +41 -0
  205. package/styles/components/fs_agenda_hours_col.scss +4 -0
  206. package/styles/components/fs_agenda_hours_row.scss +5 -0
  207. package/styles/components/fs_agenda_time_line_marker.scss +19 -0
  208. package/styles/components/fs_autocomplete_field.scss +0 -13
  209. package/styles/components/fs_breadcrumbs.scss +18 -36
  210. package/styles/components/fs_button.scss +7 -5
  211. package/styles/components/fs_chip.scss +8 -6
  212. package/styles/components/fs_clickable.scss +18 -23
  213. package/styles/components/fs_clock.scss +0 -10
  214. package/styles/components/fs_color_field.scss +1 -4
  215. package/styles/components/fs_data_iterator_item.scss +12 -10
  216. package/styles/components/fs_data_table.scss +6 -9
  217. package/styles/components/fs_dialog.scss +7 -17
  218. package/styles/components/fs_dialog_menu.scss +4 -2
  219. package/styles/components/fs_edit_image.scss +8 -0
  220. package/styles/components/fs_fade_out.scss +10 -2
  221. package/styles/components/fs_filter_button.scss +1 -6
  222. package/styles/components/fs_gradient_field.scss +11 -11
  223. package/styles/components/fs_hidden_button.scss +2 -7
  224. package/styles/components/fs_image_card.scss +6 -4
  225. package/styles/components/fs_magic_config_field.scss +1 -2
  226. package/styles/components/fs_map.scss +11 -7
  227. package/styles/components/fs_meta_field.scss +3 -5
  228. package/styles/components/fs_option_group.scss +15 -5
  229. package/styles/components/fs_password_field.scss +4 -2
  230. package/styles/components/fs_progress_bar.scss +14 -0
  231. package/styles/components/fs_radio.scss +0 -11
  232. package/styles/components/fs_rich_text_field.scss +1 -9
  233. package/styles/components/fs_select_date_settings.scss +3 -0
  234. package/styles/components/fs_select_field.scss +4 -13
  235. package/styles/components/fs_slide_group.scss +7 -0
  236. package/styles/components/fs_span.scss +13 -4
  237. package/styles/components/fs_switch.scss +1 -0
  238. package/styles/components/fs_tabs.scss +19 -33
  239. package/styles/components/fs_tag.scss +8 -22
  240. package/styles/components/fs_text_area.scss +13 -17
  241. package/styles/components/fs_tile.scss +21 -15
  242. package/styles/components/fs_window.scss +7 -0
  243. package/styles/components/fs_wrap_group.scss +7 -0
  244. package/styles/components/index.scss +6 -4
  245. package/styles/globals/index.scss +1 -5
  246. package/styles/globals/overrides.scss +28 -61
  247. package/styles/globals/scrollbars.scss +10 -0
  248. package/styles/globals/text_fonts.scss +18 -66
  249. package/tools/alertsTools.ts +69 -0
  250. package/tools/chartsTools.ts +427 -0
  251. package/tools/index.ts +4 -0
  252. package/tools/reportsTools.ts +38 -0
  253. package/tools/timeRangeTools.ts +125 -0
  254. package/utils/filter.ts +18 -0
  255. package/utils/index.ts +2 -0
  256. package/utils/leafletMarkers.ts +4 -4
  257. package/utils/operations.ts +69 -0
  258. package/utils/sort.ts +2 -2
  259. package/utils/statuses.ts +1 -1
  260. package/utils/time.ts +17 -17
  261. package/components/fields/FSTimeSlotField.vue +0 -250
  262. package/components/views/FSEntityHeader.vue +0 -350
  263. package/components/views/FSListHeader.vue +0 -83
  264. package/components/views/FSListView.vue +0 -83
  265. package/components/views/FSSkeletonView.vue +0 -100
  266. package/styles/components/fs_icon_field.scss +0 -12
  267. package/styles/components/fs_tag_field.scss +0 -8
  268. package/styles/components/fs_time_field.scss +0 -12
  269. package/styles/components/fs_timeslot_field.scss +0 -12
  270. package/styles/globals/breakpoints.scss +0 -20
  271. package/styles/globals/fixes.scss +0 -5
@@ -0,0 +1,69 @@
1
+ const MinusOperator = "-";
2
+
3
+ // Matches one of the three operators (+, *, /) or the - operator if it is preceded by something that is not another operator
4
+ const operatorsRegex = new RegExp(/[\+\*\/]|(?<=.)(?<![-\+\*\/])[-]/gm);
5
+
6
+ // Matches a nested block of parenthesis
7
+ const parenthesisRegex = new RegExp(/\([^)(]+\)/gm);
8
+
9
+ // Match a positive decimal number
10
+ const decimalRegex = new RegExp(/^\d+(.\d+)?$/gm);
11
+
12
+ const validateBlock = (block: string, operands: string[] = [], variables: string[] = []) => {
13
+ // Remove parenthesis from the block
14
+ block = block.replaceAll("(", "").replaceAll(")", "");
15
+
16
+ // Split block on operators (Leave negative signs)
17
+ const components = block.split(operatorsRegex);
18
+
19
+ // Check if each bit is a valid operand
20
+ for (let i = 0; i < components.length; i++) {
21
+ // Remove negative sign
22
+ if (components[i].startsWith(MinusOperator)) {
23
+ components[i] = components[i].substring(1);
24
+ }
25
+ if (!operands.includes(components[i]) && !variables.includes(components[i]) && !components[i].match(decimalRegex)) {
26
+ return false;
27
+ }
28
+ }
29
+ return true;
30
+ }
31
+
32
+ export const validateOperation = (rawOperation: string, operands: string[] = [], variables: string[] = []) => {
33
+ // Remove spaces
34
+ let operation = rawOperation.replaceAll(" ", "");
35
+
36
+ // Check parenthesis
37
+ const parenthesis: number[] = [];
38
+
39
+ for (let i = 0; i < operation.length; i++) {
40
+ if (operation[i] == '(') {
41
+ parenthesis.push(i);
42
+ }
43
+ else if (operation[i] == ')') {
44
+ if (parenthesis.length > 0) {
45
+ if (i == parenthesis.pop()! + 1) {
46
+ return false;
47
+ }
48
+ }
49
+ else {
50
+ return false;
51
+ }
52
+ }
53
+ }
54
+ if (parenthesis.length > 0) {
55
+ return false;
56
+ }
57
+
58
+ // Check each block between parenthesis
59
+ let match = operation.match(parenthesisRegex);
60
+
61
+ while (match?.[0]) {
62
+ if (!validateBlock(match[0], operands, variables)) {
63
+ return false;
64
+ }
65
+ operation = operation.replace(match[0], "1");
66
+ match = operation.match(parenthesisRegex);
67
+ }
68
+ return validateBlock(operation, operands, variables);
69
+ }
package/utils/sort.ts CHANGED
@@ -23,7 +23,7 @@ export const alphanumericSort = (a: any, b: any) => {
23
23
  if (b == null) {
24
24
  return 1;
25
25
  }
26
- a = asString(a);
27
- b = asString(b);
26
+ a = asString(a).trim();
27
+ b = asString(b).trim();
28
28
  return a.localeCompare(b, undefined, { numeric: true });
29
29
  };
package/utils/statuses.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { useTranslations as useTranslationsProvider } from "@dative-gpi/bones-ui/composables";
2
- import { ConnectivityStatus } from "@dative-gpi/foundation-shared-domain/models";
2
+ import { ConnectivityStatus } from "@dative-gpi/foundation-shared-domain/enums";
3
3
 
4
4
  const { $tr } = useTranslationsProvider();
5
5
 
package/utils/time.ts CHANGED
@@ -1,18 +1,18 @@
1
1
  import { useTranslations as useTranslationsProvider } from "@dative-gpi/bones-ui/composables";
2
2
 
3
- import { TimeUnit } from "@dative-gpi/foundation-shared-domain/models"
3
+ import { TimeUnit } from "@dative-gpi/foundation-shared-domain/enums"
4
4
 
5
5
  const { $tr } = useTranslationsProvider();
6
6
 
7
7
  export const timeSteps = [
8
- { id: TimeUnit.Second, label: $tr("ui.time-step.second.singular", "Second"), plural: $tr("ui.time-step.second.plural", "Seconds") },
9
- { id: TimeUnit.Minute, label: $tr("ui.time-step.minute.singular", "Minute"), plural: $tr("ui.time-step.minute.plural", "Minutes") },
10
- { id: TimeUnit.Hour, label: $tr("ui.time-step.hour.singular", "Hour"), plural: $tr("ui.time-step.hour.plural", "Hours") },
11
- { id: TimeUnit.Day, label: $tr("ui.time-step.day.singular", "Day"), plural: $tr("ui.time-step.day.plural", "Days") },
12
- { id: TimeUnit.Week, label: $tr("ui.time-step.week.singular", "Week"), plural: $tr("ui.time-step.week.plural", "Weeks") },
13
- { id: TimeUnit.Month, label: $tr("ui.time-step.month.singular", "Month"), plural: $tr("ui.time-step.month.plural", "Months") },
14
- { id: TimeUnit.Year, label: $tr("ui.time-step.year.singular", "Year"), plural: $tr("ui.time-step.year.plural", "Years") },
15
- ]
8
+ { id: TimeUnit.Second, get label() { return $tr("ui.common.second", "Second") }, get plural() { return $tr("ui.common.seconds", "Seconds") } },
9
+ { id: TimeUnit.Minute, get label() { return $tr("ui.common.minute", "Minute") }, get plural() { return $tr("ui.common.minutes", "Minutes") } },
10
+ { id: TimeUnit.Hour, get label() { return $tr("ui.common.hour", "Hour") }, get plural() { return $tr("ui.common.hours", "Hours") } },
11
+ { id: TimeUnit.Day, get label() { return $tr("ui.common.day", "Day") }, get plural() { return $tr("ui.common.days", "Days") } },
12
+ { id: TimeUnit.Week, get label() { return $tr("ui.common.week", "Week") }, get plural() { return $tr("ui.common.weeks", "Weeks") } },
13
+ { id: TimeUnit.Month, get label() { return $tr("ui.common.month", "Month") }, get plural() { return $tr("ui.common.months", "Months") } },
14
+ { id: TimeUnit.Year, get label() { return $tr("ui.common.year", "Year") }, get plural() { return $tr("ui.common.years", "Years") } },
15
+ ];
16
16
 
17
17
  export const timeStepToString = (value: { value: number, unit: TimeUnit } | null): string => {
18
18
  if (!value) {
@@ -25,15 +25,15 @@ export const timeStepToString = (value: { value: number, unit: TimeUnit } | null
25
25
  }
26
26
 
27
27
  return `${value.value} ${value.value === 1 ? unit.label.toLowerCase() : unit.plural.toLowerCase()}`;
28
- }
28
+ };
29
29
 
30
30
  // TODO : remove everything below this line
31
- export const timeScale: any[] = [
32
- { id: 1, label: $tr("ui.time-field.second.singular", "Second"), plural: $tr("ui.time-field.second.plural", "Seconds") },
33
- { id: 60, label: $tr("ui.time-field.minute.singular", "Minute"), plural: $tr("ui.time-field.minute.plural", "Minutes") },
34
- { id: 3600, label: $tr("ui.time-field.hour.singular", "Hour"), plural: $tr("ui.time-field.hour.plural", "Hours") },
35
- { id: 86400, label: $tr("ui.time-field.day.singular", "Day"), plural: $tr("ui.time-field.day.plural", "Days") },
36
- { id: 604800, label: $tr("ui.time-field.week.singular", "Week"), plural: $tr("ui.time-field.week.plural", "Weeks") },
31
+ export const timeScale = [
32
+ { id: 1, get label() { return $tr("ui.common.second", "Second") }, get plural() { return $tr("ui.common.seconds", "Seconds") } },
33
+ { id: 60, get label() { return $tr("ui.common.minute", "Minute") }, get plural() { return $tr("ui.common.minutes", "Minutes") } },
34
+ { id: 3600, get label() { return $tr("ui.common.hour", "Hour") }, get plural() { return $tr("ui.common.hours", "Hours") } },
35
+ { id: 86400, get label() { return $tr("ui.common.day", "Day") }, get plural() { return $tr("ui.common.days", "Days") } },
36
+ { id: 604800, get label() { return $tr("ui.common.week", "Week") }, get plural() { return $tr("ui.common.weeks", "Weeks") } },
37
37
  ];
38
38
 
39
39
  export const getTimeScaleIndex = (value: number): number => {
@@ -52,4 +52,4 @@ export const getTimeBestString = (value: number): string => {
52
52
  const unit = getTimeScaleIndex(value);
53
53
  const figure = value / timeScale[unit].id;
54
54
  return `${figure} ${figure === 1 ? timeScale[unit].label.toLowerCase() : timeScale[unit].plural.toLowerCase()}`;
55
- }
55
+ };
@@ -1,250 +0,0 @@
1
- <template>
2
- <FSBaseField
3
- :description="$props.description"
4
- :hideHeader="$props.hideHeader"
5
- :required="$props.required"
6
- :editable="$props.editable"
7
- :label="$props.label"
8
- :messages="messages"
9
- >
10
- <FSRow>
11
- <FSRow
12
- :wrap="false"
13
- >
14
- <FSSelectField
15
- :validationValue="$props.modelValue"
16
- :editable="$props.editable"
17
- :validateOn="validateOn"
18
- :rules="$props.rules"
19
- :items="daysObject"
20
- :hideHeader="true"
21
- :clearable="false"
22
- :style="style"
23
- :modelValue="dayStart"
24
- @update:modelValue="onChangeDayStart"
25
- />
26
- <FSClock
27
- class="fs-time-slot-field-number"
28
- :editable="$props.editable"
29
- :color="ColorEnum.Light"
30
- :slider="false"
31
- :style="style"
32
- :modelValue="$props.modelValue[0][1]"
33
- @update:modelValue="onChangeHourStart"
34
- />
35
- </FSRow>
36
- <FSRow
37
- :wrap="false"
38
- >
39
- <FSSelectField
40
- class="fs-time-slot-field-select"
41
- :editable="$props.editable"
42
- :items="daysObject"
43
- :hideHeader="true"
44
- :clearable="false"
45
- :style="style"
46
- :modelValue="dayEnd"
47
- @update:modelValue="onChangeDayEnd"
48
- />
49
- <FSClock
50
- class="fs-time-slot-field-number"
51
- :editable="$props.editable"
52
- :color="ColorEnum.Light"
53
- :slider="false"
54
- :style="style"
55
- :modelValue="$props.modelValue[1][1]"
56
- @update:modelValue="onChangeHourEnd"
57
- />
58
- </FSRow>
59
- </FSRow>
60
- </FSBaseField>
61
- </template>
62
-
63
- <script lang="ts">
64
- import { computed, defineComponent, type PropType, type StyleValue } from "vue";
65
-
66
- import { useColors, useRules } from "@dative-gpi/foundation-shared-components/composables";
67
- import { ColorEnum } from "@dative-gpi/foundation-shared-components/models";
68
- import { Days } from "@dative-gpi/foundation-shared-domain/models";
69
-
70
- import FSSelectField from "./FSSelectField.vue";
71
- import FSBaseField from "./FSBaseField.vue";
72
- import FSClock from "../FSClock.vue";
73
- import FSRow from "../FSRow.vue";
74
-
75
- export default defineComponent({
76
- name: "FSTimeSlotField",
77
- components: {
78
- FSSelectField,
79
- FSBaseField,
80
- FSClock,
81
- FSRow
82
- },
83
- props: {
84
- label: {
85
- type: String as PropType<string | null>,
86
- required: false,
87
- default: null
88
- },
89
- description: {
90
- type: String as PropType<string | null>,
91
- required: false,
92
- default: null
93
- },
94
- modelValue: {
95
- type: Array as PropType<number[][] | null>,
96
- required: true,
97
- default: null
98
- },
99
- hideHeader: {
100
- type: Boolean,
101
- required: false,
102
- default: false
103
- },
104
- required: {
105
- type: Boolean,
106
- required: false,
107
- default: false
108
- },
109
- rules: {
110
- type: Array as PropType<any[]>,
111
- required: false,
112
- default: () => []
113
- },
114
- messages: {
115
- type: Array as PropType<string[]>,
116
- required: false,
117
- default: null
118
- },
119
- editable: {
120
- type: Boolean,
121
- required: false,
122
- default: true
123
- }
124
- },
125
- emits: ["update:modelValue"],
126
- setup(props, { emit }) {
127
- const { validateOn, getMessages } = useRules();
128
- const { getColors } = useColors();
129
-
130
- const errors = getColors(ColorEnum.Error);
131
- const lights = getColors(ColorEnum.Light);
132
- const darks = getColors(ColorEnum.Dark);
133
-
134
- const daysObject: { id: number; label: string }[] = Object.keys(Days).reduce((acc, key) => {
135
- if (isNaN(Number(key))) {
136
- acc.push({
137
- id: Days[key],
138
- label: key
139
- });
140
- }
141
- return acc;
142
- }, [] as { id: number, label: string }[]);
143
-
144
- const style = computed((): StyleValue => {
145
- if (!props.editable) {
146
- return {
147
- "--fs-time-slot-field-cursor" : "default",
148
- "--fs-time-slot-field-border-color" : lights.base,
149
- "--fs-time-slot-field-color" : lights.dark,
150
- "--fs-time-slot-field-active-border-color": lights.base
151
- };
152
- }
153
- return {
154
- "--fs-time-slot-field-cursor" : "text",
155
- "--fs-time-slot-field-border-color" : lights.dark,
156
- "--fs-time-slot-field-color" : darks.base,
157
- "--fs-time-slot-field-active-border-color": darks.dark,
158
- "--fs-time-slot-field-error-color" : errors.base,
159
- "--fs-time-slot-field-error-border-color" : errors.base
160
- };
161
- });
162
-
163
- const dayStart = computed((): number => {
164
- if (props.modelValue) {
165
- return props.modelValue[1][0] === 7 ? 7 : props.modelValue[0][0];
166
- }
167
- return 0;
168
- });
169
-
170
- const dayEnd = computed((): number => {
171
- if (props.modelValue) {
172
- return props.modelValue[0][0] === 7 ? 7 : props.modelValue[1][0];
173
- }
174
- return 0;
175
- });
176
-
177
- const messages = computed((): string[] => props.messages ?? getMessages(props.modelValue, props.rules));
178
-
179
- const onChangeDayStart = (value: number) => {
180
- if (value === 7) {
181
- if (props.modelValue) {
182
- emit("update:modelValue", [[7, props.modelValue[0][1]], [7, props.modelValue[1][1]]]);
183
- return;
184
- }
185
- emit("update:modelValue", [[7, 0], [7, 0]]);
186
- return;
187
- }
188
- if (props.modelValue) {
189
- if (props.modelValue[1][0] === 7) {
190
- emit("update:modelValue", [[value, props.modelValue[0][1]], [value, props.modelValue[1][1]]]);
191
- return;
192
- }
193
- emit("update:modelValue", [[value, props.modelValue[0][1]], props.modelValue[1]]);
194
- return;
195
- }
196
- emit("update:modelValue", [[value, 0], [value, 0]]);
197
- };
198
-
199
- const onChangeHourStart = (value: number) => {
200
- if (props.modelValue) {
201
- emit("update:modelValue", [[props.modelValue[0][0], value], props.modelValue[1]]);
202
- return;
203
- }
204
- emit("update:modelValue", [[0, value], [0, 0]]);
205
- };
206
-
207
- const onChangeDayEnd = (value: number) => {
208
- if (value === 7) {
209
- if (props.modelValue) {
210
- emit("update:modelValue", [[7, props.modelValue[0][1]], [7, props.modelValue[1][1]]]);
211
- return;
212
- }
213
- emit("update:modelValue", [[7, 0], [7, 0]]);
214
- return;
215
- }
216
- if (props.modelValue) {
217
- if (props.modelValue[0][0] === 7) {
218
- emit("update:modelValue", [[value, props.modelValue[0][1]], [value, props.modelValue[1][1]]]);
219
- return;
220
- }
221
- emit("update:modelValue", [props.modelValue[0], [value, props.modelValue[1][1]]]);
222
- return;
223
- }
224
- emit("update:modelValue", [[value, 0], [value, 0]]);
225
- };
226
-
227
- const onChangeHourEnd = (value: number) => {
228
- if (props.modelValue) {
229
- emit("update:modelValue", [props.modelValue[0], [props.modelValue[1][0], value]]);
230
- return;
231
- }
232
- emit("update:modelValue", [[0, 0], [0, value]]);
233
- };
234
-
235
- return {
236
- daysObject,
237
- validateOn,
238
- ColorEnum,
239
- dayStart,
240
- messages,
241
- dayEnd,
242
- style,
243
- onChangeHourStart,
244
- onChangeDayStart,
245
- onChangeHourEnd,
246
- onChangeDayEnd
247
- };
248
- }
249
- });
250
- </script>