@dative-gpi/foundation-shared-components 1.0.87 → 1.0.89
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/FSFadeOut.vue +9 -2
- package/components/FSLoader.vue +26 -8
- package/components/FSWindow.vue +27 -4
- package/components/calendar/FSSimpleCalendar.vue +3 -18
- package/components/fields/FSRichTextField.vue +40 -27
- package/components/fields/FSSearchField.vue +7 -114
- package/components/fields/FSTimeRangeField.vue +104 -180
- package/components/fields/FSTranslateRichTextField.vue +7 -4
- package/components/lists/FSDataTableUI.vue +5 -1
- package/components/lists/FSFilterButton.vue +0 -1
- package/components/lists/FSSimpleList.vue +0 -1
- package/components/lists/FSSimpleListItem.vue +1 -0
- package/components/tiles/FSCommentTileUI.vue +26 -5
- package/models/variableNode.ts +8 -5
- package/package.json +4 -4
- package/styles/components/fs_fade_out.scss +5 -1
- package/styles/components/fs_window.scss +3 -1
- package/styles/components/index.scss +0 -1
- package/tools/alertsTools.ts +15 -1
- package/tools/chartsTools.ts +145 -18
- package/tools/timeRangeTools.ts +99 -40
- package/components/fields/FSTimeSlotField.vue +0 -250
- package/styles/components/fs_timeslot_field.scss +0 -12
package/tools/alertsTools.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useTranslations as useTranslationsProvider } from "@dative-gpi/bones-ui/composables";
|
|
2
2
|
import { AlertStatus, Criticity } from "@dative-gpi/foundation-shared-domain/enums";
|
|
3
3
|
import { ColorEnum } from "@dative-gpi/foundation-shared-components/models"
|
|
4
|
+
import { getTimeBestString } from "../utils";
|
|
4
5
|
|
|
5
6
|
const { $tr } = useTranslationsProvider();
|
|
6
7
|
|
|
@@ -51,4 +52,17 @@ export const AlertTools = {
|
|
|
51
52
|
default: return $tr("ui.alert.information", "Information");
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
|
-
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export const prettyDuration = (n: number) => {
|
|
58
|
+
const day = Math.floor(n / 24 / 60 / 60);
|
|
59
|
+
const hours = Math.floor((n - day * 24 * 60 * 60) / 3600);
|
|
60
|
+
const minutes = Math.floor((n - day * 24 * 60 * 60 - hours * 60 * 60) / 60);
|
|
61
|
+
const seconds = Math.floor(n - day * 24 * 60 * 60 - hours * 60 * 60 - minutes * 60);
|
|
62
|
+
|
|
63
|
+
return day > 0 ?
|
|
64
|
+
`${getTimeBestString(day * 24 * 60 * 60)} ${getTimeBestString(hours * 60 * 60)} ${getTimeBestString(minutes * 60)} ${getTimeBestString(seconds)}`
|
|
65
|
+
: hours > 0
|
|
66
|
+
? `${getTimeBestString(hours * 60 * 60)} ${getTimeBestString(minutes * 60)} ${getTimeBestString(seconds)}`
|
|
67
|
+
: `${getTimeBestString(minutes * 60)} ${getTimeBestString(seconds)}`;
|
|
68
|
+
};
|
package/tools/chartsTools.ts
CHANGED
|
@@ -1,32 +1,49 @@
|
|
|
1
|
-
import { AxisType, ColorSets, SerieType, ChartType, TimeUnit } from "@dative-gpi/foundation-shared-domain/enums";
|
|
1
|
+
import { AxisType, ColorSets, SerieType, ChartType, TimeUnit, ChartOrigin, AggregationType, DisplayAs, FilterType, HeatmapRule, OperationOn, PlanningType, PlotPer } from "@dative-gpi/foundation-shared-domain/enums";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { getEnumEntries } from "@dative-gpi/foundation-shared-domain/tools";
|
|
4
4
|
import { useTranslations as useTranslationsProvider } from "@dative-gpi/bones-ui/composables";
|
|
5
|
+
import { ColorEnum, type ColorBase } from "../models";
|
|
5
6
|
|
|
6
7
|
const { $tr } = useTranslationsProvider();
|
|
7
8
|
|
|
9
|
+
export const chartOriginLabel = (type: ChartOrigin): string => {
|
|
10
|
+
switch (type) {
|
|
11
|
+
case ChartOrigin.None: return $tr("ui.chart-origin.none", "None");
|
|
12
|
+
case ChartOrigin.Organisation: return $tr("ui.chart-origin.organisation", "Custom");
|
|
13
|
+
case ChartOrigin.OrganisationType: return $tr("ui.chart-origin.organisation-type", "Shared");
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const chartOriginColor = (type: ChartOrigin): ColorBase => {
|
|
18
|
+
switch (type) {
|
|
19
|
+
case ChartOrigin.None: return ColorEnum.Error;
|
|
20
|
+
case ChartOrigin.Organisation: return ColorEnum.Primary;
|
|
21
|
+
case ChartOrigin.OrganisationType: return ColorEnum.Warning;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
8
25
|
export const chartTypeLabel = (value: ChartType): string => {
|
|
9
26
|
switch (value) {
|
|
10
|
-
case ChartType.Gauge: return $tr("ui.
|
|
11
|
-
case ChartType.Heatmap: return $tr("ui.
|
|
12
|
-
case ChartType.Pie: return $tr("ui.
|
|
13
|
-
case ChartType.ScoreCard: return $tr("ui.
|
|
14
|
-
case ChartType.Slider: return $tr("ui.
|
|
15
|
-
case ChartType.Table: return $tr("ui.
|
|
16
|
-
case ChartType.XY: return $tr("ui.
|
|
17
|
-
default: return $tr("ui.
|
|
27
|
+
case ChartType.Gauge: return $tr("ui.chart-type.gauge", "Gauge");
|
|
28
|
+
case ChartType.Heatmap: return $tr("ui.chart-type.heatmap", "Heatmap");
|
|
29
|
+
case ChartType.Pie: return $tr("ui.chart-type.pie", "Pie");
|
|
30
|
+
case ChartType.ScoreCard: return $tr("ui.chart-type.score-card", "Score card");
|
|
31
|
+
case ChartType.Slider: return $tr("ui.chart-type.slider", "Slider");
|
|
32
|
+
case ChartType.Table: return $tr("ui.chart-type.table", "Table");
|
|
33
|
+
case ChartType.XY: return $tr("ui.chart-type.xy", "XY");
|
|
34
|
+
default: return $tr("ui.chart-type.none", "None");
|
|
18
35
|
}
|
|
19
36
|
}
|
|
20
37
|
|
|
21
38
|
export const colorSetLabel = (value: ColorSets | number): string => {
|
|
22
39
|
switch (value) {
|
|
23
|
-
case ColorSets.Default: return $tr("ui.
|
|
24
|
-
case ColorSets.Grafana: return $tr("ui.
|
|
25
|
-
case ColorSets.Armytage: return $tr("ui.
|
|
26
|
-
case ColorSets.Hash: return $tr("ui.
|
|
27
|
-
case ColorSets.Kelly: return $tr("ui.
|
|
28
|
-
case ColorSets.ZeileisHornikMurrell: return $tr("ui.
|
|
29
|
-
default: return $tr("ui.
|
|
40
|
+
case ColorSets.Default: return $tr("ui.color-sets.am-charts", "Am Charts");
|
|
41
|
+
case ColorSets.Grafana: return $tr("ui.color-sets.grafana", "Grafana");
|
|
42
|
+
case ColorSets.Armytage: return $tr("ui.color-sets.armytage", "Armytage");
|
|
43
|
+
case ColorSets.Hash: return $tr("ui.color-sets.hash", "Hash");
|
|
44
|
+
case ColorSets.Kelly: return $tr("ui.color-sets.material", "Kelly");
|
|
45
|
+
case ColorSets.ZeileisHornikMurrell: return $tr("ui.color-sets.material", "ZeileisHornikMurrell");
|
|
46
|
+
default: return $tr("ui.color-sets.none", "None");
|
|
30
47
|
}
|
|
31
48
|
}
|
|
32
49
|
|
|
@@ -66,6 +83,115 @@ export const serieTypeIcon = (serieType: SerieType): string => {
|
|
|
66
83
|
}
|
|
67
84
|
}
|
|
68
85
|
|
|
86
|
+
export const aggregationTypeLabel = (aggregationType: AggregationType): string => {
|
|
87
|
+
switch (aggregationType) {
|
|
88
|
+
case AggregationType.Sum: return $tr("ui.aggregation-type.sum", "Sum");
|
|
89
|
+
case AggregationType.Cardinal: return $tr("ui.aggregation-type.cardinal", "Cardinal");
|
|
90
|
+
case AggregationType.Mean: return $tr("ui.aggregation-type.mean", "Mean");
|
|
91
|
+
case AggregationType.Median: return $tr("ui.aggregation-type.median", "Median");
|
|
92
|
+
case AggregationType.First: return $tr("ui.aggregation-type.first", "First");
|
|
93
|
+
case AggregationType.Last: return $tr("ui.aggregation-type.last", "Last");
|
|
94
|
+
case AggregationType.Difference: return $tr("ui.aggregation-type.difference", "Difference");
|
|
95
|
+
case AggregationType.Minimum: return $tr("ui.aggregation-type.minimum", "Minimum");
|
|
96
|
+
case AggregationType.Maximum: return $tr("ui.common.maximum", "Maximum");
|
|
97
|
+
case AggregationType.Range: return $tr("ui.aggregation-type.range", "Range");
|
|
98
|
+
default: return $tr("ui.aggregation-type.none", "None");
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export const axisTypeLabel = (axisType: AxisType | number): string => {
|
|
103
|
+
switch (axisType) {
|
|
104
|
+
case AxisType.Date: return $tr("ui.axis-type.date", "Date");
|
|
105
|
+
case AxisType.Value: return $tr("ui.axis-type.value", "Value");
|
|
106
|
+
case AxisType.Category: return $tr("ui.axis-type.category", "Category");
|
|
107
|
+
default: return $tr("ui.axis-type.none", "None");
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export const displayAsLabel = (display: DisplayAs | number): string => {
|
|
112
|
+
switch (display) {
|
|
113
|
+
case DisplayAs.Bars: return $tr("ui.display-as.bars", "Bars");
|
|
114
|
+
case DisplayAs.Lines: return $tr("ui.display-as.lines", "Lines");
|
|
115
|
+
case DisplayAs.Points: return $tr("ui.display-as.point", "Points");
|
|
116
|
+
default: return $tr("ui.display-as.none", "None");
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export const filterTypeLabel = (filterType: FilterType | number): string => {
|
|
121
|
+
switch (filterType) {
|
|
122
|
+
case FilterType.Contains: return $tr("ui.filter-type.contains", "contains");
|
|
123
|
+
case FilterType.Different: return "≠";
|
|
124
|
+
case FilterType.EndsWith: return $tr("ui.filter-type.ends-with", "ends with");
|
|
125
|
+
case FilterType.Equal: return "=";
|
|
126
|
+
case FilterType.Less: return "<";
|
|
127
|
+
case FilterType.LessOrEqual: return "≤";
|
|
128
|
+
case FilterType.More: return ">";
|
|
129
|
+
case FilterType.MoreOrEqual: return "≥";
|
|
130
|
+
case FilterType.StartsWith: return $tr("ui.filter-type.starts-with", "start with");
|
|
131
|
+
default: return $tr("ui.filter-type.none", "None");
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
export const heatmapRuleLabel = (heatMap: HeatmapRule | number): string => {
|
|
136
|
+
switch (heatMap) {
|
|
137
|
+
case HeatmapRule.Gradient: return $tr("ui.heatmap-rule.gradient", "Gradient");
|
|
138
|
+
case HeatmapRule.Ranges: return $tr("ui.heatmap-rule.ranges", "Ranges");
|
|
139
|
+
case HeatmapRule.Fixed: return $tr("ui.heatmap-rule.fixed", "Fixed");
|
|
140
|
+
default: return $tr("ui.heatmap-rule.none", "None");
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
export const operationOnLabel = (operationOn: OperationOn | number): string => {
|
|
145
|
+
switch (operationOn) {
|
|
146
|
+
case OperationOn.SameEntity: return $tr("ui.operation-on.same-entity", "Same entity");
|
|
147
|
+
case OperationOn.SameGroup: return $tr("ui.operation-on.same-group", "Same group");
|
|
148
|
+
case OperationOn.SameGroupAndEntity: return $tr("ui.operation-on.same-group-entity", "Same group and entity");
|
|
149
|
+
default: return $tr("ui.operation-on.none", "None");
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
export const planningTypeLabel = (planningType: PlanningType | number): string => {
|
|
154
|
+
switch (planningType) {
|
|
155
|
+
case PlanningType.UntilNext: return $tr("ui.planning-type.until-next", "Until next");
|
|
156
|
+
case PlanningType.ElapsedTime: return $tr("ui.planning-type.elapsed-time", "Elapsed time");
|
|
157
|
+
case PlanningType.SinglePoint: return $tr("ui.planning-type.single-point", "Single point");
|
|
158
|
+
default: return $tr("ui.planning-type.none", "None");
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
export const plotPerLabel = (plotper: PlotPer | number): string => {
|
|
163
|
+
switch (plotper) {
|
|
164
|
+
case PlotPer.SinglePlot: return $tr("ui.plot-per.single-slot", "Single slot");
|
|
165
|
+
case PlotPer.Model: return $tr("ui.plot-per.model", "Model");
|
|
166
|
+
case PlotPer.Group: return $tr("ui.plot-per.group", "Group");
|
|
167
|
+
case PlotPer.Location: return $tr("ui.plot-per.location", "Location");
|
|
168
|
+
case PlotPer.Device: return $tr("ui.plot-per.device", "Device");
|
|
169
|
+
default: return $tr("ui.plot-per.none", "None");
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
export const serieTypeLabel = (serieType: SerieType): string => {
|
|
174
|
+
switch (serieType) {
|
|
175
|
+
case SerieType.Lines: return $tr("ui.serie-type.lines", "Lines");
|
|
176
|
+
case SerieType.Area: return $tr("ui.serie-type.area", "Area");
|
|
177
|
+
case SerieType.Range: return $tr("ui.serie-type.range", "Range");
|
|
178
|
+
case SerieType.Histogram: return $tr("ui.serie-type.histogram", "Histogram");
|
|
179
|
+
case SerieType.Operation: return $tr("ui.serie-type.operation", "Operation");
|
|
180
|
+
case SerieType.Planning: return $tr("ui.serie-type.planning", "Planning");
|
|
181
|
+
case SerieType.ScatterPlot: return $tr("ui.serie-type.scatter-plot", "Scatter plot");
|
|
182
|
+
case SerieType.Top: return $tr("ui.serie-type.top", "Top");
|
|
183
|
+
case SerieType.Bars: return $tr("ui.serie-type.bars", "Bars");
|
|
184
|
+
case SerieType.StackedBars: return $tr("ui.serie-type.stacked-bars", "Stacked bars");
|
|
185
|
+
case SerieType.Pie: return $tr("ui.serie-type.pie", "Pie");
|
|
186
|
+
case SerieType.Heatmap: return $tr('ui.serie-type.heatmap', 'Heatmap');
|
|
187
|
+
case SerieType.Slider: return $tr("ui.serie-type.slider", "Slider");
|
|
188
|
+
case SerieType.Gauge: return $tr("ui.serie-type.gauge", "Gauge");
|
|
189
|
+
case SerieType.ScoreCard: return $tr("ui.serie-type.score-card", "Score card");
|
|
190
|
+
case SerieType.Table: return $tr("ui.serie-type.table", "Table");
|
|
191
|
+
default: return "";
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
|
|
69
195
|
export const showModifiers = (serieType: SerieType) => {
|
|
70
196
|
switch (serieType) {
|
|
71
197
|
case SerieType.Lines:
|
|
@@ -297,4 +423,5 @@ export const timeMillisecond = (value: number | null | undefined, unit: TimeUnit
|
|
|
297
423
|
case TimeUnit.Year: return value * 31536000000;
|
|
298
424
|
default: return 0;
|
|
299
425
|
}
|
|
300
|
-
}
|
|
426
|
+
}
|
|
427
|
+
|
package/tools/timeRangeTools.ts
CHANGED
|
@@ -1,59 +1,96 @@
|
|
|
1
|
-
import { Days } from "@dative-gpi/foundation-shared-domain/enums";
|
|
1
|
+
import { DateType, Days } from "@dative-gpi/foundation-shared-domain/enums";
|
|
2
2
|
import { useAppTimeZone } from "@dative-gpi/foundation-shared-services/composables";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
import { useTranslations as useTranslationsProvider } from "@dative-gpi/bones-ui/composables";
|
|
5
5
|
|
|
6
|
+
const { $tr } = useTranslationsProvider();
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
const { getUserOffset } = useAppTimeZone();
|
|
8
9
|
|
|
9
|
-
const range: DateTimeRange = r;
|
|
10
|
-
|
|
11
|
-
if (negative) {
|
|
12
|
-
range.startHour = r.startHour - getUserOffset() / 1000 / 60 / 60;
|
|
13
|
-
range.endHour = r.endHour - getUserOffset() / 1000 / 60 / 60;
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
range.startHour = r.startHour + getUserOffset() / 1000 / 60 / 60;
|
|
17
|
-
range.endHour = r.endHour + getUserOffset() / 1000 / 60 / 60;
|
|
18
|
-
}
|
|
19
10
|
|
|
11
|
+
export const applyOffset = (r: DateTimeRange, negative: boolean) => {
|
|
12
|
+
const range: DateTimeRange = {
|
|
13
|
+
startDay: r.startDay,
|
|
14
|
+
startHour: r.startHour,
|
|
15
|
+
startMinute: r.startMinute,
|
|
16
|
+
endDay: r.endDay,
|
|
17
|
+
endHour: r.endHour,
|
|
18
|
+
endMinute: r.endMinute,
|
|
19
|
+
variant: r.variant
|
|
20
|
+
};
|
|
20
21
|
|
|
21
|
-
if (
|
|
22
|
-
|
|
22
|
+
if (r.variant == DateType.UTC) {
|
|
23
|
+
let innerStartHour = 0;
|
|
24
|
+
let innerEndHour = 0;
|
|
23
25
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
if (negative) {
|
|
27
|
+
innerStartHour = r.startHour - getUserOffset() / 1000 / 60 / 60;
|
|
28
|
+
innerEndHour = r.endHour - getUserOffset() / 1000 / 60 / 60;
|
|
26
29
|
}
|
|
27
|
-
else
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
else {
|
|
31
|
+
innerStartHour = r.startHour + getUserOffset() / 1000 / 60 / 60;
|
|
32
|
+
innerEndHour = r.endHour + getUserOffset() / 1000 / 60 / 60;
|
|
30
33
|
}
|
|
31
34
|
|
|
32
|
-
if (r.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
if (![Days.AllDays].includes(r.startDay)) {
|
|
36
|
+
if (innerStartHour > 23) {
|
|
37
|
+
range.startDay = (r.startDay + 1) % 7;
|
|
38
|
+
range.startHour = innerStartHour - 24;
|
|
39
|
+
}
|
|
40
|
+
else if (innerStartHour < 0) {
|
|
41
|
+
range.startDay = (r.startDay + 6) % 7;
|
|
42
|
+
range.startHour = innerStartHour + 24;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
range.startHour = innerStartHour;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (innerEndHour > 23) {
|
|
49
|
+
range.endDay = (r.endDay + 1) % 7;
|
|
50
|
+
range.endHour = innerEndHour - 24;
|
|
51
|
+
}
|
|
52
|
+
else if (innerEndHour < 0) {
|
|
53
|
+
range.endDay = (r.endDay + 6) % 7;
|
|
54
|
+
range.endHour = innerEndHour + 24;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
range.endHour = innerEndHour;
|
|
58
|
+
}
|
|
35
59
|
}
|
|
36
|
-
else
|
|
37
|
-
|
|
38
|
-
|
|
60
|
+
else {
|
|
61
|
+
if (innerStartHour > 23) {
|
|
62
|
+
range.startHour = innerStartHour - 24;
|
|
63
|
+
}
|
|
64
|
+
else if (innerStartHour < 0) {
|
|
65
|
+
range.startHour = innerStartHour + 24;
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
range.startHour = innerStartHour;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (innerEndHour > 23) {
|
|
72
|
+
range.endHour = innerEndHour - 24;
|
|
73
|
+
}
|
|
74
|
+
else if (innerEndHour < 0) {
|
|
75
|
+
range.endHour = innerEndHour + 24;
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
range.endHour = innerEndHour;
|
|
79
|
+
}
|
|
39
80
|
}
|
|
81
|
+
return {
|
|
82
|
+
startDay: range.startDay,
|
|
83
|
+
startHour: range.startHour,
|
|
84
|
+
startMinute: r.startMinute,
|
|
85
|
+
endDay: range.endDay,
|
|
86
|
+
endHour: range.endHour,
|
|
87
|
+
endMinute: range.endMinute,
|
|
88
|
+
variant: range.variant
|
|
89
|
+
};
|
|
40
90
|
}
|
|
41
91
|
else {
|
|
42
|
-
|
|
43
|
-
range.startHour -= 24;
|
|
44
|
-
}
|
|
45
|
-
else if (r.startHour < 0) {
|
|
46
|
-
range.startHour += 24;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (r.endHour > 23) {
|
|
50
|
-
range.endHour -= 24;
|
|
51
|
-
}
|
|
52
|
-
else if (r.endHour < 0) {
|
|
53
|
-
range.endHour += 24;
|
|
54
|
-
}
|
|
92
|
+
return r;
|
|
55
93
|
}
|
|
56
|
-
return range;
|
|
57
94
|
}
|
|
58
95
|
|
|
59
96
|
export interface DateTimeRange {
|
|
@@ -63,4 +100,26 @@ export interface DateTimeRange {
|
|
|
63
100
|
endDay: Days;
|
|
64
101
|
endHour: number;
|
|
65
102
|
endMinute: number;
|
|
103
|
+
variant: DateType;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export const dayLabel = (day: Days | number): string => {
|
|
107
|
+
switch (day) {
|
|
108
|
+
case Days.Monday:
|
|
109
|
+
return $tr("ui.days.monday", "Monday");
|
|
110
|
+
case Days.Tuesday:
|
|
111
|
+
return $tr("ui.days.tuesday", "Tuesday");
|
|
112
|
+
case Days.Wednesday:
|
|
113
|
+
return $tr("ui.days.wednesday", "Wednesday");
|
|
114
|
+
case Days.Thursday:
|
|
115
|
+
return $tr("ui.days.thursday", "Thursday");
|
|
116
|
+
case Days.Friday:
|
|
117
|
+
return $tr("ui.days.friday", "Friday");
|
|
118
|
+
case Days.Saturday:
|
|
119
|
+
return $tr("ui.days.saturday", "Saturday");
|
|
120
|
+
case Days.Sunday:
|
|
121
|
+
return $tr("ui.days.sunday", "Sunday");
|
|
122
|
+
default:
|
|
123
|
+
return $tr("ui.days.all-days", "All days");
|
|
124
|
+
}
|
|
66
125
|
}
|
|
@@ -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/enums";
|
|
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>
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
.fs-time-slot-field-label {
|
|
2
|
-
color: var(--fs-time-slot-field-color);
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
.fs-time-slot-field-messages {
|
|
6
|
-
align-self: stretch;
|
|
7
|
-
color: var(--fs-time-slot-field-error-color);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
.fs-time-slot-field-description {
|
|
11
|
-
color: var(--fs-time-slot-field-color);
|
|
12
|
-
}
|