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

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
  :items="dataDefinitions"
6
7
  :loading="loading"
7
8
  :modelValue="$props.modelValue"
@@ -9,50 +10,13 @@
9
10
  v-bind="$attrs"
10
11
  >
11
12
  <template
12
- #autocomplete-selection="{ item }"
13
- >
14
- <FSRow
15
- v-if="$props.modelValue"
16
- align="center-center"
17
- padding="0 8px 0 0"
18
- gap="4px"
19
- :wrap="false"
20
- >
21
- <FSSpan>
22
- {{ item.raw.label }}
23
- </FSSpan>
24
- <FSChip
25
- v-if="$props.multiple && item.raw.unit"
26
- :label="item.raw.unit"
27
- />
28
- </FSRow>
29
- </template>
30
- <template
31
- v-if="selected && selected.unit"
32
- #autocomplete-suffix
13
+ #item-append="{ item }"
33
14
  >
34
15
  <FSChip
35
- :label="selected.unit"
16
+ v-if="item.unit"
17
+ :label="item.unit"
36
18
  />
37
19
  </template>
38
- <template
39
- #item-label="{ item, font }"
40
- >
41
- <FSRow
42
- align="center-left"
43
- :wrap="false"
44
- >
45
- <FSSpan
46
- :font="font"
47
- >
48
- {{ item.raw.label }}
49
- </FSSpan>
50
- <FSChip
51
- v-if="item.raw.unit"
52
- :label="item.raw.unit"
53
- />
54
- </FSRow>
55
- </template>
56
20
  <template
57
21
  #toggle-set-item="props"
58
22
  >
@@ -79,24 +43,21 @@
79
43
  <script lang="ts">
80
44
  import { computed, defineComponent, type PropType } from "vue";
81
45
 
82
- import { type DataDefinitionInfos, type DataDefinitionFilters } from "@dative-gpi/foundation-core-domain/models";
46
+ import { type DataDefinitionFilters } from "@dative-gpi/foundation-core-domain/models";
83
47
  import { useAutocomplete } from "@dative-gpi/foundation-shared-components/composables";
84
48
  import { useDataDefinitions } from "@dative-gpi/foundation-core-services/composables";
49
+ import { useTranslations as useTranslationsProvider } from "@dative-gpi/bones-ui";
85
50
 
86
51
  import FSAutocompleteField from "@dative-gpi/foundation-shared-components/components/fields/FSAutocompleteField.vue";
87
52
  import FSButton from "@dative-gpi/foundation-shared-components/components/FSButton.vue";
88
53
  import FSChip from "@dative-gpi/foundation-shared-components/components/FSChip.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
54
 
