sprintify-ui 0.6.68 → 0.6.70

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.
@@ -42,8 +42,8 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
42
42
  type: StringConstructor;
43
43
  };
44
44
  currentModels: {
45
- default(): never[];
46
- type: PropType<Option[]>;
45
+ default(): undefined;
46
+ type: PropType<Option[] | undefined>;
47
47
  };
48
48
  hasError: {
49
49
  default: boolean;
@@ -99,8 +99,8 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
99
99
  type: StringConstructor;
100
100
  };
101
101
  currentModels: {
102
- default(): never[];
103
- type: PropType<Option[]>;
102
+ default(): undefined;
103
+ type: PropType<Option[] | undefined>;
104
104
  };
105
105
  hasError: {
106
106
  default: boolean;
@@ -118,7 +118,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
118
118
  queryKey: string;
119
119
  primaryKey: string;
120
120
  showRouteUrl: ((ids: (string | number)[]) => string) | undefined;
121
- currentModels: Option[];
121
+ currentModels: Option[] | undefined;
122
122
  }, {}>, {
123
123
  items?(_: {
124
124
  items: import("@/types").NormalizedOption[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sprintify-ui",
3
- "version": "0.6.68",
3
+ "version": "0.6.70",
4
4
  "scripts": {
5
5
  "build": "rimraf dist && vue-tsc && vite build",
6
6
  "build-fast": "rimraf dist && vite build",
@@ -19,6 +19,10 @@ export default {
19
19
  url: 'https://effettandem.com/api/content/articles',
20
20
  field: 'title',
21
21
  primaryKey: 'id',
22
+ showRouteUrl: (ids) => {
23
+ const params = QueryString.stringify({ filter: { id: ids } });
24
+ return `https://effettandem.com/api/content/articles?${params}`;
25
+ }
22
26
  },
23
27
  decorators: [() => ({ template: '<div class="mb-36"><story/></div>' })],
24
28
  };
@@ -28,7 +32,8 @@ const Template = (args) => {
28
32
  components: { BaseHasMany, ShowValue, BaseAppNotifications },
29
33
  setup() {
30
34
  const value = ref([
31
- "9acd34f6-ecf3-43e3-b84e-d8fcf5382bf4"
35
+ "9acd34f6-ecf3-43e3-b84e-d8fcf5382bf4",
36
+ "994ecd49-0796-402d-ab1a-63d4e5c2a68a",
32
37
  ]);
33
38
  return { args, value };
34
39
  },
@@ -48,10 +53,10 @@ Demo.args = {};
48
53
 
49
54
  export const Disabled = (args) => {
50
55
  return {
51
- components: { BaseHasMany },
56
+ components: { BaseHasMany, ShowValue },
52
57
  setup() {
53
- const value = ref([]);
54
- const currentModel = options[0];
58
+ const currentModel = options[1];
59
+ const value = ref([currentModel.value]);
55
60
  return { args, value, currentModel };
56
61
  },
57
62
  template: `<BaseHasMany
@@ -61,7 +66,8 @@ export const Disabled = (args) => {
61
66
  :disabled="true"
62
67
  primaryKey="value"
63
68
  field="label"
64
- ></BaseHasMany>`,
69
+ ></BaseHasMany>
70
+ <ShowValue :value="value" />`,
65
71
  };
66
72
  };
67
73
 
@@ -94,9 +94,9 @@ const props = defineProps({
94
94
  },
95
95
  currentModels: {
96
96
  default() {
97
- return [];
97
+ return undefined;
98
98
  },
99
- type: Array as PropType<Option[]>,
99
+ type: Array as PropType<Option[] | undefined>,
100
100
  },
101
101
  hasError: {
102
102
  default: false,
@@ -112,7 +112,7 @@ const tagAutocompleteFetch = ref<InstanceType<
112
112
  typeof BaseTagAutocompleteFetch
113
113
  > | null>(null);
114
114
 
115
- const models = ref(props.currentModels);
115
+ const models = ref(props.currentModels ?? []);
116
116
 
117
117
  watch(
118
118
  () => props.currentModels,
@@ -121,7 +121,7 @@ watch(
121
121
  return;
122
122
  }
123
123
 
124
- models.value = newValue;
124
+ models.value = newValue ?? [];
125
125
  },
126
126
  { deep: true }
127
127
  );
@@ -129,6 +129,15 @@ watch(
129
129
  watch(
130
130
  () => props.modelValue,
131
131
  (newValue, oldValue) => {
132
+
133
+ if (props.currentModels !== undefined) {
134
+ return;
135
+ }
136
+
137
+ if (props.showRouteUrl == null) {
138
+ return;
139
+ }
140
+
132
141
  if (!props.modelValue) {
133
142
  models.value = [];
134
143
  return;
@@ -138,12 +147,16 @@ watch(
138
147
  return;
139
148
  }
140
149
 
141
- if (props.showRouteUrl == null) {
150
+ // Do not fetch if the modelValue is the same as the local models
151
+
152
+ const ids = props.modelValue.map((id: number | string) => id.toString());
153
+
154
+ const localModelIds = models.value.map((m) => m[props.primaryKey]);
155
+
156
+ if (isEqual(ids, localModelIds)) {
142
157
  return;
143
158
  }
144
159
 
145
- const ids = props.modelValue.map((id) => id.toString());
146
-
147
160
  http
148
161
  .get(props.showRouteUrl(ids))
149
162
  .then((response: AxiosResponse) => {