sprintify-ui 0.6.30 → 0.6.32

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.
@@ -9,6 +9,10 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
9
9
  required: true;
10
10
  type: StringConstructor;
11
11
  };
12
+ showRouteUrl: {
13
+ default: undefined;
14
+ type: PropType<((ids: (string | number)[]) => string) | undefined>;
15
+ };
12
16
  primaryKey: {
13
17
  default: string;
14
18
  type: StringConstructor;
@@ -62,6 +66,10 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
62
66
  required: true;
63
67
  type: StringConstructor;
64
68
  };
69
+ showRouteUrl: {
70
+ default: undefined;
71
+ type: PropType<((ids: (string | number)[]) => string) | undefined>;
72
+ };
65
73
  primaryKey: {
66
74
  default: string;
67
75
  type: StringConstructor;
@@ -109,6 +117,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
109
117
  max: number;
110
118
  queryKey: string;
111
119
  primaryKey: string;
120
+ showRouteUrl: ((ids: (string | number)[]) => string) | undefined;
112
121
  currentModels: Option[];
113
122
  }, {}>, {
114
123
  items?(_: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sprintify-ui",
3
- "version": "0.6.30",
3
+ "version": "0.6.32",
4
4
  "scripts": {
5
5
  "build": "rimraf dist && vue-tsc && vite build",
6
6
  "build-fast": "rimraf dist && vite build",
@@ -2,6 +2,7 @@ import BaseHasMany from './BaseHasMany.vue';
2
2
  import ShowValue from '@/../.storybook/components/ShowValue.vue';
3
3
  import { createFieldStory, options } from '../../.storybook/utils';
4
4
  import BaseAppNotifications from './BaseAppNotifications.vue';
5
+ import QueryString from 'qs';
5
6
 
6
7
  export default {
7
8
  title: 'Form/BaseHasMany',
@@ -19,7 +20,9 @@ const Template = (args) => {
19
20
  return {
20
21
  components: { BaseHasMany, ShowValue, BaseAppNotifications },
21
22
  setup() {
22
- const value = ref([]);
23
+ const value = ref([
24
+ "9acd34f6-ecf3-43e3-b84e-d8fcf5382bf4"
25
+ ]);
23
26
  return { args, value };
24
27
  },
25
28
  template: `
@@ -60,6 +63,15 @@ Maximum.args = {
60
63
  max: 3,
61
64
  };
62
65
 
66
+ export const ShowRouteUrl = Template.bind({});
67
+ ShowRouteUrl.args = {
68
+ max: 3,
69
+ showRouteUrl: (ids) => {
70
+ const params = QueryString.stringify({ filter: { id: ids } });
71
+ return `https://effettandem.com/api/content/articles?${params}`;
72
+ },
73
+ };
74
+
63
75
  export const SlotOption = (args) => {
64
76
  return {
65
77
  components: { BaseHasMany },
@@ -46,8 +46,10 @@
46
46
  <script lang="ts" setup>
47
47
  import { isEqual } from 'lodash';
48
48
  import { Option } from '@/types';
49
- import BaseTagAutocompleteFetch from './BaseTagAutocompleteFetch.vue';
49
+ import { config } from '@/index';
50
50
  import { PropType } from 'vue';
51
+ import BaseTagAutocompleteFetch from './BaseTagAutocompleteFetch.vue';
52
+ import { AxiosResponse } from 'axios';
51
53
 
52
54
  const props = defineProps({
53
55
  modelValue: {
@@ -58,6 +60,10 @@ const props = defineProps({
58
60
  required: true,
59
61
  type: String,
60
62
  },
63
+ showRouteUrl: {
64
+ default: undefined,
65
+ type: Function as PropType<((ids: (string | number)[]) => string) | undefined>,
66
+ },
61
67
  primaryKey: {
62
68
  default: 'id',
63
69
  type: String,
@@ -98,6 +104,8 @@ const props = defineProps({
98
104
  },
99
105
  });
100
106
 
107
+ const http = config.http;
108
+
101
109
  const emit = defineEmits(['update:modelValue']);
102
110
 
103
111
  const tagAutocompleteFetch = ref<InstanceType<
@@ -118,6 +126,36 @@ watch(
118
126
  { deep: true }
119
127
  );
120
128
 
129
+ watch(
130
+ () => props.modelValue,
131
+ (newValue, oldValue) => {
132
+ if (!props.modelValue) {
133
+ models.value = [];
134
+ return;
135
+ }
136
+
137
+ if (newValue == oldValue) {
138
+ return;
139
+ }
140
+
141
+ if (props.showRouteUrl == null) {
142
+ return;
143
+ }
144
+
145
+ const ids = props.modelValue.map((id) => id.toString());
146
+
147
+ http
148
+ .get(props.showRouteUrl(ids))
149
+ .then((response: AxiosResponse) => {
150
+ models.value = response.data.data.filter((i: any) => {
151
+ return ids.includes(i[props.primaryKey]);
152
+ });
153
+ })
154
+ .catch((e: Error) => e);
155
+ },
156
+ { immediate: true }
157
+ );
158
+
121
159
  function onUpdate(newModels: Option[]) {
122
160
  models.value = newModels;
123
161
  emit(
package/src/index.ts CHANGED
@@ -40,14 +40,14 @@ const config = {
40
40
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
41
41
  formatQueryString(params: Record<string, any>) {
42
42
  return QueryString.stringify(params, {
43
- arrayFormat: 'comma',
44
- encode: import.meta.env.PROD ? true : false,
43
+ //arrayFormat: 'comma',
44
+ //encode: import.meta.env.PROD ? true : false,
45
45
  });
46
46
  },
47
47
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
48
48
  parseQueryString(params: string): Record<string, any> {
49
49
  return QueryString.parse(params, {
50
- comma: true,
50
+ //comma: true,
51
51
  });
52
52
  },
53
53
  countries: [] as Country[],