lkt-item-crud 1.0.7 → 1.0.8
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/lkt-item-crud.es.js
CHANGED
|
@@ -1,199 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}, re = { class: "lkt-item-crud_header-title" }, oe = { class: "lkt-item-crud_header-slot" }, se = { class: "lkt-item-crud-buttons" }, de = { key: 1 }, ie = { key: 1 }, ne = {
|
|
8
|
-
key: 1,
|
|
9
|
-
class: "lkt-item-crud_content"
|
|
10
|
-
}, ce = {
|
|
11
|
-
key: 0,
|
|
12
|
-
class: "lkt-grid-1"
|
|
13
|
-
}, ve = { name: "LktItemCrud", inheritAttrs: !1 }, fe = /* @__PURE__ */ Z({
|
|
14
|
-
...ve,
|
|
15
|
-
props: {
|
|
16
|
-
modelValue: { type: Object, required: !1, default: () => ({}) },
|
|
17
|
-
title: { type: String, default: "" },
|
|
18
|
-
editModeText: { type: String, default: "Edition Mode" },
|
|
19
|
-
saveText: { type: String, default: "Save" },
|
|
20
|
-
dropText: { type: String, default: "Delete" },
|
|
21
|
-
readResource: { type: String, required: !0 },
|
|
22
|
-
createResource: { type: String, required: !1 },
|
|
23
|
-
updateResource: { type: String, required: !1 },
|
|
24
|
-
dropResource: { type: String, required: !1 },
|
|
25
|
-
readData: { type: Object, required: !1, default: () => ({}) },
|
|
26
|
-
createData: { type: Object, required: !1, default: () => ({}) },
|
|
27
|
-
updateData: { type: Object, required: !1, default: () => ({}) },
|
|
28
|
-
dropData: { type: Object, required: !1, default: () => ({}) },
|
|
29
|
-
isCreate: { type: Boolean, default: !1 },
|
|
30
|
-
createConfirm: { type: String, default: "" },
|
|
31
|
-
updateConfirm: { type: String, default: "" },
|
|
32
|
-
dropConfirm: { type: String, default: "" },
|
|
33
|
-
createDisabled: { type: Boolean, default: !1 },
|
|
34
|
-
updateDisabled: { type: Boolean, default: !1 },
|
|
35
|
-
dropDisabled: { type: Boolean, default: !1 },
|
|
36
|
-
saveValidator: { type: Function, required: !1, default: () => !0 }
|
|
37
|
-
},
|
|
38
|
-
emits: ["update:modelValue", "read", "create", "update", "drop", "perms", "error", "modified-data"],
|
|
39
|
-
setup(a, { expose: N, emit: A }) {
|
|
40
|
-
const e = a, L = ee(), o = A;
|
|
41
|
-
let F = [];
|
|
42
|
-
const l = d(!0), r = d(e.modelValue), y = d(F), c = d(!1), n = d(!1), f = d(!1), s = d(200), S = d(null), h = d(null), k = d(new ae(r.value)), H = v(() => e.isCreate ? e.createConfirm : e.updateConfirm), P = v(() => e.isCreate ? e.createResource : e.updateResource), z = v(() => e.isCreate ? { ...e.createData, ...JSON.parse(JSON.stringify(r.value)) } : { ...e.updateData, ...JSON.parse(JSON.stringify(r.value)) }), G = v(() => e.isCreate ? e.createDisabled : e.updateDisabled), D = v(() => !e.isCreate && y.value.includes("update")), b = v(() => !e.isCreate && y.value.includes("drop")), w = async () => {
|
|
43
|
-
l.value = !0, s.value = -1, f.value = !1;
|
|
44
|
-
try {
|
|
45
|
-
const t = await te(e.readResource, e.readData);
|
|
46
|
-
if (l.value = !1, s.value = t.httpStatus, !t.success) {
|
|
47
|
-
n.value = !1, s.value = t.httpStatus, o("error", t.httpStatus);
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
n.value = !0, r.value = t.data, y.value = t.perms, k.value.increment(r.value).turnStoredIntoOriginal(), o("read", t);
|
|
51
|
-
} catch {
|
|
52
|
-
l.value = !1, n.value = !1, s.value = 404, o("error", 404);
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
}, K = v(() => l.value ? !1 : e.title || !!L["post-title"]);
|
|
56
|
-
R(() => e.modelValue, (t) => {
|
|
57
|
-
r.value = t, k.value.increment(t);
|
|
58
|
-
}, { deep: !0 }), R(r, (t) => {
|
|
59
|
-
o("update:modelValue", r.value), k.value.increment(t);
|
|
60
|
-
}, { deep: !0 }), R(y, () => o("perms", y.value));
|
|
61
|
-
const T = v(() => G.value || !e.isCreate && !D.value || typeof e.saveValidator == "function" && !e.saveValidator(r.value) ? !1 : k.value.changed());
|
|
62
|
-
R(T, (t) => o("modified-data", t)), e.readResource && !e.isCreate ? w() : e.isCreate && (n.value = !0, c.value = !0, l.value = !1);
|
|
63
|
-
const Q = (t, u) => {
|
|
64
|
-
if (l.value = !1, s.value = u.httpStatus, !u.success) {
|
|
65
|
-
f.value = !0, o("error", u.httpStatus);
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
f.value = !0, o("drop", u);
|
|
69
|
-
}, W = (t, u) => {
|
|
70
|
-
if (l.value = !1, s.value = u.httpStatus, !u.success) {
|
|
71
|
-
f.value = !0, o("error", u.httpStatus);
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
f.value = !0;
|
|
75
|
-
let g = e.isCreate ? "create" : "update";
|
|
76
|
-
e.isCreate || k.value.turnStoredIntoOriginal(), u.autoReloadId && (e.readData.id = u.autoReloadId, w()), o(g, u);
|
|
77
|
-
}, $ = () => {
|
|
78
|
-
l.value = !0, s.value = -1;
|
|
79
|
-
}, x = () => {
|
|
80
|
-
l.value = !1;
|
|
81
|
-
};
|
|
82
|
-
return N({
|
|
83
|
-
doDrop: () => {
|
|
84
|
-
h.value && typeof h.value.click == "function" && h.value.click();
|
|
85
|
-
},
|
|
86
|
-
doRefresh: w,
|
|
87
|
-
doSave: () => {
|
|
88
|
-
S.value && typeof S.value.click == "function" && S.value.click();
|
|
89
|
-
}
|
|
90
|
-
}), (t, u) => {
|
|
91
|
-
const g = V("lkt-button"), X = V("lkt-field-switch"), j = V("lkt-http-info"), Y = V("lkt-loader");
|
|
92
|
-
return i(), m("article", le, [
|
|
93
|
-
K.value ? (i(), m("header", ue, [
|
|
94
|
-
I("h1", re, M(a.title), 1),
|
|
95
|
-
I("div", oe, [
|
|
96
|
-
_(t.$slots, "post-title", {
|
|
97
|
-
item: r.value,
|
|
98
|
-
loading: l.value
|
|
99
|
-
})
|
|
100
|
-
])
|
|
101
|
-
])) : C("", !0),
|
|
102
|
-
q(I("div", se, [
|
|
103
|
-
a.isCreate ? C("", !0) : q((i(), B(g, {
|
|
104
|
-
key: 0,
|
|
105
|
-
ref: (p) => h.value = p,
|
|
106
|
-
palette: "danger",
|
|
107
|
-
disabled: a.dropDisabled || !b.value,
|
|
108
|
-
"confirm-modal": a.dropConfirm,
|
|
109
|
-
resource: a.dropResource,
|
|
110
|
-
"resource-data": a.dropData,
|
|
111
|
-
onLoading: $,
|
|
112
|
-
onLoaded: x,
|
|
113
|
-
onClick: Q
|
|
114
|
-
}, {
|
|
115
|
-
default: U(() => [
|
|
116
|
-
J(L)["button-drop"] ? _(t.$slots, "button-drop", {
|
|
117
|
-
key: 0,
|
|
118
|
-
item: r.value,
|
|
119
|
-
editMode: c.value,
|
|
120
|
-
isCreate: a.isCreate,
|
|
121
|
-
canUpdate: D.value,
|
|
122
|
-
canDrop: b.value
|
|
123
|
-
}) : (i(), m("span", de, M(a.dropText), 1))
|
|
124
|
-
]),
|
|
125
|
-
_: 3
|
|
126
|
-
}, 8, ["disabled", "confirm-modal", "resource", "resource-data"])), [
|
|
127
|
-
[O, !l.value && c.value && n.value]
|
|
128
|
-
]),
|
|
129
|
-
q(E(g, {
|
|
130
|
-
ref: (p) => S.value = p,
|
|
131
|
-
palette: "success",
|
|
132
|
-
disabled: !T.value,
|
|
133
|
-
"confirm-modal": H.value,
|
|
134
|
-
resource: P.value,
|
|
135
|
-
"resource-data": z.value,
|
|
136
|
-
onLoading: $,
|
|
137
|
-
onLoaded: x,
|
|
138
|
-
onClick: W
|
|
139
|
-
}, {
|
|
140
|
-
default: U(() => [
|
|
141
|
-
J(L)["button-save"] ? _(t.$slots, "button-save", {
|
|
142
|
-
key: 0,
|
|
143
|
-
item: r.value,
|
|
144
|
-
editMode: c.value,
|
|
145
|
-
isCreate: a.isCreate,
|
|
146
|
-
canUpdate: D.value,
|
|
147
|
-
canDrop: b.value
|
|
148
|
-
}) : (i(), m("span", ie, M(a.saveText), 1))
|
|
149
|
-
]),
|
|
150
|
-
_: 3
|
|
151
|
-
}, 8, ["disabled", "confirm-modal", "resource", "resource-data"]), [
|
|
152
|
-
[O, !l.value && c.value && n.value]
|
|
153
|
-
]),
|
|
154
|
-
q(E(X, {
|
|
155
|
-
modelValue: c.value,
|
|
156
|
-
"onUpdate:modelValue": u[0] || (u[0] = (p) => c.value = p),
|
|
157
|
-
label: a.editModeText
|
|
158
|
-
}, null, 8, ["modelValue", "label"]), [
|
|
159
|
-
[O, !l.value && n.value && !a.isCreate]
|
|
160
|
-
])
|
|
161
|
-
], 512), [
|
|
162
|
-
[O, n.value]
|
|
163
|
-
]),
|
|
164
|
-
l.value ? C("", !0) : (i(), m("div", ne, [
|
|
165
|
-
n.value ? (i(), m("div", ce, [
|
|
166
|
-
f.value ? (i(), B(j, {
|
|
167
|
-
key: 0,
|
|
168
|
-
code: s.value,
|
|
169
|
-
quick: "",
|
|
170
|
-
palette: s.value === 200 ? "success" : "danger",
|
|
171
|
-
"can-close": "",
|
|
172
|
-
onClose: u[1] || (u[1] = (p) => f.value = !1)
|
|
173
|
-
}, null, 8, ["code", "palette"])) : C("", !0),
|
|
174
|
-
_(t.$slots, "item", {
|
|
175
|
-
item: r.value,
|
|
176
|
-
loading: l.value,
|
|
177
|
-
editMode: c.value,
|
|
178
|
-
isCreate: a.isCreate,
|
|
179
|
-
canUpdate: D.value,
|
|
180
|
-
canDrop: b.value
|
|
181
|
-
})
|
|
182
|
-
])) : (i(), B(j, {
|
|
183
|
-
key: 1,
|
|
184
|
-
code: s.value
|
|
185
|
-
}, null, 8, ["code"]))
|
|
186
|
-
])),
|
|
187
|
-
l.value ? (i(), B(Y, { key: 2 })) : C("", !0)
|
|
188
|
-
]);
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
const Se = {
|
|
193
|
-
install: (a, N = {}) => {
|
|
194
|
-
a.component("LktItemCrud", fe);
|
|
1
|
+
import o from "lkt-button";
|
|
2
|
+
import n from "lkt-http-info";
|
|
3
|
+
import e from "lkt-loader";
|
|
4
|
+
const i = {
|
|
5
|
+
install: (t, m = {}) => {
|
|
6
|
+
t.component("lkt-item-crud") === void 0 && t.component("lkt-item-crud", i), t.component("lkt-button") === void 0 && t.use(o), t.component("lkt-http-info") === void 0 && t.use(n), t.component("lkt-loader") === void 0 && t.use(e);
|
|
195
7
|
}
|
|
196
8
|
};
|
|
197
9
|
export {
|
|
198
|
-
|
|
10
|
+
i as default
|
|
199
11
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,
|
|
1
|
+
(function(e,o){typeof exports=="object"&&typeof module<"u"?module.exports=o(require("lkt-button"),require("lkt-http-info"),require("lkt-loader")):typeof define=="function"&&define.amd?define(["lkt-button","lkt-http-info","lkt-loader"],o):(e=typeof globalThis<"u"?globalThis:e||self,e.LktItemCrud=o(e.LktButton,e.LktHttpInfo,e.LktLoader))})(this,function(e,o,d){"use strict";const n=t=>t&&typeof t=="object"&&"default"in t?t:{default:t},i=n(e),f=n(o),l=n(d),k="",u={install:(t,r={})=>{t.component("lkt-item-crud")===void 0&&t.component("lkt-item-crud",u),t.component("lkt-button")===void 0&&t.use(i.default),t.component("lkt-http-info")===void 0&&t.use(f.default),t.component("lkt-loader")===void 0&&t.use(l.default)}};return u});
|
|
@@ -23,7 +23,7 @@ declare const _default: {
|
|
|
23
23
|
};
|
|
24
24
|
readResource: {
|
|
25
25
|
type: StringConstructor;
|
|
26
|
-
required:
|
|
26
|
+
required: false;
|
|
27
27
|
};
|
|
28
28
|
createResource: {
|
|
29
29
|
type: StringConstructor;
|
|
@@ -127,7 +127,7 @@ declare const _default: {
|
|
|
127
127
|
};
|
|
128
128
|
readResource: {
|
|
129
129
|
type: StringConstructor;
|
|
130
|
-
required:
|
|
130
|
+
required: false;
|
|
131
131
|
};
|
|
132
132
|
createResource: {
|
|
133
133
|
type: StringConstructor;
|
|
@@ -252,7 +252,7 @@ declare const _default: {
|
|
|
252
252
|
};
|
|
253
253
|
readResource: {
|
|
254
254
|
type: StringConstructor;
|
|
255
|
-
required:
|
|
255
|
+
required: false;
|
|
256
256
|
};
|
|
257
257
|
createResource: {
|
|
258
258
|
type: StringConstructor;
|
|
@@ -378,7 +378,7 @@ declare const _default: {
|
|
|
378
378
|
};
|
|
379
379
|
readResource: {
|
|
380
380
|
type: StringConstructor;
|
|
381
|
-
required:
|
|
381
|
+
required: false;
|
|
382
382
|
};
|
|
383
383
|
createResource: {
|
|
384
384
|
type: StringConstructor;
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -2,10 +2,19 @@ import {App} from "vue";
|
|
|
2
2
|
import {default as itemCrud} from "./lib-components/LktItemCrud.vue";
|
|
3
3
|
|
|
4
4
|
import "./../lkt-item-crud.css";
|
|
5
|
+
import LktButton from "lkt-button";
|
|
6
|
+
import LktHttpInfo from "lkt-http-info";
|
|
7
|
+
import LktLoader from "lkt-loader";
|
|
5
8
|
|
|
6
9
|
const LktItemCrud = {
|
|
7
10
|
install: (app: App, options = {}) => {
|
|
8
|
-
|
|
11
|
+
// Register plugin components
|
|
12
|
+
if (app.component('lkt-item-crud') === undefined) app.component('lkt-item-crud', LktItemCrud);
|
|
13
|
+
|
|
14
|
+
// Register additional components
|
|
15
|
+
if (app.component('lkt-button') === undefined) app.use(LktButton);
|
|
16
|
+
if (app.component('lkt-http-info') === undefined) app.use(LktHttpInfo);
|
|
17
|
+
if (app.component('lkt-loader') === undefined) app.use(LktLoader);
|
|
9
18
|
},
|
|
10
19
|
};
|
|
11
20
|
export default LktItemCrud;
|
|
@@ -15,7 +15,7 @@ const props = defineProps({
|
|
|
15
15
|
saveText: {type: String, default: 'Save'},
|
|
16
16
|
dropText: {type: String, default: 'Delete'},
|
|
17
17
|
|
|
18
|
-
readResource: {type: String, required:
|
|
18
|
+
readResource: {type: String, required: false},
|
|
19
19
|
createResource: {type: String, required: false},
|
|
20
20
|
updateResource: {type: String, required: false},
|
|
21
21
|
dropResource: {type: String, required: false},
|
|
@@ -155,14 +155,16 @@ const onDrop = ($event: PointerEvent, r: HTTPResponse) => {
|
|
|
155
155
|
|
|
156
156
|
},
|
|
157
157
|
onSave = ($event: PointerEvent, r: HTTPResponse) => {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
158
|
+
if (saveResource.value) {
|
|
159
|
+
isLoading.value = false;
|
|
160
|
+
httpStatus.value = r.httpStatus;
|
|
161
|
+
if (!r.success) {
|
|
162
|
+
showStoreMessage.value = true;
|
|
163
|
+
emit('error', r.httpStatus);
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
161
166
|
showStoreMessage.value = true;
|
|
162
|
-
emit('error', r.httpStatus);
|
|
163
|
-
return;
|
|
164
167
|
}
|
|
165
|
-
showStoreMessage.value = true;
|
|
166
168
|
let emits: 'create' | 'update' = props.isCreate ? 'create' : 'update';
|
|
167
169
|
if (!props.isCreate) {
|
|
168
170
|
dataState.value.turnStoredIntoOriginal();
|
package/lkt-item-crud.css
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
.lkt-item-crud {
|
|
2
|
-
display: flex;
|
|
3
|
-
flex-direction: column;
|
|
4
|
-
gap: 15px;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
.lkt-item-crud_content {
|
|
8
|
-
display: flex;
|
|
9
|
-
flex-direction: column;
|
|
10
|
-
gap: 15px;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.lkt-item-crud-buttons {
|
|
14
|
-
position: sticky;
|
|
15
|
-
top: calc(-1 * var(--gap));
|
|
16
|
-
display: flex;
|
|
17
|
-
align-items: center;
|
|
18
|
-
gap: var(--gap);
|
|
19
|
-
transition: all linear .150s;
|
|
20
|
-
background: #ffffff;
|
|
21
|
-
z-index: 2;
|
|
22
|
-
padding: var(--gap) 0;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.lkt-item-crud-buttons > :last-child {
|
|
26
|
-
margin-left: auto;
|
|
27
|
-
}
|