lkt-item-crud 2.0.20 → 2.0.22
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 +423 -439
- package/dist/lib-components/LktItemCrud.vue.d.ts +2 -1
- package/package.json +1 -1
- package/src/lib-components/LktItemCrud.vue +27 -9
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ButtonConfig, ItemCrudButtonNavPosition, ItemCrudConfig, ItemCrudMode, ItemCrudView, LktObject, ModalConfig, ModificationView, NotificationType } from 'lkt-vue-kernel';
|
|
1
|
+
import { ButtonConfig, FormUiConfig, ItemCrudButtonNavPosition, ItemCrudConfig, ItemCrudMode, ItemCrudView, LktObject, ModalConfig, ModificationView, NotificationType } from 'lkt-vue-kernel';
|
|
2
2
|
declare var __VLS_17: {
|
|
3
3
|
canUpdate: boolean | undefined;
|
|
4
4
|
canDrop: boolean | undefined;
|
|
@@ -100,6 +100,7 @@ declare const __VLS_component: import("vue").DefineComponent<ItemCrudConfig, {
|
|
|
100
100
|
editing: boolean;
|
|
101
101
|
perms: import("lkt-vue-kernel").ValidTablePermission[];
|
|
102
102
|
customData: LktObject;
|
|
103
|
+
formUiConfig: Partial<FormUiConfig>;
|
|
103
104
|
visibleView: ModificationView;
|
|
104
105
|
modificationViews: boolean | Array<ModificationView>;
|
|
105
106
|
editModeButton: ButtonConfig | false;
|
package/package.json
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
ButtonConfig,
|
|
8
8
|
ensureButtonConfig, FormUiConfig,
|
|
9
9
|
getDefaultValues,
|
|
10
|
+
getFormDataState,
|
|
10
11
|
ItemCrud,
|
|
11
12
|
ItemCrudButtonNavPosition,
|
|
12
13
|
ItemCrudConfig,
|
|
@@ -26,7 +27,6 @@
|
|
|
26
27
|
import ButtonNav from '../components/ButtonNav.vue';
|
|
27
28
|
import { openToast } from 'lkt-toast';
|
|
28
29
|
import { useRouter } from 'vue-router';
|
|
29
|
-
import { getModificationsDataState } from '../functions/modifications-functions';
|
|
30
30
|
|
|
31
31
|
// defineOptions({
|
|
32
32
|
// inheritAttrs: false
|
|
@@ -62,6 +62,7 @@
|
|
|
62
62
|
permissions = ref(props.perms),
|
|
63
63
|
editMode = ref(props.editing),
|
|
64
64
|
validForm = ref(false),
|
|
65
|
+
changedForm = ref(false),
|
|
65
66
|
httpSuccessRead = ref(false),
|
|
66
67
|
showStoreMessage = ref(false),
|
|
67
68
|
httpStatus = ref(200),
|
|
@@ -164,7 +165,7 @@
|
|
|
164
165
|
}
|
|
165
166
|
httpSuccessRead.value = true;
|
|
166
167
|
item.value = r.data;
|
|
167
|
-
itemModifications.value = r.modifications;
|
|
168
|
+
itemModifications.value = Array.isArray(r.modifications) ? {} : r.modifications;
|
|
168
169
|
permissions.value = r.perms;
|
|
169
170
|
dataState.value.increment(item.value).turnStoredIntoOriginal();
|
|
170
171
|
modificationsDataState.value.increment(itemModifications.value).turnStoredIntoOriginal();
|
|
@@ -191,6 +192,10 @@
|
|
|
191
192
|
}
|
|
192
193
|
};
|
|
193
194
|
|
|
195
|
+
watch(itemBeingEdited, (v) => {
|
|
196
|
+
if (v) nextTick(() => itemBeingEdited.value = false);
|
|
197
|
+
})
|
|
198
|
+
|
|
194
199
|
|
|
195
200
|
watch(() => props.modelValue, v => {
|
|
196
201
|
item.value = v;
|
|
@@ -198,7 +203,6 @@
|
|
|
198
203
|
}, { deep: true });
|
|
199
204
|
|
|
200
205
|
watch(item, (v) => {
|
|
201
|
-
itemBeingEdited.value = true;
|
|
202
206
|
debug('item updated ->', item.value);
|
|
203
207
|
if (typeof props.beforeEmitUpdate === 'function') {
|
|
204
208
|
debug('item updated -> has beforeEmitUpdate');
|
|
@@ -206,14 +210,16 @@
|
|
|
206
210
|
debug('item updated -> override with: ', override);
|
|
207
211
|
if (typeof override === 'object') item.value = override;
|
|
208
212
|
}
|
|
209
|
-
|
|
213
|
+
if (computedHasForm.value) {
|
|
214
|
+
resetFormDifferencesChecker();
|
|
215
|
+
}
|
|
210
216
|
emit('update:modelValue', item.value);
|
|
211
217
|
debug('item updated -> update dataState');
|
|
212
218
|
dataState.value.increment(v);
|
|
213
219
|
if (computedEditableView.value === ModificationView.Current) {
|
|
214
220
|
dataChanged.value = dataState.value.changed();
|
|
215
221
|
}
|
|
216
|
-
|
|
222
|
+
itemBeingEdited.value = true;
|
|
217
223
|
}, { deep: true });
|
|
218
224
|
|
|
219
225
|
watch(permissions, () => emit('perms', permissions.value));
|
|
@@ -238,7 +244,7 @@
|
|
|
238
244
|
const formDifferencesChecker = ref(undefined);
|
|
239
245
|
const resetFormDifferencesChecker = () => {
|
|
240
246
|
if (computedHasForm.value) {
|
|
241
|
-
formDifferencesChecker.value =
|
|
247
|
+
formDifferencesChecker.value = getFormDataState(item.value, itemModifications.value, props.form);
|
|
242
248
|
}
|
|
243
249
|
}
|
|
244
250
|
|
|
@@ -407,6 +413,12 @@
|
|
|
407
413
|
|
|
408
414
|
|
|
409
415
|
const closeConfirm = computed(() => {
|
|
416
|
+
if (!computedHasButtons.value) return '';
|
|
417
|
+
if (computedHasForm.value) return changedForm.value ? props.modalConfig?.closeConfirm : '';
|
|
418
|
+
|
|
419
|
+
if (computedEditableView.value === ModificationView.Modifications) {
|
|
420
|
+
return modificationsDataState.value.changed() ? props.modalConfig?.closeConfirm : '';
|
|
421
|
+
}
|
|
410
422
|
return dataState.value.changed() ? props.modalConfig?.closeConfirm : '';
|
|
411
423
|
});
|
|
412
424
|
|
|
@@ -504,6 +516,10 @@
|
|
|
504
516
|
if (Object.keys(itemModifications.value).length === 0) return ModificationView.Current;
|
|
505
517
|
return ModificationView.Modifications;
|
|
506
518
|
})
|
|
519
|
+
|
|
520
|
+
const computedHasButtons = computed(() => {
|
|
521
|
+
return createMode.value || canUpdate.value || canDrop.value;
|
|
522
|
+
})
|
|
507
523
|
</script>
|
|
508
524
|
|
|
509
525
|
<template>
|
|
@@ -512,7 +528,7 @@
|
|
|
512
528
|
v-bind="computedContainerAttrs"
|
|
513
529
|
class="lkt-item-crud"
|
|
514
530
|
>
|
|
515
|
-
<template v-if="groupButton !== false && groupButtonAsModalActions" #header-actions>
|
|
531
|
+
<template v-if="groupButton !== false && groupButtonAsModalActions && computedHasButtons" #header-actions>
|
|
516
532
|
<button-nav
|
|
517
533
|
ref="buttonNav"
|
|
518
534
|
v-if="buttonNavPosition === ItemCrudButtonNavPosition.Top"
|
|
@@ -576,7 +592,7 @@
|
|
|
576
592
|
|
|
577
593
|
<button-nav
|
|
578
594
|
ref="buttonNav"
|
|
579
|
-
v-if="buttonNavPosition === ItemCrudButtonNavPosition.Top && (groupButton === false || !groupButtonAsModalActions)"
|
|
595
|
+
v-if="buttonNavPosition === ItemCrudButtonNavPosition.Top && (groupButton === false || !groupButtonAsModalActions) && computedHasButtons"
|
|
580
596
|
v-model:loading="isLoading"
|
|
581
597
|
v-model:editing="editMode"
|
|
582
598
|
v-model:picked-modification-view="pickedModificationView"
|
|
@@ -638,7 +654,9 @@
|
|
|
638
654
|
v-model="item"
|
|
639
655
|
v-model:modifications="itemModifications"
|
|
640
656
|
v-model:valid="validForm"
|
|
657
|
+
v-model:changed="changedForm"
|
|
641
658
|
v-bind="<FormUiConfig>{
|
|
659
|
+
...formUiConfig,
|
|
642
660
|
form,
|
|
643
661
|
differencesTableConfig,
|
|
644
662
|
visibleView: pickedModificationView,
|
|
@@ -668,7 +686,7 @@
|
|
|
668
686
|
|
|
669
687
|
<button-nav
|
|
670
688
|
ref="buttonNav"
|
|
671
|
-
v-if="buttonNavPosition === ItemCrudButtonNavPosition.Bottom && (groupButton === false || !groupButtonAsModalActions)"
|
|
689
|
+
v-if="buttonNavPosition === ItemCrudButtonNavPosition.Bottom && (groupButton === false || !groupButtonAsModalActions) && computedHasButtons"
|
|
672
690
|
v-model:loading="isLoading"
|
|
673
691
|
v-model:editing="editMode"
|
|
674
692
|
v-model:picked-modification-view="pickedModificationView"
|