@dative-gpi/foundation-core-components 1.1.2-fix-dialog-menu → 1.1.3-groupings

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.
@@ -47,6 +47,8 @@ export default defineComponent({
47
47
  return defineAsyncComponent(() => import("../lists/locations/FSBaseLocationsList.vue"));
48
48
  case EntityType.Model:
49
49
  return defineAsyncComponent(() => import("../lists/models/FSBaseModelsList.vue"));
50
+ case EntityType.Subgrouping:
51
+ return defineAsyncComponent(() => import("../lists/subgroupings/FSBaseSubgroupingsList.vue"));
50
52
  default:
51
53
  return null;
52
54
  };
@@ -64,7 +64,7 @@
64
64
  import { defineComponent, type PropType, computed } from "vue";
65
65
 
66
66
  import { EntityType } from "@dative-gpi/foundation-shared-domain/enums";
67
- import type { DashboardOrganisationFilters, DashboardOrganisationTypeFilters, DashboardShallowFilters, DeviceOrganisationFilters, FolderFilters, GroupFilters, LocationFilters, ModelFilters, UserOrganisationFilters } from "@dative-gpi/foundation-core-domain/models";
67
+ import type { DashboardOrganisationFilters, DashboardOrganisationTypeFilters, DashboardShallowFilters, DeviceOrganisationFilters, FolderFilters, GroupFilters, LocationFilters, ModelFilters, SubgroupingFilters, UserOrganisationFilters } from "@dative-gpi/foundation-core-domain/models";
68
68
 
69
69
  import { TABLES as T } from "../../utils";
70
70
 
@@ -147,6 +147,10 @@ export default defineComponent({
147
147
  return {
148
148
  modelsIds: props.modelValue
149
149
  } satisfies ModelFilters;
150
+ case EntityType.Subgrouping:
151
+ return {
152
+ subgroupingsIds: props.modelValue
153
+ } satisfies SubgroupingFilters;
150
154
  default:
151
155
  return undefined;
152
156
  };
@@ -164,6 +168,8 @@ export default defineComponent({
164
168
  return T.LOCATIONS_SELECT;
165
169
  case EntityType.Model:
166
170
  return T.MODELS_SELECT;
171
+ case EntityType.Subgrouping:
172
+ return T.SUBGROUPINGS_SELECT;
167
173
  default:
168
174
  return null;
169
175
  };
@@ -208,6 +214,11 @@ export default defineComponent({
208
214
  modelsFilters: props.filters,
209
215
  ...attrs
210
216
  };
217
+ case EntityType.Subgrouping:
218
+ return {
219
+ subgroupingFilters: props.filters,
220
+ ...attrs
221
+ };
211
222
  default:
212
223
  return null;
213
224
  };
@@ -43,6 +43,8 @@ export default defineComponent({
43
43
  return defineAsyncComponent(() => import("../lists/locations/FSSimpleLocationsList.vue"));
44
44
  case EntityType.Model:
45
45
  return defineAsyncComponent(() => import("../lists/models/FSSimpleModelsList.vue"));
46
+ case EntityType.Subgrouping:
47
+ return defineAsyncComponent(() => import("../lists/subgroupings/FSSimpleSubgroupingsList.vue"));
46
48
  default:
47
49
  return null;
48
50
  };
@@ -87,6 +89,11 @@ export default defineComponent({
87
89
  ...attrs,
88
90
  modelFilters : props.filters
89
91
  };
92
+ case EntityType.Subgrouping:
93
+ return {
94
+ ...attrs,
95
+ subgroupingFilters : props.filters
96
+ };
90
97
  default:
91
98
  return null;
92
99
  }
@@ -115,6 +115,25 @@
115
115
  {{ item.ownerAddress ? item.ownerAddress.formattedAddress : '' }}
116
116
  </FSSpan>
117
117
  </template>
118
+ <template
119
+ #item.subgroupings="{ item }"
120
+ >
121
+ <FSSubgroupingsChipList
122
+ :subgroupings="item.subgroupings"
123
+ />
124
+ </template>
125
+ <template
126
+ #filter.subgroupings="{ filter }"
127
+ >
128
+ <FSSubgroupingChip
129
+ v-if="filter.value && subgroupingMap[filter.value]"
130
+ :groupingLabel="subgroupingMap[filter.value].groupingLabel"
131
+ :groupingIcon="subgroupingMap[filter.value].groupingIcon"
132
+ :groupingColor="subgroupingMap[filter.value].groupingColor"
133
+ :label="subgroupingMap[filter.value].label"
134
+ :icon="subgroupingMap[filter.value].icon"
135
+ />
136
+ </template>
118
137
  <template
119
138
  #item.actions="{ item }"
120
139
  >
@@ -188,15 +207,19 @@ import FSDeviceOrganisationTileUI from "@dative-gpi/foundation-shared-components
188
207
  import FSStatusesCarousel from "@dative-gpi/foundation-shared-components/components/deviceOrganisations/FSStatusesCarousel.vue";
189
208
  import FSConnectivity from "@dative-gpi/foundation-shared-components/components/deviceOrganisations/FSConnectivity.vue";
190
209
  import FSWorstAlert from "@dative-gpi/foundation-shared-components/components/deviceOrganisations/FSWorstAlert.vue";
210
+ import FSSubgroupingChip from "@dative-gpi/foundation-shared-components/components/FSSubgroupingChip.vue";
191
211
  import FSIconCheck from "@dative-gpi/foundation-shared-components/components/FSIconCheck.vue";
192
212
  import FSTagGroup from "@dative-gpi/foundation-shared-components/components/FSTagGroup.vue";
193
213
  import FSImage from "@dative-gpi/foundation-shared-components/components/FSImage.vue";
194
214
  import FSSpan from '@dative-gpi/foundation-shared-components/components/FSSpan.vue';
215
+ import FSSubgroupingsChipList from "../subgroupings/FSSubgroupingsChipList.vue";
195
216
 
196
217
  export default defineComponent({
197
218
  name: "FSBaseDeviceOrganisationsList",
198
219
  components: {
199
220
  FSDeviceOrganisationTileUI,
221
+ FSSubgroupingsChipList,
222
+ FSSubgroupingChip,
200
223
  FSStatusesCarousel,
201
224
  FSConnectivity,
202
225
  FSWorstAlert,
@@ -261,7 +284,33 @@ export default defineComponent({
261
284
  return entities.value;
262
285
  });
263
286
 
264
- const headersOptions = computed(() => ({
287
+ const subgroupingFilters = computed(() => {
288
+ const filters: { value: string | null, text: string }[] = [{
289
+ value: null,
290
+ text: "—"
291
+ }];
292
+
293
+ const uniqueSubgroupings = _.uniqBy(
294
+ entities.value.flatMap(device => device.subgroupings),
295
+ 'id'
296
+ );
297
+
298
+ filters.push(...uniqueSubgroupings.map(subgrouping => ({
299
+ value: subgrouping.id,
300
+ text: `${subgrouping.groupingLabel} - ${subgrouping.label}`
301
+ })));
302
+
303
+ return filters.sort((a, b) => a.text.localeCompare(b.text));
304
+ });
305
+
306
+ const subgroupingMap = computed(() => {
307
+ return _.chain(entities.value)
308
+ .flatMap(device => device.subgroupings)
309
+ .keyBy('id')
310
+ .value();
311
+ });
312
+
313
+ const headersOptions = computed((): Record<string, any> => ({
265
314
  status: {
266
315
  fixedFilters: [{
267
316
  value: true,
@@ -339,6 +388,16 @@ export default defineComponent({
339
388
  },
340
389
  sort: (a: DeviceOrganisationAlert, b: DeviceOrganisationAlert) => alphanumericSort(a?.criticity, b?.criticity)
341
390
  },
391
+ subgroupings: {
392
+ fixedFilters: subgroupingFilters.value,
393
+ methodFilterRaw: (value: string | null, item: DeviceOrganisationInfos) => {
394
+ if (!value) {
395
+ return item.subgroupings.length === 0;
396
+ }
397
+ return item.subgroupings.some(s => s.id === value);
398
+ },
399
+ sort: (a: any[], b: any[]) => a.length - b.length
400
+ },
342
401
  ...customProperties.value.reduce((acc, cp) => ({
343
402
  ...acc,
344
403
  [`meta.${cp.code}`]: {
@@ -382,6 +441,7 @@ export default defineComponent({
382
441
  deviceOrganisations,
383
442
  ConnectivityStatus,
384
443
  customProperties,
444
+ subgroupingMap,
385
445
  headersOptions,
386
446
  isSelected
387
447
  };
@@ -0,0 +1,179 @@
1
+ <template>
2
+ <FSDataTable
3
+ :loading="fetchingSubgroupings"
4
+ :items="subgroupings"
5
+ :itemTo="$props.itemTo"
6
+ :tableCode="$props.tableCode"
7
+ :selectable="$props.selectable"
8
+ :showSearch="true"
9
+ :disableIterator="true"
10
+ :singleSelect="$props.singleSelect"
11
+ :groupBy="groupBy"
12
+ :modelValue="$props.modelValue"
13
+ @update:modelValue="$emit('update:modelValue', $event)"
14
+ v-bind="$attrs"
15
+ >
16
+ <template
17
+ v-for="(_, name) in $slots"
18
+ v-slot:[name]="slotData"
19
+ >
20
+ <slot
21
+ :name="name"
22
+ v-bind="slotData"
23
+ />
24
+ </template>
25
+ <template
26
+ #group-header="{ item }"
27
+ >
28
+ <FSRow
29
+ height="54px"
30
+ padding="16px 16px 16px 56px"
31
+ align="center-left"
32
+ :style="{ backgroundColor: getColors(ColorEnum.Light).base }"
33
+ >
34
+ <FSGroupingChip
35
+ :label="getGroupingLabel(item.value)"
36
+ :iconColor="getGroupingColor(item.value)"
37
+ :icon="getGroupingIcon(item.value)"
38
+ />
39
+ </FSRow>
40
+ </template>
41
+ <template
42
+ #item.icon="{ item }"
43
+ >
44
+ <FSIcon>
45
+ {{ item.icon }}
46
+ </FSIcon>
47
+ </template>
48
+ <template
49
+ #item.tile="{ item, toggleSelect }"
50
+ >
51
+ <FSSubgroupingTileUI
52
+ :selectable="$props.selectable"
53
+ :modelValue="isSelected(item.id)"
54
+ :singleSelect="$props.singleSelect"
55
+ :deviceOrganisationsCount="item.deviceOrganisationsCount"
56
+ :label="item.label"
57
+ :icon="item.icon"
58
+ :to="$props.itemTo && $props.itemTo(item)"
59
+ @update:modelValue="toggleSelect(item)"
60
+ />
61
+ </template>
62
+ </FSDataTable>
63
+ </template>
64
+
65
+ <script lang="ts">
66
+ import { computed, defineComponent, type PropType, watch } from "vue";
67
+ import { type RouteLocation } from "vue-router";
68
+ import _ from "lodash";
69
+
70
+ import type { SubgroupingFilters, SubgroupingInfos } from "@dative-gpi/foundation-core-domain/models";
71
+ import { useSubgroupings } from "@dative-gpi/foundation-core-services/composables";
72
+
73
+ import FSDataTable from "../FSDataTable.vue";
74
+
75
+ import FSSubgroupingTileUI from "@dative-gpi/foundation-shared-components/components/tiles/FSSubgroupingTileUI.vue";
76
+ import FSGroupingChip from "@dative-gpi/foundation-shared-components/components/FSGroupingChip.vue";
77
+ import FSIcon from "@dative-gpi/foundation-shared-components/components/FSIcon.vue";
78
+ import FSRow from "@dative-gpi/foundation-shared-components/components/FSRow.vue";
79
+
80
+ import { ColorEnum } from "@dative-gpi/foundation-shared-components/models";
81
+ import { useColors } from "@dative-gpi/foundation-shared-components/composables";
82
+
83
+ export default defineComponent({
84
+ name: "FSBaseSubgroupingsList",
85
+ components: {
86
+ FSSubgroupingTileUI,
87
+ FSGroupingChip,
88
+ FSDataTable,
89
+ FSIcon,
90
+ FSRow
91
+ },
92
+ props: {
93
+ tableCode: {
94
+ type: String as PropType<string | null>,
95
+ required: false,
96
+ default: null
97
+ },
98
+ itemTo: {
99
+ type: Function as PropType<(item: SubgroupingInfos) => Partial<RouteLocation>>,
100
+ required: false
101
+ },
102
+ subgroupingFilters: {
103
+ type: Object as PropType<SubgroupingFilters>,
104
+ required: false,
105
+ default: null
106
+ },
107
+ selectable: {
108
+ type: Boolean,
109
+ required: false,
110
+ default: true
111
+ },
112
+ singleSelect: {
113
+ type: Boolean,
114
+ required: false,
115
+ default: false
116
+ },
117
+ modelValue: {
118
+ type: Array as PropType<string[]>,
119
+ required: false,
120
+ default: () => []
121
+ }
122
+ },
123
+ emits: ["update:modelValue"],
124
+ setup(props) {
125
+ const { getMany: fetchSubgroupings, fetching: fetchingSubgroupings, entities: subgroupings } = useSubgroupings();
126
+ const { getColors } = useColors();
127
+
128
+ const groupBy = computed(() => ({
129
+ key: "groupingId",
130
+ order: "asc" as const
131
+ }));
132
+
133
+ const groupingMap = computed(() => {
134
+ return _.chain(subgroupings.value)
135
+ .keyBy('groupingId')
136
+ .mapValues(s => ({
137
+ label: s.groupingLabel,
138
+ color: s.groupingColor,
139
+ icon: s.groupingIcon
140
+ }))
141
+ .value();
142
+ });
143
+
144
+ const getGroupingLabel = (groupingId: string): string => {
145
+ return groupingMap.value[groupingId]?.label ?? "";
146
+ };
147
+
148
+ const getGroupingColor = (groupingId: string): string => {
149
+ return groupingMap.value[groupingId]?.color ?? "";
150
+ };
151
+
152
+ const getGroupingIcon = (groupingId: string): string => {
153
+ return groupingMap.value[groupingId]?.icon ?? "";
154
+ };
155
+
156
+ const isSelected = (id: string) => {
157
+ return props.modelValue.includes(id);
158
+ };
159
+
160
+ watch(() => props.subgroupingFilters, (next, previous) => {
161
+ if ((!next && !previous) || !_.isEqual(next, previous)) {
162
+ fetchSubgroupings(props.subgroupingFilters);
163
+ }
164
+ }, { immediate: true });
165
+
166
+ return {
167
+ fetchingSubgroupings,
168
+ getGroupingLabel,
169
+ getGroupingColor,
170
+ getGroupingIcon,
171
+ subgroupings,
172
+ isSelected,
173
+ getColors,
174
+ ColorEnum,
175
+ groupBy
176
+ };
177
+ }
178
+ });
179
+ </script>
@@ -0,0 +1,44 @@
1
+ <template>
2
+ <FSSimpleList
3
+ :items="subgroupings"
4
+ :loading="fetching"
5
+ v-bind="$attrs"
6
+ />
7
+ </template>
8
+
9
+ <script lang="ts">
10
+ import { defineComponent, type PropType, watch } from "vue";
11
+
12
+ import type { SubgroupingFilters } from "@dative-gpi/foundation-core-domain/models";
13
+ import { useSubgroupings } from "@dative-gpi/foundation-core-services/composables";
14
+
15
+ import FSSimpleList from "@dative-gpi/foundation-shared-components/components/lists/FSSimpleList.vue";
16
+
17
+ export default defineComponent({
18
+ name: "FSSimpleSubgroupingsList",
19
+ components: {
20
+ FSSimpleList,
21
+ },
22
+ props: {
23
+ subgroupingFilters: {
24
+ type: Object as PropType<SubgroupingFilters>,
25
+ required: false,
26
+ default: () => ({})
27
+ }
28
+ },
29
+ setup(props) {
30
+ const { entities: subgroupings, getMany, fetching } = useSubgroupings();
31
+
32
+ const fetch = () => {
33
+ getMany(props.subgroupingFilters);
34
+ };
35
+
36
+ watch(() => props.subgroupingFilters, fetch, { immediate: true });
37
+
38
+ return {
39
+ subgroupings,
40
+ fetching
41
+ };
42
+ }
43
+ });
44
+ </script>
@@ -0,0 +1,45 @@
1
+ <template>
2
+ <FSChipGroup
3
+ v-if="$props.subgroupings && $props.subgroupings.length > 0"
4
+ :variant="$props.variant"
5
+ >
6
+ <FSSubgroupingChip
7
+ v-for="(item, index) in $props.subgroupings"
8
+ :key="index"
9
+ :groupingLabel="item.groupingLabel"
10
+ :groupingIcon="item.groupingIcon"
11
+ :groupingColor="item.groupingColor"
12
+ :label="item.label"
13
+ :icon="item.icon"
14
+ />
15
+ </FSChipGroup>
16
+ </template>
17
+
18
+ <script lang="ts">
19
+ import type { PropType} from "vue";
20
+ import { defineComponent } from "vue";
21
+
22
+ import type { SubgroupingInfos } from "@dative-gpi/foundation-core-domain/models";
23
+
24
+ import FSSubgroupingChip from "@dative-gpi/foundation-shared-components/components/FSSubgroupingChip.vue";
25
+ import FSChipGroup from "@dative-gpi/foundation-shared-components/components/FSChipGroup.vue";
26
+
27
+ export default defineComponent({
28
+ name: "FSSubgroupingsChipList",
29
+ components: {
30
+ FSSubgroupingChip,
31
+ FSChipGroup
32
+ },
33
+ props: {
34
+ subgroupings: {
35
+ type: Array as PropType<SubgroupingInfos[]>,
36
+ required: true
37
+ },
38
+ variant: {
39
+ type: String as PropType<"wrap" | "slide" | "menu">,
40
+ required: false,
41
+ default: "menu"
42
+ }
43
+ }
44
+ });
45
+ </script>
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "url": "https://github.com/Dative-GPI/foundation-shared-ui.git"
5
5
  },
6
6
  "sideEffects": false,
7
- "version": "1.1.2-fix-dialog-menu",
7
+ "version": "1.1.3-groupings",
8
8
  "description": "",
9
9
  "publishConfig": {
10
10
  "access": "public"
@@ -13,11 +13,11 @@
13
13
  "author": "",
14
14
  "license": "ISC",
15
15
  "dependencies": {
16
- "@dative-gpi/foundation-core-domain": "1.1.2-fix-dialog-menu",
17
- "@dative-gpi/foundation-core-services": "1.1.2-fix-dialog-menu",
18
- "@dative-gpi/foundation-shared-components": "1.1.2-fix-dialog-menu",
19
- "@dative-gpi/foundation-shared-domain": "1.1.2-fix-dialog-menu",
20
- "@dative-gpi/foundation-shared-services": "1.1.2-fix-dialog-menu"
16
+ "@dative-gpi/foundation-core-domain": "1.1.3-groupings",
17
+ "@dative-gpi/foundation-core-services": "1.1.3-groupings",
18
+ "@dative-gpi/foundation-shared-components": "1.1.3-groupings",
19
+ "@dative-gpi/foundation-shared-domain": "1.1.3-groupings",
20
+ "@dative-gpi/foundation-shared-services": "1.1.3-groupings"
21
21
  },
22
22
  "peerDependencies": {
23
23
  "@dative-gpi/bones-ui": "^1.0.0",
@@ -29,5 +29,5 @@
29
29
  "sass": "1.71.1",
30
30
  "sass-loader": "13.3.2"
31
31
  },
32
- "gitHead": "8e2aaaa5517eef8d6488fe114d9dbd782a91d13d"
32
+ "gitHead": "ad40c30f9ecd5b50de62619fa3cfab64e63d7cc5"
33
33
  }
package/utils/tables.ts CHANGED
@@ -22,6 +22,7 @@ export const GROUPS_SELECT = "ui.tables.group.select";
22
22
  export const LOCATIONS_SELECT = "ui.tables.location.select";
23
23
  export const MODELS_SELECT = "ui.tables.model.select";
24
24
  export const DASHBOARDS_SELECT = "ui.tables.dashboard-mock.select";
25
+ export const SUBGROUPINGS_SELECT = "ui.tables.subgrouping.select";
25
26
 
26
27
  export const WIDGET_DASHBOARDS_EXPLORER = "ui.tables.folder-mock.widget";
27
28