@dative-gpi/foundation-core-components 1.0.34 → 1.0.36

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.
@@ -2,6 +2,7 @@
2
2
  <FSAutocompleteField
3
3
  :toggleSet="!$props.toggleSetDisabled && toggleSet"
4
4
  :multiple="$props.multiple"
5
+ :placeholder="placeholder"
5
6
  :loading="loading"
6
7
  :items="roles"
7
8
  :modelValue="$props.modelValue"
@@ -9,51 +10,22 @@
9
10
  v-bind="$attrs"
10
11
  >
11
12
  <template
12
- #autocomplete-selection="{ item }"
13
+ #item-prepend="{ item }"
13
14
  >
14
- <FSRow
15
- v-if="$props.modelValue"
16
- align="center-center"
17
- :wrap="false"
15
+ <FSIcon
16
+ v-if="item.icon"
18
17
  >
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>
18
+ {{ item.icon }}
19
+ </FSIcon>
33
20
  </template>
34
21
  <template
35
- #item-label="{ item, font }"
22
+ #item-append="{ item }"
36
23
  >
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>
24
+ <FSChip
25
+ :color="roleTypeColor(item.type)"
26
+ :label="roleTypeLabel(item.type)"
27
+ :editable="false"
28
+ />
57
29
  </template>
58
30
  <template
59
31
  #toggle-set-item="props"
@@ -87,6 +59,7 @@ import { computed, defineComponent, type PropType } from "vue";
87
59
  import { type RoleOrganisationFilters, type RoleOrganisationTypeFilters, RoleType } from "@dative-gpi/foundation-core-domain/models";
88
60
  import { useRoleOrganisations, useRoleOrganisationTypes } from "@dative-gpi/foundation-core-services/composables";
89
61
  import { useAutocomplete } from "@dative-gpi/foundation-shared-components/composables";
62
+ import { useTranslations as useTranslationsProvider } from "@dative-gpi/bones-ui";
90
63
 
91
64
  import { roleTypeColor, roleTypeLabel } from "../../utils";
92
65
 
@@ -94,8 +67,6 @@ import FSAutocompleteField from "@dative-gpi/foundation-shared-components/compon
94
67
  import FSButton from "@dative-gpi/foundation-shared-components/components/FSButton.vue";
95
68
  import FSChip from "@dative-gpi/foundation-shared-components/components/FSChip.vue";
96
69
  import FSIcon from "@dative-gpi/foundation-shared-components/components/FSIcon.vue";
97
- import FSSpan from "@dative-gpi/foundation-shared-components/components/FSSpan.vue";
98
- import FSRow from "@dative-gpi/foundation-shared-components/components/FSRow.vue";
99
70
 
