lkt-item-crud 2.0.28 → 2.0.30
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.
|
@@ -90,7 +90,7 @@ declare const __VLS_component: import("vue").DefineComponent<ItemCrudConfig, {
|
|
|
90
90
|
"onModified-data"?: ((...args: any[]) => any) | undefined;
|
|
91
91
|
}>, {
|
|
92
92
|
view: ItemCrudView;
|
|
93
|
-
form: import("lkt-vue-kernel").FormConfig;
|
|
93
|
+
form: import("lkt-vue-kernel").FormConfig | Function;
|
|
94
94
|
header: import("lkt-vue-kernel").HeaderConfig;
|
|
95
95
|
title: string;
|
|
96
96
|
mode: ItemCrudMode;
|
package/package.json
CHANGED
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
ableToCreate?: boolean
|
|
43
43
|
ableToUpdate?: boolean
|
|
44
44
|
ableToDrop?: boolean
|
|
45
|
+
canCreate?: boolean
|
|
45
46
|
canUpdate?: boolean
|
|
46
47
|
canDrop?: boolean
|
|
47
48
|
canSwitchEditMode?: boolean
|
|
@@ -129,8 +130,8 @@
|
|
|
129
130
|
&& props.httpSuccessRead;
|
|
130
131
|
}),
|
|
131
132
|
showSaveButton = computed(() => {
|
|
132
|
-
if (props.mode === ItemCrudMode.Create && props.createButton === false) return false;
|
|
133
|
-
if (props.mode === ItemCrudMode.Update && props.updateButton === false) return false;
|
|
133
|
+
if (props.mode === ItemCrudMode.Create && (props.createButton === false || !props.canCreate)) return false;
|
|
134
|
+
if (props.mode === ItemCrudMode.Update && (props.updateButton === false || !props.canUpdate)) return false;
|
|
134
135
|
if (isLoading.value) return false;
|
|
135
136
|
|
|
136
137
|
return props.editing
|
|
@@ -75,6 +75,7 @@
|
|
|
75
75
|
itemCreated = ref(false),
|
|
76
76
|
buttonNav = ref(null),
|
|
77
77
|
formRef = ref(null),
|
|
78
|
+
canCreate = computed(() => createMode.value && props.createButton !== false && Array.isArray(permissions.value) && permissions.value.includes(TablePermission.Create)),
|
|
78
79
|
canUpdate = computed(() => !createMode.value && props.updateButton !== false && Array.isArray(permissions.value) && permissions.value.includes(TablePermission.Update)),
|
|
79
80
|
canDrop = computed(() => !createMode.value && props.dropButton !== false && Array.isArray(permissions.value) && permissions.value.includes(TablePermission.Drop)),
|
|
80
81
|
canSwitchEditMode = computed(() => props.editModeButton !== false && !createMode.value && Array.isArray(permissions.value) && permissions.value.includes(TablePermission.SwitchEditMode));
|
|
@@ -252,7 +253,7 @@
|
|
|
252
253
|
const formDifferencesChecker = ref(undefined);
|
|
253
254
|
const resetFormDifferencesChecker = () => {
|
|
254
255
|
if (computedHasForm.value) {
|
|
255
|
-
formDifferencesChecker.value = getFormDataState(item.value, itemModifications.value,
|
|
256
|
+
formDifferencesChecker.value = getFormDataState(item.value, itemModifications.value, computedForm.value);
|
|
256
257
|
}
|
|
257
258
|
}
|
|
258
259
|
|
|
@@ -478,7 +479,7 @@
|
|
|
478
479
|
return true;
|
|
479
480
|
}),
|
|
480
481
|
ableToCreate = computed(() => {
|
|
481
|
-
if (props.mode !== ItemCrudMode.Create) return false;
|
|
482
|
+
if (props.mode !== ItemCrudMode.Create || !canCreate.value) return false;
|
|
482
483
|
if (!props.enabledSaveWithoutChanges && !dataChanged.value) return false;
|
|
483
484
|
if (computedHasForm.value && !validForm.value && !changedForm.value) return false;
|
|
484
485
|
|
|
@@ -520,7 +521,7 @@
|
|
|
520
521
|
return {};
|
|
521
522
|
}),
|
|
522
523
|
computedHasForm = computed(() => {
|
|
523
|
-
return typeof
|
|
524
|
+
return (typeof computedForm.value === 'object' && Object.keys(computedForm.value).length > 0);
|
|
524
525
|
}),
|
|
525
526
|
computedModificationViews = computed(() => {
|
|
526
527
|
if (Object.keys(itemModifications.value).length === 0) return [];
|
|
@@ -533,15 +534,21 @@
|
|
|
533
534
|
})
|
|
534
535
|
|
|
535
536
|
const computedHasButtons = computed(() => {
|
|
536
|
-
return
|
|
537
|
+
return canCreate.value || canUpdate.value || canDrop.value;
|
|
537
538
|
})
|
|
538
539
|
|
|
539
540
|
const computedFormSlots = computed(() => {
|
|
540
|
-
if (computedHasForm.value)
|
|
541
|
-
return getFormSlotKeys(props.form);
|
|
542
|
-
}
|
|
541
|
+
if (computedHasForm.value) return getFormSlotKeys(computedForm.value);
|
|
543
542
|
return [];
|
|
544
543
|
})
|
|
544
|
+
|
|
545
|
+
const computedForm = computed(() => {
|
|
546
|
+
if (typeof props.form === 'function') return props.form({
|
|
547
|
+
mode: props.mode,
|
|
548
|
+
view: pickedModificationView.value,
|
|
549
|
+
});
|
|
550
|
+
return props.form;
|
|
551
|
+
})
|
|
545
552
|
</script>
|
|
546
553
|
|
|
547
554
|
<template>
|
|
@@ -570,6 +577,7 @@
|
|
|
570
577
|
:group-button="safeGroupButton"
|
|
571
578
|
:data-changed="dataChanged"
|
|
572
579
|
:http-success-read="httpSuccessRead"
|
|
580
|
+
:can-create="canCreate"
|
|
573
581
|
:can-update="canUpdate"
|
|
574
582
|
:can-drop="canDrop"
|
|
575
583
|
:can-switch-edit-mode="canSwitchEditMode"
|
|
@@ -635,6 +643,7 @@
|
|
|
635
643
|
:group-button="safeGroupButton"
|
|
636
644
|
:data-changed="dataChanged"
|
|
637
645
|
:http-success-read="httpSuccessRead"
|
|
646
|
+
:can-create="canCreate"
|
|
638
647
|
:can-update="canUpdate"
|
|
639
648
|
:can-drop="canDrop"
|
|
640
649
|
:can-switch-edit-mode="canSwitchEditMode"
|
|
@@ -688,7 +697,7 @@
|
|
|
688
697
|
v-model:changed="changedForm"
|
|
689
698
|
v-bind="<FormUiConfig>{
|
|
690
699
|
...formUiConfig,
|
|
691
|
-
form,
|
|
700
|
+
form: computedForm,
|
|
692
701
|
differencesTableConfig,
|
|
693
702
|
visibleView: pickedModificationView,
|
|
694
703
|
modificationDataState: formDifferencesChecker,
|
|
@@ -738,6 +747,7 @@
|
|
|
738
747
|
:group-button="safeGroupButton"
|
|
739
748
|
:data-changed="dataChanged"
|
|
740
749
|
:http-success-read="httpSuccessRead"
|
|
750
|
+
:can-create="canCreate"
|
|
741
751
|
:can-update="canUpdate"
|
|
742
752
|
:can-drop="canDrop"
|
|
743
753
|
:can-switch-edit-mode="canSwitchEditMode"
|