@dative-gpi/foundation-core-components 1.0.62 → 1.0.64

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.
@@ -9,84 +9,29 @@
9
9
  <template
10
10
  #body
11
11
  >
12
- <FSCol
13
- gap="24px"
14
- >
15
- <FSCol>
16
- <FSText
17
- font="text-button"
18
- >
19
- {{ $tr("ui.common.selection-reminder", "Selection reminder") }}
20
- </FSText>
21
- <FSRow
22
- align="center-left"
23
- height="50px"
24
- >
25
- <FSSlideGroup
26
- v-if="actualSelecteds.length > 0"
27
- >
28
- <FSSimpleEntitiesList
29
- :entity-type="$props.entityType"
30
- :filters="simpleListFilters"
31
- :showEdit="false"
32
- :showRemove="false"
33
- direction="row"
34
- />
35
- </FSSlideGroup>
36
- <FSText
37
- v-else
38
- >
39
- {{ $tr("ui.common.no-selection", "No selection") }}
40
- </FSText>
41
- </FSRow>
42
- </FSCol>
43
-
44
- <FSCol>
45
- <FSText
46
- font="text-button"
47
- >
48
- {{ $tr("ui.common.entities-list", "Entities list") }}
49
- </FSText>
50
- <FSBaseEntitiesList
51
- :entity-type="$props.entityType"
52
- :tableCode="tableCode"
53
- v-model="actualSelecteds"
54
- v-bind="baseTableAttrs"
55
- />
56
- </FSCol>
57
- </FSCol>
12
+ <FSSelectEntitiesList
13
+ :entityType="$props.entityType"
14
+ :modelValue="actualSelecteds"
15
+ :filters="$props.filters"
16
+ @update:modelValue="actualSelecteds = $event"
17
+ />
58
18
  </template>
59
19
  </FSDialogSubmit>
60
20
  </template>
61
21
 
62
22
  <script lang="ts">
63
- import { defineComponent, type PropType, computed, ref, watch } from "vue";
64
-
65
- import { EntityType } from "@dative-gpi/foundation-shared-domain/enums";
66
- import type { DashboardOrganisationFilters, DashboardOrganisationTypeFilters, DeviceOrganisationFilters, FolderFilters, GroupFilters, LocationFilters, ModelFilters, UserOrganisationFilters } from "@dative-gpi/foundation-core-domain/models";
23
+ import { defineComponent, type PropType, ref, watch } from "vue";
67
24
 
68
- import { TABLES as T } from "../../utils";
25
+ import type { EntityType } from "@dative-gpi/foundation-shared-domain/enums";
69
26
 
70
- import FSSlideGroup from "@dative-gpi/foundation-shared-components/components/FSSlideGroup.vue";
71
27
  import FSDialogSubmit from "@dative-gpi/foundation-shared-components/components/FSDialogSubmit.vue";
72
- import FSCol from "@dative-gpi/foundation-shared-components/components/FSCol.vue";
73
- import FSRow from "@dative-gpi/foundation-shared-components/components/FSRow.vue";
74
- import FSText from "@dative-gpi/foundation-shared-components/components/FSText.vue";
75
-
76
-
77
- import FSSimpleEntitiesList from "./FSSimpleEntitiesList.vue";
78
- import FSBaseEntitiesList from "./FSBaseEntitiesList.vue";
28
+ import FSSelectEntitiesList from "./FSSelectEntitiesList.vue";
79
29
 
