lkt-item-crud 2.0.4 → 2.0.6
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 +287 -273
- package/dist/components/ButtonNav.vue.d.ts +317 -205
- package/dist/lib-components/LktItemCrud.vue.d.ts +10 -8
- package/package.json +11 -13
- package/src/components/ButtonNav.vue +17 -9
- package/src/lib-components/LktItemCrud.vue +38 -5
|
@@ -91,10 +91,11 @@ declare const __VLS_self: import("vue").DefineComponent<ItemCrudConfig, {
|
|
|
91
91
|
mode: ItemCrudMode;
|
|
92
92
|
modelValue: LktObject;
|
|
93
93
|
editing: boolean;
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
94
|
+
perms: import("lkt-vue-kernel").ValidTablePermission[];
|
|
95
|
+
editModeButton: import("lkt-vue-kernel").ButtonConfig | false;
|
|
96
|
+
dropButton: import("lkt-vue-kernel").ButtonConfig | false;
|
|
97
|
+
createButton: import("lkt-vue-kernel").ButtonConfig | false;
|
|
98
|
+
updateButton: import("lkt-vue-kernel").ButtonConfig | false;
|
|
98
99
|
buttonNavPosition: ItemCrudButtonNavPosition;
|
|
99
100
|
buttonNavVisibility: import("lkt-vue-kernel").ItemCrudButtonNavVisibility;
|
|
100
101
|
modalConfig: import("lkt-vue-kernel").ModalConfig;
|
|
@@ -138,10 +139,11 @@ declare const __VLS_component: import("vue").DefineComponent<ItemCrudConfig, {
|
|
|
138
139
|
mode: ItemCrudMode;
|
|
139
140
|
modelValue: LktObject;
|
|
140
141
|
editing: boolean;
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
142
|
+
perms: import("lkt-vue-kernel").ValidTablePermission[];
|
|
143
|
+
editModeButton: import("lkt-vue-kernel").ButtonConfig | false;
|
|
144
|
+
dropButton: import("lkt-vue-kernel").ButtonConfig | false;
|
|
145
|
+
createButton: import("lkt-vue-kernel").ButtonConfig | false;
|
|
146
|
+
updateButton: import("lkt-vue-kernel").ButtonConfig | false;
|
|
145
147
|
buttonNavPosition: ItemCrudButtonNavPosition;
|
|
146
148
|
buttonNavVisibility: import("lkt-vue-kernel").ItemCrudButtonNavVisibility;
|
|
147
149
|
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.6",
|
|
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
|
-
"lkt-button": "^2.0.4",
|
|
41
|
-
"lkt-data-state": "^1.0.9",
|
|
42
|
-
"lkt-http-client": "^1.0.12",
|
|
43
|
-
"lkt-http-info": "^1.0.2",
|
|
44
|
-
"lkt-i18n": "^1.0.4",
|
|
45
|
-
"lkt-loader": "^1.0.2",
|
|
46
|
-
"lkt-modal": "^2.0.2",
|
|
47
|
-
"lkt-string-tools": "^1.0.2",
|
|
48
|
-
"lkt-toast": "^1.0.1",
|
|
49
|
-
"lkt-vue-kernel": "^1.0.27"
|
|
50
|
-
},
|
|
51
39
|
"peerDependencies": {
|
|
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,10 +27,10 @@
|
|
|
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
|
|
|
@@ -87,13 +87,16 @@
|
|
|
87
87
|
onButtonLoaded = () => {
|
|
88
88
|
isLoading.value = false;
|
|
89
89
|
},
|
|
90
|
-
onCreate = ($event: Event, r: HTTPResponse) => {
|
|
90
|
+
onCreate = ($event: Event|undefined, r: HTTPResponse) => {
|
|
91
|
+
if (typeof $event === 'undefined') return;
|
|
91
92
|
emit('create', $event, r);
|
|
92
93
|
},
|
|
93
|
-
onSave = ($event: Event, r: HTTPResponse) => {
|
|
94
|
+
onSave = ($event: Event|undefined, r: HTTPResponse) => {
|
|
95
|
+
if (typeof $event === 'undefined') return;
|
|
94
96
|
emit('save', $event, r);
|
|
95
97
|
},
|
|
96
|
-
onDrop = ($event: Event, r: HTTPResponse) => {
|
|
98
|
+
onDrop = ($event: Event|undefined, r: HTTPResponse) => {
|
|
99
|
+
if (typeof $event === 'undefined') return;
|
|
97
100
|
emit('drop', $event, r);
|
|
98
101
|
};
|
|
99
102
|
|
|
@@ -138,7 +141,7 @@
|
|
|
138
141
|
return true;
|
|
139
142
|
}),
|
|
140
143
|
showDropButton = computed(() => {
|
|
141
|
-
if (!props.canDrop) return false;
|
|
144
|
+
if (!props.canDrop || props.dropButton === false) return false;
|
|
142
145
|
if (!props.canUpdate && props.canDrop) return true;
|
|
143
146
|
|
|
144
147
|
return !isLoading.value
|
|
@@ -146,10 +149,14 @@
|
|
|
146
149
|
&& props.httpSuccessRead;
|
|
147
150
|
}),
|
|
148
151
|
showSaveButton = computed(() => {
|
|
152
|
+
if (props.mode === ItemCrudMode.Create && props.createButton === false) return false;
|
|
153
|
+
if (props.mode === ItemCrudMode.Update && props.updateButton === false) return false;
|
|
149
154
|
if (props.dataChanged) return true;
|
|
150
155
|
if (isLoading.value) return false;
|
|
151
156
|
|
|
152
|
-
if (props.mode === ItemCrudMode.Create)
|
|
157
|
+
if (props.mode === ItemCrudMode.Create) {
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
153
160
|
|
|
154
161
|
if (props.buttonNavVisibility === ItemCrudButtonNavVisibility.Never) {
|
|
155
162
|
return false;
|
|
@@ -159,6 +166,7 @@
|
|
|
159
166
|
&& props.httpSuccessRead;
|
|
160
167
|
}),
|
|
161
168
|
showSwitchButton = computed(() => {
|
|
169
|
+
if (props.editModeButton === false) return false;
|
|
162
170
|
if (!props.canSwitchEditMode) return false;
|
|
163
171
|
if (!props.canUpdate && !props.canDrop) return false;
|
|
164
172
|
if (!props.canUpdate && props.canDrop) return false;
|
|
@@ -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) => {
|
|
@@ -187,6 +196,14 @@
|
|
|
187
196
|
itemCreated.value = true;
|
|
188
197
|
debug('onCreate -> turn stored data into original');
|
|
189
198
|
dataState.value.increment(item.value).turnStoredIntoOriginal();
|
|
199
|
+
if (props.notificationType === NotificationType.Toast) {
|
|
200
|
+
openToast(<ToastConfig>{
|
|
201
|
+
text: LktSettings.defaultCreateSuccessText,
|
|
202
|
+
details: LktSettings.defaultCreateSuccessDetails,
|
|
203
|
+
icon: LktSettings.defaultCreateSuccessIcon,
|
|
204
|
+
positionX: ToastPositionX.Right,
|
|
205
|
+
});
|
|
206
|
+
}
|
|
190
207
|
doAutoReloadId(r);
|
|
191
208
|
emit('create', r);
|
|
192
209
|
},
|
|
@@ -205,6 +222,14 @@
|
|
|
205
222
|
}
|
|
206
223
|
debug('onUpdate -> turn stored data into original');
|
|
207
224
|
dataState.value.turnStoredIntoOriginal();
|
|
225
|
+
if (props.notificationType === NotificationType.Toast) {
|
|
226
|
+
openToast(<ToastConfig>{
|
|
227
|
+
text: LktSettings.defaultUpdateSuccessText,
|
|
228
|
+
details: LktSettings.defaultUpdateSuccessDetails,
|
|
229
|
+
icon: LktSettings.defaultUpdateSuccessIcon,
|
|
230
|
+
positionX: ToastPositionX.Right,
|
|
231
|
+
});
|
|
232
|
+
}
|
|
208
233
|
doAutoReloadId(r);
|
|
209
234
|
emit('update', r);
|
|
210
235
|
},
|
|
@@ -221,6 +246,14 @@
|
|
|
221
246
|
}
|
|
222
247
|
return;
|
|
223
248
|
}
|
|
249
|
+
if (props.notificationType === NotificationType.Toast) {
|
|
250
|
+
openToast(<ToastConfig>{
|
|
251
|
+
text: LktSettings.defaultDropSuccessText,
|
|
252
|
+
details: LktSettings.defaultDropSuccessDetails,
|
|
253
|
+
icon: LktSettings.defaultDropSuccessIcon,
|
|
254
|
+
positionX: ToastPositionX.Right,
|
|
255
|
+
});
|
|
256
|
+
}
|
|
224
257
|
emit('drop', r);
|
|
225
258
|
if (props.view === ItemCrudView.Modal) {
|
|
226
259
|
debug('onDrop -> close modal');
|
|
@@ -286,8 +319,8 @@
|
|
|
286
319
|
},
|
|
287
320
|
...props.modalConfig,
|
|
288
321
|
...{
|
|
289
|
-
|
|
290
|
-
|
|
322
|
+
beforeClose: crudBeforeClose,
|
|
323
|
+
closeConfirm: closeConfirm.value,
|
|
291
324
|
},
|
|
292
325
|
};
|
|
293
326
|
}
|