lkt-item-crud 2.0.5 → 2.0.7
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 +284 -267
- package/dist/components/ButtonNav.vue.d.ts +326 -205
- package/dist/lib-components/LktItemCrud.vue.d.ts +21 -10
- package/package.json +11 -13
- package/src/components/ButtonNav.vue +26 -10
- package/src/lib-components/LktItemCrud.vue +27 -9
|
@@ -3,7 +3,7 @@ import { HTTPResponse } from 'lkt-http-client';
|
|
|
3
3
|
import { ItemCrudButtonNavPosition, ItemCrudConfig, ItemCrudMode, ItemCrudView, LktObject, NotificationType } from 'lkt-vue-kernel';
|
|
4
4
|
import ButtonNav from '../components/ButtonNav.vue';
|
|
5
5
|
declare const slots: SetupContext['slots'];
|
|
6
|
-
declare const isLoading: import("vue").Ref<boolean, boolean>, item: import("vue").Ref<LktObject, LktObject>, editMode: import("vue").Ref<boolean, boolean>, httpSuccessRead: import("vue").Ref<boolean, boolean>, showStoreMessage: import("vue").Ref<boolean, boolean>, httpStatus: import("vue").Ref<number, number>, dataChanged: import("vue").Ref<boolean, boolean>, createMode: import("vue").Ref<boolean, boolean>, itemBeingEdited: import("vue").Ref<boolean, boolean>, buttonNav: import("vue").Ref<null, null>, canUpdate: import("vue").ComputedRef<boolean>, canDrop: import("vue").ComputedRef<boolean>, canSwitchEditMode: import("vue").ComputedRef<boolean>;
|
|
6
|
+
declare const isLoading: import("vue").Ref<boolean, boolean>, item: import("vue").Ref<LktObject, LktObject>, perms: import("vue").Ref<string[], string[]>, editMode: import("vue").Ref<boolean, boolean>, httpSuccessRead: import("vue").Ref<boolean, boolean>, showStoreMessage: import("vue").Ref<boolean, boolean>, httpStatus: import("vue").Ref<number, number>, dataChanged: import("vue").Ref<boolean, boolean>, createMode: import("vue").Ref<boolean, boolean>, itemBeingEdited: import("vue").Ref<boolean, boolean>, buttonNav: import("vue").Ref<null, null>, canUpdate: import("vue").ComputedRef<boolean>, canDrop: import("vue").ComputedRef<boolean>, canSwitchEditMode: import("vue").ComputedRef<boolean>;
|
|
7
7
|
declare const onCreate: ($event: PointerEvent, r: HTTPResponse) => void, onUpdate: ($event: PointerEvent, r: HTTPResponse) => void, onDrop: ($event: PointerEvent, r: HTTPResponse) => void;
|
|
8
8
|
declare const computedTitle: import("vue").ComputedRef<string>, displayHeader: import("vue").ComputedRef<boolean>, computedInsideModal: import("vue").ComputedRef<boolean>, computedContainerTag: import("vue").ComputedRef<"lkt-modal" | "section">, computedContainerAttrs: import("vue").ComputedRef<{}>;
|
|
9
9
|
declare const __VLS_ctx: InstanceType<__VLS_PickNotAny<typeof __VLS_self, new () => {}>>;
|
|
@@ -13,7 +13,15 @@ declare var __VLS_6: {
|
|
|
13
13
|
}, __VLS_8: {
|
|
14
14
|
item: LktObject;
|
|
15
15
|
loading: boolean;
|
|
16
|
-
}, __VLS_21: {
|
|
16
|
+
}, __VLS_21: {
|
|
17
|
+
canUpdate: boolean | undefined;
|
|
18
|
+
canDrop: boolean | undefined;
|
|
19
|
+
perms: string[] | undefined;
|
|
20
|
+
}, __VLS_23: {
|
|
21
|
+
canUpdate: boolean | undefined;
|
|
22
|
+
canDrop: boolean | undefined;
|
|
23
|
+
perms: string[] | undefined;
|
|
24
|
+
}, __VLS_33: {
|
|
17
25
|
item: LktObject;
|
|
18
26
|
loading: false;
|
|
19
27
|
editMode: boolean;
|
|
@@ -44,6 +52,7 @@ declare const __VLS_self: import("vue").DefineComponent<ItemCrudConfig, {
|
|
|
44
52
|
slots: typeof slots;
|
|
45
53
|
isLoading: typeof isLoading;
|
|
46
54
|
item: typeof item;
|
|
55
|
+
perms: typeof perms;
|
|
47
56
|
editMode: typeof editMode;
|
|
48
57
|
httpSuccessRead: typeof httpSuccessRead;
|
|
49
58
|
showStoreMessage: typeof showStoreMessage;
|
|
@@ -91,10 +100,11 @@ declare const __VLS_self: import("vue").DefineComponent<ItemCrudConfig, {
|
|
|
91
100
|
mode: ItemCrudMode;
|
|
92
101
|
modelValue: LktObject;
|
|
93
102
|
editing: boolean;
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
103
|
+
perms: import("lkt-vue-kernel").ValidTablePermission[];
|
|
104
|
+
editModeButton: import("lkt-vue-kernel").ButtonConfig | false;
|
|
105
|
+
dropButton: import("lkt-vue-kernel").ButtonConfig | false;
|
|
106
|
+
createButton: import("lkt-vue-kernel").ButtonConfig | false;
|
|
107
|
+
updateButton: import("lkt-vue-kernel").ButtonConfig | false;
|
|
98
108
|
buttonNavPosition: ItemCrudButtonNavPosition;
|
|
99
109
|
buttonNavVisibility: import("lkt-vue-kernel").ItemCrudButtonNavVisibility;
|
|
100
110
|
modalConfig: import("lkt-vue-kernel").ModalConfig;
|
|
@@ -138,10 +148,11 @@ declare const __VLS_component: import("vue").DefineComponent<ItemCrudConfig, {
|
|
|
138
148
|
mode: ItemCrudMode;
|
|
139
149
|
modelValue: LktObject;
|
|
140
150
|
editing: boolean;
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
151
|
+
perms: import("lkt-vue-kernel").ValidTablePermission[];
|
|
152
|
+
editModeButton: import("lkt-vue-kernel").ButtonConfig | false;
|
|
153
|
+
dropButton: import("lkt-vue-kernel").ButtonConfig | false;
|
|
154
|
+
createButton: import("lkt-vue-kernel").ButtonConfig | false;
|
|
155
|
+
updateButton: import("lkt-vue-kernel").ButtonConfig | false;
|
|
145
156
|
buttonNavPosition: ItemCrudButtonNavPosition;
|
|
146
157
|
buttonNavVisibility: import("lkt-vue-kernel").ItemCrudButtonNavVisibility;
|
|
147
158
|
modalConfig: import("lkt-vue-kernel").ModalConfig;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lkt-item-crud",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.7",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./dist/build.js",
|
|
@@ -36,19 +36,17 @@
|
|
|
36
36
|
"vue": "^3.3.0",
|
|
37
37
|
"vue-tsc": "^2.2.0"
|
|
38
38
|
},
|
|
39
|
-
"dependencies": {
|
|
40
|
-
},
|
|
41
39
|
"peerDependencies": {
|
|
42
|
-
"lkt-button": "^2.0.
|
|
43
|
-
"lkt-data-state": "^1.0.
|
|
44
|
-
"lkt-http-client": "^1.0.
|
|
45
|
-
"lkt-http-info": "^1.
|
|
46
|
-
"lkt-i18n": "^1.0
|
|
47
|
-
"lkt-loader": "^1.0
|
|
48
|
-
"lkt-modal": "^2.0.
|
|
49
|
-
"lkt-string-tools": "^1.0
|
|
50
|
-
"lkt-toast": "^1.
|
|
51
|
-
"lkt-vue-kernel": "^1.0.
|
|
40
|
+
"lkt-button": "^2.0.12",
|
|
41
|
+
"lkt-data-state": "^1.0.11",
|
|
42
|
+
"lkt-http-client": "^1.0.34",
|
|
43
|
+
"lkt-http-info": "^1.1.1",
|
|
44
|
+
"lkt-i18n": "^1.1.0",
|
|
45
|
+
"lkt-loader": "^1.2.0",
|
|
46
|
+
"lkt-modal": "^2.0.5",
|
|
47
|
+
"lkt-string-tools": "^1.1.0",
|
|
48
|
+
"lkt-toast": "^1.1.1",
|
|
49
|
+
"lkt-vue-kernel": "^1.0.48",
|
|
52
50
|
"vue": "^3.3.0"
|
|
53
51
|
}
|
|
54
52
|
}
|
|
@@ -27,16 +27,17 @@
|
|
|
27
27
|
view: ItemCrudView
|
|
28
28
|
mode: ItemCrudMode
|
|
29
29
|
|
|
30
|
-
createButton?: ButtonConfig
|
|
31
|
-
updateButton?: ButtonConfig
|
|
32
|
-
dropButton?: ButtonConfig
|
|
33
|
-
editModeButton?: ButtonConfig
|
|
30
|
+
createButton?: ButtonConfig|false
|
|
31
|
+
updateButton?: ButtonConfig|false
|
|
32
|
+
dropButton?: ButtonConfig|false
|
|
33
|
+
editModeButton?: ButtonConfig|false
|
|
34
34
|
|
|
35
35
|
dataChanged: boolean
|
|
36
36
|
|
|
37
37
|
canUpdate?: boolean
|
|
38
38
|
canDrop?: boolean
|
|
39
39
|
canSwitchEditMode?: boolean
|
|
40
|
+
perms?: Array<string>
|
|
40
41
|
|
|
41
42
|
httpSuccessRead?: boolean
|
|
42
43
|
|
|
@@ -114,7 +115,7 @@
|
|
|
114
115
|
|
|
115
116
|
|
|
116
117
|
const ableToUpdate = computed(() => {
|
|
117
|
-
if (props.mode !== ItemCrudMode.
|
|
118
|
+
if (props.mode !== ItemCrudMode.Update || !props.canUpdate) return false;
|
|
118
119
|
if (!props.dataChanged) return false;
|
|
119
120
|
|
|
120
121
|
if (typeof safeUpdateButton.value?.disabled === 'function') return !safeUpdateButton.value.disabled(props.item);
|
|
@@ -141,7 +142,7 @@
|
|
|
141
142
|
return true;
|
|
142
143
|
}),
|
|
143
144
|
showDropButton = computed(() => {
|
|
144
|
-
if (!props.canDrop) return false;
|
|
145
|
+
if (!props.canDrop || props.dropButton === false) return false;
|
|
145
146
|
if (!props.canUpdate && props.canDrop) return true;
|
|
146
147
|
|
|
147
148
|
return !isLoading.value
|
|
@@ -149,10 +150,16 @@
|
|
|
149
150
|
&& props.httpSuccessRead;
|
|
150
151
|
}),
|
|
151
152
|
showSaveButton = computed(() => {
|
|
152
|
-
if (props.
|
|
153
|
+
if (props.mode === ItemCrudMode.Create && props.createButton === false) return false;
|
|
154
|
+
if (props.mode === ItemCrudMode.Update && props.updateButton === false) return false;
|
|
155
|
+
if (props.dataChanged) {
|
|
156
|
+
return ableToUpdate.value || ableToCreate.value;
|
|
157
|
+
}
|
|
153
158
|
if (isLoading.value) return false;
|
|
154
159
|
|
|
155
|
-
if (props.mode === ItemCrudMode.Create)
|
|
160
|
+
if (props.mode === ItemCrudMode.Create) {
|
|
161
|
+
return true;
|
|
162
|
+
}
|
|
156
163
|
|
|
157
164
|
if (props.buttonNavVisibility === ItemCrudButtonNavVisibility.Never) {
|
|
158
165
|
return false;
|
|
@@ -162,6 +169,7 @@
|
|
|
162
169
|
&& props.httpSuccessRead;
|
|
163
170
|
}),
|
|
164
171
|
showSwitchButton = computed(() => {
|
|
172
|
+
if (props.editModeButton === false) return false;
|
|
165
173
|
if (!props.canSwitchEditMode) return false;
|
|
166
174
|
if (!props.canUpdate && !props.canDrop) return false;
|
|
167
175
|
if (!props.canUpdate && props.canDrop) return false;
|
|
@@ -183,11 +191,19 @@
|
|
|
183
191
|
<div v-if="showButtons" class="lkt-item-crud-buttons">
|
|
184
192
|
|
|
185
193
|
<div class="lkt-item-crud-buttons" v-if="slots['prev-buttons-ever']" v-show="!isLoading">
|
|
186
|
-
<slot name="prev-buttons-ever"
|
|
194
|
+
<slot name="prev-buttons-ever"
|
|
195
|
+
:can-update="canUpdate"
|
|
196
|
+
:can-drop="canDrop"
|
|
197
|
+
:perms="perms"
|
|
198
|
+
/>
|
|
187
199
|
</div>
|
|
188
200
|
|
|
189
201
|
<div class="lkt-item-crud-buttons" v-if="slots['prev-buttons']" v-show="isEditing && !isLoading">
|
|
190
|
-
<slot name="prev-buttons"
|
|
202
|
+
<slot name="prev-buttons"
|
|
203
|
+
:can-update="canUpdate"
|
|
204
|
+
:can-drop="canDrop"
|
|
205
|
+
:perms="perms"
|
|
206
|
+
/>
|
|
191
207
|
</div>
|
|
192
208
|
|
|
193
209
|
<lkt-button
|
|
@@ -22,6 +22,9 @@
|
|
|
22
22
|
import ButtonNav from '../components/ButtonNav.vue';
|
|
23
23
|
import { openToast } from 'lkt-toast';
|
|
24
24
|
|
|
25
|
+
// defineOptions({
|
|
26
|
+
// inheritAttrs: false
|
|
27
|
+
// })
|
|
25
28
|
|
|
26
29
|
const props = withDefaults(defineProps<ItemCrudConfig>(), getDefaultValues(ItemCrud));
|
|
27
30
|
|
|
@@ -40,11 +43,9 @@
|
|
|
40
43
|
'modified-data',
|
|
41
44
|
]);
|
|
42
45
|
|
|
43
|
-
let basePerms: string[] = [];
|
|
44
|
-
|
|
45
46
|
const isLoading = ref(true),
|
|
46
47
|
item = ref(props.modelValue),
|
|
47
|
-
perms = ref(
|
|
48
|
+
perms = ref(props.perms),
|
|
48
49
|
editMode = ref(props.editing),
|
|
49
50
|
httpSuccessRead = ref(false),
|
|
50
51
|
showStoreMessage = ref(false),
|
|
@@ -145,6 +146,14 @@
|
|
|
145
146
|
dataState.value.increment(item.value).turnStoredIntoOriginal();
|
|
146
147
|
dataChanged.value = dataState.value.changed();
|
|
147
148
|
}
|
|
149
|
+
// Offline mode
|
|
150
|
+
else {
|
|
151
|
+
httpSuccessRead.value = true;
|
|
152
|
+
editMode.value = true;
|
|
153
|
+
isLoading.value = false;
|
|
154
|
+
dataState.value.increment(item.value).turnStoredIntoOriginal();
|
|
155
|
+
dataChanged.value = dataState.value.changed();
|
|
156
|
+
}
|
|
148
157
|
});
|
|
149
158
|
|
|
150
159
|
const ensureValidResourceSave = (r: HTTPResponse, resource?: string) => {
|
|
@@ -310,8 +319,8 @@
|
|
|
310
319
|
},
|
|
311
320
|
...props.modalConfig,
|
|
312
321
|
...{
|
|
313
|
-
|
|
314
|
-
|
|
322
|
+
beforeClose: crudBeforeClose,
|
|
323
|
+
closeConfirm: closeConfirm.value,
|
|
315
324
|
},
|
|
316
325
|
};
|
|
317
326
|
}
|
|
@@ -353,15 +362,24 @@
|
|
|
353
362
|
:can-update="canUpdate"
|
|
354
363
|
:can-drop="canDrop"
|
|
355
364
|
:can-switch-edit-mode="canSwitchEditMode"
|
|
365
|
+
:perms="perms"
|
|
356
366
|
@create="onCreate"
|
|
357
367
|
@save="onUpdate"
|
|
358
368
|
@drop="onDrop"
|
|
359
369
|
>
|
|
360
|
-
<template #prev-buttons-ever v-if="slots['prev-buttons-ever']">
|
|
361
|
-
<slot name="prev-buttons-ever"
|
|
370
|
+
<template #prev-buttons-ever="{canUpdate, canDrop, perms}" v-if="slots['prev-buttons-ever']">
|
|
371
|
+
<slot name="prev-buttons-ever"
|
|
372
|
+
:can-update="canUpdate"
|
|
373
|
+
:can-drop="canDrop"
|
|
374
|
+
:perms="perms"
|
|
375
|
+
/>
|
|
362
376
|
</template>
|
|
363
|
-
<template #prev-buttons-ever v-if="slots['prev-buttons']">
|
|
364
|
-
<slot name="prev-buttons"
|
|
377
|
+
<template #prev-buttons-ever="{canUpdate, canDrop, perms}" v-if="slots['prev-buttons']">
|
|
378
|
+
<slot name="prev-buttons"
|
|
379
|
+
:can-update="canUpdate"
|
|
380
|
+
:can-drop="canDrop"
|
|
381
|
+
:perms="perms"
|
|
382
|
+
/>
|
|
365
383
|
</template>
|
|
366
384
|
</button-nav>
|
|
367
385
|
|