@dative-gpi/foundation-core-components 1.0.27 → 1.0.28-remove-deprecated2

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.
Files changed (82) hide show
  1. package/components/autocompletes/FSAutocompleteChart.vue +60 -58
  2. package/components/autocompletes/FSAutocompleteDashboard.vue +59 -56
  3. package/components/autocompletes/FSAutocompleteDashboardOrganisation.vue +30 -39
  4. package/components/autocompletes/FSAutocompleteDataCategory.vue +52 -38
  5. package/components/autocompletes/FSAutocompleteDataDefinition.vue +25 -39
  6. package/components/autocompletes/FSAutocompleteGroup.vue +23 -38
  7. package/components/autocompletes/FSAutocompleteLocation.vue +23 -38
  8. package/components/autocompletes/FSAutocompleteManufacturer.vue +65 -2
  9. package/components/autocompletes/FSAutocompleteModel.vue +66 -3
  10. package/components/autocompletes/FSAutocompleteOrganisationType.vue +23 -0
  11. package/components/autocompletes/FSAutocompleteRole.vue +59 -56
  12. package/components/autocompletes/FSAutocompleteServiceAccountRoleOrganisation.vue +105 -0
  13. package/components/autocompletes/FSAutocompleteUserOrganisation.vue +32 -57
  14. package/components/customProperties/FSMetaField.vue +31 -35
  15. package/components/customProperties/FSMetaHistory.vue +4 -4
  16. package/components/customProperties/FSMetaValue.vue +66 -33
  17. package/components/customProperties/helpers.ts +2 -1
  18. package/components/entities/FSBaseEntitiesList.vue +50 -0
  19. package/components/entities/FSDialogSelectEntities.vue +83 -0
  20. package/components/entities/FSEntityField.vue +203 -0
  21. package/components/entities/FSSelectEntitiesList.vue +209 -0
  22. package/components/entities/FSSimpleEntitiesList.vue +100 -0
  23. package/components/explorers/FSBaseDevicesExplorer.vue +310 -0
  24. package/components/explorers/FSBaseFoldersExplorer.vue +265 -0
  25. package/components/lists/FSDataTable.vue +23 -21
  26. package/components/lists/alerts/FSBaseAlertsList.vue +337 -0
  27. package/components/lists/alerts/FSButtonAcknowledgeAlert.vue +101 -0
  28. package/components/lists/authTokens/FSBaseAuthTokensList.vue +79 -0
  29. package/components/lists/chartOrganisationTypes/FSBaseChartOrganisationTypesList.vue +204 -0
  30. package/components/lists/chartOrganisations/FSBaseChartOrganisationsList.vue +205 -0
  31. package/components/lists/charts/FSBaseChartsList.vue +268 -0
  32. package/components/lists/comments/FSBaseCommentsList.vue +143 -0
  33. package/components/lists/connectivityScenarios/FSBaseConnectivityScenariosList.vue +128 -0
  34. package/components/lists/dashboardOrganisationTypes/FSBaseDashboardOrganisationTypesList.vue +168 -0
  35. package/components/lists/dashboards/FSBaseDashboardsList.vue +227 -0
  36. package/components/lists/dashboards/FSSimpleDashboardsList.vue +63 -0
  37. package/components/lists/dataCategories/FSBaseDataCategoriesList.vue +154 -0
  38. package/components/lists/dataDefinitions/FSBaseDataDefinitionsList.vue +129 -0
  39. package/components/lists/deviceOrganisations/FSBaseDeviceOrganisationsList.vue +327 -0
  40. package/components/lists/deviceOrganisations/FSSimpleDeviceOrganisationsList.vue +44 -0
  41. package/components/lists/folders/FSBaseFoldersList.vue +127 -0
  42. package/components/lists/folders/FSSimpleFoldersList.vue +44 -0
  43. package/components/lists/groups/FSBaseGroupsList.vue +136 -0
  44. package/components/lists/groups/FSSimpleGroupsList.vue +44 -0
  45. package/components/lists/locations/FSBaseLocationsList.vue +118 -0
  46. package/components/lists/locations/FSSimpleLocationsList.vue +44 -0
  47. package/components/lists/models/FSBaseModelsList.vue +155 -0
  48. package/components/lists/models/FSSimpleModelsList.vue +44 -0
  49. package/components/lists/roleOrganisationTypes/FSBaseRoleOrganisationTypesList.vue +128 -0
  50. package/components/lists/roleOrganisations/FSBaseRoleOrganisationsList.vue +128 -0
  51. package/components/lists/scenarioOrganisationTypes/FSBaseScenarioOrganisationTypesList.vue +157 -0
  52. package/components/lists/scenarioOrganisations/FSBaseScenarioOrganisationsList.vue +145 -0
  53. package/components/lists/scenarios/FSBaseScenariosList.vue +241 -0
  54. package/components/lists/serviceAccountOrganisations/FSBaseServiceAccountOrganisationsList.vue +156 -0
  55. package/components/lists/serviceAccountRoleOrganisations/FSBaseServiceAccountRoleOrganisationsList.vue +128 -0
  56. package/components/lists/userOrganisations/FSBaseUserOrganisationsList.vue +172 -0
  57. package/components/lists/userOrganisations/FSSimpleUserOrganisationsList.vue +45 -0
  58. package/components/tiles/FSDeviceOrganisationTile.vue +9 -2
  59. package/components/tiles/FSLocationTile.vue +66 -0
  60. package/components/treeviews/FSTreeViewFolder.vue +15 -3
  61. package/components/treeviews/FSTreeViewGroup.vue +22 -4
  62. package/package.json +9 -9
  63. package/utils/dashboards.ts +33 -5
  64. package/utils/index.ts +2 -2
  65. package/utils/permissions.ts +80 -0
  66. package/utils/roles.ts +4 -4
  67. package/utils/tables.ts +41 -0
  68. package/utils/users.ts +7 -4
  69. package/components/selects/FSAggregationSelector.vue +0 -51
  70. package/components/selects/FSAxisTypeSelector.vue +0 -48
  71. package/components/selects/FSDataCategorySelector.vue +0 -62
  72. package/components/selects/FSDataDefinitionSelector.vue +0 -66
  73. package/components/selects/FSDisplayAsSelector.vue +0 -52
  74. package/components/selects/FSFilterTypeSelector.vue +0 -53
  75. package/components/selects/FSHeatmapRuleSelector.vue +0 -52
  76. package/components/selects/FSModelSelector.vue +0 -56
  77. package/components/selects/FSOperationOnSelector.vue +0 -51
  78. package/components/selects/FSPlanningTypeSelector.vue +0 -51
  79. package/components/selects/FSPlotPerSelector.vue +0 -51
  80. package/components/selects/FSSelectSelectedEntities.vue +0 -59
  81. package/components/selects/FSSerieTypeSelector.vue +0 -51
  82. package/utils/charts.ts +0 -136
