@hostlink/nuxt-light 1.42.1 → 1.43.0
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/module.json +1 -1
- package/dist/runtime/components/l-table.vue +27 -44
- package/dist/runtime/components/l-table.vue.d.ts +1 -1
- package/dist/runtime/composables/list.d.ts +3 -7
- package/dist/runtime/composables/list.js +3 -38
- package/dist/runtime/formkit/Repeater.vue +32 -28
- package/package.json +2 -2
- package/dist/runtime/composables/GQLFieldBuilder.d.ts +0 -1
- package/dist/runtime/composables/GQLFieldBuilder.js +0 -28
package/dist/module.json
CHANGED
|
@@ -3,10 +3,9 @@ import { useQuasar, QTable, Dialog } from "quasar";
|
|
|
3
3
|
import { defu } from "defu";
|
|
4
4
|
import { ref, computed, onMounted, useSlots, watch, reactive } from "vue";
|
|
5
5
|
import useLight from "../composables/useLight";
|
|
6
|
-
import GQLFieldBuilder from "../composables/GQLFieldBuilder";
|
|
7
6
|
import model from "../composables/model";
|
|
8
7
|
import { toQuery } from "@hostlink/light";
|
|
9
|
-
import {
|
|
8
|
+
import { list } from "#imports";
|
|
10
9
|
import { useI18n } from "vue-i18n";
|
|
11
10
|
const $q = useQuasar();
|
|
12
11
|
const { t } = useI18n();
|
|
@@ -180,37 +179,39 @@ const validateData = () => {
|
|
|
180
179
|
};
|
|
181
180
|
const onLocalRequest = async (p) => {
|
|
182
181
|
if (!isServerSide) return;
|
|
182
|
+
let localFields = {};
|
|
183
183
|
let sort = "";
|
|
184
184
|
if (p.pagination.sortBy) {
|
|
185
185
|
sort = p.pagination.sortBy + ":" + (p.pagination.descending ? "desc" : "asc");
|
|
186
186
|
}
|
|
187
|
-
const builder = GQLFieldBuilder();
|
|
188
187
|
if (props.rowKey) {
|
|
189
|
-
|
|
188
|
+
localFields = defu(localFields, {
|
|
189
|
+
[props.rowKey]: true
|
|
190
|
+
});
|
|
190
191
|
}
|
|
191
192
|
props.columns?.forEach((col) => {
|
|
192
193
|
if (col.gqlField) {
|
|
193
|
-
|
|
194
|
+
localFields = defu(localFields, col.gqlField);
|
|
194
195
|
return;
|
|
195
196
|
}
|
|
196
197
|
if (!col.name) return;
|
|
197
198
|
if (col.name.startsWith("_")) {
|
|
198
199
|
return;
|
|
199
200
|
}
|
|
200
|
-
|
|
201
|
+
localFields = defu(localFields, { [col.name]: true });
|
|
201
202
|
});
|
|
202
203
|
if (actionView) {
|
|
203
|
-
|
|
204
|
+
localFields = defu(localFields, { canView: true });
|
|
204
205
|
}
|
|
205
206
|
if (actionDelete) {
|
|
206
|
-
|
|
207
|
+
localFields = defu(localFields, { canDelete: true });
|
|
207
208
|
}
|
|
208
209
|
if (activeEdit) {
|
|
209
|
-
|
|
210
|
+
localFields = defu(localFields, { canUpdate: true });
|
|
210
211
|
}
|
|
211
212
|
const callback = {
|
|
212
213
|
sort,
|
|
213
|
-
fields:
|
|
214
|
+
fields: localFields,
|
|
214
215
|
offset: (p.pagination.page - 1) * p.pagination.rowsPerPage,
|
|
215
216
|
limit: p.pagination.rowsPerPage,
|
|
216
217
|
gql: {
|
|
@@ -223,7 +224,7 @@ const onLocalRequest = async (p) => {
|
|
|
223
224
|
limit: p.pagination.rowsPerPage,
|
|
224
225
|
offset: (p.pagination.page - 1) * p.pagination.rowsPerPage
|
|
225
226
|
},
|
|
226
|
-
...toQuery(
|
|
227
|
+
...toQuery(localFields)
|
|
227
228
|
},
|
|
228
229
|
meta: {
|
|
229
230
|
total: true,
|
|
@@ -257,48 +258,30 @@ const onLocalRequest = async (p) => {
|
|
|
257
258
|
p.pagination.rowsPerPage = saved;
|
|
258
259
|
}
|
|
259
260
|
}
|
|
260
|
-
|
|
261
|
+
if (Array.isArray(fields)) {
|
|
262
|
+
fields.forEach((f) => {
|
|
263
|
+
localFields = defu(localFields, { [f]: true });
|
|
264
|
+
});
|
|
265
|
+
} else {
|
|
266
|
+
localFields = defu(localFields, fields);
|
|
267
|
+
}
|
|
261
268
|
let localFilters = getFilterValue();
|
|
262
269
|
if (filters2) {
|
|
263
|
-
localFilters =
|
|
264
|
-
...localFilters,
|
|
265
|
-
...filters2
|
|
266
|
-
};
|
|
270
|
+
localFilters = defu(localFilters, filters2);
|
|
267
271
|
}
|
|
268
272
|
loading.value = true;
|
|
269
273
|
try {
|
|
270
|
-
let
|
|
271
|
-
|
|
272
|
-
for (let [key, value] of Object.entries(localFilters)) {
|
|
273
|
-
if (typeof value == "object" && value !== null) {
|
|
274
|
-
const filterValue = value;
|
|
275
|
-
if (filterValue.contains) {
|
|
276
|
-
c = c.whereContains(key, filterValue.contains);
|
|
277
|
-
}
|
|
278
|
-
if (filterValue.between) {
|
|
279
|
-
c = c.whereBetween(key, filterValue.between);
|
|
280
|
-
}
|
|
281
|
-
} else {
|
|
282
|
-
c = c.where(key, value);
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
}
|
|
274
|
+
let l = list(model2, localFields);
|
|
275
|
+
l = l.filters(localFilters);
|
|
286
276
|
if (sort) {
|
|
287
|
-
|
|
288
|
-
c = c.sortBy(sort.split(":")[0]);
|
|
289
|
-
} else {
|
|
290
|
-
c = c.sortByDesc(sort.split(":")[0]);
|
|
291
|
-
}
|
|
277
|
+
l = l.sort(sort);
|
|
292
278
|
}
|
|
293
279
|
if (p.pagination.rowsPerPage != 0) {
|
|
294
|
-
|
|
280
|
+
l = l.limit(p.pagination.rowsPerPage);
|
|
281
|
+
l = l.offset((p.pagination.page - 1) * p.pagination.rowsPerPage);
|
|
295
282
|
}
|
|
296
|
-
const data = await
|
|
297
|
-
|
|
298
|
-
data,
|
|
299
|
-
meta: c.meta
|
|
300
|
-
};
|
|
301
|
-
this.setData(allData);
|
|
283
|
+
const data = await l.fetchWithMeta();
|
|
284
|
+
this.setData(data);
|
|
302
285
|
} catch (e) {
|
|
303
286
|
quasar.dialog({
|
|
304
287
|
message: e,
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
filters?: object;
|
|
5
|
-
offset?: number;
|
|
6
|
-
limit?: number;
|
|
7
|
-
} | null, fields?: Fields): Promise<any>;
|
|
1
|
+
import { default as api } from "./api.js";
|
|
2
|
+
declare const _default: (name: string, fields: Object) => ReturnType<typeof api.list>;
|
|
3
|
+
export default _default;
|
|
@@ -1,39 +1,4 @@
|
|
|
1
|
-
import { toQuery } from "@hostlink/light";
|
|
2
1
|
import { default as api } from "./api.js";
|
|
3
|
-
export default
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
if (props.sort) {
|
|
7
|
-
q.__args = q.__args || {};
|
|
8
|
-
q.__args.sort = props.sort;
|
|
9
|
-
}
|
|
10
|
-
if (props.filters) {
|
|
11
|
-
q.__args = q.__args || {};
|
|
12
|
-
q.__args.filters = props.filters;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
q.data = {};
|
|
16
|
-
if (props) {
|
|
17
|
-
if (props.offset) {
|
|
18
|
-
q.data.__args = q.data.__args || {};
|
|
19
|
-
q.data.__args.offset = props.offset;
|
|
20
|
-
}
|
|
21
|
-
if (props.limit) {
|
|
22
|
-
q.data.__args = q.data.__args || {};
|
|
23
|
-
q.data.__args.limit = props.limit;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
q.data = {
|
|
27
|
-
...q.data,
|
|
28
|
-
...toQuery(fields)
|
|
29
|
-
};
|
|
30
|
-
q.meta = {
|
|
31
|
-
total: true,
|
|
32
|
-
key: true,
|
|
33
|
-
name: true
|
|
34
|
-
};
|
|
35
|
-
const resp = await api.query({
|
|
36
|
-
[`list${name}`]: q
|
|
37
|
-
});
|
|
38
|
-
return resp[`list${name}`];
|
|
39
|
-
}
|
|
2
|
+
export default (name, fields) => {
|
|
3
|
+
return api.list(name, fields);
|
|
4
|
+
};
|
|
@@ -61,36 +61,40 @@ const cursor = ref("cursor-grab");
|
|
|
61
61
|
</style>
|
|
62
62
|
|
|
63
63
|
<template>
|
|
64
|
-
<
|
|
65
|
-
<
|
|
66
|
-
<
|
|
67
|
-
<
|
|
68
|
-
<q-item
|
|
69
|
-
<
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
64
|
+
<div class="col col-12 ">
|
|
65
|
+
<FormKit type="list" v-model="localValue" dynamic #default="{ items, node }" :name="node.name">
|
|
66
|
+
<q-list bordered separator ref="parent">
|
|
67
|
+
<FormKit type="group" v-for="(item, index) in items" :index="index" :key="item" #default="{ node }">
|
|
68
|
+
<q-item class="q-pa-xs">
|
|
69
|
+
<q-item-section avatar class="">
|
|
70
|
+
<div class="l-repeater-handle" v-if="sortable" :class="cursor"
|
|
71
|
+
@mousedown="cursor = 'cursor-grabbing'" @mouseup="cursor = 'cursor-grab'"
|
|
72
|
+
@mouseleave="cursor = 'cursor-grab'">
|
|
73
|
+
<q-icon name="sym_o_drag_indicator" :color="$light.color" size="sm" />
|
|
74
|
+
</div>
|
|
75
|
+
</q-item-section>
|
|
74
76
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
77
|
+
<q-item-section>
|
|
78
|
+
<slot v-bind="{ value: localValue[index], index: index, node: node }"></slot>
|
|
79
|
+
</q-item-section>
|
|
78
80
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
<q-item-section side>
|
|
82
|
+
<!-- up -->
|
|
83
|
+
<q-btn type="button" @click="onMoveUp(index)" icon="sym_o_arrow_upward"
|
|
84
|
+
:color="$light.color" dense flat :disable="!isAllowMoveUp(index)" />
|
|
83
85
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
<q-btn type="button" @click="onRemove(index)" icon="sym_o_delete" :color="$light.color"
|
|
87
|
+
dense :disable="!isAllowRemove" flat />
|
|
88
|
+
<!-- down -->
|
|
89
|
+
<q-btn type="button" @click="onMoveDown(index)" icon="sym_o_arrow_downward"
|
|
90
|
+
:color="$light.color" dense flat :disable="!isAllowMoveDown(index)" />
|
|
89
91
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
92
|
+
</q-item-section>
|
|
93
|
+
</q-item>
|
|
94
|
+
</FormKit>
|
|
95
|
+
</q-list>
|
|
96
|
+
<q-btn @click="onAdd" :label="addLabel" icon="sym_o_add" :color="$light.color" outline class="q-mt-sm"
|
|
97
|
+
:disable="localValue.length >= max" />
|
|
98
|
+
</FormKit>
|
|
99
|
+
</div>
|
|
96
100
|
</template>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hostlink/nuxt-light",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.43.0",
|
|
4
4
|
"description": "HostLink Nuxt Light Framework",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@azure/msal-browser": "^3.26.1",
|
|
34
34
|
"@formkit/drag-and-drop": "^0.5.3",
|
|
35
|
-
"@hostlink/light": "^2.
|
|
35
|
+
"@hostlink/light": "^2.11.0",
|
|
36
36
|
"@nuxt/module-builder": "^1.0.1",
|
|
37
37
|
"@quasar/extras": "^1.17.0",
|
|
38
38
|
"@quasar/quasar-ui-qmarkdown": "^2.0.5",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function (): any;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { toQuery } from "@hostlink/light";
|
|
2
|
-
import { defu } from "defu";
|
|
3
|
-
export default function() {
|
|
4
|
-
let fields = {};
|
|
5
|
-
return {
|
|
6
|
-
//deep merge
|
|
7
|
-
merge: defu,
|
|
8
|
-
add: (f) => {
|
|
9
|
-
if (typeof f === "string") {
|
|
10
|
-
fields = defu(fields, { [f]: true });
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
if (Array.isArray(f)) {
|
|
14
|
-
f.forEach((item) => {
|
|
15
|
-
fields = defu(fields, { [item]: true });
|
|
16
|
-
});
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
if (typeof f === "object") {
|
|
20
|
-
fields = defu(fields, toQuery(f));
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
get() {
|
|
25
|
-
return fields;
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
}
|