@dative-gpi/foundation-shared-components 0.1.120 → 1.0.0
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/assets/images/map/imagery.png +0 -0
- package/assets/images/map/map.png +0 -0
- package/components/FSAccordion.vue +2 -1
- package/components/FSAccordionPanel.vue +20 -1
- package/components/FSBadge.vue +7 -3
- package/components/FSBreadcrumbs.vue +4 -2
- package/components/FSButton.vue +15 -8
- package/components/FSCalendar.vue +5 -2
- package/components/FSCalendarTwin.vue +6 -3
- package/components/FSCard.vue +4 -2
- package/components/FSCardPlaceholder.vue +80 -0
- package/components/FSCheckbox.vue +10 -7
- package/components/FSChip.vue +4 -2
- package/components/FSClickable.vue +5 -3
- package/components/FSClock.vue +18 -4
- package/components/FSCol.vue +12 -5
- package/components/FSColor.vue +4 -2
- package/components/FSColorIcon.vue +5 -3
- package/components/FSDialog.vue +28 -87
- package/components/FSDialogContent.vue +133 -0
- package/components/FSDialogForm.vue +25 -236
- package/components/FSDialogFormBody.vue +273 -0
- package/components/FSDialogMenu.vue +5 -2
- package/components/FSDialogMultiForm.vue +21 -197
- package/components/FSDialogMultiFormBody.vue +231 -0
- package/components/FSDialogSubmit.vue +4 -2
- package/components/FSDivider.vue +6 -4
- package/components/FSEditImage.vue +16 -9
- package/components/FSErrorToast.vue +2 -1
- package/components/FSFadeOut.vue +1 -1
- package/components/FSForm.vue +7 -7
- package/components/FSGrid.vue +4 -2
- package/components/FSGridMosaic.vue +3 -2
- package/components/FSIcon.vue +3 -2
- package/components/FSIconCard.vue +10 -3
- package/components/FSIconCheck.vue +2 -1
- package/components/FSIconFlag.vue +2 -1
- package/components/FSImage.vue +2 -1
- package/components/FSImageCard.vue +72 -0
- package/components/FSLabel.vue +4 -2
- package/components/FSLink.vue +5 -3
- package/components/FSLoader.vue +2 -1
- package/components/FSOptionGroup.vue +28 -20
- package/components/FSOptionItem.vue +8 -18
- package/components/FSPagination.vue +4 -2
- package/components/FSRadio.vue +23 -11
- package/components/FSRadioGroup.vue +23 -10
- package/components/FSRow.vue +8 -1
- package/components/FSSlideGroup.vue +27 -6
- package/components/FSSlider.vue +4 -2
- package/components/FSSpan.vue +2 -1
- package/components/FSSwitch.vue +13 -10
- package/components/FSTab.vue +4 -2
- package/components/FSTabs.vue +5 -14
- package/components/FSTag.vue +11 -4
- package/components/FSTagGroup.vue +4 -2
- package/components/FSText.vue +4 -2
- package/components/FSToggleSet.vue +30 -17
- package/components/FSTooltip.vue +15 -4
- package/components/FSWindow.vue +2 -2
- package/components/FSWrapGroup.vue +2 -1
- package/components/autocompletes/FSAutoCompleteAddress.vue +104 -0
- package/components/autocompletes/FSAutocompleteLanguage.vue +18 -26
- package/components/autocompletes/FSAutocompleteTag.vue +138 -0
- package/components/autocompletes/FSAutocompleteTimeZone.vue +19 -30
- package/components/buttons/FSButtonAdd.vue +28 -0
- package/components/buttons/FSButtonAddIcon.vue +28 -0
- package/components/buttons/FSButtonAddLabel.vue +27 -0
- package/components/buttons/FSButtonAddMini.vue +27 -0
- package/components/buttons/FSButtonFile.vue +4 -4
- package/components/buttons/FSButtonFileIcon.vue +4 -4
- package/components/buttons/FSButtonFileLabel.vue +4 -4
- package/components/buttons/FSButtonFileMini.vue +4 -4
- package/components/deviceOrganisations/FSConnectivity.vue +3 -2
- package/components/deviceOrganisations/FSConnectivityCard.vue +3 -2
- package/components/deviceOrganisations/FSStatus.vue +3 -2
- package/components/deviceOrganisations/FSStatusCard.vue +3 -2
- package/components/deviceOrganisations/FSStatusesCarousel.vue +3 -2
- package/components/deviceOrganisations/FSStatusesRow.vue +3 -2
- package/components/deviceOrganisations/FSWorstAlert.vue +5 -4
- package/components/deviceOrganisations/FSWorstAlertCard.vue +4 -2
- package/components/fields/FSAutocompleteField.vue +210 -97
- package/components/fields/FSBaseField.vue +2 -1
- package/components/fields/FSColorField.vue +65 -94
- package/components/fields/FSDateField.vue +12 -25
- package/components/fields/FSDateRangeField.vue +15 -27
- package/components/fields/FSDateTimeField.vue +22 -32
- package/components/fields/FSDateTimeRangeField.vue +43 -51
- package/components/fields/FSGradientField.vue +143 -0
- package/components/fields/FSIconField.vue +9 -6
- package/components/fields/FSMagicConfigField.vue +154 -0
- package/components/fields/FSMagicField.vue +185 -0
- package/components/fields/FSNumberField.vue +3 -1
- package/components/fields/FSPasswordField.vue +10 -10
- package/components/fields/FSRichTextField.vue +136 -50
- package/components/fields/FSSearchField.vue +41 -62
- package/components/fields/FSSelectField.vue +148 -53
- package/components/fields/FSTagField.vue +19 -16
- package/components/fields/FSTermField.vue +192 -186
- package/components/fields/FSTextArea.vue +4 -4
- package/components/fields/FSTextField.vue +29 -6
- package/components/fields/FSTimeField.vue +55 -20
- package/components/fields/FSTimeSlotField.vue +6 -5
- package/components/fields/FSTranslateField.vue +234 -0
- package/components/fields/FSTranslateRichTextField.vue +185 -0
- package/components/fields/FSTreeViewField.vue +520 -0
- package/components/lists/FSDataIteratorItem.vue +18 -3
- package/components/lists/FSDataTableUI.vue +138 -51
- package/components/lists/FSFilterButton.vue +4 -2
- package/components/lists/FSHiddenButton.vue +4 -2
- package/components/map/FSMap.vue +598 -0
- package/components/map/FSMapEditPointAddressOverlay.vue +164 -0
- package/components/map/FSMapLayerButton.vue +77 -0
- package/components/map/FSMapOverlay.vue +150 -0
- package/components/selects/FSSelectAutoRefresh.vue +62 -0
- package/components/selects/FSSelectDashboardVariableType.vue +47 -0
- package/components/selects/FSSelectDateSetting.vue +39 -37
- package/components/selects/FSSelectDays.vue +62 -0
- package/components/tiles/FSDashboardOrganisationTileUI.vue +7 -5
- package/components/tiles/FSDashboardOrganisationTypeTileUI.vue +7 -5
- package/components/tiles/FSDashboardShallowTileUI.vue +7 -5
- package/components/tiles/FSDeviceOrganisationTileUI.vue +11 -12
- package/components/tiles/FSFolderTileUI.vue +8 -6
- package/components/tiles/FSGroupTileUI.vue +13 -15
- package/components/tiles/{FSSimpleIconTileUI.vue → FSSimpleTileUI.vue} +29 -15
- package/components/tiles/FSTile.vue +5 -11
- package/components/tiles/FSUserOrganisationTileUI.vue +2 -1
- package/components/toggleSets/FSToggleSetPosition.vue +61 -0
- package/composables/index.ts +5 -1
- package/composables/useAddress.ts +158 -0
- package/composables/useAutocomplete.ts +4 -3
- package/composables/useColors.ts +8 -25
- package/composables/useDebounce.ts +2 -1
- package/composables/useMagicFieldProvider.ts +22 -0
- package/composables/useRules.ts +4 -12
- package/composables/useSlots.ts +46 -26
- package/composables/useTables.ts +29 -0
- package/composables/useTreeView.ts +48 -0
- package/elements/FSFormElement.ts +2 -1
- package/icons/flags/France.vue +21 -5
- package/icons/flags/Germany.vue +16 -4
- package/icons/flags/GreatBritain.vue +25 -6
- package/icons/flags/Italy.vue +21 -5
- package/icons/flags/Portugal.vue +225 -51
- package/icons/flags/Spain.vue +2781 -543
- package/icons/flags/UnitedStates.vue +31 -7
- package/icons/widgetTemplates/DevicesWidget.vue +189 -189
- package/icons/widgetTemplates/ProfileWidget.vue +9 -9
- package/icons/widgetTemplates/TextWidget.vue +6 -6
- package/models/breadcrumbs.ts +1 -1
- package/models/deviceAlerts.ts +1 -1
- package/models/deviceConnectivities.ts +1 -1
- package/models/index.ts +2 -0
- package/models/magicFields.ts +9 -0
- package/models/map.ts +18 -0
- package/models/richTextVariable.ts +5 -0
- package/models/rules.ts +11 -2
- package/models/tables.ts +30 -21
- package/models/variableNode.ts +104 -0
- package/package.json +21 -18
- package/plugins/colorPlugin.ts +2 -2
- package/plugins/index.ts +2 -1
- package/plugins/mapsPlugin.ts +37 -0
- package/shims-plugin.d.ts +2 -2
- package/shims-window.d.ts +3 -0
- package/styles/components/fs_button.scss +5 -0
- package/styles/components/fs_card.scss +0 -1
- package/styles/components/fs_col.scss +1 -0
- package/styles/components/fs_color_field.scss +12 -2
- package/styles/components/fs_data_iterator_item.scss +19 -6
- package/styles/components/fs_dialog.scss +12 -22
- package/styles/components/fs_gradient_field.scss +16 -0
- package/styles/components/fs_image_card.scss +18 -0
- package/styles/components/fs_magic_config_field.scss +13 -0
- package/styles/components/fs_map.scss +129 -0
- package/styles/components/fs_map_overlay.scss +38 -0
- package/styles/components/fs_meta_field.scss +6 -0
- package/styles/components/fs_option_group.scss +1 -0
- package/styles/components/fs_radio.scss +1 -1
- package/styles/components/fs_rich_text_field.scss +17 -5
- package/styles/components/fs_row.scss +1 -1
- package/styles/components/fs_select_field.scss +9 -14
- package/styles/components/fs_text.scss +1 -1
- package/styles/components/fs_time_field.scss +0 -4
- package/styles/components/fs_translate_field.scss +3 -0
- package/styles/components/fs_tree_view_field.scss +53 -0
- package/styles/components/index.scss +8 -1
- package/styles/globals/overrides.scss +54 -8
- package/styles/globals/scrollbars.scss +2 -2
- package/themes/default.ts +1 -1
- package/utils/gradient.ts +1601 -0
- package/utils/index.ts +3 -1
- package/utils/leafletMarkers.ts +23 -0
- package/utils/lexical.ts +3 -1
- package/components/selects/FSSelectTimeZone.vue +0 -67
- package/styles/components/fs_date_field.scss +0 -8
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<FSCol
|
|
3
|
+
class="fs-gradient-field"
|
|
4
|
+
>
|
|
5
|
+
<FSBaseField
|
|
6
|
+
:label="$props.label"
|
|
7
|
+
:description="$props.description"
|
|
8
|
+
:required="$props.required"
|
|
9
|
+
:editable="$props.editable"
|
|
10
|
+
v-bind="$attrs"
|
|
11
|
+
>
|
|
12
|
+
<FSRow>
|
|
13
|
+
<FSColorField
|
|
14
|
+
v-for="colorIndex in $props.colorCount"
|
|
15
|
+
:allowOpacity="$props.allowOpacity"
|
|
16
|
+
:modelValue="$props.modelValue[colorIndex - 1]"
|
|
17
|
+
:required="$props.required"
|
|
18
|
+
:editable="$props.editable"
|
|
19
|
+
:key="colorIndex"
|
|
20
|
+
@update:modelValue="$emit('update:modelValue', $props.modelValue.map((color, i) => colorIndex === i + 1 ? $event : color))"
|
|
21
|
+
/>
|
|
22
|
+
</FSRow>
|
|
23
|
+
<FSSelectField
|
|
24
|
+
class="fs-gradient-select-field"
|
|
25
|
+
:clearable="false"
|
|
26
|
+
:editable="$props.editable"
|
|
27
|
+
:items="items"
|
|
28
|
+
:modelValue="JSON.stringify($props.modelValue)"
|
|
29
|
+
@update:modelValue="$emit('update:modelValue', presetGradients[$event])"
|
|
30
|
+
>
|
|
31
|
+
<template
|
|
32
|
+
v-slot:selection="{ item }"
|
|
33
|
+
>
|
|
34
|
+
<FSRow
|
|
35
|
+
class="fs-gradient-field-preview"
|
|
36
|
+
height="fill"
|
|
37
|
+
width="100%"
|
|
38
|
+
:style="{ '--fs-gradient-field-background': `linear-gradient(to right, ${encodeGradientCssColors(JSON.parse(item.value))})` }"
|
|
39
|
+
>
|
|
40
|
+
<span />
|
|
41
|
+
</FSRow>
|
|
42
|
+
</template>
|
|
43
|
+
<template
|
|
44
|
+
v-slot:item="{ item, props }"
|
|
45
|
+
>
|
|
46
|
+
<v-list-item
|
|
47
|
+
v-bind="props"
|
|
48
|
+
>
|
|
49
|
+
<template
|
|
50
|
+
#title
|
|
51
|
+
>
|
|
52
|
+
<FSRow
|
|
53
|
+
class="fs-gradient-field-preview"
|
|
54
|
+
height="fill"
|
|
55
|
+
width="100%"
|
|
56
|
+
:style="{ '--fs-gradient-field-background': `linear-gradient(to right, ${encodeGradientCssColors(presetGradients[item.value])})` }"
|
|
57
|
+
>
|
|
58
|
+
<span />
|
|
59
|
+
</FSRow>
|
|
60
|
+
</template>
|
|
61
|
+
</v-list-item>
|
|
62
|
+
</template>
|
|
63
|
+
</FSSelectField>
|
|
64
|
+
</FSBaseField>
|
|
65
|
+
</FSCol>
|
|
66
|
+
</template>
|
|
67
|
+
|
|
68
|
+
<script lang="ts">
|
|
69
|
+
import { type PropType, defineComponent } from "vue";
|
|
70
|
+
|
|
71
|
+
import { groupedGradients } from "../../utils";
|
|
72
|
+
import { useColors } from "../../composables";
|
|
73
|
+
|
|
74
|
+
import FSSelectField from "./FSSelectField.vue";
|
|
75
|
+
import FSColorField from "./FSColorField.vue";
|
|
76
|
+
import FSBaseField from "./FSBaseField.vue";
|
|
77
|
+
import FSCol from "../FSCol.vue";
|
|
78
|
+
import FSRow from "../FSRow.vue";
|
|
79
|
+
|
|
80
|
+
export default defineComponent({
|
|
81
|
+
name: "FSGradientField",
|
|
82
|
+
components: {
|
|
83
|
+
FSSelectField,
|
|
84
|
+
FSColorField,
|
|
85
|
+
FSBaseField,
|
|
86
|
+
FSCol,
|
|
87
|
+
FSRow
|
|
88
|
+
},
|
|
89
|
+
props: {
|
|
90
|
+
label: {
|
|
91
|
+
type: String as PropType<string | null>,
|
|
92
|
+
required: false,
|
|
93
|
+
default: null
|
|
94
|
+
},
|
|
95
|
+
description: {
|
|
96
|
+
type: String as PropType<string | null>,
|
|
97
|
+
required: false,
|
|
98
|
+
default: null
|
|
99
|
+
},
|
|
100
|
+
colorCount: {
|
|
101
|
+
type: Number,
|
|
102
|
+
required: false,
|
|
103
|
+
default: 2
|
|
104
|
+
},
|
|
105
|
+
modelValue: {
|
|
106
|
+
type: Array as PropType<string[]>,
|
|
107
|
+
required: true
|
|
108
|
+
},
|
|
109
|
+
required: {
|
|
110
|
+
type: Boolean,
|
|
111
|
+
required: false,
|
|
112
|
+
default: false
|
|
113
|
+
},
|
|
114
|
+
editable: {
|
|
115
|
+
type: Boolean,
|
|
116
|
+
required: false,
|
|
117
|
+
default: true
|
|
118
|
+
},
|
|
119
|
+
allowOpacity: {
|
|
120
|
+
type: Boolean,
|
|
121
|
+
required: false,
|
|
122
|
+
default: false
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
emits: ["update:modelValue"],
|
|
126
|
+
setup(props) {
|
|
127
|
+
const { getColors } = useColors();
|
|
128
|
+
|
|
129
|
+
const presetGradients = groupedGradients[props.colorCount];
|
|
130
|
+
const items = Object.keys(presetGradients)
|
|
131
|
+
|
|
132
|
+
const encodeGradientCssColors = (colors: string[]) => {
|
|
133
|
+
return colors.map((color) => getColors(color).base).join(", ");
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
return {
|
|
137
|
+
presetGradients,
|
|
138
|
+
items,
|
|
139
|
+
encodeGradientCssColors
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
</script>
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
:messages="messages"
|
|
11
11
|
:validateOn="validateOn"
|
|
12
12
|
:validationValue="$props.modelValue"
|
|
13
|
-
@blur="blurred = true"
|
|
14
13
|
v-model="innerValue"
|
|
15
14
|
v-bind="$attrs"
|
|
16
15
|
>
|
|
@@ -23,6 +22,9 @@
|
|
|
23
22
|
>
|
|
24
23
|
{{ $props.modelValue }}
|
|
25
24
|
</FSIcon>
|
|
25
|
+
<slot
|
|
26
|
+
name="append-inner"
|
|
27
|
+
/>
|
|
26
28
|
</template>
|
|
27
29
|
</FSTextField>
|
|
28
30
|
<FSToggleSet
|
|
@@ -41,12 +43,14 @@
|
|
|
41
43
|
</template>
|
|
42
44
|
|
|
43
45
|
<script lang="ts">
|
|
44
|
-
import {
|
|
46
|
+
import type { PropType} from "vue";
|
|
47
|
+
import { computed, defineComponent, ref, watch } from "vue";
|
|
45
48
|
|
|
46
49
|
import { Icons, sortByLevenshteinDistance } from "@dative-gpi/foundation-shared-components/utils";
|
|
47
50
|
import { useColors, useRules } from "@dative-gpi/foundation-shared-components/composables";
|
|
48
|
-
import { ColorBase
|
|
49
|
-
import {
|
|
51
|
+
import type { ColorBase} from "@dative-gpi/foundation-shared-components/models";
|
|
52
|
+
import { ColorEnum } from "@dative-gpi/foundation-shared-components/models";
|
|
53
|
+
import type { FSToggle } from "@dative-gpi/foundation-shared-components/models";
|
|
50
54
|
|
|
51
55
|
import FSToggleSet from "../FSToggleSet.vue";
|
|
52
56
|
import FSTextField from "./FSTextField.vue";
|
|
@@ -125,7 +129,7 @@ export default defineComponent({
|
|
|
125
129
|
},
|
|
126
130
|
emits: ["update:modelValue"],
|
|
127
131
|
setup(props) {
|
|
128
|
-
const { validateOn,
|
|
132
|
+
const { validateOn, getMessages } = useRules();
|
|
129
133
|
const { getColors } = useColors();
|
|
130
134
|
|
|
131
135
|
const errors = getColors(ColorEnum.Error);
|
|
@@ -201,7 +205,6 @@ export default defineComponent({
|
|
|
201
205
|
innerValue,
|
|
202
206
|
validateOn,
|
|
203
207
|
messages,
|
|
204
|
-
blurred,
|
|
205
208
|
style,
|
|
206
209
|
icons
|
|
207
210
|
};
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<FSRow>
|
|
3
|
+
<component
|
|
4
|
+
class="fs-magic-config-field-value"
|
|
5
|
+
:is="get($props.type)"
|
|
6
|
+
:label="$tr('ui.magic-config-field.value', 'Value')"
|
|
7
|
+
:editable="$props.editable"
|
|
8
|
+
:required="true"
|
|
9
|
+
:rules="rules"
|
|
10
|
+
:modelValue="valueToInput"
|
|
11
|
+
@update:modelValue="inputToValue"
|
|
12
|
+
/>
|
|
13
|
+
<FSRow
|
|
14
|
+
gap="24px"
|
|
15
|
+
>
|
|
16
|
+
<FSTranslateField
|
|
17
|
+
:label="$tr('ui.magic-config-field.label', 'Label')"
|
|
18
|
+
:editable="$props.editable"
|
|
19
|
+
:modelValue="$props.labelDefault"
|
|
20
|
+
:translations="$props.translations"
|
|
21
|
+
@update:modelValue="$emit('update:labelDefault', $event)"
|
|
22
|
+
@update:translations="$emit('update:translations', $event)"
|
|
23
|
+
/>
|
|
24
|
+
<FSRow
|
|
25
|
+
class="fs-magic-config-field-actions"
|
|
26
|
+
width="hug"
|
|
27
|
+
:wrap="false"
|
|
28
|
+
>
|
|
29
|
+
<FSButtonRemoveIcon
|
|
30
|
+
@click="$emit('click:remove')"
|
|
31
|
+
/>
|
|
32
|
+
<FSButtonAddIcon
|
|
33
|
+
@click="$emit('click:add')"
|
|
34
|
+
/>
|
|
35
|
+
</FSRow>
|
|
36
|
+
</FSRow>
|
|
37
|
+
</FSRow>
|
|
38
|
+
</template>
|
|
39
|
+
|
|
40
|
+
<script lang="ts">
|
|
41
|
+
import type { PropType } from "vue";
|
|
42
|
+
import { computed, defineComponent } from "vue";
|
|
43
|
+
|
|
44
|
+
import { DateRules, IconRules, NumberRules, TextRules, TimeRules } from "../../models";
|
|
45
|
+
import { useMagicFieldProvider } from "../../composables";
|
|
46
|
+
import { MagicFieldType } from "../../models/magicFields";
|
|
47
|
+
|
|
48
|
+
import FSButtonRemoveIcon from "../buttons/FSButtonRemoveIcon.vue";
|
|
49
|
+
import FSButtonAddIcon from "../buttons/FSButtonAddIcon.vue";
|
|
50
|
+
import FSTranslateField from "./FSTranslateField.vue";
|
|
51
|
+
import FSRow from "../FSRow.vue";
|
|
52
|
+
|
|
53
|
+
export default defineComponent({
|
|
54
|
+
name: "FSMagicConfigField",
|
|
55
|
+
components: {
|
|
56
|
+
FSButtonRemoveIcon,
|
|
57
|
+
FSTranslateField,
|
|
58
|
+
FSButtonAddIcon,
|
|
59
|
+
FSRow
|
|
60
|
+
},
|
|
61
|
+
props: {
|
|
62
|
+
type: {
|
|
63
|
+
type: Number as PropType<MagicFieldType>,
|
|
64
|
+
required: false,
|
|
65
|
+
default: MagicFieldType.TextField
|
|
66
|
+
},
|
|
67
|
+
labelDefault: {
|
|
68
|
+
type: String as PropType<string | null>,
|
|
69
|
+
required: false,
|
|
70
|
+
default: null
|
|
71
|
+
},
|
|
72
|
+
value: {
|
|
73
|
+
type: String as PropType<string | null>,
|
|
74
|
+
required: false,
|
|
75
|
+
default: null
|
|
76
|
+
},
|
|
77
|
+
translations: {
|
|
78
|
+
type: Array as PropType<{ languageCode: string; label: string }[]>,
|
|
79
|
+
required: false,
|
|
80
|
+
default: () => []
|
|
81
|
+
},
|
|
82
|
+
editable: {
|
|
83
|
+
type: Boolean,
|
|
84
|
+
required: false,
|
|
85
|
+
default: true
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
emits: ["click:remove", "click:add", "update:value", "update:labelDefault", "update:translations"],
|
|
89
|
+
setup(props, { emit }) {
|
|
90
|
+
const { get } = useMagicFieldProvider();
|
|
91
|
+
|
|
92
|
+
const rules = computed((): Function[] => {
|
|
93
|
+
switch (props.type) {
|
|
94
|
+
case MagicFieldType.NumberField:
|
|
95
|
+
return [NumberRules.required()];
|
|
96
|
+
case MagicFieldType.TextField:
|
|
97
|
+
return [TextRules.required()];
|
|
98
|
+
case MagicFieldType.DateTimeField:
|
|
99
|
+
return [DateRules.required()];
|
|
100
|
+
case MagicFieldType.IconField:
|
|
101
|
+
return [IconRules.required()];
|
|
102
|
+
case MagicFieldType.TimeField:
|
|
103
|
+
return [TimeRules.required()];
|
|
104
|
+
}
|
|
105
|
+
return [];
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const valueToInput = computed((): any => {
|
|
109
|
+
switch (props.type) {
|
|
110
|
+
case MagicFieldType.NumberField:
|
|
111
|
+
case MagicFieldType.DateTimeField:
|
|
112
|
+
case MagicFieldType.TimeField:
|
|
113
|
+
if (props.value == null || isNaN(parseFloat(props.value))) {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
return parseFloat(props.value);
|
|
117
|
+
case MagicFieldType.Switch:
|
|
118
|
+
if (props.value == null) {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
return props.value === "true";
|
|
122
|
+
default:
|
|
123
|
+
return props.value;
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
const inputToValue = (value: any) => {
|
|
128
|
+
switch (props.type) {
|
|
129
|
+
case MagicFieldType.NumberField:
|
|
130
|
+
case MagicFieldType.Switch:
|
|
131
|
+
case MagicFieldType.DateTimeField:
|
|
132
|
+
case MagicFieldType.TimeField:
|
|
133
|
+
if (value == null) {
|
|
134
|
+
emit("update:value", null);
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
emit("update:value", value.toString());
|
|
138
|
+
break;
|
|
139
|
+
default:
|
|
140
|
+
emit("update:value", value);
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
return {
|
|
146
|
+
MagicFieldType,
|
|
147
|
+
valueToInput,
|
|
148
|
+
rules,
|
|
149
|
+
inputToValue,
|
|
150
|
+
get
|
|
151
|
+
};
|
|
152
|
+
},
|
|
153
|
+
});
|
|
154
|
+
</script>
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<component
|
|
3
|
+
v-if="!$props.useOnlyAllowedValues"
|
|
4
|
+
:is="get($props.type)"
|
|
5
|
+
:modelValue="valueToInput"
|
|
6
|
+
@update:modelValue="inputToValue"
|
|
7
|
+
v-bind="$attrs"
|
|
8
|
+
/>
|
|
9
|
+
<FSSelectField
|
|
10
|
+
v-else
|
|
11
|
+
itemValue="value"
|
|
12
|
+
:items="items"
|
|
13
|
+
:modelValue="$props.modelValue"
|
|
14
|
+
@update:modelValue="$emit('update:modelValue', $event)"
|
|
15
|
+
v-bind="$attrs"
|
|
16
|
+
>
|
|
17
|
+
<template
|
|
18
|
+
v-if="$props.type === MagicFieldType.IconField"
|
|
19
|
+
#selection="{ item }"
|
|
20
|
+
>
|
|
21
|
+
<FSRow
|
|
22
|
+
align="center-center"
|
|
23
|
+
:wrap="false"
|
|
24
|
+
>
|
|
25
|
+
<FSIcon
|
|
26
|
+
v-if="item.raw.value"
|
|
27
|
+
>
|
|
28
|
+
{{ item.raw.value }}
|
|
29
|
+
</FSIcon>
|
|
30
|
+
<FSSpan
|
|
31
|
+
v-if="item.raw.value !== item.raw.label"
|
|
32
|
+
>
|
|
33
|
+
{{ item.raw.label }}
|
|
34
|
+
</FSSpan>
|
|
35
|
+
</FSRow>
|
|
36
|
+
</template>
|
|
37
|
+
<template
|
|
38
|
+
v-if="$props.type === MagicFieldType.IconField"
|
|
39
|
+
#item-label="{ item }"
|
|
40
|
+
>
|
|
41
|
+
<FSRow
|
|
42
|
+
align="center-center"
|
|
43
|
+
:wrap="false"
|
|
44
|
+
>
|
|
45
|
+
<FSIcon
|
|
46
|
+
v-if="item.raw.value"
|
|
47
|
+
>
|
|
48
|
+
{{ item.raw.value }}
|
|
49
|
+
</FSIcon>
|
|
50
|
+
<FSSpan
|
|
51
|
+
v-if="item.raw.value !== item.raw.label"
|
|
52
|
+
>
|
|
53
|
+
{{ item.raw.label }}
|
|
54
|
+
</FSSpan>
|
|
55
|
+
</FSRow>
|
|
56
|
+
</template>
|
|
57
|
+
</FSSelectField>
|
|
58
|
+
</template>
|
|
59
|
+
|
|
60
|
+
<script lang="ts">
|
|
61
|
+
import type { PropType } from "vue";
|
|
62
|
+
import { computed, defineComponent } from "vue";
|
|
63
|
+
|
|
64
|
+
import { useTranslations as useTranslationsProvider } from "@dative-gpi/bones-ui/composables";
|
|
65
|
+
|
|
66
|
+
import { useAppTimeZone } from "@dative-gpi/foundation-shared-services/composables";
|
|
67
|
+
|
|
68
|
+
import { useMagicFieldProvider } from "../../composables";
|
|
69
|
+
import { MagicFieldType } from "../../models/magicFields";
|
|
70
|
+
import { getTimeBestString } from "../../utils";
|
|
71
|
+
|
|
72
|
+
import FSSelectField from "./FSSelectField.vue";
|
|
73
|
+
import FSIcon from "../FSIcon.vue";
|
|
74
|
+
import FSSpan from "../FSSpan.vue";
|
|
75
|
+
import FSRow from "../FSRow.vue";
|
|
76
|
+
|
|
77
|
+
export default defineComponent({
|
|
78
|
+
name: "FSMagicField",
|
|
79
|
+
components: {
|
|
80
|
+
FSSelectField,
|
|
81
|
+
FSIcon,
|
|
82
|
+
FSSpan,
|
|
83
|
+
FSRow
|
|
84
|
+
},
|
|
85
|
+
props: {
|
|
86
|
+
type: {
|
|
87
|
+
type: Number as PropType<MagicFieldType>,
|
|
88
|
+
required: false,
|
|
89
|
+
default: MagicFieldType.TextField
|
|
90
|
+
},
|
|
91
|
+
modelValue: {
|
|
92
|
+
type: String as PropType<string | null>,
|
|
93
|
+
required: false,
|
|
94
|
+
default: null
|
|
95
|
+
},
|
|
96
|
+
allowedValues: {
|
|
97
|
+
type: Array as PropType<{ value: string; label: string }[]>,
|
|
98
|
+
required: false,
|
|
99
|
+
default: () => []
|
|
100
|
+
},
|
|
101
|
+
useOnlyAllowedValues: {
|
|
102
|
+
type: Boolean,
|
|
103
|
+
required: false,
|
|
104
|
+
default: false
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
emits: ["update:modelValue"],
|
|
108
|
+
setup(props, { emit }) {
|
|
109
|
+
const { epochToShortTimeFormat } = useAppTimeZone();
|
|
110
|
+
const { $tr } = useTranslationsProvider();
|
|
111
|
+
const { get } = useMagicFieldProvider();
|
|
112
|
+
|
|
113
|
+
const items = computed(() => props.allowedValues.map((av) => ({
|
|
114
|
+
value: av.value,
|
|
115
|
+
label: av.label || asString(av.value),
|
|
116
|
+
})));
|
|
117
|
+
|
|
118
|
+
const valueToInput = computed((): any => {
|
|
119
|
+
switch (props.type) {
|
|
120
|
+
case MagicFieldType.NumberField:
|
|
121
|
+
case MagicFieldType.DateTimeField:
|
|
122
|
+
case MagicFieldType.TimeField:
|
|
123
|
+
if (props.modelValue == null || isNaN(parseFloat(props.modelValue))) {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
return parseFloat(props.modelValue);
|
|
127
|
+
case MagicFieldType.Switch:
|
|
128
|
+
if (props.modelValue == null) {
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
return props.modelValue === "true";
|
|
132
|
+
default:
|
|
133
|
+
return props.modelValue;
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
const asString = (value: any): string | null => {
|
|
138
|
+
if (value == null) {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
switch (props.type) {
|
|
142
|
+
case MagicFieldType.NumberField:
|
|
143
|
+
return value.toString();
|
|
144
|
+
case MagicFieldType.Switch:
|
|
145
|
+
if (value) {
|
|
146
|
+
return $tr("ui.magic-field.true", "True");
|
|
147
|
+
}
|
|
148
|
+
return $tr("ui.magic-field.false", "False");
|
|
149
|
+
case MagicFieldType.DateTimeField:
|
|
150
|
+
return epochToShortTimeFormat(value);
|
|
151
|
+
case MagicFieldType.TimeField:
|
|
152
|
+
return getTimeBestString(value);
|
|
153
|
+
default:
|
|
154
|
+
return value;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const inputToValue = (value: any) => {
|
|
159
|
+
switch (props.type) {
|
|
160
|
+
case MagicFieldType.NumberField:
|
|
161
|
+
case MagicFieldType.Switch:
|
|
162
|
+
case MagicFieldType.DateTimeField:
|
|
163
|
+
case MagicFieldType.TimeField:
|
|
164
|
+
if (value == null) {
|
|
165
|
+
emit("update:modelValue", null);
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
emit("update:modelValue", value.toString());
|
|
169
|
+
break;
|
|
170
|
+
default:
|
|
171
|
+
emit("update:modelValue", value);
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
return {
|
|
177
|
+
MagicFieldType,
|
|
178
|
+
valueToInput,
|
|
179
|
+
items,
|
|
180
|
+
inputToValue,
|
|
181
|
+
get
|
|
182
|
+
};
|
|
183
|
+
},
|
|
184
|
+
});
|
|
185
|
+
</script>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<FSTextField
|
|
3
|
+
class="fs-number-field"
|
|
3
4
|
:editable="$props.editable"
|
|
4
5
|
:modelValue="$props.modelValue?.toString()"
|
|
5
6
|
@update:modelValue="onUpdate"
|
|
@@ -18,7 +19,8 @@
|
|
|
18
19
|
</template>
|
|
19
20
|
|
|
20
21
|
<script lang="ts">
|
|
21
|
-
import {
|
|
22
|
+
import type { PropType } from "vue";
|
|
23
|
+
import { defineComponent } from "vue";
|
|
22
24
|
|
|
23
25
|
import FSTextField from "./FSTextField.vue";
|
|
24
26
|
|
|
@@ -18,23 +18,23 @@
|
|
|
18
18
|
<template
|
|
19
19
|
#append-inner
|
|
20
20
|
>
|
|
21
|
+
<FSButton
|
|
22
|
+
variant="icon"
|
|
23
|
+
:editable="$props.editable"
|
|
24
|
+
:color="ColorEnum.Dark"
|
|
25
|
+
:icon="icon"
|
|
26
|
+
@click="onToggle"
|
|
27
|
+
/>
|
|
21
28
|
<slot
|
|
22
29
|
name="append-inner"
|
|
23
|
-
|
|
24
|
-
<FSButton
|
|
25
|
-
variant="icon"
|
|
26
|
-
:editable="$props.editable"
|
|
27
|
-
:color="ColorEnum.Dark"
|
|
28
|
-
:icon="icon"
|
|
29
|
-
@click="onToggle"
|
|
30
|
-
/>
|
|
31
|
-
</slot>
|
|
30
|
+
/>
|
|
32
31
|
</template>
|
|
33
32
|
</FSTextField>
|
|
34
33
|
</template>
|
|
35
34
|
|
|
36
35
|
<script lang="ts">
|
|
37
|
-
import {
|
|
36
|
+
import type { PropType} from "vue";
|
|
37
|
+
import { computed, defineComponent, ref } from "vue";
|
|
38
38
|
|
|
39
39
|
import { useColors } from "@dative-gpi/foundation-shared-components/composables";
|
|
40
40
|
import { ColorEnum } from "@dative-gpi/foundation-shared-components/models";
|