@@ -1,27 +1,71 @@
1
1
  <template>
2
2
  <FSAutocompleteField
3
+ :label="$props.label ?? $tr('ui.common.model', 'Model')"
3
4
  :toggleSet="!$props.toggleSetDisabled && toggleSet"
5
+ :multiple="$props.multiple"
6
+ :placeholder="placeholder"
4
7
  :loading="loading"
5
8
  :items="models"
6
9
  :modelValue="$props.modelValue"
7
10
  @update:modelValue="onUpdate"
8
11
  v-bind="$attrs"
9
- />
12
+ >
13
+ <template
14
+ #item-prepend="{ item }"
15
+ >
16
+ <FSImage
17
+ v-if="item.imageId"
18
+ height="26px"
19
+ width="26px"
20
+ :imageId="item.imageId"
21
+ :thumbnail="true"
22
+ />
23
+ </template>
24
+ <template
25
+ #toggle-set-item="props"
26
+ >
27
+ <FSButton
28
+ :padding="props.item.imageId ? ['6px 16px', '4px 12px'] : undefined"
29
+ :variant="props.getVariant(props.item)"
30
+ :color="props.getColor(props.item)"
31
+ :class="props.getClass(props.item)"
32
+ :label="props.item.label"
33
+ @click="props.toggle(props.item)"
34
+ >
35
+ <template
36
+ v-if="props.item.imageId"
37
+ #prepend
38
+ >
39
+ <FSImage
40
+ height="26px"
41
+ width="26px"
42
+ :imageId="props.item.imageId"
43
+ :thumbnail="true"
44
+ />
45
+ </template>
46
+ </FSButton>
47
+ </template>
48
+ </FSAutocompleteField>
10
49
  </template>