80
30
  export default defineComponent({
81
31
  name: "FSDialogSelectEntities",
82
32
  components: {
83
- FSSimpleEntitiesList,
84
- FSBaseEntitiesList,
85
- FSSlideGroup,
33
+ FSSelectEntitiesList,
86
34
  FSDialogSubmit,
87
- FSCol,
88
- FSRow,
89
- FSText
90
35
  },
91
36
  emits: ["update:modelValue", "update:selecteds"],
92
37
  props: {
@@ -110,98 +55,9 @@ export default defineComponent({
110
55
  default: false
111
56
  }
112
57
  },
113
- setup(props, { attrs, emit }){
58
+ setup(props, { emit }){
114
59
  const actualSelecteds = ref<string[]>([]);
115
60
 
116
- const simpleListFilters = computed(() => {
117
- switch(props.entityType) {
118
- case EntityType.Device:
119
- return {
120
- deviceOrganisationsIds: actualSelecteds.value
121
- } satisfies DeviceOrganisationFilters;
122
- case EntityType.Dashboard:
123
- return {
124
- dashboardOrganisationsIds: actualSelecteds.value,
125
- dashboardOrganisationTypesIds: actualSelecteds.value
126
- } satisfies DashboardOrganisationFilters & DashboardOrganisationTypeFilters;
127
- case EntityType.Group:
128
- return {
129
- groupsIds: actualSelecteds.value
130
- } satisfies GroupFilters;
131
- case EntityType.Folder:
132
- return {
133
- foldersIds: actualSelecteds.value
134
- } satisfies FolderFilters;
135
- case EntityType.Location:
136
- return {
137
- locationsIds: actualSelecteds.value
138
- } satisfies LocationFilters;
139
- case EntityType.User:
140
- return {
141
- userOrganisationsIds: actualSelecteds.value
142
- } satisfies UserOrganisationFilters;
143
- case EntityType.Model:
144
- return {
145
- modelsIds: actualSelecteds.value
146
- } satisfies ModelFilters;
147
- default:
148
- return undefined;
149
- };
150
- })
151
-
152
- const tableCode = computed(() => {
153
- switch(props.entityType) {
154
- case EntityType.Device:
155
- return T.DEVICES_SELECT;
156
- default:
157
- return null;
158
- };
159
- })
160
-
161
- const baseTableAttrs = computed(() => {
162
- switch(props.entityType) {
163
- case EntityType.Device:
164
- return {
165
- deviceOrganisationFilters: props.filters,
166
- ...attrs
167
- };
168
- case EntityType.Dashboard:
169
- return {
170
- dashboardShallowsFilters: props.filters,
171
- dashboardOrganisationsFilters: props.filters,
172
- dashboardOrganisationTypeFetchFilter: props.filters,
173
- ...attrs
174
- };
175
- case EntityType.Group:
176
- return {
177
- groupsFilters: props.filters,
178
- ...attrs
179
- };
180
- case EntityType.Folder:
181
- return {
182
- foldersFilters: props.filters,
183
- ...attrs
184
- };
185
- case EntityType.Location:
186
- return {
187
- locationsFilters: props.filters,
188
- ...attrs
189
- };
190
- case EntityType.User:
191
- return {
192
- userOrganisationsFilters: props.filters,
193
- ...attrs
194
- };
195
- case EntityType.Model:
196
- return {
197
- modelsFilters: props.filters,
198
- ...attrs
199
- };
200
- default:
201
- return null;
202
- };
203
- });
204
-
205
61
  const onSubmit = () => {
206
62
  emit("update:selecteds", actualSelecteds.value);
207
63
  emit("update:modelValue", false);
@@ -213,10 +69,7 @@ export default defineComponent({
213
69
 
214
70
  return {
215
71
  onSubmit,
216
- actualSelecteds,
217
- simpleListFilters,
218
- baseTableAttrs,
219
- tableCode
72
+ actualSelecteds
220
73
  }
221
74
  }
222
75
  });
@@ -0,0 +1,192 @@
1
+ <template>
2
+ <FSCol
3
+ gap="24px"
4
+ >
5
+ <FSCol>
6
+ <FSText
7
+ font="text-button"
8
+ >
9
+ {{ $tr("ui.common.selection-reminder", "Selection reminder") }}
10
+ </FSText>
11
+ <FSRow
12
+ align="center-left"
13
+ height="50px"
14
+ >
15
+ <FSSlideGroup
16
+ v-if="$props.modelValue && $props.modelValue.length > 0"
17
+ >
18
+ <FSSimpleEntitiesList
19
+ :entity-type="$props.entityType"
20
+ :filters="simpleListFilters"
21
+ :showEdit="false"
22
+ :showRemove="false"
23
+ direction="row"
24
+ />
25
+ </FSSlideGroup>
26
+ <FSText
27
+ v-else
28
+ >
29
+ {{ $tr("ui.common.no-selection", "No selection") }}
30
+ </FSText>
31
+ </FSRow>
32
+ </FSCol>
33
+
34
+ <FSCol>
35
+ <FSText
36
+ font="text-button"
37
+ >
38
+ {{ $tr("ui.common.entities-list", "Entities list") }}
39
+ </FSText>
40
+ <FSBaseEntitiesList
41
+ :entity-type="$props.entityType"
42
+ :tableCode="tableCode"
43
+ :modelValue="$props.modelValue"
44
+ @update:modelValue="$emit('update:modelValue', $event)"
45
+ v-bind="baseTableAttrs"
46
+ />
47
+ </FSCol>
48
+ </FSCol>
49
+ </template>
50
+
51
+ <script lang="ts">
52
+ import { defineComponent, type PropType, computed } from "vue";
53
+
54
+ import { EntityType } from "@dative-gpi/foundation-shared-domain/enums";
55
+ import type { DashboardOrganisationFilters, DashboardOrganisationTypeFilters, DeviceOrganisationFilters, FolderFilters, GroupFilters, LocationFilters, ModelFilters, UserOrganisationFilters } from "@dative-gpi/foundation-core-domain/models";
56
+
57
+ import { TABLES as T } from "../../utils";
58
+
59
+ import FSSlideGroup from "@dative-gpi/foundation-shared-components/components/FSSlideGroup.vue";
60
+ import FSCol from "@dative-gpi/foundation-shared-components/components/FSCol.vue";
61
+ import FSRow from "@dative-gpi/foundation-shared-components/components/FSRow.vue";
62
+ import FSText from "@dative-gpi/foundation-shared-components/components/FSText.vue";
63
+
64
+
65
+ import FSSimpleEntitiesList from "./FSSimpleEntitiesList.vue";
66
+ import FSBaseEntitiesList from "./FSBaseEntitiesList.vue";
67
+
68
+ export default defineComponent({
69
+ name: "FSSelectEntitiesList",
70
+ components: {
71
+ FSSimpleEntitiesList,
72
+ FSBaseEntitiesList,
73
+ FSSlideGroup,
74
+ FSCol,
75
+ FSRow,
76
+ FSText
77
+ },
78
+ emits: ["update:modelValue"],
79
+ props: {
80
+ entityType: {
81
+ type: Number as PropType<EntityType>,
82
+ required: true
83
+ },
84
+ modelValue: {
85
+ type: Array as PropType<string[]>,
86
+ required: false,
87
+ default: () => []
88
+ },
89
+ filters: {
90
+ type: Object,
91
+ required: false,
92
+ default: null
93
+ }
94
+ },
95
+ setup(props, { attrs }){
96
+ const simpleListFilters = computed(() => {
97
+ switch(props.entityType) {
98
+ case EntityType.Device:
99
+ return {
100
+ deviceOrganisationsIds: props.modelValue
101
+ } satisfies DeviceOrganisationFilters;
102
+ case EntityType.Dashboard:
103
+ return {
104
+ dashboardOrganisationsIds: props.modelValue,
105
+ dashboardOrganisationTypesIds: props.modelValue
106
+ } satisfies DashboardOrganisationFilters & DashboardOrganisationTypeFilters;
107
+ case EntityType.Group:
108
+ return {
109
+ groupsIds: props.modelValue
110
+ } satisfies GroupFilters;
111
+ case EntityType.Folder:
112
+ return {
113
+ foldersIds: props.modelValue
114
+ } satisfies FolderFilters;
115
+ case EntityType.Location:
116
+ return {
117
+ locationsIds: props.modelValue
118
+ } satisfies LocationFilters;
119
+ case EntityType.User:
120
+ return {
121
+ userOrganisationsIds: props.modelValue
122
+ } satisfies UserOrganisationFilters;
123
+ case EntityType.Model:
124
+ return {
125
+ modelsIds: props.modelValue
126
+ } satisfies ModelFilters;
127
+ default:
128
+ return undefined;
129
+ };
130
+ })
131
+
132
+ const tableCode = computed(() => {
133
+ switch(props.entityType) {
134
+ case EntityType.Device:
135
+ return T.DEVICES_SELECT;
136
+ default:
137
+ return null;
138
+ };
139
+ })
140
+
141
+ const baseTableAttrs = computed(() => {
142
+ switch(props.entityType) {
143
+ case EntityType.Device:
144
+ return {
145
+ deviceOrganisationFilters: props.filters,
146
+ ...attrs
147
+ };
148
+ case EntityType.Dashboard:
149
+ return {
150
+ dashboardShallowsFilters: props.filters,
151
+ dashboardOrganisationsFilters: props.filters,
152
+ dashboardOrganisationTypeFetchFilter: props.filters,
153
+ ...attrs
154
+ };
155
+ case EntityType.Group:
156
+ return {
157
+ groupsFilters: props.filters,
158
+ ...attrs
159
+ };
160
+ case EntityType.Folder:
161
+ return {
162
+ foldersFilters: props.filters,
163
+ ...attrs
164
+ };
165
+ case EntityType.Location:
166
+ return {
167
+ locationsFilters: props.filters,
168
+ ...attrs
169
+ };
170
+ case EntityType.User:
171
+ return {
172
+ userOrganisationsFilters: props.filters,
173
+ ...attrs
174
+ };
175
+ case EntityType.Model:
176
+ return {
177
+ modelsFilters: props.filters,
178
+ ...attrs
179
+ };
180
+ default:
181
+ return null;
182
+ };
183
+ });
184
+
185
+ return {
186
+ simpleListFilters,
187
+ baseTableAttrs,
188
+ tableCode
189
+ }
190
+ }
191
+ });
192
+ </script>
@@ -29,6 +29,7 @@ import { computed, defineComponent, onUnmounted, type PropType, watch } from "vu
29
29
 
30
30
  import { useUserOrganisationTable, useUpdateUserOrganisationTable, useDataTables } from "@dative-gpi/foundation-core-services/composables";
31
31
  import { useDebounce, useTables } from "@dative-gpi/foundation-shared-components/composables";
32
+ import { type FSDataTableColumn } from "@dative-gpi/foundation-shared-components/models";
32
33
 
33
34
  import FSLoadDataTable from "@dative-gpi/foundation-shared-components/components/lists/FSLoadDataTable.vue";
34
35
  import FSDataTableUI from "@dative-gpi/foundation-shared-components/components/lists/FSDataTableUI.vue";
@@ -49,13 +50,8 @@ export default defineComponent({
49
50
  required: false,
50
51
  default: 1000
51
52
  },
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 }>,
53
+ headersOptions: {
54
+ type: Object as PropType<{ [key: string]: Partial<FSDataTableColumn> }>,
59
55
  required: false,
60
56
  default: () => ({})
61
57
  }
@@ -67,9 +63,7 @@ export default defineComponent({
67
63
  const { getTable, setTable } = useTables();
68
64
  const { debounce, cancel } = useDebounce();
69
65
 
70
- const computedTable = computed(() => computeTable(props.customSorts, props.customSortRaws));
71
-
72
- console.log(JSON.stringify(computedTable.value));
66
+ const computedTable = computed(() => computeTable(props.headersOptions));
73
67
 
74
68
  onUnmounted(() => {
75
69
  cancel();
@@ -90,7 +84,6 @@ export default defineComponent({
90
84
  getTable,
91
85
  props.tableCode
92
86
  );
93
- console.log(JSON.stringify(computedTable.value));
94
87
  }, { immediate: true });
95
88
 
96
89
  watch(() => table.value, () => {
@@ -1,10 +1,10 @@
1
1
  <template>
2
2
  <FSDataTable
3
- :items="deviceOrganisations"
4
- :customSorts="customSorts"
5
- :itemTo="$props.itemTo"
6
3
  :loading="fetchingDeviceOrganisations"
4
+ :headersOptions="headersOptions"
7
5
  :tableCode="$props.tableCode"
6
+ :items="deviceOrganisations"
7
+ :itemTo="$props.itemTo"
8
8
  :modelValue="$props.modelValue"
9
9
  @update:modelValue="$emit('update:modelValue', $event)"
10
10
  v-bind="$attrs"
@@ -87,6 +87,9 @@
87
87
  :deviceAlerts="item.alerts"
88
88
  :alertTo="$props.alertTo"
89
89
  />
90
+ <div
91
+ v-else
92
+ />
90
93
  </template>
91
94
  <template
92
95
  #item.alerts="{ item }"
@@ -97,6 +100,9 @@
97
100
  :deviceAlerts="item.alerts"
98
101
  :alertTo="$props.alertTo"
99
102
  />
103
+ <div
104
+ v-else
105
+ />
100
106
  </template>
101
107
  <template
102
108
  #item.status="{ item }"
@@ -146,16 +152,15 @@
146
152
  </template>
147
153
 
148
154
  <script lang="ts">
149
- import type { PropType} from "vue";
150
- import type { RouteLocation } from "vue-router";
151
- import { computed, defineComponent, onMounted, watch } from "vue";
155
+ import { computed, defineComponent, onMounted, type PropType, watch } from "vue";
156
+ import { type RouteLocation } from "vue-router";
152
157
  import _ from "lodash";
153
158
 
154
- import { alphanumericSort } from "@dative-gpi/foundation-shared-components/utils";
159
+ import { alphanumericSort, connectivityLabel } from "@dative-gpi/foundation-shared-components/utils";
155
160
  import { ConnectivityStatus, PropertyEntity } from "@dative-gpi/foundation-shared-domain/enums";
156
161
 
157
162
  import { useCustomProperties, useDeviceOrganisations } from "@dative-gpi/foundation-core-services/composables";
158
- import type { DeviceConnectivityDetails, DeviceOrganisationFilters, DeviceOrganisationInfos} from "@dative-gpi/foundation-core-domain/models";
163
+ import type { DeviceConnectivityDetails, DeviceOrganisationAlert, DeviceOrganisationFilters, DeviceOrganisationInfos} from "@dative-gpi/foundation-core-domain/models";
159
164
 
160
165
  import FSDataTable from "../FSDataTable.vue";
161
166
  import FSMetaValue from "../../customProperties/FSMetaValue.vue";
@@ -228,17 +233,61 @@ export default defineComponent({
228
233
  }
229
234
  return entities.value;
230
235
  });
231
-
232
- const customSorts = computed(() => {
233
- return {
234
- connectable: (a:DeviceConnectivityDetails, b:DeviceConnectivityDetails) => {
235
- return alphanumericSort(a?.status, b?.status);
236
- },
237
- connectivity: (a:DeviceConnectivityDetails, b:DeviceConnectivityDetails) => {
238
- return alphanumericSort(a?.status, b?.status);
239
- }
240
- }
241
- });
236
+
237
+ const headersOptions = computed(() => ({
238
+ connectable: {
239
+ fixedFilters: [{
240
+ value: ConnectivityStatus.None,
241
+ text: "—"
242
+ }, {
243
+ value: ConnectivityStatus.Offline,
244
+ text: connectivityLabel(ConnectivityStatus.Offline)
245
+ }, {
246
+ value: ConnectivityStatus.AlmostOffline,
247
+ text: connectivityLabel(ConnectivityStatus.AlmostOffline)
248
+ }, {
249
+ value: ConnectivityStatus.PartiallyConnected,
250
+ text: connectivityLabel(ConnectivityStatus.PartiallyConnected)
251
+ }, {
252
+ value: ConnectivityStatus.Connected,
253
+ text: connectivityLabel(ConnectivityStatus.Connected)
254
+ }],
255
+ methodFilter: (value: ConnectivityStatus, item: DeviceConnectivityDetails) => !item.status && !value || item.status == value,
256
+ sort: (a: DeviceConnectivityDetails, b: DeviceConnectivityDetails) => alphanumericSort(a?.status, b?.status)
257
+ },
258
+ connectivity: {
259
+ fixedFilters: [{
260
+ value: ConnectivityStatus.None,
261
+ text: "—"
262
+ }, {
263
+ value: ConnectivityStatus.Offline,
264
+ text: connectivityLabel(ConnectivityStatus.Offline)
265
+ }, {
266
+ value: ConnectivityStatus.AlmostOffline,
267
+ text: connectivityLabel(ConnectivityStatus.AlmostOffline)
268
+ }, {
269
+ value: ConnectivityStatus.PartiallyConnected,
270
+ text: connectivityLabel(ConnectivityStatus.PartiallyConnected)
271
+ }, {
272
+ value: ConnectivityStatus.Connected,
273
+ text: connectivityLabel(ConnectivityStatus.Connected)
274
+ }],
275
+ methodFilter: (value: ConnectivityStatus, item: DeviceConnectivityDetails) => !item.status && !value || item.status == value,
276
+ sort: (a: DeviceConnectivityDetails, b: DeviceConnectivityDetails) => alphanumericSort(a?.status, b?.status)
277
+ },
278
+ worstAlert: {
279
+ sort: (a: DeviceOrganisationAlert, b: DeviceOrganisationAlert) => alphanumericSort(a?.criticity, b?.criticity)
280
+ },
281
+ // ...customProperties.value.reduce((acc, cp) => ({
282
+ // ...acc,
283
+ // [`meta.${cp.code}`]: {
284
+ // innerValue: (item: DeviceOrganisationInfos) => {
285
+ // return item
286
+ // },
287
+ // sort: (a: string, b: string) => alphanumericSort(a, b)
288
+ // }
289
+ // }), {})
290
+ }));
242
291
 
243
292
  const isSelected = (id: string): boolean => {
244
293
  return props.modelValue.includes(id);
@@ -262,7 +311,7 @@ export default defineComponent({
262
311
  deviceOrganisations,
263
312
  ConnectivityStatus,
264
313
  customProperties,
265
- customSorts,
314
+ headersOptions,
266
315
  isSelected
267
316
  };
268
317
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dative-gpi/foundation-core-components",
3
3
  "sideEffects": false,
4
- "version": "1.0.62",
4
+ "version": "1.0.64",
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": "1.0.62",
14
- "@dative-gpi/foundation-core-services": "1.0.62",
15
- "@dative-gpi/foundation-shared-components": "1.0.62",
16
- "@dative-gpi/foundation-shared-domain": "1.0.62",
17
- "@dative-gpi/foundation-shared-services": "1.0.62"
13
+ "@dative-gpi/foundation-core-domain": "1.0.64",
14
+ "@dative-gpi/foundation-core-services": "1.0.64",
15
+ "@dative-gpi/foundation-shared-components": "1.0.64",
16
+ "@dative-gpi/foundation-shared-domain": "1.0.64",
17
+ "@dative-gpi/foundation-shared-services": "1.0.64"
18
18
  },
19
19
  "peerDependencies": {
20
20
  "@dative-gpi/bones-ui": "^0.0.75",
@@ -26,5 +26,5 @@
26
26
  "sass": "1.71.1",
27
27
  "sass-loader": "13.3.2"
28
28
  },
29
- "gitHead": "aebca5afe970e1d7117b5515abba742a6c96fa3a"
29
+ "gitHead": "2774a6e01e85f2b27b543f3fdd91a9370b95fbee"
30
30
  }