92
55
  export default defineComponent({
93
56
  name: "FSAutocompleteDataDefinition",
94
57
  components: {
95
58
  FSAutocompleteField,
96
59
  FSButton,
97
- FSChip,
98
- FSSpan,
99
- FSRow
60
+ FSChip
100
61
  },
101
62
  props: {
102
63
  dataDefinitionFilters: {
@@ -123,16 +84,17 @@ export default defineComponent({
123
84
  emits: ["update:modelValue"],
124
85
  setup(props, { emit }) {
125
86
  const { getMany: getManyDataDefinitions, fetching: fetchingDataDefinitions, entities: dataDefinitions } = useDataDefinitions();
87
+ const { $tr } = useTranslationsProvider();
126
88
 
127
89
  const loading = computed((): boolean => {
128
90
  return init.value && fetchingDataDefinitions.value;
129
91
  });
130
92
 
131
- const selected = computed((): DataDefinitionInfos | undefined => {
132
- if (props.multiple) {
133
- return undefined;
93
+ const placeholder = computed((): string | null => {
94
+ if (props.multiple && props.modelValue) {
95
+ return $tr("ui.autocomplete-data-definition.placeholder", "{0} data definition(s) selected", props.modelValue.length);
134
96
  }
135
- return dataDefinitions.value.find((dataDefinition: DataDefinitionInfos) => dataDefinition.id === props.modelValue);
97
+ return null;
136
98
  });
137
99
 
138
100
  const fetch = (search: string | null) => {
@@ -148,8 +110,8 @@ export default defineComponent({
148
110
 
149
111
  return {
150
112
  dataDefinitions,
113
+ placeholder,
151
114
  toggleSet,
152
- selected,
153
115
  loading,
154
116
  onUpdate
155
117
  };
@@ -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="groups"
7
8
  :modelValue="$props.modelValue"
@@ -9,41 +10,13 @@
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>
@@ -52,21 +25,18 @@
52
25
  import { computed, defineComponent, type PropType } from "vue";
53
26
 
54
27
  import { useAutocomplete } from "@dative-gpi/foundation-shared-components/composables";
28
+ import { useTranslations as useTranslationsProvider } from "@dative-gpi/bones-ui";
55
29
  import { type GroupFilters } from "@dative-gpi/foundation-core-domain/models";
56
30
  import { useGroups } from "@dative-gpi/foundation-core-services/composables";
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: "FSAutocompleteGroup",
65
37
  components: {
66
38
  FSAutocompleteField,
67
- FSIcon,
68
- FSSpan,
69
- FSRow
39
+ FSIcon
70
40
  },
71
41
  props: {
72
42
  groupFilters: {
@@ -93,11 +63,19 @@ export default defineComponent({
93
63
  emits: ["update:modelValue"],
94
64
  setup(props, { emit }) {
95
65
  const { getMany: getManyGroups, fetching: fetchingGroups, entities: groups } = useGroups();
66
+ const { $tr } = useTranslationsProvider();
96
67
 
97
68
  const loading = computed((): boolean => {
98
69
  return init.value && fetchingGroups.value;
99
70
  });
100
71
 
72
+ const placeholder = computed((): string | null => {
73
+ if (props.multiple && props.modelValue) {
74
+ return $tr("ui.autocomplete-group.placeholder", "{0} group(s) selected", props.modelValue.length);
75
+ }
76
+ return null;
77
+ });
78
+
101
79
  const fetch = (search: string | null) => {
102
80
  return getManyGroups({ ...props.groupFilters, search: search ?? undefined });
103
81
  };
@@ -110,6 +88,7 @@ export default defineComponent({
110
88
  );
111
89
 
112
90
  return {
91
+ placeholder,
113
92
  toggleSet,
114
93
  loading,
115
94
  groups,
@@ -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="locations"
7
8
  :modelValue="$props.modelValue"
@@ -9,41 +10,13 @@
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>
@@ -52,21 +25,18 @@
52
25
  import { computed, defineComponent, type PropType } from "vue";
53
26
 
54
27
  import { useAutocomplete } from "@dative-gpi/foundation-shared-components/composables";
28
+ import { useTranslations as useTranslationsProvider } from "@dative-gpi/bones-ui";
55
29
  import { type LocationFilters } from "@dative-gpi/foundation-core-domain/models";
56
30
  import { useLocations } from "@dative-gpi/foundation-core-services/composables";
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: "FSAutocompleteLocation",
65
37
  components: {
66
38
  FSAutocompleteField,
67
- FSIcon,
68
- FSSpan,
69
- FSRow
39
+ FSIcon
70
40
  },
71
41
  props: {
72
42
  locationFilters: {
@@ -93,11 +63,19 @@ export default defineComponent({
93
63
  emits: ["update:modelValue"],
94
64
  setup(props, { emit }) {
95
65
  const { getMany: getManyLocations, fetching: fetchingLocations, entities: locations } = useLocations();
66
+ const { $tr } = useTranslationsProvider();
96
67
 
97
68
  const loading = computed((): boolean => {
98
69
  return init.value && fetchingLocations.value;
99
70
  });
100
71
 
72
+ const placeholder = computed((): string | null => {
73
+ if (props.multiple && props.modelValue) {
74
+ return $tr("ui.autocomplete-location.placeholder", "{0} location(s) selected", props.modelValue.length);
75
+ }
76
+ return null;
77
+ });
78
+
101
79
  const fetch = (search: string | null) => {
102
80
  return getManyLocations({ ...props.locationFilters, search: search ?? undefined });
103
81
  };
@@ -110,6 +88,7 @@ export default defineComponent({
110
88
  );
111
89
 
112
90
  return {
91
+ placeholder,
113
92
  locations,
114
93
  toggleSet,
115
94
  loading,
@@ -1,12 +1,48 @@
1
1
  <template>
2
2
  <FSAutocompleteField
3
3
  :toggleSet="!$props.toggleSetDisabled && toggleSet"
4
+ :multiple="$props.multiple"
5
+ :placeholder="placeholder"
4
6
  :items="manufacturers"
5
7
  :loading="loading"
6
8
  :modelValue="$props.modelValue"
7
9
  @update:modelValue="onUpdate"
8
10
  v-bind="$attrs"
9
- />
11
+ >
12
+ <template
13
+ #item-prepend="{ item }"
14
+ >
15
+ <FSImage
16
+ v-if="item.imageId"
17
+ height="26px"
18
+ width="26px"
19
+ :imageId="item.imageId"
20
+ />
21
+ </template>
22
+ <template
23
+ #toggle-set-item="props"
24
+ >
25
+ <FSButton
26
+ :padding="props.item.imageId ? ['6px 16px', '4px 12px'] : undefined"
27
+ :variant="props.getVariant(props.item)"
28
+ :color="props.getColor(props.item)"
29
+ :class="props.getClass(props.item)"
30
+ :label="props.item.label"
31
+ @click="props.toggle(props.item)"
32
+ >
33
+ <template
34
+ v-if="props.item.imageId"
35
+ #prepend
36
+ >
37
+ <FSImage
38
+ height="26px"
39
+ width="26px"
40
+ :imageId="props.item.imageId"
41
+ />
42
+ </template>
43
+ </FSButton>
44
+ </template>
45
+ </FSAutocompleteField>
10
46
  </template>
11
47
 
12
48
  <script lang="ts">
@@ -15,13 +51,18 @@ import { computed, defineComponent, type PropType } from "vue";
15
51
  import { useAutocomplete } from "@dative-gpi/foundation-shared-components/composables";
16
52
  import { type ManufacturerFilters } from "@dative-gpi/foundation-core-domain/models";
17
53
  import { useManufacturers } from "@dative-gpi/foundation-core-services/composables";
54
+ import { useTranslations as useTranslationsProvider } from "@dative-gpi/bones-ui";
18
55
 
19
56
  import FSAutocompleteField from "@dative-gpi/foundation-shared-components/components/fields/FSAutocompleteField.vue";
57
+ import FSButton from "@dative-gpi/foundation-shared-components/components/FSButton.vue";
58
+ import FSImage from "@dative-gpi/foundation-shared-components/components/FSImage.vue";
20
59
 
21
60
  export default defineComponent({
22
61
  name: "FSAutocompleteManufacturer",
23
62
  components: {
24
- FSAutocompleteField
63
+ FSAutocompleteField,
64
+ FSButton,
65
+ FSImage
25
66
  },
26
67
  props: {
27
68
  manufacturerFilters: {
@@ -34,6 +75,11 @@ export default defineComponent({
34
75
  required: false,
35
76
  default: null
36
77
  },
78
+ multiple: {
79
+ type: Boolean,
80
+ required: false,
81
+ default: false
82
+ },
37
83
  toggleSetDisabled: {
38
84
  type: Boolean,
39
85
  required: false,
@@ -43,11 +89,19 @@ export default defineComponent({
43
89
  emits: ["update:modelValue"],
44
90
  setup(props, { emit }) {
45
91
  const { getMany: getManyManufacturers, fetching: fetchingManufacturers, entities: manufacturers } = useManufacturers();
92
+ const { $tr } = useTranslationsProvider();
46
93
 
47
94
  const loading = computed((): boolean => {
48
95
  return init.value && fetchingManufacturers.value;
49
96
  });
50
97
 
98
+ const placeholder = computed((): string | null => {
99
+ if (props.multiple && props.modelValue) {
100
+ return $tr("ui.autocomplete-manufacturer.placeholder", "{0} manufacturer(s) selected", props.modelValue.length);
101
+ }
102
+ return null;
103
+ });
104
+
51
105
  const fetch = (search: string | null) => {
52
106
  return getManyManufacturers({ ...props.manufacturerFilters, search: search ?? undefined });
53
107
  };
@@ -61,6 +115,7 @@ export default defineComponent({
61
115
 
62
116
  return {
63
117
  manufacturers,
118
+ placeholder,
64
119
  toggleSet,
65
120
  loading,
66
121
  onUpdate
@@ -1,27 +1,68 @@
1
1
  <template>
2
2
  <FSAutocompleteField
3
3
  :toggleSet="!$props.toggleSetDisabled && toggleSet"
4
+ :multiple="$props.multiple"
5
+ :placeholder="placeholder"
4
6
  :loading="loading"
5
7
  :items="models"
6
8
  :modelValue="$props.modelValue"
7
9
  @update:modelValue="onUpdate"
8
10
  v-bind="$attrs"
9
- />
11
+ >
12
+ <template
13
+ #item-prepend="{ item }"
14
+ >
15
+ <FSImage
16
+ v-if="item.imageId"
17
+ height="26px"
18
+ width="26px"
19
+ :imageId="item.imageId"
20
+ />
21
+ </template>
22
+ <template
23
+ #toggle-set-item="props"
24
+ >
25
+ <FSButton
26
+ :padding="props.item.imageId ? ['6px 16px', '4px 12px'] : undefined"
27
+ :variant="props.getVariant(props.item)"
28
+ :color="props.getColor(props.item)"
29
+ :class="props.getClass(props.item)"
30
+ :label="props.item.label"
31
+ @click="props.toggle(props.item)"
32
+ >
33
+ <template
34
+ v-if="props.item.imageId"
35
+ #prepend
36
+ >
37
+ <FSImage
38
+ height="26px"
39
+ width="26px"
40
+ :imageId="props.item.imageId"
41
+ />
42
+ </template>
43
+ </FSButton>
44
+ </template>
45
+ </FSAutocompleteField>
10
46
  </template>
11
47
 
12
48
  <script lang="ts">
13
49
  import { computed, defineComponent, type PropType } from "vue";
14
50
 
15
51
  import { useAutocomplete } from "@dative-gpi/foundation-shared-components/composables";
52
+ import { useTranslations as useTranslationsProvider } from "@dative-gpi/bones-ui";
16
53
  import { type ModelFilters } from "@dative-gpi/foundation-core-domain/models";
17
54
  import { useModels } from "@dative-gpi/foundation-core-services/composables";
18
55
 
19
56
  import FSAutocompleteField from "@dative-gpi/foundation-shared-components/components/fields/FSAutocompleteField.vue";
57
+ import FSButton from "@dative-gpi/foundation-shared-components/components/FSButton.vue";
58
+ import FSImage from "@dative-gpi/foundation-shared-components/components/FSImage.vue";
20
59
 
21
60
  export default defineComponent({
22
61
  name: "FSAutocompleteModel",
23
62
  components: {
24
- FSAutocompleteField
63
+ FSAutocompleteField,
64
+ FSButton,
65
+ FSImage
25
66
  },
26
67
  props: {
27
68
  modelFilters: {
@@ -34,6 +75,11 @@ export default defineComponent({
34
75
  required: false,
35
76
  default: null
36
77
  },
78
+ multiple: {
79
+ type: Boolean,
80
+ required: false,
81
+ default: false
82
+ },
37
83
  toggleSetDisabled: {
38
84
  type: Boolean,
39
85
  required: false,
@@ -43,11 +89,19 @@ export default defineComponent({
43
89
  emits: ["update:modelValue"],
44
90
  setup(props, { emit }) {
45
91
  const { getMany: getManyModels, fetching: fetchingModels, entities: models } = useModels();
92
+ const { $tr } = useTranslationsProvider();
46
93
 
47
94
  const loading = computed((): boolean => {
48
95
  return init.value && fetchingModels.value;
49
96
  });
50
97
 
98
+ const placeholder = computed((): string | null => {
99
+ if (props.multiple && props.modelValue) {
100
+ return $tr("ui.autocomplete-model.placeholder", "{0} model(s) selected", props.modelValue.length);
101
+ }
102
+ return null;
103
+ });
104
+
51
105
  const fetch = (search: string | null) => {
52
106
  return getManyModels({ ...props.modelFilters, search: search ?? undefined });
53
107
  };
@@ -60,6 +114,7 @@ export default defineComponent({
60
114
  );
61
115
 
62
116
  return {
117
+ placeholder,
63
118
  toggleSet,
64
119
  loading,
65
120
  models,
@@ -1,6 +1,8 @@
1
1
  <template>
2
2
  <FSAutocompleteField
3
3
  :toggleSet="!$props.toggleSetDisabled && toggleSet"
4
+ :multiple="$props.multiple"
5
+ :placeholder="placeholder"
4
6
  :items="organisationTypes"
5
7
  :loading="loading"
6
8
  :modelValue="$props.modelValue"
@@ -15,6 +17,7 @@ import { computed, defineComponent, type PropType } from "vue";
15
17
  import { type OrganisationTypeFilters } from "@dative-gpi/foundation-shared-domain/models";
16
18
  import { useOrganisationTypes } from "@dative-gpi/foundation-core-services/composables";
17
19
  import { useAutocomplete } from "@dative-gpi/foundation-shared-components/composables";
20
+ import { useTranslations as useTranslationsProvider } from "@dative-gpi/bones-ui";
18
21
 
19
22
  import FSAutocompleteField from "@dative-gpi/foundation-shared-components/components/fields/FSAutocompleteField.vue";
20
23
 
@@ -34,6 +37,11 @@ export default defineComponent({
34
37
  required: false,
35
38
  default: null
36
39
  },
40
+ multiple: {
41
+ type: Boolean,
42
+ required: false,
43
+ default: false
44
+ },
37
45
  toggleSetDisabled: {
38
46
  type: Boolean,
39
47
  required: false,
@@ -43,11 +51,19 @@ export default defineComponent({
43
51
  emits: ["update:modelValue"],
44
52
  setup(props, { emit }) {
45
53
  const { getMany: getManyOrganisationTypes, fetching: fetchingOrganisationTypes, entities: organisationTypes } = useOrganisationTypes();
54
+ const { $tr } = useTranslationsProvider();
46
55
 
47
56
  const loading = computed((): boolean => {
48
57
  return init.value && fetchingOrganisationTypes.value;
49
58
  });
50
59
 
60
+ const placeholder = computed((): string | null => {
61
+ if (props.multiple && props.modelValue) {
62
+ return $tr("ui.autocomplete-organisation-type.placeholder", "{0} organisation type(s) selected", props.modelValue.length);
63
+ }
64
+ return null;
65
+ });
66
+
51
67
  const fetch = (search: string | null) => {
52
68
  return getManyOrganisationTypes({ ...props.organisationTypeFilters, search: search ?? undefined });
53
69
  };
@@ -61,6 +77,7 @@ export default defineComponent({
61
77
 
62
78
  return {
63
79
  organisationTypes,
80
+ placeholder,
64
81
  toggleSet,
65
82
  loading,
66
83
  onUpdate