sprintify-ui 0.6.70 → 0.6.72
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.
- package/dist/sprintify-ui.es.js +1888 -1888
- package/package.json +1 -1
- package/src/components/BaseHasMany.vue +41 -32
package/package.json
CHANGED
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
</template>
|
|
45
45
|
|
|
46
46
|
<script lang="ts" setup>
|
|
47
|
-
import { isEqual } from 'lodash';
|
|
47
|
+
import { debounce, isEqual } from 'lodash';
|
|
48
48
|
import { Option } from '@/types';
|
|
49
49
|
import { config } from '@/index';
|
|
50
50
|
import { PropType } from 'vue';
|
|
@@ -128,46 +128,55 @@ watch(
|
|
|
128
128
|
|
|
129
129
|
watch(
|
|
130
130
|
() => props.modelValue,
|
|
131
|
-
(
|
|
131
|
+
debounce(() => fetchModels(), 300),
|
|
132
|
+
{ immediate: true }
|
|
133
|
+
);
|
|
132
134
|
|
|
133
|
-
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
135
|
+
function fetchModels() {
|
|
136
136
|
|
|
137
|
-
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
137
|
+
console.log('check if currentModels is undefined');
|
|
140
138
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}
|
|
139
|
+
if (props.currentModels !== undefined) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
145
142
|
|
|
146
|
-
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
143
|
+
console.log('check if showRouteUrl is empty');
|
|
149
144
|
|
|
150
|
-
|
|
145
|
+
if (props.showRouteUrl == null) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
151
148
|
|
|
152
|
-
|
|
149
|
+
console.log('check if modelValue is empty');
|
|
153
150
|
|
|
154
|
-
|
|
151
|
+
if (!props.modelValue) {
|
|
152
|
+
models.value = [];
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
155
|
|
|
156
|
-
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
156
|
+
console.log('check models');
|
|
159
157
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
158
|
+
|
|
159
|
+
// Do not fetch if the modelValue is the same as the local models
|
|
160
|
+
|
|
161
|
+
const ids = props.modelValue.map((id: number | string) => id.toString());
|
|
162
|
+
|
|
163
|
+
const localModelIds = models.value.map((m) => m[props.primaryKey]);
|
|
164
|
+
|
|
165
|
+
if (isEqual(ids, localModelIds)) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
console.log('fetch models');
|
|
170
|
+
|
|
171
|
+
http
|
|
172
|
+
.get(props.showRouteUrl(ids))
|
|
173
|
+
.then((response: AxiosResponse) => {
|
|
174
|
+
models.value = response.data.data.filter((i: any) => {
|
|
175
|
+
return ids.includes(i[props.primaryKey]);
|
|
176
|
+
});
|
|
177
|
+
})
|
|
178
|
+
.catch((e: Error) => e);
|
|
179
|
+
}
|
|
171
180
|
|
|
172
181
|
function onUpdate(newModels: Option[]) {
|
|
173
182
|
models.value = newModels;
|