@dative-gpi/foundation-core-components 0.0.83 → 0.0.84

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.
@@ -0,0 +1,72 @@
1
+ <template>
2
+ <FSAutocompleteField
3
+ :toggleSet="!$props.toggleSetDisabled && toggleSet"
4
+ :loading="loading"
5
+ :items="locations"
6
+ :modelValue="$props.modelValue"
7
+ @update:modelValue="onUpdate"
8
+ v-model:search="search"
9
+ v-bind="$attrs"
10
+ />
11
+ </template>
12
+
13
+ <script lang="ts">
14
+ import { computed, defineComponent, PropType } from "vue";
15
+
16
+ import { useAutocomplete } from "@dative-gpi/foundation-shared-components/composables";
17
+ import { useLocations } from "@dative-gpi/foundation-core-services/composables";
18
+ import { LocationFilters } from "@dative-gpi/foundation-core-domain/models";
19
+
20
+ import FSAutocompleteField from "@dative-gpi/foundation-shared-components/components/fields/FSAutocompleteField.vue";
21
+
22
+ export default defineComponent({
23
+ name: "FSAutocompleteLocation",
24
+ components: {
25
+ FSAutocompleteField
26
+ },
27
+ props: {
28
+ locationFilters: {
29
+ type: Object as PropType<LocationFilters>,
30
+ required: false,
31
+ default: null
32
+ },
33
+ modelValue: {
34
+ type: [Array, String] as PropType<string[] | string | null>,
35
+ required: false,
36
+ default: null
37
+ },
38
+ toggleSetDisabled: {
39
+ type: Boolean,
40
+ required: false,
41
+ default: false
42
+ }
43
+ },
44
+ emits: ["update:modelValue"],
45
+ setup(props, { emit }) {
46
+ const { getMany: getManyLocations, fetching: fetchingLocations, entities: locations } = useLocations();
47
+
48
+ const innerFetch = (search: string | null) => {
49
+ return getManyLocations({ ...props.locationFilters, search: search ?? undefined });
50
+ };
51
+
52
+ const { toggleSet, search, init, onUpdate } = useAutocomplete(
53
+ locations,
54
+ [() => props.locationFilters],
55
+ emit,
56
+ innerFetch
57
+ );
58
+
59
+ const loading = computed((): boolean => {
60
+ return init.value && fetchingLocations.value;
61
+ });
62
+
63
+ return {
64
+ locations,
65
+ toggleSet,
66
+ loading,
67
+ search,
68
+ onUpdate
69
+ };
70
+ }
71
+ });
72
+ </script>
@@ -0,0 +1,114 @@
1
+ <template>
2
+ <FSAutocompleteField
3
+ :toggleSet="!$props.toggleSetDisabled && toggleSet"
4
+ :loading="loading"
5
+ :items="roles"
6
+ :modelValue="$props.modelValue"
7
+ @update:modelValue="onUpdate"
8
+ v-model:search="search"
9
+ v-bind="$attrs"
10
+ />
11
+ </template>
12
+
13
+ <script lang="ts">
14
+ import { computed, defineComponent, PropType } from "vue";
15
+
16
+ import { RoleOrganisationFilters, RoleOrganisationTypeFilters, RoleType } from "@dative-gpi/foundation-core-domain/models";
17
+ import { useRoleOrganisations, useRoleOrganisationTypes } from "@dative-gpi/foundation-core-services/composables";
18
+ import { useAutocomplete } from "@dative-gpi/foundation-shared-components/composables";
19
+
20
+ import FSAutocompleteField from "@dative-gpi/foundation-shared-components/components/fields/FSAutocompleteField.vue";
21
+
22
+ export default defineComponent({
23
+ name: "FSAutocompleteRole",
24
+ components: {
25
+ FSAutocompleteField
26
+ },
27
+ props: {
28
+ roleOrganisationTypeFilters: {
29
+ type: Object as PropType<RoleOrganisationTypeFilters>,
30
+ required: false,
31
+ default: null
32
+ },
33
+ roleOrganisationFilters: {
34
+ type: Object as PropType<RoleOrganisationFilters>,
35
+ required: false,
36
+ default: null
37
+ },
38
+ modelValue: {
39
+ type: [Array, String] as PropType<string[] | string | null>,
40
+ required: false,
41
+ default: null
42
+ },
43
+ toggleSetDisabled: {
44
+ type: Boolean,
45
+ required: false,
46
+ default: false
47
+ }
48
+ },
49
+ emits: ["update:modelValue", "update:type"],
50
+ setup(props, { emit }) {
51
+ const { getMany: getManyRoleOrganisationTypes, fetching: fetchingRoleOrganisationTypes, entities: roleOrganisationTypes } = useRoleOrganisationTypes();
52
+ const { getMany: getManyRoleOrganisations, fetching: fetchingRoleOrganisations, entities: roleOrganisations } = useRoleOrganisations();
53
+
54
+ const roles = computed(() => {
55
+ return roleOrganisationTypes.value.map(rot => ({
56
+ id: rot.id,
57
+ icon: rot.icon,
58
+ label: rot.label,
59
+ type: RoleType.OrganisationType
60
+ })).concat(roleOrganisations.value.map(ro => ({
61
+ id: ro.id,
62
+ icon: ro.icon,
63
+ label: ro.label,
64
+ type: RoleType.Organisation
65
+ })));
66
+ });
67
+
68
+ const innerUpdate = (value: Role[] | Role | null) => {
69
+ if (Array.isArray(value)) {
70
+ emit("update:modelValue", value.map(v => v.id));
71
+ emit("update:type", value.map(v => v.type));
72
+ }
73
+ else {
74
+ emit("update:modelValue", value?.id);
75
+ emit("update:type", value?.type);
76
+ }
77
+ };
78
+
79
+ const innerFetch = (search: string | null) => {
80
+ return Promise.all([
81
+ getManyRoleOrganisationTypes({ ...props.roleOrganisationTypeFilters, search: search ?? undefined }),
82
+ getManyRoleOrganisations({ ...props.roleOrganisationFilters, search: search ?? undefined })
83
+ ]);
84
+ };
85
+
86
+ const { toggleSet, search, init, onUpdate } = useAutocomplete(
87
+ roles,
88
+ [() => props.roleOrganisationTypeFilters, () => props.roleOrganisationFilters],
89
+ emit,
90
+ innerFetch,
91
+ innerUpdate
92
+ );
93
+
94
+ const loading = computed((): boolean => {
95
+ return init.value && (fetchingRoleOrganisationTypes.value || fetchingRoleOrganisations.value);
96
+ });
97
+
98
+ return {
99
+ toggleSet,
100
+ loading,
101
+ search,
102
+ roles,
103
+ onUpdate
104
+ };
105
+ }
106
+ });
107
+
108
+ interface Role {
109
+ id: string;
110
+ icon: string;
111
+ label: string;
112
+ type: RoleType;
113
+ }
114
+ </script>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dative-gpi/foundation-core-components",
3
3
  "sideEffects": false,
4
- "version": "0.0.83",
4
+ "version": "0.0.84",
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": "0.0.83",
14
- "@dative-gpi/foundation-core-services": "0.0.83",
15
- "@dative-gpi/foundation-shared-components": "0.0.83",
16
- "@dative-gpi/foundation-shared-domain": "0.0.83",
17
- "@dative-gpi/foundation-shared-services": "0.0.83",
13
+ "@dative-gpi/foundation-core-domain": "0.0.84",
14
+ "@dative-gpi/foundation-core-services": "0.0.84",
15
+ "@dative-gpi/foundation-shared-components": "0.0.84",
16
+ "@dative-gpi/foundation-shared-domain": "0.0.84",
17
+ "@dative-gpi/foundation-shared-services": "0.0.84",
18
18
  "color": "^4.2.3",
19
19
  "vue": "^3.4.23",
20
20
  "vuedraggable": "^4.1.0"
@@ -24,5 +24,5 @@
24
24
  "sass": "^1.69.5",
25
25
  "sass-loader": "^13.3.2"
26
26
  },
27
- "gitHead": "97d34af7b3481be94f7fd50ca7a0a209f9eac517"
27
+ "gitHead": "3e92b90afe656cd7aaa98a0a73c014de059a4296"
28
28
  }