lkt-item-crud 1.1.4 → 1.1.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 +3 -3
- package/dist/build.js +111 -111
- package/dist/lib-components/LktItemCrud.vue.d.ts +5 -3
- package/package.json +1 -1
- package/src/lib-components/LktItemCrud.vue +28 -22
package/dist/build.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
2
|
-
declare namespace
|
|
3
|
-
function install(
|
|
1
|
+
export { _e as default };
|
|
2
|
+
declare namespace _e {
|
|
3
|
+
function install(o: any, I?: {}): void;
|
|
4
4
|
}
|
package/dist/build.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { httpCall as
|
|
3
|
-
import { DataState as
|
|
4
|
-
const
|
|
1
|
+
import { defineComponent as oe, useSlots as re, ref as s, computed as d, watch as k, resolveComponent as w, openBlock as c, createElementBlock as y, createElementVNode as j, toDisplayString as U, renderSlot as O, createCommentVNode as D, withDirectives as R, createBlock as V, withCtx as H, unref as P, vShow as q, createVNode as z } from "vue";
|
|
2
|
+
import { httpCall as de } from "lkt-http-client";
|
|
3
|
+
import { DataState as ne } from "lkt-data-state";
|
|
4
|
+
const se = { class: "lkt-item-crud" }, ie = {
|
|
5
5
|
key: 0,
|
|
6
6
|
class: "lkt-item-crud_header"
|
|
7
|
-
},
|
|
7
|
+
}, ce = { class: "lkt-item-crud_header-title" }, ve = { class: "lkt-item-crud_header-slot" }, fe = { class: "lkt-item-crud-buttons" }, pe = { key: 1 }, me = { key: 1 }, ye = {
|
|
8
8
|
key: 1,
|
|
9
9
|
class: "lkt-item-crud_content"
|
|
10
|
-
},
|
|
10
|
+
}, he = {
|
|
11
11
|
key: 0,
|
|
12
12
|
class: "lkt-grid-1"
|
|
13
|
-
},
|
|
14
|
-
...
|
|
13
|
+
}, Se = { name: "LktItemCrud", inheritAttrs: !1 }, ke = /* @__PURE__ */ oe({
|
|
14
|
+
...Se,
|
|
15
15
|
props: {
|
|
16
16
|
modelValue: { type: Object, required: !1, default: () => ({}) },
|
|
17
17
|
title: { type: String, default: "" },
|
|
@@ -43,170 +43,170 @@ const ne = { class: "lkt-item-crud" }, se = {
|
|
|
43
43
|
onCreate: { type: Function, required: !1, default: () => !0 },
|
|
44
44
|
onUpdate: { type: Function, required: !1, default: () => !0 }
|
|
45
45
|
},
|
|
46
|
-
emits: ["update:modelValue", "read", "create", "update", "drop", "perms", "error", "modified-data"],
|
|
47
|
-
setup(
|
|
48
|
-
const e =
|
|
49
|
-
let
|
|
50
|
-
const l = s(!0), r = s(e.modelValue),
|
|
51
|
-
l.value = !0,
|
|
46
|
+
emits: ["update:modelValue", "update:isCreate", "read", "create", "update", "drop", "perms", "error", "modified-data"],
|
|
47
|
+
setup(o, { expose: I, emit: G }) {
|
|
48
|
+
const e = o, L = re(), n = G;
|
|
49
|
+
let K = [];
|
|
50
|
+
const l = s(!0), r = s(e.modelValue), h = s(K), v = s(!1), f = s(!1), p = s(!1), i = s(200), C = s(null), b = s(null), S = s(new ne(r.value)), a = s(a.value), Q = d(() => a.value ? e.createConfirm : e.updateConfirm), W = d(() => a.value ? e.createConfirmData : e.updateConfirmData), N = d(() => a.value ? e.createResource : e.updateResource), X = d(() => a.value ? { ...e.createData, ...JSON.parse(JSON.stringify(r.value)) } : { ...e.updateData, ...JSON.parse(JSON.stringify(r.value)) }), Y = d(() => a.value ? e.createDisabled : e.updateDisabled), g = d(() => !a.value && h.value.includes("update")), B = d(() => !a.value && h.value.includes("drop")), M = async () => {
|
|
51
|
+
l.value = !0, i.value = -1, p.value = !1;
|
|
52
52
|
try {
|
|
53
|
-
const t = await
|
|
54
|
-
if (l.value = !1,
|
|
55
|
-
f.value = !1,
|
|
53
|
+
const t = await de(e.readResource, e.readData);
|
|
54
|
+
if (l.value = !1, i.value = t.httpStatus, !t.success) {
|
|
55
|
+
f.value = !1, i.value = t.httpStatus, n("error", t.httpStatus);
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
58
|
-
f.value = !0, r.value = t.data,
|
|
58
|
+
f.value = !0, r.value = t.data, h.value = t.perms, S.value.increment(r.value).turnStoredIntoOriginal(), n("read", t);
|
|
59
59
|
} catch {
|
|
60
|
-
l.value = !1, f.value = !1,
|
|
60
|
+
l.value = !1, f.value = !1, i.value = 404, n("error", 404);
|
|
61
61
|
return;
|
|
62
62
|
}
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
r.value = t,
|
|
66
|
-
}, { deep: !0 }),
|
|
67
|
-
|
|
68
|
-
}, { deep: !0 }),
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
const
|
|
72
|
-
if (l.value = !1,
|
|
73
|
-
|
|
63
|
+
}, Z = d(() => l.value ? !1 : e.title || !!L["post-title"]);
|
|
64
|
+
k(() => e.modelValue, (t) => {
|
|
65
|
+
r.value = t, S.value.increment(t);
|
|
66
|
+
}, { deep: !0 }), k(r, (t) => {
|
|
67
|
+
n("update:modelValue", r.value), S.value.increment(t);
|
|
68
|
+
}, { deep: !0 }), k(h, () => n("perms", h.value));
|
|
69
|
+
const T = d(() => Y.value || !a.value && !g.value || typeof e.saveValidator == "function" && !e.saveValidator(r.value) ? !1 : S.value.changed());
|
|
70
|
+
k(T, (t) => n("modified-data", t)), k(a, (t) => n("update:isCreate", t)), e.readResource && !a.value ? M() : a.value && (f.value = !0, v.value = !0, l.value = !1);
|
|
71
|
+
const ee = (t, u) => {
|
|
72
|
+
if (l.value = !1, i.value = u.httpStatus, !u.success) {
|
|
73
|
+
p.value = !0, n("error", u.httpStatus);
|
|
74
74
|
return;
|
|
75
75
|
}
|
|
76
|
-
|
|
77
|
-
},
|
|
78
|
-
if (
|
|
79
|
-
if (l.value = !1,
|
|
80
|
-
|
|
76
|
+
p.value = !0, n("drop", u);
|
|
77
|
+
}, te = (t, u) => {
|
|
78
|
+
if (N.value) {
|
|
79
|
+
if (l.value = !1, i.value = u.httpStatus, !u.success) {
|
|
80
|
+
p.value = !0, n("error", u.httpStatus);
|
|
81
81
|
return;
|
|
82
82
|
}
|
|
83
|
-
|
|
83
|
+
p.value = !0;
|
|
84
84
|
}
|
|
85
|
-
let
|
|
86
|
-
|
|
87
|
-
}, T = () => {
|
|
88
|
-
l.value = !0, n.value = -1;
|
|
85
|
+
let _ = a.value ? "create" : "update";
|
|
86
|
+
a.value || S.value.turnStoredIntoOriginal(), u.autoReloadId && (e.readData.id = u.autoReloadId, a.value = !1, M()), a.value ? typeof e.onCreate == "function" && e.onCreate() : typeof e.onUpdate == "function" && e.onUpdate(), n(_, u);
|
|
89
87
|
}, $ = () => {
|
|
88
|
+
l.value = !0, i.value = -1;
|
|
89
|
+
}, x = () => {
|
|
90
90
|
l.value = !1;
|
|
91
91
|
};
|
|
92
|
-
|
|
92
|
+
I({
|
|
93
93
|
doDrop: () => {
|
|
94
|
-
|
|
94
|
+
b.value && typeof b.value.click == "function" && b.value.click();
|
|
95
95
|
},
|
|
96
|
-
doRefresh:
|
|
96
|
+
doRefresh: M,
|
|
97
97
|
doSave: () => {
|
|
98
|
-
|
|
98
|
+
C.value && typeof C.value.click == "function" && C.value.click();
|
|
99
99
|
}
|
|
100
100
|
});
|
|
101
|
-
const
|
|
101
|
+
const J = d(() => !e.hiddenDrop && !l.value && v.value && f.value), E = d(() => l.value ? !1 : a.value ? !0 : !e.hiddenSave && v.value && f.value), F = d(() => !l.value && !a.value && f.value), ae = d(() => !e.hiddenButtons && (E.value || J.value || F.value));
|
|
102
102
|
return (t, u) => {
|
|
103
|
-
const
|
|
104
|
-
return
|
|
105
|
-
|
|
106
|
-
j("h1",
|
|
107
|
-
j("div",
|
|
103
|
+
const _ = w("lkt-button"), le = w("lkt-field-switch"), A = w("lkt-http-info"), ue = w("lkt-loader");
|
|
104
|
+
return c(), y("article", se, [
|
|
105
|
+
Z.value ? (c(), y("header", ie, [
|
|
106
|
+
j("h1", ce, U(o.title), 1),
|
|
107
|
+
j("div", ve, [
|
|
108
108
|
O(t.$slots, "post-title", {
|
|
109
109
|
item: r.value,
|
|
110
110
|
loading: l.value
|
|
111
111
|
})
|
|
112
112
|
])
|
|
113
|
-
])) :
|
|
113
|
+
])) : D("", !0),
|
|
114
114
|
R(j("div", fe, [
|
|
115
|
-
a.
|
|
115
|
+
a.value ? D("", !0) : R((c(), V(_, {
|
|
116
116
|
key: 0,
|
|
117
|
-
ref: (
|
|
117
|
+
ref: (m) => b.value = m,
|
|
118
118
|
palette: "danger",
|
|
119
|
-
disabled:
|
|
120
|
-
"confirm-modal":
|
|
121
|
-
"confirm-data":
|
|
122
|
-
resource:
|
|
123
|
-
"resource-data":
|
|
124
|
-
onLoading:
|
|
125
|
-
onLoaded:
|
|
126
|
-
onClick:
|
|
119
|
+
disabled: o.dropDisabled || !B.value,
|
|
120
|
+
"confirm-modal": o.dropConfirm,
|
|
121
|
+
"confirm-data": o.dropConfirmData,
|
|
122
|
+
resource: o.dropResource,
|
|
123
|
+
"resource-data": o.dropData,
|
|
124
|
+
onLoading: $,
|
|
125
|
+
onLoaded: x,
|
|
126
|
+
onClick: ee
|
|
127
127
|
}, {
|
|
128
|
-
default:
|
|
129
|
-
|
|
128
|
+
default: H(() => [
|
|
129
|
+
P(L)["button-drop"] ? O(t.$slots, "button-drop", {
|
|
130
130
|
key: 0,
|
|
131
131
|
item: r.value,
|
|
132
|
-
editMode:
|
|
133
|
-
isCreate: a.
|
|
134
|
-
canUpdate:
|
|
135
|
-
canDrop:
|
|
136
|
-
}) : (
|
|
132
|
+
editMode: v.value,
|
|
133
|
+
isCreate: a.value,
|
|
134
|
+
canUpdate: g.value,
|
|
135
|
+
canDrop: B.value
|
|
136
|
+
}) : (c(), y("span", pe, U(o.dropText), 1))
|
|
137
137
|
]),
|
|
138
138
|
_: 3
|
|
139
139
|
}, 8, ["disabled", "confirm-modal", "confirm-data", "resource", "resource-data"])), [
|
|
140
|
-
[q,
|
|
140
|
+
[q, J.value]
|
|
141
141
|
]),
|
|
142
|
-
R(
|
|
143
|
-
ref: (
|
|
142
|
+
R(z(_, {
|
|
143
|
+
ref: (m) => C.value = m,
|
|
144
144
|
palette: "success",
|
|
145
|
-
disabled: !
|
|
146
|
-
"confirm-modal":
|
|
147
|
-
"confirm-data":
|
|
148
|
-
resource:
|
|
149
|
-
"resource-data":
|
|
150
|
-
onLoading:
|
|
151
|
-
onLoaded:
|
|
152
|
-
onClick:
|
|
145
|
+
disabled: !T.value,
|
|
146
|
+
"confirm-modal": Q.value,
|
|
147
|
+
"confirm-data": W.value,
|
|
148
|
+
resource: N.value,
|
|
149
|
+
"resource-data": X.value,
|
|
150
|
+
onLoading: $,
|
|
151
|
+
onLoaded: x,
|
|
152
|
+
onClick: te
|
|
153
153
|
}, {
|
|
154
|
-
default:
|
|
155
|
-
|
|
154
|
+
default: H(() => [
|
|
155
|
+
P(L)["button-save"] ? O(t.$slots, "button-save", {
|
|
156
156
|
key: 0,
|
|
157
157
|
item: r.value,
|
|
158
|
-
editMode:
|
|
159
|
-
isCreate: a.
|
|
160
|
-
canUpdate:
|
|
161
|
-
canDrop:
|
|
162
|
-
}) : (
|
|
158
|
+
editMode: v.value,
|
|
159
|
+
isCreate: a.value,
|
|
160
|
+
canUpdate: g.value,
|
|
161
|
+
canDrop: B.value
|
|
162
|
+
}) : (c(), y("span", me, U(o.saveText), 1))
|
|
163
163
|
]),
|
|
164
164
|
_: 3
|
|
165
165
|
}, 8, ["disabled", "confirm-modal", "confirm-data", "resource", "resource-data"]), [
|
|
166
|
-
[q,
|
|
166
|
+
[q, E.value]
|
|
167
167
|
]),
|
|
168
|
-
R(
|
|
169
|
-
modelValue:
|
|
170
|
-
"onUpdate:modelValue": u[0] || (u[0] = (
|
|
171
|
-
label:
|
|
168
|
+
R(z(le, {
|
|
169
|
+
modelValue: v.value,
|
|
170
|
+
"onUpdate:modelValue": u[0] || (u[0] = (m) => v.value = m),
|
|
171
|
+
label: o.editModeText
|
|
172
172
|
}, null, 8, ["modelValue", "label"]), [
|
|
173
|
-
[q,
|
|
173
|
+
[q, F.value]
|
|
174
174
|
])
|
|
175
175
|
], 512), [
|
|
176
|
-
[q,
|
|
176
|
+
[q, ae.value]
|
|
177
177
|
]),
|
|
178
|
-
l.value ?
|
|
179
|
-
f.value ? (
|
|
180
|
-
|
|
178
|
+
l.value ? D("", !0) : (c(), y("div", ye, [
|
|
179
|
+
f.value ? (c(), y("div", he, [
|
|
180
|
+
p.value ? (c(), V(A, {
|
|
181
181
|
key: 0,
|
|
182
|
-
code:
|
|
182
|
+
code: i.value,
|
|
183
183
|
quick: "",
|
|
184
|
-
palette:
|
|
184
|
+
palette: i.value === 200 ? "success" : "danger",
|
|
185
185
|
"can-close": "",
|
|
186
|
-
onClose: u[1] || (u[1] = (
|
|
187
|
-
}, null, 8, ["code", "palette"])) :
|
|
186
|
+
onClose: u[1] || (u[1] = (m) => p.value = !1)
|
|
187
|
+
}, null, 8, ["code", "palette"])) : D("", !0),
|
|
188
188
|
O(t.$slots, "item", {
|
|
189
189
|
item: r.value,
|
|
190
190
|
loading: l.value,
|
|
191
|
-
editMode:
|
|
192
|
-
isCreate: a.
|
|
193
|
-
canUpdate:
|
|
194
|
-
canDrop:
|
|
191
|
+
editMode: v.value,
|
|
192
|
+
isCreate: a.value,
|
|
193
|
+
canUpdate: g.value,
|
|
194
|
+
canDrop: B.value
|
|
195
195
|
})
|
|
196
|
-
])) : (
|
|
196
|
+
])) : (c(), V(A, {
|
|
197
197
|
key: 1,
|
|
198
|
-
code:
|
|
198
|
+
code: i.value
|
|
199
199
|
}, null, 8, ["code"]))
|
|
200
200
|
])),
|
|
201
|
-
l.value ? (
|
|
201
|
+
l.value ? (c(), V(ue, { key: 2 })) : D("", !0)
|
|
202
202
|
]);
|
|
203
203
|
};
|
|
204
204
|
}
|
|
205
|
-
}),
|
|
206
|
-
install: (
|
|
207
|
-
|
|
205
|
+
}), _e = {
|
|
206
|
+
install: (o, I = {}) => {
|
|
207
|
+
o.component("lkt-item-crud") === void 0 && o.component("lkt-item-crud", ke);
|
|
208
208
|
}
|
|
209
209
|
};
|
|
210
210
|
export {
|
|
211
|
-
|
|
211
|
+
_e as default
|
|
212
212
|
};
|
|
@@ -132,6 +132,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
132
132
|
drop: (...args: any[]) => void;
|
|
133
133
|
update: (...args: any[]) => void;
|
|
134
134
|
"update:modelValue": (...args: any[]) => void;
|
|
135
|
+
"update:isCreate": (...args: any[]) => void;
|
|
135
136
|
read: (...args: any[]) => void;
|
|
136
137
|
create: (...args: any[]) => void;
|
|
137
138
|
perms: (...args: any[]) => void;
|
|
@@ -266,6 +267,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
266
267
|
onDrop?: ((...args: any[]) => any) | undefined;
|
|
267
268
|
onUpdate?: ((...args: any[]) => any) | undefined;
|
|
268
269
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
270
|
+
"onUpdate:isCreate"?: ((...args: any[]) => any) | undefined;
|
|
269
271
|
onRead?: ((...args: any[]) => any) | undefined;
|
|
270
272
|
onCreate?: ((...args: any[]) => any) | undefined;
|
|
271
273
|
onPerms?: ((...args: any[]) => any) | undefined;
|
|
@@ -304,14 +306,14 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
304
306
|
"button-drop"?(_: {
|
|
305
307
|
item: Record<string, any>;
|
|
306
308
|
editMode: boolean;
|
|
307
|
-
isCreate:
|
|
309
|
+
isCreate: any;
|
|
308
310
|
canUpdate: boolean;
|
|
309
311
|
canDrop: boolean;
|
|
310
312
|
}): any;
|
|
311
313
|
"button-save"?(_: {
|
|
312
314
|
item: Record<string, any>;
|
|
313
315
|
editMode: boolean;
|
|
314
|
-
isCreate:
|
|
316
|
+
isCreate: any;
|
|
315
317
|
canUpdate: boolean;
|
|
316
318
|
canDrop: boolean;
|
|
317
319
|
}): any;
|
|
@@ -319,7 +321,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
319
321
|
item: Record<string, any>;
|
|
320
322
|
loading: false;
|
|
321
323
|
editMode: boolean;
|
|
322
|
-
isCreate:
|
|
324
|
+
isCreate: any;
|
|
323
325
|
canUpdate: boolean;
|
|
324
326
|
canDrop: boolean;
|
|
325
327
|
}): any;
|
package/package.json
CHANGED
|
@@ -49,7 +49,7 @@ const props = defineProps({
|
|
|
49
49
|
|
|
50
50
|
const slots = useSlots();
|
|
51
51
|
|
|
52
|
-
const emit = defineEmits(['update:modelValue', 'read', 'create', 'update', 'drop', 'perms', 'error', 'modified-data']);
|
|
52
|
+
const emit = defineEmits(['update:modelValue', 'update:isCreate', 'read', 'create', 'update', 'drop', 'perms', 'error', 'modified-data']);
|
|
53
53
|
|
|
54
54
|
let basePerms: string[] = [];
|
|
55
55
|
|
|
@@ -62,36 +62,37 @@ const isLoading = ref(true),
|
|
|
62
62
|
httpStatus = ref(200),
|
|
63
63
|
saveButton = ref(null),
|
|
64
64
|
dropButton = ref(null),
|
|
65
|
-
dataState = ref(new DataState(item.value))
|
|
65
|
+
dataState = ref(new DataState(item.value)),
|
|
66
|
+
createMode = ref(createMode.value);
|
|
66
67
|
|
|
67
68
|
const saveConfirm = computed(() => {
|
|
68
|
-
return
|
|
69
|
+
return createMode.value
|
|
69
70
|
? props.createConfirm
|
|
70
71
|
: props.updateConfirm;
|
|
71
72
|
}),
|
|
72
73
|
confirmData = computed(() => {
|
|
73
|
-
return
|
|
74
|
+
return createMode.value
|
|
74
75
|
? props.createConfirmData
|
|
75
76
|
: props.updateConfirmData;
|
|
76
77
|
}),
|
|
77
78
|
saveResource = computed(() => {
|
|
78
|
-
return
|
|
79
|
+
return createMode.value
|
|
79
80
|
? props.createResource
|
|
80
81
|
: props.updateResource;
|
|
81
82
|
}),
|
|
82
83
|
saveData = computed(() => {
|
|
83
|
-
if (
|
|
84
|
+
if (createMode.value) {
|
|
84
85
|
return {...props.createData, ...JSON.parse(JSON.stringify(item.value))};
|
|
85
86
|
}
|
|
86
87
|
return {...props.updateData, ...JSON.parse(JSON.stringify(item.value))};
|
|
87
88
|
}),
|
|
88
89
|
saveDisabled = computed(() => {
|
|
89
|
-
return
|
|
90
|
+
return createMode.value
|
|
90
91
|
? props.createDisabled
|
|
91
92
|
: props.updateDisabled;
|
|
92
93
|
}),
|
|
93
|
-
canUpdate = computed(() => !
|
|
94
|
-
canDrop = computed(() => !
|
|
94
|
+
canUpdate = computed(() => !createMode.value && perms.value.includes('update')),
|
|
95
|
+
canDrop = computed(() => !createMode.value && perms.value.includes('drop'));
|
|
95
96
|
|
|
96
97
|
const fetchItem = async () => {
|
|
97
98
|
isLoading.value = true;
|
|
@@ -141,17 +142,18 @@ watch(perms, () => emit('perms', perms.value));
|
|
|
141
142
|
|
|
142
143
|
const ableToSave = computed(() => {
|
|
143
144
|
if (saveDisabled.value) return false;
|
|
144
|
-
if (!
|
|
145
|
+
if (!createMode.value && !canUpdate.value) return false;
|
|
145
146
|
|
|
146
147
|
if (typeof props.saveValidator === 'function' && !props.saveValidator(item.value)) return false;
|
|
147
148
|
|
|
148
149
|
return dataState.value.changed();
|
|
149
150
|
});
|
|
150
151
|
watch(ableToSave, (v) => emit('modified-data', v));
|
|
152
|
+
watch(createMode, (v) => emit('update:isCreate', v));
|
|
151
153
|
|
|
152
154
|
// Fetch item
|
|
153
|
-
if (props.readResource && !
|
|
154
|
-
else if (
|
|
155
|
+
if (props.readResource && !createMode.value) fetchItem();
|
|
156
|
+
else if (createMode.value) {
|
|
155
157
|
httpSuccessRead.value = true;
|
|
156
158
|
editMode.value = true;
|
|
157
159
|
isLoading.value = false;
|
|
@@ -180,17 +182,21 @@ const onDrop = ($event: PointerEvent, r: HTTPResponse) => {
|
|
|
180
182
|
}
|
|
181
183
|
showStoreMessage.value = true;
|
|
182
184
|
}
|
|
183
|
-
let emits: 'create' | 'update' =
|
|
184
|
-
if (!
|
|
185
|
+
let emits: 'create' | 'update' = createMode.value ? 'create' : 'update';
|
|
186
|
+
if (!createMode.value) {
|
|
185
187
|
dataState.value.turnStoredIntoOriginal();
|
|
186
188
|
}
|
|
187
189
|
|
|
188
190
|
if (r.autoReloadId) {
|
|
189
191
|
props.readData['id'] = r.autoReloadId;
|
|
192
|
+
createMode.value = false;
|
|
190
193
|
fetchItem();
|
|
191
194
|
}
|
|
192
|
-
if (
|
|
193
|
-
|
|
195
|
+
if (createMode.value) {
|
|
196
|
+
if (typeof props.onCreate === 'function') props.onCreate();
|
|
197
|
+
} else {
|
|
198
|
+
if (typeof props.onUpdate === 'function') props.onUpdate();
|
|
199
|
+
}
|
|
194
200
|
emit(emits, r)
|
|
195
201
|
},
|
|
196
202
|
onButtonLoading = () => {
|
|
@@ -224,7 +230,7 @@ const showDropButton = computed(() => {
|
|
|
224
230
|
showSaveButton = computed(() => {
|
|
225
231
|
if (isLoading.value) return false;
|
|
226
232
|
|
|
227
|
-
if (
|
|
233
|
+
if (createMode.value) return true;
|
|
228
234
|
|
|
229
235
|
return !props.hiddenSave
|
|
230
236
|
&& editMode.value
|
|
@@ -232,7 +238,7 @@ const showDropButton = computed(() => {
|
|
|
232
238
|
}),
|
|
233
239
|
showSwitchButton = computed(() => {
|
|
234
240
|
return !isLoading.value
|
|
235
|
-
&& !
|
|
241
|
+
&& !createMode.value
|
|
236
242
|
&& httpSuccessRead.value;
|
|
237
243
|
}),
|
|
238
244
|
showButtons = computed(() => {
|
|
@@ -252,7 +258,7 @@ const showDropButton = computed(() => {
|
|
|
252
258
|
<lkt-button
|
|
253
259
|
:ref="(el:any) => dropButton = el"
|
|
254
260
|
v-show="showDropButton"
|
|
255
|
-
v-if="!
|
|
261
|
+
v-if="!createMode"
|
|
256
262
|
palette="danger"
|
|
257
263
|
v-bind:disabled="dropDisabled || !canDrop"
|
|
258
264
|
v-bind:confirm-modal="dropConfirm"
|
|
@@ -264,7 +270,7 @@ const showDropButton = computed(() => {
|
|
|
264
270
|
v-on:click="onDrop">
|
|
265
271
|
<slot v-if="!!slots['button-drop']" name="button-drop" v-bind:item="item"
|
|
266
272
|
v-bind:edit-mode="editMode"
|
|
267
|
-
v-bind:is-create="
|
|
273
|
+
v-bind:is-create="createMode"
|
|
268
274
|
v-bind:can-update="canUpdate"
|
|
269
275
|
v-bind:can-drop="canDrop"></slot>
|
|
270
276
|
<span v-else>{{ dropText }}</span>
|
|
@@ -284,7 +290,7 @@ const showDropButton = computed(() => {
|
|
|
284
290
|
v-on:click="onSave">
|
|
285
291
|
<slot v-if="!!slots['button-save']" name="button-save" v-bind:item="item"
|
|
286
292
|
v-bind:edit-mode="editMode"
|
|
287
|
-
v-bind:is-create="
|
|
293
|
+
v-bind:is-create="createMode"
|
|
288
294
|
v-bind:can-update="canUpdate"
|
|
289
295
|
v-bind:can-drop="canDrop"></slot>
|
|
290
296
|
<span v-else>{{ saveText }}</span>
|
|
@@ -300,7 +306,7 @@ const showDropButton = computed(() => {
|
|
|
300
306
|
:palette="httpStatus === 200 ? 'success' : 'danger'" can-close
|
|
301
307
|
v-on:close="showStoreMessage = false"></lkt-http-info>
|
|
302
308
|
<slot name="item" v-bind:item="item" v-bind:loading="isLoading" v-bind:edit-mode="editMode"
|
|
303
|
-
v-bind:is-create="
|
|
309
|
+
v-bind:is-create="createMode"
|
|
304
310
|
v-bind:can-update="canUpdate"
|
|
305
311
|
v-bind:can-drop="canDrop"></slot>
|
|
306
312
|
</div>
|