lkt-item-crud 2.0.14 → 2.0.16
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 +449 -429
- package/dist/components/ButtonNav.vue.d.ts +4 -0
- package/dist/components/ButtonNavButtons.vue.d.ts +75 -0
- package/dist/lib-components/LktItemCrud.vue.d.ts +8 -7
- package/package.json +1 -1
- package/src/components/ButtonNav.vue +21 -82
- package/src/lib-components/LktItemCrud.vue +88 -22
|
@@ -3,6 +3,7 @@ type __VLS_Props = {
|
|
|
3
3
|
item: LktObject;
|
|
4
4
|
editing?: boolean;
|
|
5
5
|
loading?: boolean;
|
|
6
|
+
grouped?: boolean;
|
|
6
7
|
view: ItemCrudView;
|
|
7
8
|
mode: ItemCrudMode;
|
|
8
9
|
createButton?: ButtonConfig | false;
|
|
@@ -12,6 +13,9 @@ type __VLS_Props = {
|
|
|
12
13
|
groupButton?: ButtonConfig | boolean;
|
|
13
14
|
groupButtonAsModalActions?: boolean;
|
|
14
15
|
dataChanged: boolean;
|
|
16
|
+
ableToCreate?: boolean;
|
|
17
|
+
ableToUpdate?: boolean;
|
|
18
|
+
ableToDrop?: boolean;
|
|
15
19
|
canUpdate?: boolean;
|
|
16
20
|
canDrop?: boolean;
|
|
17
21
|
canSwitchEditMode?: boolean;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { ButtonConfig, ItemCrudButtonNavVisibility, ItemCrudMode, ItemCrudView, LktObject } from 'lkt-vue-kernel';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
item: LktObject;
|
|
4
|
+
editing?: boolean;
|
|
5
|
+
loading?: boolean;
|
|
6
|
+
view: ItemCrudView;
|
|
7
|
+
mode: ItemCrudMode;
|
|
8
|
+
createButton?: ButtonConfig | false;
|
|
9
|
+
updateButton?: ButtonConfig | false;
|
|
10
|
+
dropButton?: ButtonConfig | false;
|
|
11
|
+
editModeButton?: ButtonConfig | false;
|
|
12
|
+
groupButton?: ButtonConfig | boolean;
|
|
13
|
+
groupButtonAsModalActions?: boolean;
|
|
14
|
+
dataChanged: boolean;
|
|
15
|
+
ableToCreate?: boolean;
|
|
16
|
+
ableToUpdate?: boolean;
|
|
17
|
+
ableToDrop?: boolean;
|
|
18
|
+
canUpdate?: boolean;
|
|
19
|
+
canDrop?: boolean;
|
|
20
|
+
canSwitchEditMode?: boolean;
|
|
21
|
+
perms?: Array<string>;
|
|
22
|
+
httpSuccessRead?: boolean;
|
|
23
|
+
buttonNavVisibility: ItemCrudButtonNavVisibility;
|
|
24
|
+
};
|
|
25
|
+
declare var __VLS_5: {
|
|
26
|
+
canUpdate: boolean | undefined;
|
|
27
|
+
canDrop: boolean | undefined;
|
|
28
|
+
perms: string[] | undefined;
|
|
29
|
+
}, __VLS_7: {
|
|
30
|
+
canUpdate: boolean | undefined;
|
|
31
|
+
canDrop: boolean | undefined;
|
|
32
|
+
perms: string[] | undefined;
|
|
33
|
+
}, __VLS_21: {
|
|
34
|
+
item: LktObject;
|
|
35
|
+
editMode: any;
|
|
36
|
+
isCreate: boolean;
|
|
37
|
+
canUpdate: boolean | undefined;
|
|
38
|
+
canDrop: boolean | undefined;
|
|
39
|
+
}, __VLS_35: {
|
|
40
|
+
item: LktObject;
|
|
41
|
+
editMode: any;
|
|
42
|
+
isCreate: boolean;
|
|
43
|
+
canUpdate: boolean | undefined;
|
|
44
|
+
canDrop: boolean | undefined;
|
|
45
|
+
}, __VLS_49: {
|
|
46
|
+
item: LktObject;
|
|
47
|
+
editMode: any;
|
|
48
|
+
isCreate: boolean;
|
|
49
|
+
canUpdate: boolean | undefined;
|
|
50
|
+
canDrop: boolean | undefined;
|
|
51
|
+
}, __VLS_51: {};
|
|
52
|
+
type __VLS_Slots = {} & {
|
|
53
|
+
'prev-buttons-ever'?: (props: typeof __VLS_5) => any;
|
|
54
|
+
} & {
|
|
55
|
+
'prev-buttons'?: (props: typeof __VLS_7) => any;
|
|
56
|
+
} & {
|
|
57
|
+
'button-save'?: (props: typeof __VLS_21) => any;
|
|
58
|
+
} & {
|
|
59
|
+
'button-save'?: (props: typeof __VLS_35) => any;
|
|
60
|
+
} & {
|
|
61
|
+
'button-drop'?: (props: typeof __VLS_49) => any;
|
|
62
|
+
} & {
|
|
63
|
+
buttons?: (props: typeof __VLS_51) => any;
|
|
64
|
+
};
|
|
65
|
+
declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
66
|
+
item: LktObject;
|
|
67
|
+
editing: boolean;
|
|
68
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
69
|
+
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
70
|
+
export default _default;
|
|
71
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
72
|
+
new (): {
|
|
73
|
+
$slots: S;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ItemCrudButtonNavPosition, ItemCrudConfig, ItemCrudMode, ItemCrudView, LktObject, NotificationType } from 'lkt-vue-kernel';
|
|
1
|
+
import { ButtonConfig, ItemCrudButtonNavPosition, ItemCrudConfig, ItemCrudMode, ItemCrudView, LktObject, ModalConfig, NotificationType } from 'lkt-vue-kernel';
|
|
2
2
|
declare var __VLS_17: {
|
|
3
3
|
canUpdate: boolean | undefined;
|
|
4
4
|
canDrop: boolean | undefined;
|
|
@@ -85,21 +85,22 @@ declare const __VLS_component: import("vue").DefineComponent<ItemCrudConfig, {
|
|
|
85
85
|
modelValue: LktObject;
|
|
86
86
|
editing: boolean;
|
|
87
87
|
perms: import("lkt-vue-kernel").ValidTablePermission[];
|
|
88
|
-
editModeButton:
|
|
89
|
-
dropButton:
|
|
90
|
-
createButton:
|
|
91
|
-
updateButton:
|
|
92
|
-
groupButton:
|
|
88
|
+
editModeButton: ButtonConfig | false;
|
|
89
|
+
dropButton: ButtonConfig | false;
|
|
90
|
+
createButton: ButtonConfig | false;
|
|
91
|
+
updateButton: ButtonConfig | false;
|
|
92
|
+
groupButton: ButtonConfig | boolean;
|
|
93
93
|
groupButtonAsModalActions: boolean;
|
|
94
94
|
buttonNavPosition: ItemCrudButtonNavPosition;
|
|
95
95
|
buttonNavVisibility: import("lkt-vue-kernel").ItemCrudButtonNavVisibility;
|
|
96
|
-
modalConfig:
|
|
96
|
+
modalConfig: ModalConfig;
|
|
97
97
|
saveConfig: import("lkt-vue-kernel").SaveConfig;
|
|
98
98
|
dataStateConfig: import("lkt-data-state").DataStateConfig;
|
|
99
99
|
readResource: string;
|
|
100
100
|
readData: LktObject;
|
|
101
101
|
beforeEmitUpdate: Function;
|
|
102
102
|
notificationType: NotificationType;
|
|
103
|
+
enabledSaveWithoutChanges: boolean;
|
|
103
104
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
104
105
|
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
105
106
|
export default _default;
|
package/package.json
CHANGED
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed, ref, SetupContext, useSlots, watch } from 'vue';
|
|
3
|
-
import {
|
|
4
|
-
ButtonConfig,
|
|
5
|
-
ensureButtonConfig,
|
|
6
|
-
ItemCrudButtonNavVisibility,
|
|
7
|
-
ItemCrudMode,
|
|
8
|
-
ItemCrudView,
|
|
9
|
-
LktObject,
|
|
10
|
-
LktSettings,
|
|
11
|
-
} from 'lkt-vue-kernel';
|
|
3
|
+
import { ButtonConfig, ItemCrudButtonNavVisibility, ItemCrudMode, ItemCrudView, LktObject } from 'lkt-vue-kernel';
|
|
12
4
|
import { HTTPResponse } from 'lkt-http-client';
|
|
13
5
|
|
|
14
6
|
const emit = defineEmits([
|
|
@@ -23,6 +15,7 @@
|
|
|
23
15
|
item: LktObject,
|
|
24
16
|
editing?: boolean
|
|
25
17
|
loading?: boolean
|
|
18
|
+
grouped?: boolean
|
|
26
19
|
|
|
27
20
|
view: ItemCrudView
|
|
28
21
|
mode: ItemCrudMode
|
|
@@ -36,6 +29,9 @@
|
|
|
36
29
|
|
|
37
30
|
dataChanged: boolean
|
|
38
31
|
|
|
32
|
+
ableToCreate?: boolean
|
|
33
|
+
ableToUpdate?: boolean
|
|
34
|
+
ableToDrop?: boolean
|
|
39
35
|
canUpdate?: boolean
|
|
40
36
|
canDrop?: boolean
|
|
41
37
|
canSwitchEditMode?: boolean
|
|
@@ -50,28 +46,6 @@
|
|
|
50
46
|
isLoading: false,
|
|
51
47
|
});
|
|
52
48
|
|
|
53
|
-
const safeCreateButton = ref(ensureButtonConfig(props.createButton, LktSettings.defaultCreateButton)),
|
|
54
|
-
safeUpdateButton = ref(ensureButtonConfig(props.updateButton, LktSettings.defaultUpdateButton)),
|
|
55
|
-
safeDropButton = ref(ensureButtonConfig(props.dropButton, LktSettings.defaultDropButton)),
|
|
56
|
-
safeEditModeButton = ref(ensureButtonConfig(props.editModeButton, LktSettings.defaultEditModeButton)),
|
|
57
|
-
safeGroupButton = ref(ensureButtonConfig(props.groupButton, LktSettings.defaultGroupButton));
|
|
58
|
-
|
|
59
|
-
watch(() => props.createButton, v => {
|
|
60
|
-
safeCreateButton.value = ensureButtonConfig(v, LktSettings.defaultCreateButton);
|
|
61
|
-
}, { deep: true });
|
|
62
|
-
|
|
63
|
-
watch(() => props.updateButton, v => {
|
|
64
|
-
safeUpdateButton.value = ensureButtonConfig(v, LktSettings.defaultUpdateButton);
|
|
65
|
-
}, { deep: true });
|
|
66
|
-
|
|
67
|
-
watch(() => props.dropButton, v => {
|
|
68
|
-
safeDropButton.value = ensureButtonConfig(v, LktSettings.defaultDropButton);
|
|
69
|
-
}, { deep: true });
|
|
70
|
-
|
|
71
|
-
watch(() => props.editModeButton, v => {
|
|
72
|
-
safeEditModeButton.value = ensureButtonConfig(v, LktSettings.defaultEditModeButton);
|
|
73
|
-
}, { deep: true });
|
|
74
|
-
|
|
75
49
|
const slots: SetupContext['slots'] = useSlots();
|
|
76
50
|
|
|
77
51
|
const saveButtonRef = ref(<HTMLButtonElement | null>null);
|
|
@@ -117,34 +91,7 @@
|
|
|
117
91
|
});
|
|
118
92
|
|
|
119
93
|
|
|
120
|
-
const
|
|
121
|
-
if (props.mode !== ItemCrudMode.Update || !props.canUpdate) return false;
|
|
122
|
-
if (!props.dataChanged) return false;
|
|
123
|
-
|
|
124
|
-
if (typeof safeUpdateButton.value?.disabled === 'function') return !safeUpdateButton.value.disabled(props.item);
|
|
125
|
-
if (typeof safeUpdateButton.value?.disabled === 'boolean') return !safeUpdateButton.value.disabled;
|
|
126
|
-
|
|
127
|
-
return true;
|
|
128
|
-
}),
|
|
129
|
-
ableToCreate = computed(() => {
|
|
130
|
-
if (props.mode !== ItemCrudMode.Create) return false;
|
|
131
|
-
if (!props.dataChanged) return false;
|
|
132
|
-
|
|
133
|
-
if (typeof safeCreateButton.value?.disabled === 'function') return !safeCreateButton.value.disabled(props.item);
|
|
134
|
-
if (typeof safeCreateButton.value?.disabled === 'boolean') return !safeCreateButton.value.disabled;
|
|
135
|
-
|
|
136
|
-
return true;
|
|
137
|
-
}),
|
|
138
|
-
ableToDrop = computed(() => {
|
|
139
|
-
|
|
140
|
-
if (!props.canDrop) return false;
|
|
141
|
-
|
|
142
|
-
if (typeof safeDropButton.value?.disabled === 'function') return !safeDropButton.value.disabled(props.item);
|
|
143
|
-
if (typeof safeDropButton.value?.disabled === 'boolean') return !safeDropButton.value.disabled;
|
|
144
|
-
|
|
145
|
-
return true;
|
|
146
|
-
}),
|
|
147
|
-
showDropButton = computed(() => {
|
|
94
|
+
const showDropButton = computed(() => {
|
|
148
95
|
if (!props.canDrop || props.dropButton === false) return false;
|
|
149
96
|
if (!props.canUpdate && props.canDrop) return true;
|
|
150
97
|
|
|
@@ -157,14 +104,6 @@
|
|
|
157
104
|
if (props.mode === ItemCrudMode.Update && props.updateButton === false) return false;
|
|
158
105
|
if (isLoading.value) return false;
|
|
159
106
|
|
|
160
|
-
// if (props.dataChanged) {
|
|
161
|
-
// return ableToUpdate.value || ableToCreate.value;
|
|
162
|
-
// }
|
|
163
|
-
|
|
164
|
-
// if (props.buttonNavVisibility === ItemCrudButtonNavVisibility.Never) {
|
|
165
|
-
// return false;
|
|
166
|
-
// }
|
|
167
|
-
|
|
168
107
|
return props.editing
|
|
169
108
|
&& props.httpSuccessRead;
|
|
170
109
|
}),
|
|
@@ -190,10 +129,10 @@
|
|
|
190
129
|
<template>
|
|
191
130
|
<div v-if="showButtons" class="lkt-item-crud-buttons">
|
|
192
131
|
|
|
193
|
-
<template v-if="
|
|
132
|
+
<template v-if="grouped && groupButtonAsModalActions">
|
|
194
133
|
<lkt-button
|
|
195
134
|
v-if="showSwitchButton"
|
|
196
|
-
v-bind="
|
|
135
|
+
v-bind="editModeButton"
|
|
197
136
|
v-model:checked="isEditing"
|
|
198
137
|
class="lkt-item-crud--switch-mode-button" />
|
|
199
138
|
|
|
@@ -217,7 +156,7 @@
|
|
|
217
156
|
<lkt-button
|
|
218
157
|
ref="saveButtonRef"
|
|
219
158
|
v-show="mode === ItemCrudMode.Update && showSaveButton"
|
|
220
|
-
v-bind="
|
|
159
|
+
v-bind="updateButton"
|
|
221
160
|
:disabled="!ableToUpdate"
|
|
222
161
|
@loading="onButtonLoading"
|
|
223
162
|
@loaded="onButtonLoaded"
|
|
@@ -232,7 +171,7 @@
|
|
|
232
171
|
<lkt-button
|
|
233
172
|
ref="saveButtonRef"
|
|
234
173
|
v-show="mode === ItemCrudMode.Create && showSaveButton"
|
|
235
|
-
v-bind="
|
|
174
|
+
v-bind="createButton"
|
|
236
175
|
:disabled="!ableToCreate"
|
|
237
176
|
@loading="onButtonLoading"
|
|
238
177
|
@loaded="onButtonLoaded"
|
|
@@ -247,7 +186,7 @@
|
|
|
247
186
|
<lkt-button
|
|
248
187
|
ref="dropButtonRef"
|
|
249
188
|
v-show="showDropButton && mode !== ItemCrudMode.Create"
|
|
250
|
-
v-bind="
|
|
189
|
+
v-bind="dropButton"
|
|
251
190
|
:disabled="!ableToDrop"
|
|
252
191
|
@loading="onButtonLoading"
|
|
253
192
|
@loaded="onButtonLoaded"
|
|
@@ -263,16 +202,16 @@
|
|
|
263
202
|
<slot name="buttons" />
|
|
264
203
|
</template>
|
|
265
204
|
</template>
|
|
266
|
-
<template v-else-if="
|
|
205
|
+
<template v-else-if="grouped">
|
|
267
206
|
<lkt-button
|
|
268
207
|
ref="groupButton"
|
|
269
|
-
v-bind="
|
|
208
|
+
v-bind="groupButton"
|
|
270
209
|
class="lkt-item-crud-group-button"
|
|
271
210
|
>
|
|
272
211
|
<template #split>
|
|
273
212
|
<lkt-button
|
|
274
213
|
v-if="showSwitchButton"
|
|
275
|
-
v-bind="
|
|
214
|
+
v-bind="editModeButton"
|
|
276
215
|
v-model:checked="isEditing"
|
|
277
216
|
class="lkt-item-crud--switch-mode-button" />
|
|
278
217
|
|
|
@@ -296,7 +235,7 @@
|
|
|
296
235
|
<lkt-button
|
|
297
236
|
ref="saveButtonRef"
|
|
298
237
|
v-show="mode === ItemCrudMode.Update && showSaveButton"
|
|
299
|
-
v-bind="
|
|
238
|
+
v-bind="updateButton"
|
|
300
239
|
:disabled="!ableToUpdate"
|
|
301
240
|
@loading="onButtonLoading"
|
|
302
241
|
@loaded="onButtonLoaded"
|
|
@@ -311,7 +250,7 @@
|
|
|
311
250
|
<lkt-button
|
|
312
251
|
ref="saveButtonRef"
|
|
313
252
|
v-show="mode === ItemCrudMode.Create && showSaveButton"
|
|
314
|
-
v-bind="
|
|
253
|
+
v-bind="createButton"
|
|
315
254
|
:disabled="!ableToCreate"
|
|
316
255
|
@loading="onButtonLoading"
|
|
317
256
|
@loaded="onButtonLoaded"
|
|
@@ -326,7 +265,7 @@
|
|
|
326
265
|
<lkt-button
|
|
327
266
|
ref="dropButtonRef"
|
|
328
267
|
v-show="showDropButton && mode !== ItemCrudMode.Create"
|
|
329
|
-
v-bind="
|
|
268
|
+
v-bind="dropButton"
|
|
330
269
|
:disabled="!ableToDrop"
|
|
331
270
|
@loading="onButtonLoading"
|
|
332
271
|
@loaded="onButtonLoaded"
|
|
@@ -366,7 +305,7 @@
|
|
|
366
305
|
<lkt-button
|
|
367
306
|
ref="saveButtonRef"
|
|
368
307
|
v-show="mode === ItemCrudMode.Update && showSaveButton"
|
|
369
|
-
v-bind="
|
|
308
|
+
v-bind="updateButton"
|
|
370
309
|
:disabled="!ableToUpdate"
|
|
371
310
|
@loading="onButtonLoading"
|
|
372
311
|
@loaded="onButtonLoaded"
|
|
@@ -381,7 +320,7 @@
|
|
|
381
320
|
<lkt-button
|
|
382
321
|
ref="saveButtonRef"
|
|
383
322
|
v-show="mode === ItemCrudMode.Create && showSaveButton"
|
|
384
|
-
v-bind="
|
|
323
|
+
v-bind="createButton"
|
|
385
324
|
:disabled="!ableToCreate"
|
|
386
325
|
@loading="onButtonLoading"
|
|
387
326
|
@loaded="onButtonLoaded"
|
|
@@ -396,7 +335,7 @@
|
|
|
396
335
|
<lkt-button
|
|
397
336
|
ref="dropButtonRef"
|
|
398
337
|
v-show="showDropButton && mode !== ItemCrudMode.Create"
|
|
399
|
-
v-bind="
|
|
338
|
+
v-bind="dropButton"
|
|
400
339
|
:disabled="!ableToDrop"
|
|
401
340
|
@loading="onButtonLoading"
|
|
402
341
|
@loaded="onButtonLoaded"
|
|
@@ -414,7 +353,7 @@
|
|
|
414
353
|
|
|
415
354
|
<lkt-button
|
|
416
355
|
v-if="showSwitchButton"
|
|
417
|
-
v-bind="
|
|
356
|
+
v-bind="editModeButton"
|
|
418
357
|
v-model:checked="isEditing"
|
|
419
358
|
class="lkt-item-crud--switch-mode-button" />
|
|
420
359
|
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
import { DataState } from 'lkt-data-state';
|
|
5
5
|
import { debug } from '../functions/debug';
|
|
6
6
|
import {
|
|
7
|
+
ButtonConfig,
|
|
8
|
+
ensureButtonConfig,
|
|
7
9
|
getDefaultValues,
|
|
8
10
|
ItemCrud,
|
|
9
11
|
ItemCrudButtonNavPosition,
|
|
@@ -11,7 +13,7 @@
|
|
|
11
13
|
ItemCrudMode,
|
|
12
14
|
ItemCrudView,
|
|
13
15
|
LktObject,
|
|
14
|
-
LktSettings,
|
|
16
|
+
LktSettings, ModalConfig,
|
|
15
17
|
NotificationType,
|
|
16
18
|
TablePermission,
|
|
17
19
|
ToastConfig,
|
|
@@ -65,6 +67,28 @@
|
|
|
65
67
|
createMode.value = v === ItemCrudMode.Create;
|
|
66
68
|
})
|
|
67
69
|
|
|
70
|
+
const safeCreateButton = ref(ensureButtonConfig(props.createButton, LktSettings.defaultCreateButton)),
|
|
71
|
+
safeUpdateButton = ref(ensureButtonConfig(props.updateButton, LktSettings.defaultUpdateButton)),
|
|
72
|
+
safeDropButton = ref(ensureButtonConfig(props.dropButton, LktSettings.defaultDropButton)),
|
|
73
|
+
safeEditModeButton = ref(ensureButtonConfig(props.editModeButton, LktSettings.defaultEditModeButton)),
|
|
74
|
+
safeGroupButton = ref(ensureButtonConfig(props.groupButton, LktSettings.defaultGroupButton));
|
|
75
|
+
|
|
76
|
+
watch(() => props.createButton, v => {
|
|
77
|
+
safeCreateButton.value = ensureButtonConfig(v, LktSettings.defaultCreateButton);
|
|
78
|
+
}, { deep: true });
|
|
79
|
+
|
|
80
|
+
watch(() => props.updateButton, v => {
|
|
81
|
+
safeUpdateButton.value = ensureButtonConfig(v, LktSettings.defaultUpdateButton);
|
|
82
|
+
}, { deep: true });
|
|
83
|
+
|
|
84
|
+
watch(() => props.dropButton, v => {
|
|
85
|
+
safeDropButton.value = ensureButtonConfig(v, LktSettings.defaultDropButton);
|
|
86
|
+
}, { deep: true });
|
|
87
|
+
|
|
88
|
+
watch(() => props.editModeButton, v => {
|
|
89
|
+
safeEditModeButton.value = ensureButtonConfig(v, LktSettings.defaultEditModeButton);
|
|
90
|
+
}, { deep: true });
|
|
91
|
+
|
|
68
92
|
const fetchItem = async () => {
|
|
69
93
|
debug('fetchItem');
|
|
70
94
|
isLoading.value = true;
|
|
@@ -193,7 +217,7 @@
|
|
|
193
217
|
},
|
|
194
218
|
onCreate = ($event: PointerEvent, r: HTTPResponse) => {
|
|
195
219
|
debug('onCreate');
|
|
196
|
-
if (!ensureValidResourceSave(r,
|
|
220
|
+
if (!ensureValidResourceSave(r, safeCreateButton.value.resource)) {
|
|
197
221
|
if (props.notificationType === NotificationType.Toast) {
|
|
198
222
|
openToast(<ToastConfig>{
|
|
199
223
|
text: LktSettings.defaultCreateErrorText,
|
|
@@ -221,7 +245,7 @@
|
|
|
221
245
|
},
|
|
222
246
|
onUpdate = ($event: PointerEvent, r: HTTPResponse) => {
|
|
223
247
|
debug('onUpdate');
|
|
224
|
-
if (!ensureValidResourceSave(r,
|
|
248
|
+
if (!ensureValidResourceSave(r, safeUpdateButton.value.resource)) {
|
|
225
249
|
if (props.notificationType === NotificationType.Toast) {
|
|
226
250
|
openToast(<ToastConfig>{
|
|
227
251
|
text: LktSettings.defaultUpdateErrorText,
|
|
@@ -247,7 +271,7 @@
|
|
|
247
271
|
},
|
|
248
272
|
onDrop = ($event: PointerEvent, r: HTTPResponse) => {
|
|
249
273
|
debug('onDrop');
|
|
250
|
-
if (!ensureValidResourceSave(r,
|
|
274
|
+
if (!ensureValidResourceSave(r, safeDropButton.value.resource)) {
|
|
251
275
|
if (props.notificationType === NotificationType.Toast) {
|
|
252
276
|
openToast(<ToastConfig>{
|
|
253
277
|
text: LktSettings.defaultDropErrorText,
|
|
@@ -325,9 +349,36 @@
|
|
|
325
349
|
if (computedInsideModal.value) return 'lkt-modal';
|
|
326
350
|
return 'section';
|
|
327
351
|
}),
|
|
352
|
+
ableToUpdate = computed(() => {
|
|
353
|
+
if (props.mode !== ItemCrudMode.Update || !canUpdate.value) return false;
|
|
354
|
+
if (!props.enabledSaveWithoutChanges && !dataChanged.value) return false;
|
|
355
|
+
|
|
356
|
+
if (typeof safeUpdateButton.value?.disabled === 'function') return !safeUpdateButton.value.disabled(item.value);
|
|
357
|
+
if (typeof safeUpdateButton.value?.disabled === 'boolean') return !safeUpdateButton.value.disabled;
|
|
358
|
+
|
|
359
|
+
return true;
|
|
360
|
+
}),
|
|
361
|
+
ableToCreate = computed(() => {
|
|
362
|
+
if (props.mode !== ItemCrudMode.Create) return false;
|
|
363
|
+
if (!props.enabledSaveWithoutChanges && !dataChanged.value) return false;
|
|
364
|
+
|
|
365
|
+
if (typeof safeCreateButton.value?.disabled === 'function') return !safeCreateButton.value.disabled(item.value);
|
|
366
|
+
if (typeof safeCreateButton.value?.disabled === 'boolean') return !safeCreateButton.value.disabled;
|
|
367
|
+
|
|
368
|
+
return true;
|
|
369
|
+
}),
|
|
370
|
+
ableToDrop = computed(() => {
|
|
371
|
+
|
|
372
|
+
if (!canDrop.value) return false;
|
|
373
|
+
|
|
374
|
+
if (typeof safeDropButton.value?.disabled === 'function') return !safeDropButton.value.disabled(item.value);
|
|
375
|
+
if (typeof safeDropButton.value?.disabled === 'boolean') return !safeDropButton.value.disabled;
|
|
376
|
+
|
|
377
|
+
return true;
|
|
378
|
+
}),
|
|
328
379
|
computedContainerAttrs = computed(() => {
|
|
329
380
|
if (computedContainerTag.value === 'lkt-modal') {
|
|
330
|
-
return {
|
|
381
|
+
return <ModalConfig>{
|
|
331
382
|
...{
|
|
332
383
|
title: props.title,
|
|
333
384
|
item: item.value,
|
|
@@ -337,10 +388,13 @@
|
|
|
337
388
|
beforeClose: crudBeforeClose,
|
|
338
389
|
closeConfirm: closeConfirm.value,
|
|
339
390
|
},
|
|
391
|
+
headerActionsButton: props.groupButton !== false ? <ButtonConfig>{
|
|
392
|
+
dot: ableToCreate.value || ableToUpdate.value,
|
|
393
|
+
} : false
|
|
340
394
|
};
|
|
341
395
|
}
|
|
342
396
|
return {};
|
|
343
|
-
})
|
|
397
|
+
})
|
|
344
398
|
</script>
|
|
345
399
|
|
|
346
400
|
<template>
|
|
@@ -358,18 +412,22 @@
|
|
|
358
412
|
:item="item"
|
|
359
413
|
:mode="mode"
|
|
360
414
|
:view="view"
|
|
415
|
+
:grouped="true"
|
|
361
416
|
:button-nav-visibility="buttonNavVisibility"
|
|
362
|
-
:create-button="
|
|
363
|
-
:update-button="
|
|
364
|
-
:drop-button="
|
|
365
|
-
:edit-mode-button="
|
|
366
|
-
:group-button="
|
|
367
|
-
:group-button-as-modal-actions="groupButtonAsModalActions"
|
|
417
|
+
:create-button="safeCreateButton"
|
|
418
|
+
:update-button="safeUpdateButton"
|
|
419
|
+
:drop-button="safeDropButton"
|
|
420
|
+
:edit-mode-button="safeEditModeButton"
|
|
421
|
+
:group-button="safeGroupButton"
|
|
368
422
|
:data-changed="dataChanged"
|
|
369
423
|
:http-success-read="httpSuccessRead"
|
|
370
424
|
:can-update="canUpdate"
|
|
371
425
|
:can-drop="canDrop"
|
|
372
426
|
:can-switch-edit-mode="canSwitchEditMode"
|
|
427
|
+
:group-button-as-modal-actions="groupButtonAsModalActions"
|
|
428
|
+
:able-to-create="ableToCreate"
|
|
429
|
+
:able-to-update="ableToUpdate"
|
|
430
|
+
:able-to-drop="ableToDrop"
|
|
373
431
|
:perms="perms"
|
|
374
432
|
@create="onCreate"
|
|
375
433
|
@save="onUpdate"
|
|
@@ -411,18 +469,22 @@
|
|
|
411
469
|
:item="item"
|
|
412
470
|
:mode="mode"
|
|
413
471
|
:view="view"
|
|
472
|
+
:grouped="groupButton !== false"
|
|
414
473
|
:button-nav-visibility="buttonNavVisibility"
|
|
415
|
-
:create-button="
|
|
416
|
-
:update-button="
|
|
417
|
-
:drop-button="
|
|
418
|
-
:edit-mode-button="
|
|
419
|
-
:group-button="
|
|
474
|
+
:create-button="safeCreateButton"
|
|
475
|
+
:update-button="safeUpdateButton"
|
|
476
|
+
:drop-button="safeDropButton"
|
|
477
|
+
:edit-mode-button="safeEditModeButton"
|
|
478
|
+
:group-button="safeGroupButton"
|
|
420
479
|
:data-changed="dataChanged"
|
|
421
480
|
:http-success-read="httpSuccessRead"
|
|
422
481
|
:can-update="canUpdate"
|
|
423
482
|
:can-drop="canDrop"
|
|
424
483
|
:can-switch-edit-mode="canSwitchEditMode"
|
|
425
484
|
:group-button-as-modal-actions="groupButtonAsModalActions"
|
|
485
|
+
:able-to-create="ableToCreate"
|
|
486
|
+
:able-to-update="ableToUpdate"
|
|
487
|
+
:able-to-drop="ableToDrop"
|
|
426
488
|
:perms="perms"
|
|
427
489
|
@create="onCreate"
|
|
428
490
|
@save="onUpdate"
|
|
@@ -476,18 +538,22 @@
|
|
|
476
538
|
:item="item"
|
|
477
539
|
:mode="mode"
|
|
478
540
|
:view="view"
|
|
541
|
+
:grouped="groupButton !== false"
|
|
479
542
|
:button-nav-visibility="buttonNavVisibility"
|
|
480
|
-
:create-button="
|
|
481
|
-
:update-button="
|
|
482
|
-
:drop-button="
|
|
483
|
-
:edit-mode-button="
|
|
484
|
-
:group-button="
|
|
543
|
+
:create-button="safeCreateButton"
|
|
544
|
+
:update-button="safeUpdateButton"
|
|
545
|
+
:drop-button="safeDropButton"
|
|
546
|
+
:edit-mode-button="safeEditModeButton"
|
|
547
|
+
:group-button="safeGroupButton"
|
|
485
548
|
:data-changed="dataChanged"
|
|
486
549
|
:http-success-read="httpSuccessRead"
|
|
487
550
|
:can-update="canUpdate"
|
|
488
551
|
:can-drop="canDrop"
|
|
489
552
|
:can-switch-edit-mode="canSwitchEditMode"
|
|
490
553
|
:group-button-as-modal-actions="groupButtonAsModalActions"
|
|
554
|
+
:able-to-create="ableToCreate"
|
|
555
|
+
:able-to-update="ableToUpdate"
|
|
556
|
+
:able-to-drop="ableToDrop"
|
|
491
557
|
:perms="perms"
|
|
492
558
|
@create="onCreate"
|
|
493
559
|
@save="onUpdate"
|