lkt-item-crud 2.0.17 → 2.0.18
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 +5 -5
- package/dist/build.js +459 -436
- package/dist/lib-components/LktItemCrud.vue.d.ts +9 -0
- package/package.json +1 -1
- package/src/lib-components/LktItemCrud.vue +46 -14
|
@@ -65,6 +65,8 @@ declare const __VLS_component: import("vue").DefineComponent<ItemCrudConfig, {
|
|
|
65
65
|
perms: (...args: any[]) => void;
|
|
66
66
|
"update:editing": (...args: any[]) => void;
|
|
67
67
|
"update:modelValue": (...args: any[]) => void;
|
|
68
|
+
"update:perms": (...args: any[]) => void;
|
|
69
|
+
"update:customData": (...args: any[]) => void;
|
|
68
70
|
"before-save": (...args: any[]) => void;
|
|
69
71
|
"modified-data": (...args: any[]) => void;
|
|
70
72
|
}, string, import("vue").PublicProps, Readonly<ItemCrudConfig> & Readonly<{
|
|
@@ -76,6 +78,8 @@ declare const __VLS_component: import("vue").DefineComponent<ItemCrudConfig, {
|
|
|
76
78
|
onPerms?: ((...args: any[]) => any) | undefined;
|
|
77
79
|
"onUpdate:editing"?: ((...args: any[]) => any) | undefined;
|
|
78
80
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
81
|
+
"onUpdate:perms"?: ((...args: any[]) => any) | undefined;
|
|
82
|
+
"onUpdate:customData"?: ((...args: any[]) => any) | undefined;
|
|
79
83
|
"onBefore-save"?: ((...args: any[]) => any) | undefined;
|
|
80
84
|
"onModified-data"?: ((...args: any[]) => any) | undefined;
|
|
81
85
|
}>, {
|
|
@@ -83,8 +87,13 @@ declare const __VLS_component: import("vue").DefineComponent<ItemCrudConfig, {
|
|
|
83
87
|
title: string;
|
|
84
88
|
mode: ItemCrudMode;
|
|
85
89
|
modelValue: LktObject;
|
|
90
|
+
events: {
|
|
91
|
+
httpStart?: undefined | Function;
|
|
92
|
+
httpEnd?: (data: import("lkt-vue-kernel").ClickEventArgs) => void | undefined;
|
|
93
|
+
};
|
|
86
94
|
editing: boolean;
|
|
87
95
|
perms: import("lkt-vue-kernel").ValidTablePermission[];
|
|
96
|
+
customData: LktObject;
|
|
88
97
|
editModeButton: ButtonConfig | false;
|
|
89
98
|
dropButton: ButtonConfig | false;
|
|
90
99
|
createButton: ButtonConfig | false;
|
package/package.json
CHANGED
|
@@ -38,6 +38,8 @@
|
|
|
38
38
|
const emit = defineEmits([
|
|
39
39
|
'update:modelValue',
|
|
40
40
|
'update:editing',
|
|
41
|
+
'update:perms',
|
|
42
|
+
'update:customData',
|
|
41
43
|
'read',
|
|
42
44
|
'create',
|
|
43
45
|
'update',
|
|
@@ -50,7 +52,8 @@
|
|
|
50
52
|
|
|
51
53
|
const isLoading = ref(true),
|
|
52
54
|
item = ref(props.modelValue),
|
|
53
|
-
|
|
55
|
+
custom = ref(props.customData),
|
|
56
|
+
permissions = ref(props.perms),
|
|
54
57
|
editMode = ref(props.editing),
|
|
55
58
|
httpSuccessRead = ref(false),
|
|
56
59
|
showStoreMessage = ref(false),
|
|
@@ -62,14 +65,20 @@
|
|
|
62
65
|
itemBeingEdited = ref(false),
|
|
63
66
|
itemCreated = ref(false),
|
|
64
67
|
buttonNav = ref(null),
|
|
65
|
-
canUpdate = computed(() => !createMode.value && Array.isArray(
|
|
66
|
-
canDrop = computed(() => !createMode.value && Array.isArray(
|
|
67
|
-
canSwitchEditMode = computed(() => !createMode.value && Array.isArray(
|
|
68
|
+
canUpdate = computed(() => !createMode.value && Array.isArray(permissions.value) && permissions.value.includes(TablePermission.Update)),
|
|
69
|
+
canDrop = computed(() => !createMode.value && Array.isArray(permissions.value) && permissions.value.includes(TablePermission.Drop)),
|
|
70
|
+
canSwitchEditMode = computed(() => !createMode.value && Array.isArray(permissions.value) && permissions.value.includes(TablePermission.SwitchEditMode));
|
|
68
71
|
|
|
69
72
|
watch(() => props.mode, (v) => {
|
|
70
73
|
createMode.value = v === ItemCrudMode.Create;
|
|
71
74
|
})
|
|
72
75
|
|
|
76
|
+
watch(() => props.perms, (v) => {permissions.value = v});
|
|
77
|
+
watch(permissions, (v) => {emit('update:perms', v)});
|
|
78
|
+
|
|
79
|
+
watch(() => props.customData, (v) => {custom.value = v});
|
|
80
|
+
watch(custom, (v) => {emit('update:customData', v)});
|
|
81
|
+
|
|
73
82
|
const safeCreateButton = ref(ensureButtonConfig(props.createButton, LktSettings.defaultCreateButton)),
|
|
74
83
|
safeUpdateButton = ref(ensureButtonConfig(props.updateButton, LktSettings.defaultUpdateButton)),
|
|
75
84
|
safeDropButton = ref(ensureButtonConfig(props.dropButton, LktSettings.defaultDropButton)),
|
|
@@ -98,23 +107,40 @@
|
|
|
98
107
|
httpStatus.value = -1;
|
|
99
108
|
showStoreMessage.value = false;
|
|
100
109
|
|
|
110
|
+
if (typeof props.events?.httpStart === 'function') {
|
|
111
|
+
props.events.httpStart();
|
|
112
|
+
}
|
|
113
|
+
|
|
101
114
|
try {
|
|
102
|
-
const r = await httpCall(props.readResource, props.readData);
|
|
115
|
+
const r: HTTPResponse = await httpCall(props.readResource, props.readData);
|
|
103
116
|
debug('fetchItem -> response', r);
|
|
104
117
|
isLoading.value = false;
|
|
105
118
|
httpStatus.value = r.httpStatus;
|
|
119
|
+
custom.value = r.custom;
|
|
106
120
|
if (!r.success) {
|
|
107
121
|
httpSuccessRead.value = false;
|
|
108
122
|
httpStatus.value = r.httpStatus;
|
|
123
|
+
|
|
124
|
+
if (typeof props.events?.httpEnd === 'function') {
|
|
125
|
+
props.events.httpEnd({
|
|
126
|
+
httpResponse: r,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
109
129
|
emit('error', r.httpStatus);
|
|
110
130
|
return;
|
|
111
131
|
}
|
|
112
132
|
httpSuccessRead.value = true;
|
|
113
133
|
item.value = r.data;
|
|
114
|
-
|
|
134
|
+
permissions.value = r.perms;
|
|
115
135
|
dataState.value.increment(item.value).turnStoredIntoOriginal();
|
|
116
136
|
dataChanged.value = dataState.value.changed();
|
|
117
137
|
readDataState.value.turnStoredIntoOriginal();
|
|
138
|
+
|
|
139
|
+
if (typeof props.events?.httpEnd === 'function') {
|
|
140
|
+
props.events.httpEnd({
|
|
141
|
+
httpResponse: r,
|
|
142
|
+
});
|
|
143
|
+
}
|
|
118
144
|
emit('read', r);
|
|
119
145
|
|
|
120
146
|
} catch (e) {
|
|
@@ -148,7 +174,7 @@
|
|
|
148
174
|
nextTick(() => itemBeingEdited.value = false);
|
|
149
175
|
}, { deep: true });
|
|
150
176
|
|
|
151
|
-
watch(
|
|
177
|
+
watch(permissions, () => emit('perms', permissions.value));
|
|
152
178
|
watch(dataChanged, (v) => {
|
|
153
179
|
emit('modified-data', v);
|
|
154
180
|
});
|
|
@@ -367,7 +393,9 @@
|
|
|
367
393
|
if (props.mode !== ItemCrudMode.Update || !canUpdate.value) return false;
|
|
368
394
|
if (!props.enabledSaveWithoutChanges && !dataChanged.value) return false;
|
|
369
395
|
|
|
370
|
-
if (typeof safeUpdateButton.value?.disabled === 'function') return !safeUpdateButton.value.disabled(
|
|
396
|
+
if (typeof safeUpdateButton.value?.disabled === 'function') return !safeUpdateButton.value.disabled({
|
|
397
|
+
prop: item.value
|
|
398
|
+
});
|
|
371
399
|
if (typeof safeUpdateButton.value?.disabled === 'boolean') return !safeUpdateButton.value.disabled;
|
|
372
400
|
|
|
373
401
|
return true;
|
|
@@ -376,7 +404,9 @@
|
|
|
376
404
|
if (props.mode !== ItemCrudMode.Create) return false;
|
|
377
405
|
if (!props.enabledSaveWithoutChanges && !dataChanged.value) return false;
|
|
378
406
|
|
|
379
|
-
if (typeof safeCreateButton.value?.disabled === 'function') return !safeCreateButton.value.disabled(
|
|
407
|
+
if (typeof safeCreateButton.value?.disabled === 'function') return !safeCreateButton.value.disabled({
|
|
408
|
+
prop: item.value
|
|
409
|
+
});
|
|
380
410
|
if (typeof safeCreateButton.value?.disabled === 'boolean') return !safeCreateButton.value.disabled;
|
|
381
411
|
|
|
382
412
|
return true;
|
|
@@ -385,7 +415,9 @@
|
|
|
385
415
|
|
|
386
416
|
if (!canDrop.value) return false;
|
|
387
417
|
|
|
388
|
-
if (typeof safeDropButton.value?.disabled === 'function') return !safeDropButton.value.disabled(
|
|
418
|
+
if (typeof safeDropButton.value?.disabled === 'function') return !safeDropButton.value.disabled({
|
|
419
|
+
prop: item.value
|
|
420
|
+
});
|
|
389
421
|
if (typeof safeDropButton.value?.disabled === 'boolean') return !safeDropButton.value.disabled;
|
|
390
422
|
|
|
391
423
|
return true;
|
|
@@ -442,7 +474,7 @@
|
|
|
442
474
|
:able-to-create="ableToCreate"
|
|
443
475
|
:able-to-update="ableToUpdate"
|
|
444
476
|
:able-to-drop="ableToDrop"
|
|
445
|
-
:perms="
|
|
477
|
+
:perms="permissions"
|
|
446
478
|
@create="onCreate"
|
|
447
479
|
@save="onUpdate"
|
|
448
480
|
@drop="onDrop"
|
|
@@ -499,7 +531,7 @@
|
|
|
499
531
|
:able-to-create="ableToCreate"
|
|
500
532
|
:able-to-update="ableToUpdate"
|
|
501
533
|
:able-to-drop="ableToDrop"
|
|
502
|
-
:perms="
|
|
534
|
+
:perms="permissions"
|
|
503
535
|
@create="onCreate"
|
|
504
536
|
@save="onUpdate"
|
|
505
537
|
@drop="onDrop"
|
|
@@ -537,7 +569,7 @@
|
|
|
537
569
|
:can-update="canUpdate"
|
|
538
570
|
:can-drop="canDrop"
|
|
539
571
|
:item-being-edited="itemBeingEdited"
|
|
540
|
-
:perms="
|
|
572
|
+
:perms="permissions"
|
|
541
573
|
/>
|
|
542
574
|
</div>
|
|
543
575
|
<lkt-http-info :code="httpStatus" v-else-if="notificationType === NotificationType.Inline" />
|
|
@@ -568,7 +600,7 @@
|
|
|
568
600
|
:able-to-create="ableToCreate"
|
|
569
601
|
:able-to-update="ableToUpdate"
|
|
570
602
|
:able-to-drop="ableToDrop"
|
|
571
|
-
:perms="
|
|
603
|
+
:perms="permissions"
|
|
572
604
|
@create="onCreate"
|
|
573
605
|
@save="onUpdate"
|
|
574
606
|
@drop="onDrop"
|