11
50
 
12
51
  <script lang="ts">
13
52
  import { computed, defineComponent, type PropType } from "vue";
14
53
 
15
54
  import { useAutocomplete } from "@dative-gpi/foundation-shared-components/composables";
55
+ import { useTranslations as useTranslationsProvider } from "@dative-gpi/bones-ui";
16
56
  import { type ModelFilters } from "@dative-gpi/foundation-core-domain/models";
17
57
  import { useModels } from "@dative-gpi/foundation-core-services/composables";
18
58
 
19
59
  import FSAutocompleteField from "@dative-gpi/foundation-shared-components/components/fields/FSAutocompleteField.vue";
60
+ import FSButton from "@dative-gpi/foundation-shared-components/components/FSButton.vue";
61
+ import FSImage from "@dative-gpi/foundation-shared-components/components/FSImage.vue";
20
62
 
21
63
  export default defineComponent({
22
64
  name: "FSAutocompleteModel",
23
65
  components: {
24
- FSAutocompleteField
66
+ FSAutocompleteField,
67
+ FSButton,
68
+ FSImage
25
69
  },
26
70
  props: {
27
71
  modelFilters: {
@@ -34,20 +78,38 @@ export default defineComponent({
34
78
  required: false,
35
79
  default: null
36
80
  },
81
+ multiple: {
82
+ type: Boolean,
83
+ required: false,
84
+ default: false
85
+ },
37
86
  toggleSetDisabled: {
38
87
  type: Boolean,
39
88
  required: false,
40
89
  default: false
90
+ },
91
+ label: {
92
+ type: String as PropType<string | null>,
93
+ required: false,
94
+ default: null
41
95
  }
42
96
  },
43
97
  emits: ["update:modelValue"],
44
98
  setup(props, { emit }) {
45
99
  const { getMany: getManyModels, fetching: fetchingModels, entities: models } = useModels();
100
+ const { $tr } = useTranslationsProvider();
46
101
 
47
102
  const loading = computed((): boolean => {
48
103
  return init.value && fetchingModels.value;
49
104
  });
50
105
 
106
+ const placeholder = computed((): string | null => {
107
+ if (props.multiple && props.modelValue) {
108
+ return $tr("autocomplete.model.placeholder", "{0} model(s) selected", props.modelValue.length);
109
+ }
110
+ return null;
111
+ });
112
+
51
113
  const fetch = (search: string | null) => {
52
114
  return getManyModels({ ...props.modelFilters, search: search ?? undefined });
53
115
  };
@@ -60,9 +122,10 @@ export default defineComponent({
60
122
  );
61
123
 
62
124
  return {
63
- models,
125
+ placeholder,
64
126
  toggleSet,
65
127
  loading,
128
+ models,
66
129
  onUpdate
67
130
  };
68
131
  }
@@ -1,6 +1,9 @@
1
1
  <template>
2
2
  <FSAutocompleteField
3
+ :label="$props.label ?? $tr('ui.common.organisation-type', 'Organisation type')"
3
4
  :toggleSet="!$props.toggleSetDisabled && toggleSet"
5
+ :multiple="$props.multiple"
6
+ :placeholder="placeholder"
4
7
  :items="organisationTypes"
5
8
  :loading="loading"
6
9
  :modelValue="$props.modelValue"
@@ -15,6 +18,7 @@ import { computed, defineComponent, type PropType } from "vue";
15
18
  import { type OrganisationTypeFilters } from "@dative-gpi/foundation-shared-domain/models";
16
19
  import { useOrganisationTypes } from "@dative-gpi/foundation-core-services/composables";
17
20
  import { useAutocomplete } from "@dative-gpi/foundation-shared-components/composables";
21
+ import { useTranslations as useTranslationsProvider } from "@dative-gpi/bones-ui";
18
22
 
19
23
  import FSAutocompleteField from "@dative-gpi/foundation-shared-components/components/fields/FSAutocompleteField.vue";
20
24
 
@@ -34,20 +38,38 @@ export default defineComponent({
34
38
  required: false,
35
39
  default: null
36
40
  },
41
+ multiple: {
42
+ type: Boolean,
43
+ required: false,
44
+ default: false
45
+ },
37
46
  toggleSetDisabled: {
38
47
  type: Boolean,
39
48
  required: false,
40
49
  default: false
50
+ },
51
+ label: {
52
+ type: String as PropType<string | null>,
53
+ required: false,
54
+ default: null
41
55
  }
42
56
  },
43
57
  emits: ["update:modelValue"],
44
58
  setup(props, { emit }) {
45
59
  const { getMany: getManyOrganisationTypes, fetching: fetchingOrganisationTypes, entities: organisationTypes } = useOrganisationTypes();
60
+ const { $tr } = useTranslationsProvider();
46
61
 
47
62
  const loading = computed((): boolean => {
48
63
  return init.value && fetchingOrganisationTypes.value;
49
64
  });
50
65
 
66
+ const placeholder = computed((): string | null => {
67
+ if (props.multiple && props.modelValue) {
68
+ return $tr("autocomplete.organisation-type.placeholder", "{0} organisation type(s) selected", props.modelValue.length);
69
+ }
70
+ return null;
71
+ });
72
+
51
73
  const fetch = (search: string | null) => {
52
74
  return getManyOrganisationTypes({ ...props.organisationTypeFilters, search: search ?? undefined });
53
75
  };
@@ -61,6 +83,7 @@ export default defineComponent({
61
83
 
62
84
  return {
63
85
  organisationTypes,
86
+ placeholder,
64
87
  toggleSet,
65
88
  loading,
66
89
  onUpdate
@@ -1,7 +1,9 @@
1
1
  <template>
2
2
  <FSAutocompleteField
3
+ :label="$props.label ?? $tr('ui.common.role', 'Role')"
3
4
  :toggleSet="!$props.toggleSetDisabled && toggleSet"
4
5
  :multiple="$props.multiple"
6
+ :placeholder="placeholder"
5
7
  :loading="loading"
6
8
  :items="roles"
7
9
  :modelValue="$props.modelValue"
@@ -9,51 +11,22 @@
9
11
  v-bind="$attrs"
10
12
  >
11
13
  <template
12
- #autocomplete-selection="{ item }"
14
+ #item-prepend="{ item }"
13
15
  >
14
- <FSRow
15
- v-if="$props.modelValue"
16
- align="center-center"
17
- :wrap="false"
16
+ <FSIcon
17
+ v-if="item.icon"
18
18
  >
19
- <FSIcon
20
- v-if="item.raw.icon"
21
- >
22
- {{ item.raw.icon }}
23
- </FSIcon>
24
- <FSSpan>
25
- {{ item.raw.label }}
26
- </FSSpan>
27
- <FSChip
28
- :color="roleTypeColor(item.raw.type)"
29
- :label="roleTypeLabel(item.raw.type)"
30
- :editable="false"
31
- />
32
- </FSRow>
19
+ {{ item.icon }}
20
+ </FSIcon>
33
21
  </template>
34
22
  <template
35
- #item-label="{ item, font }"
23
+ #item-append="{ item }"
36
24
  >
37
- <FSRow
38
- align="center-left"
39
- :wrap="false"
40
- >
41
- <FSIcon
42
- v-if="item.raw.icon"
43
- >
44
- {{ item.raw.icon }}
45
- </FSIcon>
46
- <FSSpan
47
- :font="font"
48
- >
49
- {{ item.raw.label }}
50
- </FSSpan>
51
- <FSChip
52
- :color="roleTypeColor(item.raw.type)"
53
- :label="roleTypeLabel(item.raw.type)"
54
- :editable="false"
55
- />
56
- </FSRow>
25
+ <FSChip
26
+ :color="roleTypeColor(item.type)"
27
+ :label="roleTypeLabel(item.type)"
28
+ :editable="false"
29
+ />
57
30
  </template>
58
31
  <template
59
32
  #toggle-set-item="props"
@@ -67,6 +40,7 @@
67
40
  @click="props.toggle(props.item)"
68
41
  >
69
42
  <template
43
+ v-if="props.item.type"
70
44
  #append
71
45
  >
72
46
  <FSChip
@@ -83,9 +57,11 @@
83
57
  <script lang="ts">
84
58
  import { computed, defineComponent, type PropType } from "vue";
85
59
 
86
- import { type RoleOrganisationFilters, type RoleOrganisationTypeFilters, RoleType } from "@dative-gpi/foundation-core-domain/models";
60
+ import { type RoleOrganisationFilters, type RoleOrganisationTypeFilters } from "@dative-gpi/foundation-core-domain/models";
87
61
  import { useRoleOrganisations, useRoleOrganisationTypes } from "@dative-gpi/foundation-core-services/composables";
88
62
  import { useAutocomplete } from "@dative-gpi/foundation-shared-components/composables";
63
+ import { useTranslations as useTranslationsProvider } from "@dative-gpi/bones-ui";
64
+ import { RoleType } from "@dative-gpi/foundation-shared-domain/enums";
89
65
 
90
66
  import { roleTypeColor, roleTypeLabel } from "../../utils";
91
67
 
@@ -93,8 +69,6 @@ import FSAutocompleteField from "@dative-gpi/foundation-shared-components/compon
93
69
  import FSButton from "@dative-gpi/foundation-shared-components/components/FSButton.vue";
94
70
  import FSChip from "@dative-gpi/foundation-shared-components/components/FSChip.vue";
95
71
  import FSIcon from "@dative-gpi/foundation-shared-components/components/FSIcon.vue";
96
- import FSSpan from "@dative-gpi/foundation-shared-components/components/FSSpan.vue";
97
- import FSRow from "@dative-gpi/foundation-shared-components/components/FSRow.vue";
98
72
 
99
73
  export default defineComponent({
100
74
  name: "FSAutocompleteRole",
@@ -102,9 +76,7 @@ export default defineComponent({
102
76
  FSAutocompleteField,
103
77
  FSButton,
104
78
  FSChip,
105
- FSIcon,
106
- FSSpan,
107
- FSRow
79
+ FSIcon
108
80
  },
109
81
  props: {
110
82
  roleOrganisationTypeFilters: {
@@ -123,10 +95,20 @@ export default defineComponent({
123
95
  default: null
124
96
  },
125
97
  type: {
126
- type: Number as PropType<RoleType>,
98
+ type: [Array, Number] as PropType<RoleType[] | RoleType>,
127
99
  required: false,
128
100
  default: RoleType.None
129
101
  },
102
+ ignoreRoleOrganisationTypes: {
103
+ type: Boolean,
104
+ required: false,
105
+ default: false
106
+ },
107
+ ignoreRoleOrganisations: {
108
+ type: Boolean,
109
+ required: false,
110
+ default: false
111
+ },
130
112
  multiple: {
131
113
  type: Boolean,
132
114
  required: false,
@@ -136,12 +118,18 @@ export default defineComponent({
136
118
  type: Boolean,
137
119
  required: false,
138
120
  default: false
121
+ },
122
+ label: {
123
+ type: String as PropType<string | null>,
124
+ required: false,
125
+ default: null
139
126
  }
140
127
  },
141
- emits: ["update:modelValue", "update:type"],
128
+ emits: ["update", "update:modelValue", "update:type"],
142
129
  setup(props, { emit }) {
143
130
  const { getMany: getManyRoleOrganisationTypes, fetching: fetchingRoleOrganisationTypes, entities: roleOrganisationTypes } = useRoleOrganisationTypes();
144
131
  const { getMany: getManyRoleOrganisations, fetching: fetchingRoleOrganisations, entities: roleOrganisations } = useRoleOrganisations();
132
+ const { $tr } = useTranslationsProvider();
145
133
 
146
134
  const roles = computed(() => {
147
135
  return roleOrganisationTypes.value.map(rot => ({
@@ -161,25 +149,40 @@ export default defineComponent({
161
149
  return init.value && (fetchingRoleOrganisationTypes.value || fetchingRoleOrganisations.value);
162
150
  });
163
151
 
152
+ const placeholder = computed((): string | null => {
153
+ if (props.multiple && props.modelValue) {
154
+ return $tr("autocomplete.role.placeholder", "{0} role(s) selected", props.modelValue.length);
155
+ }
156
+ return null;
157
+ });
158
+
164
159
  const update = (value: Role[] | Role | null) => {
165
160
  if (Array.isArray(value)) {
166
- emit("update:modelValue", value.map(v => v.id));
167
- emit("update:type", value.map(v => v.type));
161
+ const newModelValue = value.map(v => v.id);
162
+ const newType = value.map(v => v.type);
163
+ emit("update:modelValue", newModelValue);
164
+ emit("update:type", newType);
165
+ emit("update", { modelValue: newModelValue, type: newType });
168
166
  }
169
167
  else {
170
168
  emit("update:modelValue", value?.id);
171
169
  emit("update:type", value?.type);
170
+ emit("update", { modelValue: value?.id, type: value?.type });
172
171
  }
173
172
  };
174
173
 
175
174
  const fetch = (search: string | null) => {
176
- return Promise.all([
177
- getManyRoleOrganisationTypes({ ...props.roleOrganisationTypeFilters, search: search ?? undefined }),
178
- getManyRoleOrganisations({ ...props.roleOrganisationFilters, search: search ?? undefined })
179
- ]);
175
+ const promises = [];
176
+ if (!props.ignoreRoleOrganisations) {
177
+ promises.push(getManyRoleOrganisations({ ...props.roleOrganisationFilters, search: search ?? undefined }));
178
+ }
179
+ if (!props.ignoreRoleOrganisationTypes) {
180
+ promises.push(getManyRoleOrganisationTypes({ ...props.roleOrganisationTypeFilters, search: search ?? undefined }));
181
+ }
182
+ return Promise.all(promises);
180
183
  };
181
184
 
182
- const { toggleSet, search, init, onUpdate } = useAutocomplete(
185
+ const { toggleSet, init, onUpdate } = useAutocomplete(
183
186
  roles,
184
187
  [() => props.roleOrganisationTypeFilters, () => props.roleOrganisationFilters],
185
188
  emit,
@@ -188,10 +191,10 @@ export default defineComponent({
188
191
  );
189
192
 
190
193
  return {
194
+ placeholder,
191
195
  toggleSet,
192
196
  RoleType,
193
197
  loading,
194
- search,
195
198
  roles,
196
199
  roleTypeColor,
197
200
  roleTypeLabel,
@@ -0,0 +1,105 @@
1
+ <template>
2
+ <FSAutocompleteField
3
+ :label="$props.label ?? $tr('ui.common.service-account-role', 'Service account role')"
4
+ :toggleSet="!$props.toggleSetDisabled && toggleSet"
5
+ :items="serviceAccountRoleOrganisations"
6
+ :multiple="$props.multiple"
7
+ :placeholder="placeholder"
8
+ :loading="loading"
9
+ :modelValue="$props.modelValue"
10
+ @update:modelValue="onUpdate"
11
+ v-bind="$attrs"
12
+ >
13
+ <template
14
+ #item-prepend="{ item }"
15
+ >
16
+ <FSIcon
17
+ v-if="item.icon"
18
+ >
19
+ {{ item.icon }}
20
+ </FSIcon>
21
+ </template>
22
+ </FSAutocompleteField>
23
+ </template>
24
+
25
+ <script lang="ts">
26
+ import { computed, defineComponent, type PropType } from "vue";
27
+
28
+ import { type ServiceAccountRoleOrganisationFilters } from "@dative-gpi/foundation-core-domain/models";
29
+ import { useServiceAccountRoleOrganisations } from "@dative-gpi/foundation-core-services/composables";
30
+ import { useAutocomplete } from "@dative-gpi/foundation-shared-components/composables";
31
+ import { useTranslations as useTranslationsProvider } from "@dative-gpi/bones-ui";
32
+
33
+ import FSAutocompleteField from "@dative-gpi/foundation-shared-components/components/fields/FSAutocompleteField.vue";
34
+ import FSIcon from "@dative-gpi/foundation-shared-components/components/FSIcon.vue";
35
+
36
+ export default defineComponent({
37
+ name: "FSAutocompleteServiceAccountRoleOrganisation",
38
+ components: {
39
+ FSAutocompleteField,
40
+ FSIcon
41
+ },
42
+ props: {
43
+ serviceAccountRoleOrganisationsFilters: {
44
+ type: Object as PropType<ServiceAccountRoleOrganisationFilters>,
45
+ required: false,
46
+ default: null
47
+ },
48
+ modelValue: {
49
+ type: [Array, String] as PropType<string[] | string | null>,
50
+ required: false,
51
+ default: null
52
+ },
53
+ multiple: {
54
+ type: Boolean,
55
+ required: false,
56
+ default: false
57
+ },
58
+ toggleSetDisabled: {
59
+ type: Boolean,
60
+ required: false,
61
+ default: false
62
+ },
63
+ label: {
64
+ type: String as PropType<string | null>,
65
+ required: false,
66
+ default: null
67
+ }
68
+ },
69
+ emits: ["update:modelValue"],
70
+ setup(props, { emit }) {
71
+ const { getMany: getManyServiceAccountRoleOrganisations, fetching: fetchingServiceAccountRoleOrganisations, entities: serviceAccountRoleOrganisations } = useServiceAccountRoleOrganisations();
72
+ const { $tr } = useTranslationsProvider();
73
+
74
+ const loading = computed((): boolean => {
75
+ return init.value && fetchingServiceAccountRoleOrganisations.value;
76
+ });
77
+
78
+ const placeholder = computed((): string | null => {
79
+ if (props.multiple && props.modelValue) {
80
+ return $tr("autocomplete.service-account-role.placeholder", "{0} role(s) selected", props.modelValue.length);
81
+ }
82
+ return null;
83
+ });
84
+
85
+ const fetch = (search: string | null) => {
86
+ return getManyServiceAccountRoleOrganisations({ ...props.serviceAccountRoleOrganisationsFilters, search: search ?? undefined })
87
+ };
88
+
89
+ const { toggleSet, init, onUpdate } = useAutocomplete(
90
+ serviceAccountRoleOrganisations,
91
+ [() => props.serviceAccountRoleOrganisationsFilters],
92
+ emit,
93
+ fetch
94
+ );
95
+
96
+ return {
97
+ serviceAccountRoleOrganisations,
98
+ placeholder,
99
+ toggleSet,
100
+ loading,
101
+ onUpdate
102
+ };
103
+ }
104
+ });
105
+ </script>
@@ -1,8 +1,10 @@
1
1
  <template>
2
2
  <FSAutocompleteField
3
3
  itemTitle="name"
4
+ :label="$props.label ?? $tr('ui.common.user', 'User')"
4
5
  :toggleSet="!$props.toggleSetDisabled && toggleSet"
5
6
  :multiple="$props.multiple"
7
+ :placeholder="placeholder"
6
8
  :items="userOrganisations"
7
9
  :loading="loading"
8
10
  :modelValue="$props.modelValue"
@@ -10,67 +12,38 @@
10
12
  v-bind="$attrs"
11
13
  >
12
14
  <template
13
- #autocomplete-selection="{ item }"
15
+ #item-prepend="{ item }"
14
16
  >
15
- <FSRow
16
- v-if="$props.modelValue"
17
- align="center-center"
18
- :wrap="false"
19
- >
20
- <FSImage
21
- v-if="item.raw.imageId"
22
- height="26px"
23
- width="26px"
24
- :imageId="item.raw.imageId"
25
- />
26
- <FSSpan>
27
- {{ item.raw.name }}
28
- </FSSpan>
29
- </FSRow>
30
- </template>
31
- <template
32
- #item-label="{ item, font }"
33
- >
34
- <FSRow
35
- align="center-left"
36
- :wrap="false"
37
- >
38
- <FSImage
39
- v-if="item.raw.imageId"
40
- height="26px"
41
- width="26px"
42
- :imageId="item.raw.imageId"
43
- />
44
- <FSSpan
45
- :font="font"
46
- >
47
- {{ item.raw.name }}
48
- </FSSpan>
49
- </FSRow>
17
+ <FSImage
18
+ v-if="item.imageId"
19
+ height="26px"
20
+ width="26px"
21
+ :imageId="item.imageId"
22
+ :thumbnail="true"
23
+ />
50
24
  </template>
51
25
  <template
52
26
  #toggle-set-item="props"
53
27
  >
54
28
  <FSButton
29
+ :padding="props.item.imageId ? ['6px 16px', '4px 12px'] : undefined"
55
30
  :variant="props.getVariant(props.item)"
56
31
  :color="props.getColor(props.item)"
57
32
  :class="props.getClass(props.item)"
33
+ :label="props.item.name"
58
34
  @click="props.toggle(props.item)"
59
35
  >
60
- <FSRow
61
- align="center-center"
62
- :wrap="false"
36
+ <template
37
+ v-if="props.item.imageId"
38
+ #prepend
63
39
  >
64
40
  <FSImage
65
- v-if="props.item.imageId"
66
41
  height="26px"
67
42
  width="26px"
68
43
  :imageId="props.item.imageId"
44
+ :thumbnail="true"
69
45
  />
70
- <FSSpan>
71
- {{ props.item.name }}
72
- </FSSpan>
73
- </FSRow>
46
+ </template>
74
47
  </FSButton>
75
48
  </template>
76
49
  </FSAutocompleteField>
@@ -82,21 +55,18 @@ import { computed, defineComponent, type PropType } from "vue";
82
55
  import { type UserOrganisationFilters, type UserOrganisationInfos } from "@dative-gpi/foundation-core-domain/models";
83
56
  import { useUserOrganisations } from "@dative-gpi/foundation-core-services/composables";
84
57
  import { useAutocomplete } from "@dative-gpi/foundation-shared-components/composables";
58
+ import { useTranslations as useTranslationsProvider } from "@dative-gpi/bones-ui";
85
59
 
86
60
  import FSAutocompleteField from "@dative-gpi/foundation-shared-components/components/fields/FSAutocompleteField.vue";
87
61
  import FSButton from "@dative-gpi/foundation-shared-components/components/FSButton.vue";
88
62
  import FSImage from "@dative-gpi/foundation-shared-components/components/FSImage.vue";
89
- import FSSpan from "@dative-gpi/foundation-shared-components/components/FSSpan.vue";
90
- import FSRow from "@dative-gpi/foundation-shared-components/components/FSRow.vue";
91
63
 
92
64
  export default defineComponent({
93
65
  name: "FSAutocompleteUserOrganisation",
94
66
  components: {
95
67
  FSAutocompleteField,
96
68
  FSButton,
97
- FSImage,
98
- FSSpan,
99
- FSRow
69
+ FSImage
100
70
  },
101
71
  props: {
102
72
  userOrganisationFilters: {
@@ -118,28 +88,34 @@ export default defineComponent({
118
88
  type: Boolean,
119
89
  required: false,
120
90
  default: false
91
+ },
92
+ label: {
93
+ type: String as PropType<string | null>,
94
+ required: false,
95
+ default: null
121
96
  }
122
97
  },
123
98
  emits: ["update:modelValue"],
124
99
  setup(props, { emit }) {
125
100
  const { getMany: getManyUserOrganisations, fetching: fetchingUserOrganisations, entities: userOrganisations } = useUserOrganisations();
101
+ const { $tr } = useTranslationsProvider();
126
102
 
127
103
  const loading = computed((): boolean => {
128
104
  return init.value && fetchingUserOrganisations.value;
129
105
  });
130
106
 
131
- const toggleSetItems = computed((): any[] => {
132
- return userOrganisations.value.map((userOrganisation: UserOrganisationInfos) => ({
133
- id: userOrganisation.id,
134
- label: userOrganisation.name
135
- }));
107
+ const placeholder = computed((): string | null => {
108
+ if (props.multiple && props.modelValue) {
109
+ return $tr("autocomplete.user.placeholder", "{0} user(s) selected", props.modelValue.length);
110
+ }
111
+ return null;
136
112
  });
137
113
 
138
114
  const fetch = (search: string | null) => {
139
115
  return getManyUserOrganisations({ ...props.userOrganisationFilters, search: search ?? undefined });
140
116
  };
141
117
 
142
- const { toggleSet, search, init, onUpdate } = useAutocomplete(
118
+ const { toggleSet, init, onUpdate } = useAutocomplete(
143
119
  userOrganisations,
144
120
  [() => props.userOrganisationFilters],
145
121
  emit,
@@ -151,10 +127,9 @@ export default defineComponent({
151
127
 
152
128
  return {
153
129
  userOrganisations,
154
- toggleSetItems,
130
+ placeholder,
155
131
  toggleSet,
156
132
  loading,
157
- search,
158
133
  onUpdate
159
134
  };
160
135
  }