@dative-gpi/foundation-core-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/components/autocompletes/FSAutocompleteChart.vue +208 -0
- package/components/autocompletes/FSAutocompleteDashboard.vue +33 -37
- package/components/autocompletes/FSAutocompleteDashboardOrganisation.vue +115 -0
- package/components/autocompletes/FSAutocompleteDataCategory.vue +16 -25
- package/components/autocompletes/FSAutocompleteDataDefinition.vue +17 -26
- package/components/autocompletes/FSAutocompleteGroup.vue +18 -27
- package/components/autocompletes/FSAutocompleteLocation.vue +22 -31
- package/components/autocompletes/FSAutocompleteManufacturer.vue +8 -8
- package/components/autocompletes/FSAutocompleteModel.vue +4 -4
- package/components/autocompletes/FSAutocompleteOrganisationType.vue +4 -4
- package/components/autocompletes/FSAutocompleteRole.vue +30 -34
- package/components/autocompletes/FSAutocompleteUserOrganisation.vue +20 -34
- package/components/customProperties/FSMetaField.vue +139 -107
- package/components/customProperties/FSMetaFormContent.vue +3 -2
- package/components/customProperties/FSMetaGrid.vue +4 -3
- package/components/customProperties/FSMetaHistory.vue +3 -2
- package/components/customProperties/FSMetaValue.vue +4 -2
- package/components/customProperties/helpers.ts +2 -1
- package/components/lists/FSDataTable.vue +48 -133
- package/components/selects/FSAggregationSelector.vue +51 -0
- package/components/selects/FSAxisTypeSelector.vue +48 -0
- package/components/selects/FSDataCategorySelector.vue +62 -0
- package/components/selects/FSDataDefinitionSelector.vue +66 -0
- package/components/selects/FSDisplayAsSelector.vue +52 -0
- package/components/selects/FSFilterTypeSelector.vue +53 -0
- package/components/selects/FSHeatmapRuleSelector.vue +52 -0
- package/components/selects/FSModelSelector.vue +56 -0
- package/components/selects/FSOperationOnSelector.vue +51 -0
- package/components/selects/FSPlanningTypeSelector.vue +50 -0
- package/components/selects/FSPlotPerSelector.vue +51 -0
- package/components/selects/FSSelectSelectedEntities.vue +59 -0
- package/components/selects/FSSerieTypeSelector.vue +51 -0
- package/components/tiles/FSDashboardOrganisationTile.vue +3 -2
- package/components/tiles/FSDashboardOrganisationTypeTile.vue +3 -2
- package/components/tiles/FSDashboardShallowTile.vue +4 -3
- package/components/tiles/FSFolderTile.vue +2 -1
- package/components/tiles/FSUserOrganisationTile.vue +21 -21
- package/components/treeviews/FSTreeViewFolder.vue +77 -0
- package/components/treeviews/FSTreeViewGroup.vue +77 -0
- package/package.json +14 -12
- package/utils/charts.ts +136 -0
- package/utils/dashboards.ts +6 -5
- package/utils/index.ts +1 -0
- package/utils/roles.ts +2 -1
- package/utils/users.ts +11 -2
|
@@ -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,86 @@
|
|
|
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 { PropType
|
|
110
|
-
|
|
111
|
-
import FSSwitch from "@dative-gpi/foundation-shared-components/components/FSSwitch.vue";
|
|
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";
|
|
92
|
+
import type { PropType } from "vue";
|
|
93
|
+
import { computed, defineComponent } from "vue";
|
|
116
94
|
|
|
117
|
-
import { CustomPropertyInfos, PropertyDataType } from "../../../foundation-core-domain/models";
|
|
118
95
|
import { useAppTimeZone } from "@dative-gpi/foundation-shared-services/composables";
|
|
119
96
|
|
|
97
|
+
import type { CustomPropertyInfos} from "../../../foundation-core-domain/models";
|
|
98
|
+
import { PropertyDataType } from "../../../foundation-core-domain/models";
|
|
99
|
+
|
|
100
|
+
import FSDateTimeField from "@dative-gpi/foundation-shared-components/components/fields/FSDateTimeField.vue";
|
|
101
|
+
import FSNumberField from "@dative-gpi/foundation-shared-components/components/fields/FSNumberField.vue";
|
|
102
|
+
import FSSelectField from "@dative-gpi/foundation-shared-components/components/fields/FSSelectField.vue";
|
|
103
|
+
import FSIconField from "@dative-gpi/foundation-shared-components/components/fields/FSIconField.vue";
|
|
104
|
+
import FSSwitch from "@dative-gpi/foundation-shared-components/components/FSSwitch.vue";
|
|
105
|
+
import FSIcon from "@dative-gpi/foundation-shared-components/components/FSIcon.vue";
|
|
106
|
+
import FSSpan from "@dative-gpi/foundation-shared-components/components/FSSpan.vue";
|
|
107
|
+
import FSText from "@dative-gpi/foundation-shared-components/components/FSText.vue";
|
|
120
108
|
|
|
121
109
|
export default defineComponent({
|
|
122
110
|
name: "FSMetaField",
|
|
123
111
|
components: {
|
|
124
|
-
|
|
125
|
-
FSIconField,
|
|
126
|
-
FSSelectField,
|
|
112
|
+
FSDateTimeField,
|
|
127
113
|
FSNumberField,
|
|
128
|
-
|
|
114
|
+
FSSelectField,
|
|
115
|
+
FSIconField,
|
|
116
|
+
FSSwitch,
|
|
117
|
+
FSIcon,
|
|
118
|
+
FSSpan,
|
|
119
|
+
FSText
|
|
129
120
|
},
|
|
130
121
|
props: {
|
|
122
|
+
label: {
|
|
123
|
+
type: String as PropType<string | null>,
|
|
124
|
+
required: false,
|
|
125
|
+
default: null
|
|
126
|
+
},
|
|
131
127
|
customProperty: {
|
|
132
128
|
type: Object as PropType<CustomPropertyInfos>,
|
|
133
129
|
required: true
|
|
134
130
|
},
|
|
135
131
|
modelValue: {
|
|
136
|
-
type: String
|
|
137
|
-
required:
|
|
132
|
+
type: String as PropType<string | null>,
|
|
133
|
+
required: false,
|
|
134
|
+
default: null
|
|
138
135
|
},
|
|
139
136
|
editable: {
|
|
140
137
|
type: Boolean,
|
|
@@ -142,53 +139,88 @@ export default defineComponent({
|
|
|
142
139
|
default: true
|
|
143
140
|
}
|
|
144
141
|
},
|
|
145
|
-
|
|
146
|
-
|
|
142
|
+
emits: ["update:modelValue"],
|
|
143
|
+
setup(props, { emit }) {
|
|
144
|
+
const { epochToLongTimeFormat } = useAppTimeZone();
|
|
147
145
|
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
146
|
+
const items = computed((): { id: string, label: string, icon: string | null }[] => {
|
|
147
|
+
return Object.keys(props.customProperty.allowedValues).map((key: string) => {
|
|
148
|
+
// If the allowed value is translated
|
|
149
|
+
if (props.customProperty.allowedValues[key]) {
|
|
150
|
+
return {
|
|
151
|
+
id: key,
|
|
152
|
+
label: props.customProperty.allowedValues[key],
|
|
153
|
+
icon: null
|
|
153
154
|
}
|
|
154
|
-
return "mdi-close-circle-outline";
|
|
155
|
-
}
|
|
156
|
-
case PropertyDataType.DateTime: {
|
|
157
|
-
return epochToLongTimeFormat(parseInt(item));
|
|
158
155
|
}
|
|
159
|
-
|
|
160
|
-
|
|
156
|
+
// If we have the value without translation
|
|
157
|
+
else {
|
|
158
|
+
switch (props.customProperty.dataType) {
|
|
159
|
+
case PropertyDataType.Boolean: return {
|
|
160
|
+
id: key,
|
|
161
|
+
label: key,
|
|
162
|
+
icon: key === "true" ? "mdi-check-circle-outline" : "mdi-close-circle-outline"
|
|
163
|
+
}
|
|
164
|
+
case PropertyDataType.DateTime: return {
|
|
165
|
+
id: key,
|
|
166
|
+
label: epochToLongTimeFormat(parseInt(key)),
|
|
167
|
+
icon: null
|
|
168
|
+
}
|
|
169
|
+
case PropertyDataType.Icon: return {
|
|
170
|
+
id: key,
|
|
171
|
+
label: key,
|
|
172
|
+
icon: key
|
|
173
|
+
}
|
|
174
|
+
default: return {
|
|
175
|
+
id: key,
|
|
176
|
+
label: key,
|
|
177
|
+
icon: null
|
|
178
|
+
}
|
|
179
|
+
}
|
|
161
180
|
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
181
|
+
});
|
|
182
|
+
});
|
|
164
183
|
|
|
165
|
-
const asNumber = (): number |
|
|
184
|
+
const asNumber = (): number | null => {
|
|
185
|
+
if (!props.modelValue) {
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
166
188
|
if (!isNaN(parseFloat(props.modelValue))) {
|
|
167
189
|
return parseFloat(props.modelValue);
|
|
168
190
|
}
|
|
169
|
-
return
|
|
170
|
-
}
|
|
191
|
+
return null;
|
|
192
|
+
};
|
|
171
193
|
|
|
172
|
-
const asBoolean = (): boolean => {
|
|
194
|
+
const asBoolean = (): boolean | null => {
|
|
195
|
+
if (!props.modelValue) {
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
173
198
|
return props.modelValue === "true";
|
|
174
|
-
}
|
|
199
|
+
};
|
|
175
200
|
|
|
176
|
-
const
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
201
|
+
const onUpdate = (value: any) => {
|
|
202
|
+
switch (props.customProperty.dataType) {
|
|
203
|
+
case PropertyDataType.Boolean:
|
|
204
|
+
case PropertyDataType.DateTime:
|
|
205
|
+
case PropertyDataType.Number:
|
|
206
|
+
if (value) {
|
|
207
|
+
emit("update:modelValue", value.toString());
|
|
208
|
+
break;
|
|
209
|
+
}
|
|
210
|
+
emit("update:modelValue", null);
|
|
211
|
+
break;
|
|
212
|
+
default:
|
|
213
|
+
emit("update:modelValue", value);
|
|
214
|
+
break;
|
|
180
215
|
}
|
|
181
|
-
|
|
182
|
-
}
|
|
216
|
+
};
|
|
183
217
|
|
|
184
218
|
return {
|
|
185
219
|
PropertyDataType,
|
|
186
|
-
|
|
187
|
-
getUserOffsetMillis,
|
|
188
|
-
asSelector,
|
|
189
|
-
asDateTime,
|
|
220
|
+
items,
|
|
190
221
|
asBoolean,
|
|
191
|
-
asNumber
|
|
222
|
+
asNumber,
|
|
223
|
+
onUpdate
|
|
192
224
|
};
|
|
193
225
|
}
|
|
194
226
|
});
|
|
@@ -27,9 +27,10 @@
|
|
|
27
27
|
</template>
|
|
28
28
|
|
|
29
29
|
<script lang="ts">
|
|
30
|
-
import {
|
|
30
|
+
import type { PropType } from 'vue';
|
|
31
|
+
import { defineComponent } from 'vue';
|
|
31
32
|
|
|
32
|
-
import { CustomPropertyInfos } from '@dative-gpi/foundation-core-domain/models';
|
|
33
|
+
import type { CustomPropertyInfos } from '@dative-gpi/foundation-core-domain/models';
|
|
33
34
|
|
|
34
35
|
import FSText from '@dative-gpi/foundation-shared-components/components/FSText.vue';
|
|
35
36
|
|
|
@@ -38,11 +38,12 @@
|
|
|
38
38
|
</template>
|
|
39
39
|
|
|
40
40
|
<script lang="ts">
|
|
41
|
-
import {
|
|
41
|
+
import type { PropType } from "vue";
|
|
42
|
+
import { computed, defineComponent } from "vue";
|
|
42
43
|
|
|
43
|
-
import { FSGridItem } from "@dative-gpi/foundation-shared-components/models";
|
|
44
|
+
import type { FSGridItem } from "@dative-gpi/foundation-shared-components/models";
|
|
44
45
|
|
|
45
|
-
import { CustomPropertyInfos } from "../../../foundation-core-domain/models";
|
|
46
|
+
import type { CustomPropertyInfos } from "../../../foundation-core-domain/models";
|
|
46
47
|
|
|
47
48
|
import FSGrid from "@dative-gpi/foundation-shared-components/components/FSGrid.vue";
|
|
48
49
|
|
|
@@ -33,7 +33,8 @@
|
|
|
33
33
|
</FSDialog>
|
|
34
34
|
</template>
|
|
35
35
|
<script lang="ts">
|
|
36
|
-
import { PropType
|
|
36
|
+
import type { PropType} from 'vue';
|
|
37
|
+
import { defineComponent, ref, watch } from 'vue';
|
|
37
38
|
import _ from 'lodash';
|
|
38
39
|
|
|
39
40
|
import { useAppTimeZone } from '@dative-gpi/foundation-shared-services/composables';
|
|
@@ -41,7 +42,7 @@ import { useAppTimeZone } from '@dative-gpi/foundation-shared-services/composabl
|
|
|
41
42
|
import FSDialog from "@dative-gpi/foundation-shared-components/components/FSDialog.vue";
|
|
42
43
|
import FSButton from "@dative-gpi/foundation-shared-components/components/FSButton.vue";
|
|
43
44
|
|
|
44
|
-
import { CustomPropertyInfos, PropertyEntity } from '../../../foundation-core-domain/models';
|
|
45
|
+
import type { CustomPropertyInfos, PropertyEntity } from '../../../foundation-core-domain/models';
|
|
45
46
|
import { useCustomPropertyValues } from '../../../foundation-core-services/composables';
|
|
46
47
|
|
|
47
48
|
import FSMetaValue from './FSMetaValue.vue';
|
|
@@ -28,11 +28,13 @@
|
|
|
28
28
|
</template>
|
|
29
29
|
|
|
30
30
|
<script lang="ts">
|
|
31
|
-
import { PropType
|
|
31
|
+
import type { PropType} from "vue";
|
|
32
|
+
import { computed, defineComponent } from "vue";
|
|
32
33
|
|
|
33
34
|
import { useAppTimeZone } from "@dative-gpi/foundation-shared-services/composables";
|
|
34
35
|
|
|
35
|
-
import { CustomPropertyInfos
|
|
36
|
+
import type { CustomPropertyInfos} from "../../../foundation-core-domain/models";
|
|
37
|
+
import { PropertyDataType } from "../../../foundation-core-domain/models";
|
|
36
38
|
import { getColor } from "./helpers";
|
|
37
39
|
|
|
38
40
|
import FSIconCheck from "@dative-gpi/foundation-shared-components/components/FSIconCheck.vue";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useAppTimeZone } from "@dative-gpi/foundation-shared-services/composables";
|
|
2
|
-
import { CustomPropertyInfos
|
|
2
|
+
import type { CustomPropertyInfos} from "../../../foundation-core-domain/models";
|
|
3
|
+
import { FilterType, PropertyDataType } from "../../../foundation-core-domain/models";
|
|
3
4
|
|
|
4
5
|
const { getUserOffsetMillis, getMachineOffsetMillis } = useAppTimeZone();
|
|
5
6
|
|
|
@@ -1,22 +1,16 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<FSLoadDataTable
|
|
3
|
-
v-if="gettingUserOrganisationTable"
|
|
3
|
+
v-if="!initialized || gettingUserOrganisationTable"
|
|
4
4
|
/>
|
|
5
5
|
<FSDataTableUI
|
|
6
6
|
v-else
|
|
7
|
-
:
|
|
8
|
-
:
|
|
9
|
-
:
|
|
10
|
-
:
|
|
11
|
-
:
|
|
12
|
-
:page="
|
|
13
|
-
|
|
14
|
-
@update:mode="updateMode"
|
|
15
|
-
@update:sortBy="updateSortBy"
|
|
16
|
-
@update:rowsPerPage="updateRowsPerPage"
|
|
17
|
-
@update:filters="updateFilters"
|
|
18
|
-
@update:page="updatePage"
|
|
19
|
-
v-bind="$attrs"
|
|
7
|
+
@update:rowsPerPage="table.rowsPerPage = $event"
|
|
8
|
+
@update:filters="table.filters = $event"
|
|
9
|
+
@update:headers="table.headers = $event"
|
|
10
|
+
@update:sortBy="table.sortBy = $event"
|
|
11
|
+
@update:mode="table.mode = $event"
|
|
12
|
+
@update:page="table.page = $event"
|
|
13
|
+
v-bind="{ ...computedTable, ...$attrs }"
|
|
20
14
|
>
|
|
21
15
|
<template
|
|
22
16
|
v-for="(_, name) in $slots"
|
|
@@ -31,12 +25,10 @@
|
|
|
31
25
|
</template>
|
|
32
26
|
|
|
33
27
|
<script lang="ts">
|
|
34
|
-
import { defineComponent, onUnmounted,
|
|
35
|
-
import { useRouter } from "vue-router";
|
|
28
|
+
import { computed, defineComponent, onUnmounted, type PropType, watch } from "vue";
|
|
36
29
|
|
|
37
|
-
import { useUserOrganisationTable, useUpdateUserOrganisationTable } from "@dative-gpi/foundation-core-services/composables";
|
|
38
|
-
import {
|
|
39
|
-
import { useDebounce } from "@dative-gpi/foundation-shared-components/composables";
|
|
30
|
+
import { useUserOrganisationTable, useUpdateUserOrganisationTable, useDataTables } from "@dative-gpi/foundation-core-services/composables";
|
|
31
|
+
import { useDebounce, useTables } from "@dative-gpi/foundation-shared-components/composables";
|
|
40
32
|
|
|
41
33
|
import FSLoadDataTable from "@dative-gpi/foundation-shared-components/components/lists/FSLoadDataTable.vue";
|
|
42
34
|
import FSDataTableUI from "@dative-gpi/foundation-shared-components/components/lists/FSDataTableUI.vue";
|
|
@@ -56,136 +48,59 @@ export default defineComponent({
|
|
|
56
48
|
type: Number,
|
|
57
49
|
required: false,
|
|
58
50
|
default: 1000
|
|
51
|
+
},
|
|
52
|
+
customSorts: {
|
|
53
|
+
type: Object as PropType<{ [key: string]: any }>,
|
|
54
|
+
required: false,
|
|
55
|
+
default: () => ({})
|
|
56
|
+
},
|
|
57
|
+
customSortRaws: {
|
|
58
|
+
type: Object as PropType<{ [key: string]: any }>,
|
|
59
|
+
required: false,
|
|
60
|
+
default: () => ({})
|
|
59
61
|
}
|
|
60
62
|
},
|
|
61
63
|
setup(props) {
|
|
62
|
-
const { get: getUserOrganisationTable, getting: gettingUserOrganisationTable
|
|
64
|
+
const { get: getUserOrganisationTable, getting: gettingUserOrganisationTable } = useUserOrganisationTable();
|
|
65
|
+
const { initialized, table, updateTable, computeTable, onTableCodeChange } = useDataTables();
|
|
63
66
|
const { update: updateUserOrganisationTable } = useUpdateUserOrganisationTable();
|
|
67
|
+
const { getTable, setTable } = useTables();
|
|
64
68
|
const { debounce, cancel } = useDebounce();
|
|
65
|
-
const router = useRouter();
|
|
66
|
-
|
|
67
|
-
const innerHeaders: Ref<FSDataTableColumn[]> = ref([]);
|
|
68
|
-
const innerSortBy: Ref<FSDataTableOrder | null> = ref(null);
|
|
69
|
-
const innerMode: Ref<"table" | "iterator"> = ref("table");
|
|
70
|
-
const innerRowsPerPage = ref(10);
|
|
71
|
-
|
|
72
|
-
const innerFilters = ref<{ [key: string]: FSDataTableFilter[] }>({});
|
|
73
|
-
const innerPage = ref(1);
|
|
74
|
-
|
|
75
|
-
const reset = (): void => {
|
|
76
|
-
if (router.currentRoute.value.meta.tables && (router.currentRoute.value.meta.tables as any)[props.tableCode]) {
|
|
77
|
-
const meta = (router.currentRoute.value.meta.tables as any)[props.tableCode];
|
|
78
|
-
innerHeaders.value = meta.columns;
|
|
79
|
-
innerRowsPerPage.value = meta.rowsPerPage;
|
|
80
|
-
innerSortBy.value = meta.sortBy;
|
|
81
|
-
innerMode.value = meta.mode;
|
|
82
|
-
|
|
83
|
-
innerFilters.value = meta.filters;
|
|
84
|
-
innerPage.value = meta.page;
|
|
85
|
-
}
|
|
86
|
-
else if (userOrganisationTable.value) {
|
|
87
|
-
innerHeaders.value = userOrganisationTable.value.columns;
|
|
88
|
-
innerRowsPerPage.value = userOrganisationTable.value.rowsPerPage;
|
|
89
|
-
if (userOrganisationTable.value.sortByKey && userOrganisationTable.value.sortByOrder) {
|
|
90
|
-
innerSortBy.value = {
|
|
91
|
-
key: userOrganisationTable.value.sortByKey,
|
|
92
|
-
order: userOrganisationTable.value.sortByOrder
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
innerMode.value = userOrganisationTable.value.mode;
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
const updateHeaders = (value: FSDataTableColumn[]): void => {
|
|
100
|
-
innerHeaders.value = value;
|
|
101
|
-
debounce(updateTable, props.debounceTime);
|
|
102
|
-
};
|
|
103
69
|
|
|
104
|
-
const
|
|
105
|
-
innerMode.value = value;
|
|
106
|
-
debounce(updateTable, props.debounceTime);
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
const updateSortBy = (value: FSDataTableOrder | null): void => {
|
|
110
|
-
innerSortBy.value = value;
|
|
111
|
-
debounce(updateTable, props.debounceTime);
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
const updateRowsPerPage = (value: -1 | 10 | 30): void => {
|
|
115
|
-
innerRowsPerPage.value = value;
|
|
116
|
-
debounce(updateTable, props.debounceTime);
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
const updateFilters = (value: { [key: string]: FSDataTableFilter[] }): void => {
|
|
120
|
-
innerFilters.value = value;
|
|
121
|
-
updateRouter();
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
const updatePage = (value: number): void => {
|
|
125
|
-
innerPage.value = value;
|
|
126
|
-
updateRouter();
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
const updateTable = (): void => {
|
|
130
|
-
updateRouter();
|
|
131
|
-
updateUserOrganisationTable(props.tableCode, {
|
|
132
|
-
columns: innerHeaders.value.map(column => ({
|
|
133
|
-
columnId: column.columnId,
|
|
134
|
-
hidden: column.hidden,
|
|
135
|
-
index: column.index
|
|
136
|
-
})),
|
|
137
|
-
rowsPerPage: innerRowsPerPage.value,
|
|
138
|
-
sortByKey: innerSortBy.value?.key ?? null,
|
|
139
|
-
sortByOrder: innerSortBy.value?.order ?? null,
|
|
140
|
-
mode: innerMode.value
|
|
141
|
-
});
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
const updateRouter = (): void => {
|
|
145
|
-
if (router) {
|
|
146
|
-
router.currentRoute.value.meta.tables = {
|
|
147
|
-
...(router.currentRoute.value.meta.tables as any),
|
|
148
|
-
[props.tableCode]: {
|
|
149
|
-
columns: innerHeaders.value,
|
|
150
|
-
filters: innerFilters.value,
|
|
151
|
-
rowsPerPage: innerRowsPerPage.value,
|
|
152
|
-
sortBy: innerSortBy.value,
|
|
153
|
-
mode: innerMode.value,
|
|
154
|
-
page: innerPage.value
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
};
|
|
70
|
+
const computedTable = computed(() => computeTable(props.customSorts, props.customSortRaws));
|
|
159
71
|
|
|
160
72
|
onUnmounted(() => {
|
|
161
73
|
cancel();
|
|
162
|
-
|
|
74
|
+
update();
|
|
163
75
|
});
|
|
164
76
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
77
|
+
const update = () => {
|
|
78
|
+
updateTable(
|
|
79
|
+
updateUserOrganisationTable,
|
|
80
|
+
setTable,
|
|
81
|
+
props.tableCode
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
watch(() => props.tableCode, async (): Promise<void> => {
|
|
86
|
+
onTableCodeChange(
|
|
87
|
+
getUserOrganisationTable,
|
|
88
|
+
getTable,
|
|
89
|
+
props.tableCode
|
|
90
|
+
);
|
|
169
91
|
}, { immediate: true });
|
|
170
92
|
|
|
171
|
-
watch(
|
|
172
|
-
|
|
173
|
-
|
|
93
|
+
watch(() => table.value, () => {
|
|
94
|
+
if (table.value && initialized.value) {
|
|
95
|
+
debounce(update, props.debounceTime);
|
|
96
|
+
}
|
|
97
|
+
}, { deep: true });
|
|
174
98
|
|
|
175
99
|
return {
|
|
176
100
|
gettingUserOrganisationTable,
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
innerSortBy,
|
|
181
|
-
innerMode,
|
|
182
|
-
innerPage,
|
|
183
|
-
updateRowsPerPage,
|
|
184
|
-
updateFilters,
|
|
185
|
-
updateHeaders,
|
|
186
|
-
updateSortBy,
|
|
187
|
-
updateMode,
|
|
188
|
-
updatePage
|
|
101
|
+
computedTable,
|
|
102
|
+
initialized,
|
|
103
|
+
table
|
|
189
104
|
};
|
|
190
105
|
},
|
|
191
106
|
});
|