@dative-gpi/foundation-core-components 0.0.123 → 0.0.124
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.
|
@@ -1,67 +1,50 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<FSSelectField
|
|
3
3
|
v-if="$props.customProperty.useOnlyAllowedValues"
|
|
4
|
-
|
|
5
|
-
:
|
|
6
|
-
:
|
|
4
|
+
class="fs-meta-field"
|
|
5
|
+
:editable="$props.editable"
|
|
6
|
+
:label="$props.label"
|
|
7
|
+
:items="items"
|
|
7
8
|
:modelValue="$props.modelValue"
|
|
8
|
-
@update:modelValue="
|
|
9
|
+
@update:modelValue="onUpdate"
|
|
9
10
|
>
|
|
10
11
|
<template
|
|
11
12
|
#selection="{ item }"
|
|
12
13
|
>
|
|
13
|
-
<
|
|
14
|
-
v-if="
|
|
15
|
-
class="text-body-1"
|
|
14
|
+
<FSIcon
|
|
15
|
+
v-if="item.raw.icon"
|
|
16
16
|
>
|
|
17
|
-
{{
|
|
18
|
-
</
|
|
19
|
-
<
|
|
20
|
-
v-else
|
|
21
|
-
class="text-body-1"
|
|
17
|
+
{{ item.raw.icon }}
|
|
18
|
+
</FSIcon>
|
|
19
|
+
<FSText
|
|
20
|
+
v-else
|
|
22
21
|
>
|
|
23
|
-
{{
|
|
24
|
-
</
|
|
22
|
+
{{ item.raw.label }}
|
|
23
|
+
</FSText>
|
|
24
|
+
</template>
|
|
25
|
+
<template
|
|
26
|
+
#selection-mobile="{ item }"
|
|
27
|
+
>
|
|
25
28
|
<FSIcon
|
|
26
|
-
v-
|
|
29
|
+
v-if="item.raw.icon"
|
|
27
30
|
>
|
|
28
|
-
{{
|
|
31
|
+
{{ item.raw.icon }}
|
|
29
32
|
</FSIcon>
|
|
30
33
|
</template>
|
|
31
34
|
<template
|
|
32
|
-
#item="{
|
|
35
|
+
#item-label="{ item, font }"
|
|
33
36
|
>
|
|
34
|
-
<
|
|
35
|
-
v-
|
|
37
|
+
<FSIcon
|
|
38
|
+
v-if="item.raw.icon"
|
|
39
|
+
>
|
|
40
|
+
{{ item.raw.icon }}
|
|
41
|
+
</FSIcon>
|
|
42
|
+
<FSSpan
|
|
43
|
+
v-else
|
|
44
|
+
:font="font"
|
|
36
45
|
>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
>
|
|
40
|
-
<FSSpan
|
|
41
|
-
v-if="customProperty.allowedValues[item.value] != null"
|
|
42
|
-
class="text-body-1"
|
|
43
|
-
>
|
|
44
|
-
{{ customProperty.allowedValues[item.value] }}
|
|
45
|
-
</FSSpan>
|
|
46
|
-
<FSSpan
|
|
47
|
-
v-else-if="[PropertyDataType.Number, PropertyDataType.String].includes($props.customProperty.dataType)"
|
|
48
|
-
class="text-body-1"
|
|
49
|
-
>
|
|
50
|
-
{{ asSelector(item.value) }}
|
|
51
|
-
</FSSpan>
|
|
52
|
-
<FSSpan
|
|
53
|
-
v-else-if="[PropertyDataType.DateTime].includes($props.customProperty.dataType)"
|
|
54
|
-
class="text-body-1"
|
|
55
|
-
>
|
|
56
|
-
{{ asSelector(item.value) }}
|
|
57
|
-
</FSSpan>
|
|
58
|
-
<FSIcon
|
|
59
|
-
v-else-if="[PropertyDataType.Boolean, PropertyDataType.Icon].includes($props.customProperty.dataType)"
|
|
60
|
-
>
|
|
61
|
-
{{ asSelector(item.value) }}
|
|
62
|
-
</FSIcon>
|
|
63
|
-
</FSRow>
|
|
64
|
-
</v-list-item>
|
|
46
|
+
{{ item.raw.label }}
|
|
47
|
+
</FSSpan>
|
|
65
48
|
</template>
|
|
66
49
|
</FSSelectField>
|
|
67
50
|
<template
|
|
@@ -69,72 +52,84 @@
|
|
|
69
52
|
>
|
|
70
53
|
<FSNumberField
|
|
71
54
|
v-if="$props.customProperty.dataType === PropertyDataType.Number"
|
|
72
|
-
:
|
|
73
|
-
:
|
|
55
|
+
:editable="$props.editable"
|
|
56
|
+
:label="$props.label"
|
|
74
57
|
:modelValue="asNumber()"
|
|
75
|
-
@update:modelValue="
|
|
58
|
+
@update:modelValue="onUpdate"
|
|
76
59
|
/>
|
|
77
60
|
<FSSwitch
|
|
78
61
|
v-else-if="$props.customProperty.dataType === PropertyDataType.Boolean"
|
|
79
|
-
:
|
|
80
|
-
:
|
|
62
|
+
:editable="$props.editable"
|
|
63
|
+
:label="$props.label"
|
|
81
64
|
:modelValue="asBoolean()"
|
|
82
|
-
@update:modelValue="
|
|
65
|
+
@update:modelValue="onUpdate"
|
|
83
66
|
/>
|
|
84
67
|
<FSTextField
|
|
85
68
|
v-else-if="$props.customProperty.dataType === PropertyDataType.String"
|
|
86
|
-
:
|
|
87
|
-
:
|
|
69
|
+
:editable="$props.editable"
|
|
70
|
+
:label="$props.label"
|
|
88
71
|
:modelValue="$props.modelValue"
|
|
89
|
-
@update:modelValue="
|
|
72
|
+
@update:modelValue="onUpdate"
|
|
90
73
|
/>
|
|
91
74
|
<FSDateTimeField
|
|
92
75
|
v-else-if="$props.customProperty.dataType === PropertyDataType.DateTime"
|
|
93
|
-
:
|
|
94
|
-
:
|
|
76
|
+
:editable="$props.editable"
|
|
77
|
+
:label="$props.label"
|
|
95
78
|
:modelValue="asNumber()"
|
|
96
|
-
@update:modelValue="
|
|
79
|
+
@update:modelValue="onUpdate"
|
|
97
80
|
/>
|
|
98
81
|
<FSIconField
|
|
99
82
|
v-else-if="$props.customProperty.dataType === PropertyDataType.Icon"
|
|
100
|
-
:
|
|
101
|
-
:
|
|
83
|
+
:editable="$props.editable"
|
|
84
|
+
:label="$props.label"
|
|
102
85
|
:modelValue="modelValue"
|
|
103
|
-
@update:modelValue="
|
|
86
|
+
@update:modelValue="onUpdate"
|
|
104
87
|
/>
|
|
105
88
|
</template>
|
|
106
89
|
</template>
|
|
107
90
|
|
|
108
91
|
<script lang="ts">
|
|
109
|
-
import {
|
|
92
|
+
import { computed, defineComponent, PropType } from "vue";
|
|
110
93
|
|
|
111
|
-
import
|
|
112
|
-
import FSIconField from "@dative-gpi/foundation-shared-components/components/fields/FSIconField.vue";
|
|
113
|
-
import FSSelectField from "@dative-gpi/foundation-shared-components/components/fields/FSSelectField.vue";
|
|
114
|
-
import FSNumberField from "@dative-gpi/foundation-shared-components/components/fields/FSNumberField.vue";
|
|
115
|
-
import FSDateTimeField from "@dative-gpi/foundation-shared-components/components/fields/FSDateTimeField.vue";
|
|
94
|
+
import { useAppTimeZone } from "@dative-gpi/foundation-shared-services/composables";
|
|
116
95
|
|
|
117
96
|
import { CustomPropertyInfos, PropertyDataType } from "../../../foundation-core-domain/models";
|
|
118
|
-
import { useAppTimeZone } from "@dative-gpi/foundation-shared-services/composables";
|
|
119
97
|
|
|
98
|
+
import FSDateTimeField from "@dative-gpi/foundation-shared-components/components/fields/FSDateTimeField.vue";
|
|
99
|
+
import FSNumberField from "@dative-gpi/foundation-shared-components/components/fields/FSNumberField.vue";
|
|
100
|
+
import FSSelectField from "@dative-gpi/foundation-shared-components/components/fields/FSSelectField.vue";
|
|
101
|
+
import FSIconField from "@dative-gpi/foundation-shared-components/components/fields/FSIconField.vue";
|
|
102
|
+
import FSSwitch from "@dative-gpi/foundation-shared-components/components/FSSwitch.vue";
|
|
103
|
+
import FSIcon from "@dative-gpi/foundation-shared-components/components/FSIcon.vue";
|
|
104
|
+
import FSSpan from "@dative-gpi/foundation-shared-components/components/FSSpan.vue";
|
|
105
|
+
import FSText from "@dative-gpi/foundation-shared-components/components/FSText.vue";
|
|
120
106
|
|
|
121
107
|
export default defineComponent({
|
|
122
108
|
name: "FSMetaField",
|
|
123
109
|
components: {
|
|
124
|
-
|
|
125
|
-
FSIconField,
|
|
126
|
-
FSSelectField,
|
|
110
|
+
FSDateTimeField,
|
|
127
111
|
FSNumberField,
|
|
128
|
-
|
|
112
|
+
FSSelectField,
|
|
113
|
+
FSIconField,
|
|
114
|
+
FSSwitch,
|
|
115
|
+
FSIcon,
|
|
116
|
+
FSSpan,
|
|
117
|
+
FSText
|
|
129
118
|
},
|
|
130
119
|
props: {
|
|
120
|
+
label: {
|
|
121
|
+
type: String as PropType<string | null>,
|
|
122
|
+
required: false,
|
|
123
|
+
default: null
|
|
124
|
+
},
|
|
131
125
|
customProperty: {
|
|
132
126
|
type: Object as PropType<CustomPropertyInfos>,
|
|
133
127
|
required: true
|
|
134
128
|
},
|
|
135
129
|
modelValue: {
|
|
136
|
-
type: String
|
|
137
|
-
required:
|
|
130
|
+
type: String as PropType<string | null>,
|
|
131
|
+
required: false,
|
|
132
|
+
default: null
|
|
138
133
|
},
|
|
139
134
|
editable: {
|
|
140
135
|
type: Boolean,
|
|
@@ -142,53 +137,88 @@ export default defineComponent({
|
|
|
142
137
|
default: true
|
|
143
138
|
}
|
|
144
139
|
},
|
|
145
|
-
|
|
146
|
-
|
|
140
|
+
emits: ["update:modelValue"],
|
|
141
|
+
setup(props, { emit }) {
|
|
142
|
+
const { epochToLongTimeFormat } = useAppTimeZone();
|
|
147
143
|
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
144
|
+
const items = computed((): { id: string, label: string, icon: string | null }[] => {
|
|
145
|
+
return Object.keys(props.customProperty.allowedValues).map((key: string) => {
|
|
146
|
+
// If the allowed value is translated
|
|
147
|
+
if (props.customProperty.allowedValues[key]) {
|
|
148
|
+
return {
|
|
149
|
+
id: key,
|
|
150
|
+
label: props.customProperty.allowedValues[key],
|
|
151
|
+
icon: null
|
|
153
152
|
}
|
|
154
|
-
return "mdi-close-circle-outline";
|
|
155
|
-
}
|
|
156
|
-
case PropertyDataType.DateTime: {
|
|
157
|
-
return epochToLongTimeFormat(parseInt(item));
|
|
158
153
|
}
|
|
159
|
-
|
|
160
|
-
|
|
154
|
+
// If we have the value without translation
|
|
155
|
+
else {
|
|
156
|
+
switch (props.customProperty.dataType) {
|
|
157
|
+
case PropertyDataType.Boolean: return {
|
|
158
|
+
id: key,
|
|
159
|
+
label: key,
|
|
160
|
+
icon: key === "true" ? "mdi-check-circle-outline" : "mdi-close-circle-outline"
|
|
161
|
+
}
|
|
162
|
+
case PropertyDataType.DateTime: return {
|
|
163
|
+
id: key,
|
|
164
|
+
label: epochToLongTimeFormat(parseInt(key)),
|
|
165
|
+
icon: null
|
|
166
|
+
}
|
|
167
|
+
case PropertyDataType.Icon: return {
|
|
168
|
+
id: key,
|
|
169
|
+
label: key,
|
|
170
|
+
icon: key
|
|
171
|
+
}
|
|
172
|
+
default: return {
|
|
173
|
+
id: key,
|
|
174
|
+
label: key,
|
|
175
|
+
icon: null
|
|
176
|
+
}
|
|
177
|
+
}
|
|
161
178
|
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
179
|
+
});
|
|
180
|
+
});
|
|
164
181
|
|
|
165
|
-
const asNumber = (): number |
|
|
182
|
+
const asNumber = (): number | null => {
|
|
183
|
+
if (!props.modelValue) {
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
166
186
|
if (!isNaN(parseFloat(props.modelValue))) {
|
|
167
187
|
return parseFloat(props.modelValue);
|
|
168
188
|
}
|
|
169
|
-
return
|
|
170
|
-
}
|
|
189
|
+
return null;
|
|
190
|
+
};
|
|
171
191
|
|
|
172
|
-
const asBoolean = (): boolean => {
|
|
192
|
+
const asBoolean = (): boolean | null => {
|
|
193
|
+
if (!props.modelValue) {
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
173
196
|
return props.modelValue === "true";
|
|
174
|
-
}
|
|
197
|
+
};
|
|
175
198
|
|
|
176
|
-
const
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
199
|
+
const onUpdate = (value: any) => {
|
|
200
|
+
switch (props.customProperty.dataType) {
|
|
201
|
+
case PropertyDataType.Boolean:
|
|
202
|
+
case PropertyDataType.DateTime:
|
|
203
|
+
case PropertyDataType.Number:
|
|
204
|
+
if (value) {
|
|
205
|
+
emit("update:modelValue", value.toString());
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
emit("update:modelValue", null);
|
|
209
|
+
break;
|
|
210
|
+
default:
|
|
211
|
+
emit("update:modelValue", value);
|
|
212
|
+
break;
|
|
180
213
|
}
|
|
181
|
-
|
|
182
|
-
}
|
|
214
|
+
};
|
|
183
215
|
|
|
184
216
|
return {
|
|
185
217
|
PropertyDataType,
|
|
186
|
-
|
|
187
|
-
getUserOffsetMillis,
|
|
188
|
-
asSelector,
|
|
189
|
-
asDateTime,
|
|
218
|
+
items,
|
|
190
219
|
asBoolean,
|
|
191
|
-
asNumber
|
|
220
|
+
asNumber,
|
|
221
|
+
onUpdate
|
|
192
222
|
};
|
|
193
223
|
}
|
|
194
224
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dative-gpi/foundation-core-components",
|
|
3
3
|
"sideEffects": false,
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.124",
|
|
5
5
|
"description": "",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
"author": "",
|
|
11
11
|
"license": "ISC",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@dative-gpi/foundation-core-domain": "0.0.
|
|
14
|
-
"@dative-gpi/foundation-core-services": "0.0.
|
|
15
|
-
"@dative-gpi/foundation-shared-components": "0.0.
|
|
16
|
-
"@dative-gpi/foundation-shared-domain": "0.0.
|
|
17
|
-
"@dative-gpi/foundation-shared-services": "0.0.
|
|
13
|
+
"@dative-gpi/foundation-core-domain": "0.0.124",
|
|
14
|
+
"@dative-gpi/foundation-core-services": "0.0.124",
|
|
15
|
+
"@dative-gpi/foundation-shared-components": "0.0.124",
|
|
16
|
+
"@dative-gpi/foundation-shared-domain": "0.0.124",
|
|
17
|
+
"@dative-gpi/foundation-shared-services": "0.0.124",
|
|
18
18
|
"color": "^4.2.3",
|
|
19
19
|
"vue": "^3.4.23",
|
|
20
20
|
"vuedraggable": "^4.1.0"
|
|
@@ -24,5 +24,5 @@
|
|
|
24
24
|
"sass": "^1.69.5",
|
|
25
25
|
"sass-loader": "^13.3.2"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "37128d517dbaf731a08637d60b8b996b4d6e8019"
|
|
28
28
|
}
|