lkt-item-crud 2.0.34 → 2.0.36
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 +742 -644
- package/dist/components/ButtonNav.vue.d.ts +2 -1
- package/dist/functions/modifications-functions.d.ts +1 -3
- package/dist/lib-components/LktItemCrud.vue.d.ts +21 -11
- package/package.json +1 -1
- package/src/components/ButtonNav.vue +29 -9
- package/src/lib-components/LktItemCrud.vue +85 -12
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ButtonConfig, ItemCrudButtonNavVisibility, ItemCrudMode, ItemCrudView, LktObject, ModificationView } from 'lkt-vue-kernel';
|
|
1
|
+
import { ButtonConfig, ItemCrudButtonNavVisibility, ItemCrudMode, ItemCrudSaveConfig, ItemCrudView, LktObject, ModificationView } from 'lkt-vue-kernel';
|
|
2
2
|
type __VLS_Props = {
|
|
3
3
|
item: LktObject;
|
|
4
4
|
modifications: LktObject;
|
|
@@ -33,6 +33,7 @@ type __VLS_Props = {
|
|
|
33
33
|
navStartButtonsEditing?: Array<ButtonConfig>;
|
|
34
34
|
navEndButtons?: Array<ButtonConfig>;
|
|
35
35
|
navEndButtonsEditing?: Array<ButtonConfig>;
|
|
36
|
+
updateConfig: ItemCrudSaveConfig;
|
|
36
37
|
};
|
|
37
38
|
declare var __VLS_13: {
|
|
38
39
|
canUpdate: boolean | undefined;
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
import { FormConfig
|
|
2
|
-
import { DataState } from 'lkt-data-state';
|
|
3
|
-
export declare const getModificationsDataState: (value: LktObject, modifications: LktObject, form: FormConfig) => DataState;
|
|
1
|
+
import { FormConfig } from 'lkt-vue-kernel';
|
|
4
2
|
export declare const detectFormFieldsKeys: (form: FormConfig) => string[];
|
|
@@ -21,7 +21,15 @@ declare var __VLS_17: {
|
|
|
21
21
|
canUpdate: boolean | undefined;
|
|
22
22
|
canDrop: boolean | undefined;
|
|
23
23
|
perms: string[] | undefined;
|
|
24
|
-
},
|
|
24
|
+
}, __VLS_55: {
|
|
25
|
+
canUpdate: boolean | undefined;
|
|
26
|
+
canDrop: boolean | undefined;
|
|
27
|
+
perms: string[] | undefined;
|
|
28
|
+
}, __VLS_57: {
|
|
29
|
+
canUpdate: boolean | undefined;
|
|
30
|
+
canDrop: boolean | undefined;
|
|
31
|
+
perms: string[] | undefined;
|
|
32
|
+
}, __VLS_74: string, __VLS_75: {}, __VLS_77: {
|
|
25
33
|
item: LktObject;
|
|
26
34
|
loading: false;
|
|
27
35
|
editMode: boolean;
|
|
@@ -30,9 +38,9 @@ declare var __VLS_17: {
|
|
|
30
38
|
canDrop: boolean;
|
|
31
39
|
itemBeingEdited: boolean;
|
|
32
40
|
perms: string[];
|
|
33
|
-
},
|
|
41
|
+
}, __VLS_98: {}, __VLS_100: {};
|
|
34
42
|
type __VLS_Slots = {} & {
|
|
35
|
-
[K in NonNullable<typeof
|
|
43
|
+
[K in NonNullable<typeof __VLS_74>]?: (props: typeof __VLS_75) => any;
|
|
36
44
|
} & {
|
|
37
45
|
'prev-buttons-ever'?: (props: typeof __VLS_17) => any;
|
|
38
46
|
} & {
|
|
@@ -46,11 +54,15 @@ type __VLS_Slots = {} & {
|
|
|
46
54
|
} & {
|
|
47
55
|
'prev-buttons'?: (props: typeof __VLS_42) => any;
|
|
48
56
|
} & {
|
|
49
|
-
|
|
57
|
+
'prev-buttons-ever'?: (props: typeof __VLS_55) => any;
|
|
50
58
|
} & {
|
|
51
|
-
'prev-buttons
|
|
59
|
+
'prev-buttons'?: (props: typeof __VLS_57) => any;
|
|
52
60
|
} & {
|
|
53
|
-
|
|
61
|
+
item?: (props: typeof __VLS_77) => any;
|
|
62
|
+
} & {
|
|
63
|
+
'prev-buttons-ever'?: (props: typeof __VLS_98) => any;
|
|
64
|
+
} & {
|
|
65
|
+
'prev-buttons'?: (props: typeof __VLS_100) => any;
|
|
54
66
|
};
|
|
55
67
|
declare const __VLS_component: import("vue").DefineComponent<ItemCrudConfig, {
|
|
56
68
|
doDrop: () => void;
|
|
@@ -94,13 +106,10 @@ declare const __VLS_component: import("vue").DefineComponent<ItemCrudConfig, {
|
|
|
94
106
|
header: import("lkt-vue-kernel").HeaderConfig;
|
|
95
107
|
title: string;
|
|
96
108
|
mode: ItemCrudMode;
|
|
109
|
+
modifications: LktObject;
|
|
97
110
|
modelValue: LktObject;
|
|
98
111
|
createButton: ButtonConfig | false;
|
|
99
|
-
events:
|
|
100
|
-
httpStart?: undefined | Function;
|
|
101
|
-
httpEnd?: (data: import("lkt-vue-kernel").ClickEventArgs) => void | undefined;
|
|
102
|
-
};
|
|
103
|
-
modifications: LktObject;
|
|
112
|
+
events: import("lkt-vue-kernel").ItemCrudEvents;
|
|
104
113
|
editing: boolean;
|
|
105
114
|
perms: import("lkt-vue-kernel").ValidTablePermission[];
|
|
106
115
|
customData: LktObject;
|
|
@@ -130,6 +139,7 @@ declare const __VLS_component: import("vue").DefineComponent<ItemCrudConfig, {
|
|
|
130
139
|
navStartButtonsEditing: Array<ButtonConfig>;
|
|
131
140
|
navEndButtons: Array<ButtonConfig>;
|
|
132
141
|
navEndButtonsEditing: Array<ButtonConfig>;
|
|
142
|
+
updateConfig: import("lkt-vue-kernel").ItemCrudSaveConfig;
|
|
133
143
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
134
144
|
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
135
145
|
export default _default;
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
ButtonConfig,
|
|
5
5
|
ButtonType,
|
|
6
6
|
ItemCrudButtonNavVisibility,
|
|
7
|
-
ItemCrudMode,
|
|
7
|
+
ItemCrudMode, ItemCrudSaveConfig,
|
|
8
8
|
ItemCrudView,
|
|
9
9
|
LktObject,
|
|
10
10
|
ModificationView,
|
|
@@ -61,6 +61,10 @@
|
|
|
61
61
|
navStartButtonsEditing?: Array<ButtonConfig>
|
|
62
62
|
navEndButtons?: Array<ButtonConfig>
|
|
63
63
|
navEndButtonsEditing?: Array<ButtonConfig>
|
|
64
|
+
|
|
65
|
+
updateConfig: ItemCrudSaveConfig
|
|
66
|
+
|
|
67
|
+
|
|
64
68
|
}>(), {
|
|
65
69
|
item: () => ({}),
|
|
66
70
|
modifications: () => ({}),
|
|
@@ -75,12 +79,18 @@
|
|
|
75
79
|
|
|
76
80
|
const slots: SetupContext['slots'] = useSlots();
|
|
77
81
|
|
|
82
|
+
const createButtonRef = ref(<HTMLButtonElement | null>null);
|
|
83
|
+
const createAndNewButtonRef = ref(<HTMLButtonElement | null>null);
|
|
78
84
|
const saveButtonRef = ref(<HTMLButtonElement | null>null);
|
|
79
85
|
const dropButtonRef = ref(<HTMLButtonElement | null>null);
|
|
80
86
|
|
|
81
87
|
const isLoading = ref(props.loading);
|
|
82
88
|
watch(() => props.loading, v => isLoading.value = v);
|
|
83
|
-
watch(isLoading, v =>
|
|
89
|
+
watch(isLoading, v => {
|
|
90
|
+
if (props.updateConfig.executionMode === 'blocking') {
|
|
91
|
+
emit('update:loading', v);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
84
94
|
|
|
85
95
|
const isEditing = ref(props.editing);
|
|
86
96
|
watch(() => props.editing, v => isEditing.value = v);
|
|
@@ -111,7 +121,17 @@
|
|
|
111
121
|
})
|
|
112
122
|
|
|
113
123
|
const doSave = () => {
|
|
114
|
-
if (
|
|
124
|
+
if (showSaveButton.value) {
|
|
125
|
+
switch (props.mode) {
|
|
126
|
+
case ItemCrudMode.Update:
|
|
127
|
+
if (saveButtonRef.value && typeof saveButtonRef.value.click === 'function') saveButtonRef.value.click();
|
|
128
|
+
break;
|
|
129
|
+
|
|
130
|
+
case ItemCrudMode.Create:
|
|
131
|
+
if (createButtonRef.value && typeof createButtonRef.value.click === 'function') createButtonRef.value.click();
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
115
135
|
},
|
|
116
136
|
doDrop = () => {
|
|
117
137
|
if (dropButtonRef.value && typeof dropButtonRef.value.click === 'function') dropButtonRef.value.click();
|
|
@@ -289,7 +309,7 @@
|
|
|
289
309
|
/>
|
|
290
310
|
|
|
291
311
|
<lkt-button
|
|
292
|
-
ref="
|
|
312
|
+
ref="createButtonRef"
|
|
293
313
|
v-show="mode === ItemCrudMode.Create && showSaveButton"
|
|
294
314
|
v-bind="{
|
|
295
315
|
...createButton,
|
|
@@ -305,7 +325,7 @@
|
|
|
305
325
|
/>
|
|
306
326
|
|
|
307
327
|
<lkt-button
|
|
308
|
-
ref="
|
|
328
|
+
ref="createAndNewButtonRef"
|
|
309
329
|
v-show="mode === ItemCrudMode.Create && showSaveButton && ableToCreateAndNew"
|
|
310
330
|
v-bind="{
|
|
311
331
|
...createAndNewButton,
|
|
@@ -401,7 +421,7 @@
|
|
|
401
421
|
/>
|
|
402
422
|
|
|
403
423
|
<lkt-button
|
|
404
|
-
ref="
|
|
424
|
+
ref="createButtonRef"
|
|
405
425
|
v-show="mode === ItemCrudMode.Create && showSaveButton"
|
|
406
426
|
v-bind="{
|
|
407
427
|
...createButton,
|
|
@@ -418,7 +438,7 @@
|
|
|
418
438
|
/>
|
|
419
439
|
|
|
420
440
|
<lkt-button
|
|
421
|
-
ref="
|
|
441
|
+
ref="createAndNewButtonRef"
|
|
422
442
|
v-show="mode === ItemCrudMode.Create && showSaveButton && ableToCreateAndNew"
|
|
423
443
|
v-bind="{
|
|
424
444
|
...createAndNewButton,
|
|
@@ -494,7 +514,7 @@
|
|
|
494
514
|
/>
|
|
495
515
|
|
|
496
516
|
<lkt-button
|
|
497
|
-
ref="
|
|
517
|
+
ref="createButtonRef"
|
|
498
518
|
v-show="mode === ItemCrudMode.Create && showSaveButton"
|
|
499
519
|
v-bind="{
|
|
500
520
|
...createButton,
|
|
@@ -510,7 +530,7 @@
|
|
|
510
530
|
/>
|
|
511
531
|
|
|
512
532
|
<lkt-button
|
|
513
|
-
ref="
|
|
533
|
+
ref="createAndNewButtonRef"
|
|
514
534
|
v-show="mode === ItemCrudMode.Create && showSaveButton && ableToCreateAndNew"
|
|
515
535
|
v-bind="{
|
|
516
536
|
...createAndNewButton,
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { debug } from '../functions/debug';
|
|
6
6
|
import {
|
|
7
7
|
ButtonConfig,
|
|
8
|
-
ensureButtonConfig, FormUiConfig,
|
|
8
|
+
ensureButtonConfig, extractI18nValue, FormUiConfig,
|
|
9
9
|
getDefaultValues,
|
|
10
10
|
getFormDataState, getFormSlotKeys,
|
|
11
11
|
ItemCrud,
|
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
ToastPositionX,
|
|
24
24
|
} from 'lkt-vue-kernel';
|
|
25
25
|
import { closeModal, updateModalKey } from 'lkt-modal';
|
|
26
|
-
import { __ } from 'lkt-i18n';
|
|
27
26
|
import ButtonNav from '../components/ButtonNav.vue';
|
|
28
27
|
import { openToast } from 'lkt-toast';
|
|
29
28
|
import { useRouter } from 'vue-router';
|
|
@@ -228,6 +227,7 @@
|
|
|
228
227
|
dataState.value.increment(v);
|
|
229
228
|
if (computedEditableView.value === ModificationView.Current) {
|
|
230
229
|
dataChanged.value = dataState.value.changed();
|
|
230
|
+
debug('item updated -> dataState changed');
|
|
231
231
|
}
|
|
232
232
|
itemBeingEdited.value = true;
|
|
233
233
|
}, { deep: true });
|
|
@@ -444,12 +444,7 @@
|
|
|
444
444
|
}
|
|
445
445
|
};
|
|
446
446
|
|
|
447
|
-
const computedTitle = computed(() =>
|
|
448
|
-
if (props.title.startsWith('__:')) {
|
|
449
|
-
return String(__(props.title.substring(3)));
|
|
450
|
-
}
|
|
451
|
-
return props.title;
|
|
452
|
-
}),
|
|
447
|
+
const computedTitle = computed(() => extractI18nValue(props.title)),
|
|
453
448
|
displayHeader = computed(() => {
|
|
454
449
|
if (isLoading.value) return false;
|
|
455
450
|
|
|
@@ -469,8 +464,16 @@
|
|
|
469
464
|
}),
|
|
470
465
|
ableToUpdate = computed(() => {
|
|
471
466
|
if (props.mode !== ItemCrudMode.Update || !canUpdate.value) return false;
|
|
472
|
-
if (
|
|
473
|
-
|
|
467
|
+
if (computedHasForm.value) {
|
|
468
|
+
if (!validForm.value) return false;
|
|
469
|
+
}
|
|
470
|
+
if (!props.enabledSaveWithoutChanges) {
|
|
471
|
+
if (computedHasForm.value) {
|
|
472
|
+
if (!changedForm.value) return false;
|
|
473
|
+
} else if (!dataChanged.value) {
|
|
474
|
+
return false;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
474
477
|
|
|
475
478
|
if (typeof safeUpdateButton.value?.disabled === 'function') return !safeUpdateButton.value.disabled({
|
|
476
479
|
prop: item.value
|
|
@@ -481,8 +484,18 @@
|
|
|
481
484
|
}),
|
|
482
485
|
ableToCreate = computed(() => {
|
|
483
486
|
if (props.mode !== ItemCrudMode.Create || !canCreate.value) return false;
|
|
484
|
-
if (
|
|
485
|
-
|
|
487
|
+
if (computedHasForm.value) {
|
|
488
|
+
if (!validForm.value) return false;
|
|
489
|
+
}
|
|
490
|
+
if (!props.enabledSaveWithoutChanges) {
|
|
491
|
+
if (computedHasForm.value) {
|
|
492
|
+
if (!changedForm.value) return false;
|
|
493
|
+
} else if (!dataChanged.value) {
|
|
494
|
+
return false;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
// if (!props.enabledSaveWithoutChanges && !computedHasForm.value && !dataChanged.value) return false;
|
|
498
|
+
// if (computedHasForm.value && (!validForm.value || (!props.enabledSaveWithoutChanges && !changedForm.value))) return false;
|
|
486
499
|
|
|
487
500
|
if (typeof safeCreateButton.value?.disabled === 'function') return !safeCreateButton.value.disabled({
|
|
488
501
|
prop: item.value
|
|
@@ -604,6 +617,7 @@
|
|
|
604
617
|
:nav-start-buttons-editing="navStartButtonsEditing"
|
|
605
618
|
:nav-end-buttons="navEndButtons"
|
|
606
619
|
:nav-end-buttons-editing="navEndButtonsEditing"
|
|
620
|
+
:update-config="updateConfig"
|
|
607
621
|
@create="onCreate"
|
|
608
622
|
@save="onUpdate"
|
|
609
623
|
@drop="onDrop"
|
|
@@ -672,6 +686,7 @@
|
|
|
672
686
|
:nav-start-buttons-editing="navStartButtonsEditing"
|
|
673
687
|
:nav-end-buttons="navEndButtons"
|
|
674
688
|
:nav-end-buttons-editing="navEndButtonsEditing"
|
|
689
|
+
:update-config="updateConfig"
|
|
675
690
|
@create="onCreate"
|
|
676
691
|
@save="onUpdate"
|
|
677
692
|
@drop="onDrop"
|
|
@@ -691,6 +706,63 @@
|
|
|
691
706
|
/>
|
|
692
707
|
</template>
|
|
693
708
|
</button-nav>
|
|
709
|
+
<template v-else-if="computedHasButtons && buttonNavPosition === ItemCrudButtonNavPosition.Hidden">
|
|
710
|
+
<button-nav
|
|
711
|
+
ref="buttonNav"
|
|
712
|
+
v-show="false"
|
|
713
|
+
v-model:loading="isLoading"
|
|
714
|
+
v-model:editing="editMode"
|
|
715
|
+
v-model:picked-modification-view="pickedModificationView"
|
|
716
|
+
:item="item"
|
|
717
|
+
:modifications="itemModifications"
|
|
718
|
+
:mode="mode"
|
|
719
|
+
:view="view"
|
|
720
|
+
:button-nav-visibility="buttonNavVisibility"
|
|
721
|
+
:create-button="safeCreateButton"
|
|
722
|
+
:create-and-new-button="safeCreateAndNewButton"
|
|
723
|
+
:update-button="safeUpdateButton"
|
|
724
|
+
:drop-button="safeDropButton"
|
|
725
|
+
:edit-mode-button="safeEditModeButton"
|
|
726
|
+
:group-button="safeGroupButton"
|
|
727
|
+
:data-changed="dataChanged"
|
|
728
|
+
:http-success-read="httpSuccessRead"
|
|
729
|
+
:can-create="canCreate"
|
|
730
|
+
:can-update="canUpdate"
|
|
731
|
+
:can-drop="canDrop"
|
|
732
|
+
:can-switch-edit-mode="canSwitchEditMode"
|
|
733
|
+
:group-button-as-modal-actions="groupButtonAsModalActions"
|
|
734
|
+
:able-to-create="ableToCreate"
|
|
735
|
+
:able-to-create-and-new="ableToCreateAndNew"
|
|
736
|
+
:able-to-update="ableToUpdate"
|
|
737
|
+
:able-to-drop="ableToDrop"
|
|
738
|
+
:perms="permissions"
|
|
739
|
+
:modification-view="computedModificationViews"
|
|
740
|
+
:editable-view="computedEditableView"
|
|
741
|
+
:nav-start-buttons="navStartButtons"
|
|
742
|
+
:nav-start-buttons-editing="navStartButtonsEditing"
|
|
743
|
+
:nav-end-buttons="navEndButtons"
|
|
744
|
+
:nav-end-buttons-editing="navEndButtonsEditing"
|
|
745
|
+
:update-config="updateConfig"
|
|
746
|
+
@create="onCreate"
|
|
747
|
+
@save="onUpdate"
|
|
748
|
+
@drop="onDrop"
|
|
749
|
+
>
|
|
750
|
+
<template #prev-buttons-ever="{canUpdate, canDrop, perms}" v-if="slots['prev-buttons-ever']">
|
|
751
|
+
<slot name="prev-buttons-ever"
|
|
752
|
+
:can-update="canUpdate"
|
|
753
|
+
:can-drop="canDrop"
|
|
754
|
+
:perms="perms"
|
|
755
|
+
/>
|
|
756
|
+
</template>
|
|
757
|
+
<template #prev-buttons="{canUpdate, canDrop, perms}" v-if="slots['prev-buttons']">
|
|
758
|
+
<slot name="prev-buttons"
|
|
759
|
+
:can-update="canUpdate"
|
|
760
|
+
:can-drop="canDrop"
|
|
761
|
+
:perms="perms"
|
|
762
|
+
/>
|
|
763
|
+
</template>
|
|
764
|
+
</button-nav>
|
|
765
|
+
</template>
|
|
694
766
|
|
|
695
767
|
<div class="lkt-item-crud_content" v-if="!isLoading">
|
|
696
768
|
<div v-if="httpSuccessRead" class="lkt-grid-1">
|
|
@@ -778,6 +850,7 @@
|
|
|
778
850
|
:nav-start-buttons-editing="navStartButtonsEditing"
|
|
779
851
|
:nav-end-buttons="navEndButtons"
|
|
780
852
|
:nav-end-buttons-editing="navEndButtonsEditing"
|
|
853
|
+
:update-config="updateConfig"
|
|
781
854
|
@create="onCreate"
|
|
782
855
|
@save="onUpdate"
|
|
783
856
|
@drop="onDrop"
|