lkt-item-crud 2.0.16 → 2.0.17
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/build.d.ts +6 -6
- package/dist/build.js +432 -422
- package/dist/lib-components/LktItemCrud.vue.d.ts +2 -0
- package/package.json +1 -1
- package/src/lib-components/LktItemCrud.vue +17 -3
|
@@ -101,6 +101,8 @@ declare const __VLS_component: import("vue").DefineComponent<ItemCrudConfig, {
|
|
|
101
101
|
beforeEmitUpdate: Function;
|
|
102
102
|
notificationType: NotificationType;
|
|
103
103
|
enabledSaveWithoutChanges: boolean;
|
|
104
|
+
redirectOnCreate: string | ((id: number | string) => string);
|
|
105
|
+
redirectOnDrop: string | (() => string);
|
|
104
106
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
105
107
|
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
106
108
|
export default _default;
|
package/package.json
CHANGED
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
import { __ } from 'lkt-i18n';
|
|
24
24
|
import ButtonNav from '../components/ButtonNav.vue';
|
|
25
25
|
import { openToast } from 'lkt-toast';
|
|
26
|
+
import { useRouter } from 'vue-router';
|
|
26
27
|
|
|
27
28
|
// defineOptions({
|
|
28
29
|
// inheritAttrs: false
|
|
@@ -30,6 +31,8 @@
|
|
|
30
31
|
|
|
31
32
|
const props = withDefaults(defineProps<ItemCrudConfig>(), getDefaultValues(ItemCrud));
|
|
32
33
|
|
|
34
|
+
const router = useRouter();
|
|
35
|
+
|
|
33
36
|
const slots: SetupContext['slots'] = useSlots();
|
|
34
37
|
|
|
35
38
|
const emit = defineEmits([
|
|
@@ -199,11 +202,16 @@
|
|
|
199
202
|
}
|
|
200
203
|
return true;
|
|
201
204
|
},
|
|
202
|
-
doAutoReloadId = (r?: HTTPResponse) => {
|
|
205
|
+
doAutoReloadId = (r?: HTTPResponse, redirect?: string|Function) => {
|
|
203
206
|
debug('doAutoReloadId -> enter: ', r);
|
|
204
207
|
if (typeof r !== 'undefined' && r.autoReloadId) {
|
|
205
208
|
debug('doAutoReloadId -> autoReloadId detected: ', r.autoReloadId);
|
|
206
|
-
if (
|
|
209
|
+
if (typeof redirect !== 'undefined') {
|
|
210
|
+
let route = redirect;
|
|
211
|
+
if (typeof redirect === 'function') route = redirect(r.autoReloadId);
|
|
212
|
+
router.push(route);
|
|
213
|
+
}
|
|
214
|
+
else if (!computedInsideModal.value) {
|
|
207
215
|
debug('doAutoReloadId -> outsideModal');
|
|
208
216
|
props.readData['id'] = r.autoReloadId;
|
|
209
217
|
debug('doAutoReloadId -> turning off create mode');
|
|
@@ -239,7 +247,7 @@
|
|
|
239
247
|
positionX: ToastPositionX.Right,
|
|
240
248
|
});
|
|
241
249
|
}
|
|
242
|
-
doAutoReloadId(r);
|
|
250
|
+
doAutoReloadId(r, props.redirectOnCreate);
|
|
243
251
|
debug('onCreate -> beforeEmitCreate');
|
|
244
252
|
emit('create', r);
|
|
245
253
|
},
|
|
@@ -296,6 +304,12 @@
|
|
|
296
304
|
//@ts-ignore
|
|
297
305
|
closeModal(props.modalConfig.modalName, props.modalConfig.modalKey);
|
|
298
306
|
}
|
|
307
|
+
|
|
308
|
+
if (typeof props.redirectOnDrop !== 'undefined') {
|
|
309
|
+
let route = props.redirectOnDrop;
|
|
310
|
+
if (typeof props.redirectOnDrop === 'function') route = props.redirectOnDrop();
|
|
311
|
+
router.push(route);
|
|
312
|
+
}
|
|
299
313
|
},
|
|
300
314
|
doSave = () => {
|
|
301
315
|
// @ts-ignore
|