100
71
  export default defineComponent({
101
72
  name: "FSAutocompleteRole",
@@ -103,9 +74,7 @@ export default defineComponent({
103
74
  FSAutocompleteField,
104
75
  FSButton,
105
76
  FSChip,
106
- FSIcon,
107
- FSSpan,
108
- FSRow
77
+ FSIcon
109
78
  },
110
79
  props: {
111
80
  roleOrganisationTypeFilters: {
@@ -128,6 +97,16 @@ export default defineComponent({
128
97
  required: false,
129
98
  default: RoleType.None
130
99
  },
100
+ ignoreRoleOrganisationTypes: {
101
+ type: Boolean,
102
+ required: false,
103
+ default: false
104
+ },
105
+ ignoreRoleOrganisations: {
106
+ type: Boolean,
107
+ required: false,
108
+ default: false
109
+ },
131
110
  multiple: {
132
111
  type: Boolean,
133
112
  required: false,
@@ -143,6 +122,7 @@ export default defineComponent({
143
122
  setup(props, { emit }) {
144
123
  const { getMany: getManyRoleOrganisationTypes, fetching: fetchingRoleOrganisationTypes, entities: roleOrganisationTypes } = useRoleOrganisationTypes();
145
124
  const { getMany: getManyRoleOrganisations, fetching: fetchingRoleOrganisations, entities: roleOrganisations } = useRoleOrganisations();
125
+ const { $tr } = useTranslationsProvider();
146
126
 
147
127
  const roles = computed(() => {
148
128
  return roleOrganisationTypes.value.map(rot => ({
@@ -162,6 +142,13 @@ export default defineComponent({
162
142
  return init.value && (fetchingRoleOrganisationTypes.value || fetchingRoleOrganisations.value);
163
143
  });
164
144
 
145
+ const placeholder = computed((): string | null => {
146
+ if (props.multiple && props.modelValue) {
147
+ return $tr("ui.autocomplete-role.placeholder", "{0} role(s) selected", props.modelValue.length);
148
+ }
149
+ return null;
150
+ });
151
+
165
152
  const update = (value: Role[] | Role | null) => {
166
153
  if (Array.isArray(value)) {
167
154
  emit("update:modelValue", value.map(v => v.id));
@@ -174,10 +161,14 @@ export default defineComponent({
174
161
  };
175
162
 
176
163
  const fetch = (search: string | null) => {
177
- return Promise.all([
178
- getManyRoleOrganisationTypes({ ...props.roleOrganisationTypeFilters, search: search ?? undefined }),
179
- getManyRoleOrganisations({ ...props.roleOrganisationFilters, search: search ?? undefined })
180
- ]);
164
+ const promises = [];
165
+ if (!props.ignoreRoleOrganisations) {
166
+ promises.push(getManyRoleOrganisations({ ...props.roleOrganisationFilters, search: search ?? undefined }));
167
+ }
168
+ if (!props.ignoreRoleOrganisationTypes) {
169
+ promises.push(getManyRoleOrganisationTypes({ ...props.roleOrganisationTypeFilters, search: search ?? undefined }));
170
+ }
171
+ return Promise.all(promises);
181
172
  };
182
173
 
183
174
  const { toggleSet, init, onUpdate } = useAutocomplete(
@@ -189,6 +180,7 @@ export default defineComponent({
189
180
  );
190
181
 
191
182
  return {
183
+ placeholder,
192
184
  toggleSet,
193
185
  RoleType,
194
186
  loading,
@@ -3,47 +3,20 @@
3
3
  :toggleSet="!$props.toggleSetDisabled && toggleSet"
4
4
  :items="serviceAccountRoleOrganisations"
5
5
  :multiple="$props.multiple"
6
+ :placeholder="placeholder"
6
7
  :loading="loading"
7
8
  :modelValue="$props.modelValue"
8
9
  @update:modelValue="onUpdate"
9
10
  v-bind="$attrs"
10
11
  >
11
12
  <template
12
- #autocomplete-selection="{ item }"
13
+ #item-prepend="{ item }"
13
14
  >
14
- <FSRow
15
- v-if="$props.modelValue"
16
- align="center-center"
17
- :wrap="false"
15
+ <FSIcon
16
+ v-if="item.icon"
18
17
  >
19
- <FSIcon
20
- v-if="item.raw.icon"
21
- >
22
- {{ item.raw.icon }}
23
- </FSIcon>
24
- <FSSpan>
25
- {{ item.raw.label }}
26
- </FSSpan>
27
- </FSRow>
28
- </template>
29
- <template
30
- #item-label="{ item, font }"
31
- >
32
- <FSRow
33
- align="center-left"
34
- :wrap="false"
35
- >
36
- <FSIcon
37
- v-if="item.raw.icon"
38
- >
39
- {{ item.raw.icon }}
40
- </FSIcon>
41
- <FSSpan
42
- :font="font"
43
- >
44
- {{ item.raw.label }}
45
- </FSSpan>
46
- </FSRow>
18
+ {{ item.icon }}
19
+ </FSIcon>
47
20
  </template>
48
21
  </FSAutocompleteField>
49
22
  </template>
@@ -51,26 +24,23 @@
51
24
  <script lang="ts">
52
25
  import { computed, defineComponent, type PropType } from "vue";
53
26
 
54
- import { type ServiceAccountRoleOrganisationsFilters } from "@dative-gpi/foundation-core-domain/models";
27
+ import { type ServiceAccountRoleOrganisationFilters } from "@dative-gpi/foundation-core-domain/models";
55
28
  import { useServiceAccountRoleOrganisations } from "@dative-gpi/foundation-core-services/composables";
56
29
  import { useAutocomplete } from "@dative-gpi/foundation-shared-components/composables";
30
+ import { useTranslations as useTranslationsProvider } from "@dative-gpi/bones-ui";
57
31
 
58
32
  import FSAutocompleteField from "@dative-gpi/foundation-shared-components/components/fields/FSAutocompleteField.vue";
59
33
  import FSIcon from "@dative-gpi/foundation-shared-components/components/FSIcon.vue";
60
- import FSSpan from "@dative-gpi/foundation-shared-components/components/FSSpan.vue";
61
- import FSRow from "@dative-gpi/foundation-shared-components/components/FSRow.vue";
62
34
 
63
35
  export default defineComponent({
64
36
  name: "FSAutocompleteServiceAccountRoleOrganisation",
65
37
  components: {
66
38
  FSAutocompleteField,
67
- FSIcon,
68
- FSSpan,
69
- FSRow
39
+ FSIcon
70
40
  },
71
41
  props: {
72
42
  serviceAccountRoleOrganisationsFilters: {
73
- type: Object as PropType<ServiceAccountRoleOrganisationsFilters>,
43
+ type: Object as PropType<ServiceAccountRoleOrganisationFilters>,
74
44
  required: false,
75
45
  default: null
76
46
  },
@@ -93,11 +63,19 @@ export default defineComponent({
93
63
  emits: ["update:modelValue"],
94
64
  setup(props, { emit }) {
95
65
  const { getMany: getManyServiceAccountRoleOrganisations, fetching: fetchingServiceAccountRoleOrganisations, entities: serviceAccountRoleOrganisations } = useServiceAccountRoleOrganisations();
66
+ const { $tr } = useTranslationsProvider();
96
67
 
97
68
  const loading = computed((): boolean => {
98
69
  return init.value && fetchingServiceAccountRoleOrganisations.value;
99
70
  });
100
71
 
72
+ const placeholder = computed((): string | null => {
73
+ if (props.multiple && props.modelValue) {
74
+ return $tr("ui.autocomplete-service-account-role-organisation.placeholder", "{0} role(s) selected", props.modelValue.length);
75
+ }
76
+ return null;
77
+ });
78
+
101
79
  const fetch = (search: string | null) => {
102
80
  return getManyServiceAccountRoleOrganisations({ ...props.serviceAccountRoleOrganisationsFilters, search: search ?? undefined })
103
81
  };
@@ -111,6 +89,7 @@ export default defineComponent({
111
89
 
112
90
  return {
113
91
  serviceAccountRoleOrganisations,
92
+ placeholder,
114
93
  toggleSet,
115
94
  loading,
116
95
  onUpdate
@@ -3,6 +3,7 @@
3
3
  itemTitle="name"
4
4
  :toggleSet="!$props.toggleSetDisabled && toggleSet"
5
5
  :multiple="$props.multiple"
6
+ :placeholder="placeholder"
6
7
  :items="userOrganisations"
7
8
  :loading="loading"
8
9
  :modelValue="$props.modelValue"
@@ -10,50 +11,21 @@
10
11
  v-bind="$attrs"
11
12
  >
12
13
  <template
13
- #autocomplete-selection="{ item }"
14
+ #item-prepend="{ item }"
14
15
  >
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>
16
+ <FSImage
17
+ v-if="item.imageId"
18
+ height="26px"
19
+ width="26px"
20
+ :imageId="item.imageId"
21
+ />
50
22
  </template>
51
23
  <template
52
24
  #toggle-set-item="props"
53
25
  >
54
26
  <FSButton
27
+ :padding="props.item.imageId ? ['6px 16px', '4px 12px'] : undefined"
55
28
  :variant="props.getVariant(props.item)"
56
- :padding="['6px 16px', '4px 12px']"
57
29
  :color="props.getColor(props.item)"
58
30
  :class="props.getClass(props.item)"
59
31
  :label="props.item.name"
@@ -80,21 +52,18 @@ import { computed, defineComponent, type PropType } from "vue";
80
52
  import { type UserOrganisationFilters, type UserOrganisationInfos } from "@dative-gpi/foundation-core-domain/models";
81
53
  import { useUserOrganisations } from "@dative-gpi/foundation-core-services/composables";
82
54
  import { useAutocomplete } from "@dative-gpi/foundation-shared-components/composables";
55
+ import { useTranslations as useTranslationsProvider } from "@dative-gpi/bones-ui";
83
56
 
84
57
  import FSAutocompleteField from "@dative-gpi/foundation-shared-components/components/fields/FSAutocompleteField.vue";
85
58
  import FSButton from "@dative-gpi/foundation-shared-components/components/FSButton.vue";
86
59
  import FSImage from "@dative-gpi/foundation-shared-components/components/FSImage.vue";
87
- import FSSpan from "@dative-gpi/foundation-shared-components/components/FSSpan.vue";
88
- import FSRow from "@dative-gpi/foundation-shared-components/components/FSRow.vue";
89
60
 
90
61
  export default defineComponent({
91
62
  name: "FSAutocompleteUserOrganisation",
92
63
  components: {
93
64
  FSAutocompleteField,
94
65
  FSButton,
95
- FSImage,
96
- FSSpan,
97
- FSRow
66
+ FSImage
98
67
  },
99
68
  props: {
100
69
  userOrganisationFilters: {
@@ -121,10 +90,18 @@ export default defineComponent({
121
90
  emits: ["update:modelValue"],
122
91
  setup(props, { emit }) {
123
92
  const { getMany: getManyUserOrganisations, fetching: fetchingUserOrganisations, entities: userOrganisations } = useUserOrganisations();
93
+ const { $tr } = useTranslationsProvider();
124
94
 
125
95
  const loading = computed((): boolean => {
126
96
  return init.value && fetchingUserOrganisations.value;
127
97
  });
98
+
99
+ const placeholder = computed((): string | null => {
100
+ if (props.multiple && props.modelValue) {
101
+ return $tr("ui.autocomplete-user-organisation.placeholder", "{0} user(s) selected", props.modelValue.length);
102
+ }
103
+ return null;
104
+ });
128
105
 
129
106
  const fetch = (search: string | null) => {
130
107
  return getManyUserOrganisations({ ...props.userOrganisationFilters, search: search ?? undefined });
@@ -142,6 +119,7 @@ export default defineComponent({
142
119
 
143
120
  return {
144
121
  userOrganisations,
122
+ placeholder,
145
123
  toggleSet,
146
124
  loading,
147
125
  onUpdate
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.34",
4
+ "version": "1.0.36",
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.34",
14
- "@dative-gpi/foundation-core-services": "1.0.34",
15
- "@dative-gpi/foundation-shared-components": "1.0.34",
16
- "@dative-gpi/foundation-shared-domain": "1.0.34",
17
- "@dative-gpi/foundation-shared-services": "1.0.34"
13
+ "@dative-gpi/foundation-core-domain": "1.0.36",
14
+ "@dative-gpi/foundation-core-services": "1.0.36",
15
+ "@dative-gpi/foundation-shared-components": "1.0.36",
16
+ "@dative-gpi/foundation-shared-domain": "1.0.36",
17
+ "@dative-gpi/foundation-shared-services": "1.0.36"
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": "c73eb4aecb216537fab5b040f85ecf0ccc06e752"
29
+ "gitHead": "687d6ae60b16a75dc332400cd6eee19cb306767b"
30
30
  }