@hostlink/nuxt-light 0.0.100 → 0.0.102
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
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
import { useQuasar, QTable } from 'quasar';
|
|
2
|
+
import { useQuasar, QTable, is } from 'quasar';
|
|
4
3
|
import { ref, computed, onMounted, useSlots, useAttrs } from "vue";
|
|
5
4
|
import { t, deleteObject, q, useLight, GQLFieldBuilder } from '../';
|
|
5
|
+
import { toQuery } from '@hostlink/light';
|
|
6
6
|
|
|
7
7
|
const errors = ref<InstanceType<any>>([]);
|
|
8
8
|
|
|
@@ -77,6 +77,7 @@ const props = defineProps({
|
|
|
77
77
|
}
|
|
78
78
|
})
|
|
79
79
|
|
|
80
|
+
|
|
80
81
|
const pagination = ref(props.pagination);
|
|
81
82
|
|
|
82
83
|
if (props.rowsPerPageOptions[0] == 0) {
|
|
@@ -102,8 +103,8 @@ if (props.columns) {
|
|
|
102
103
|
if (typeof opts == "function") {
|
|
103
104
|
props.columns[i].searchOptions = await opts();
|
|
104
105
|
}
|
|
105
|
-
|
|
106
|
-
|
|
106
|
+
|
|
107
|
+
|
|
107
108
|
}
|
|
108
109
|
}
|
|
109
110
|
}
|
|
@@ -127,8 +128,26 @@ const renderColumns = computed(() => {
|
|
|
127
128
|
})
|
|
128
129
|
|
|
129
130
|
interface LTableRequest {
|
|
130
|
-
|
|
131
|
-
|
|
131
|
+
sort: string,
|
|
132
|
+
fields: Array<string>,
|
|
133
|
+
gql: {
|
|
134
|
+
data: {
|
|
135
|
+
__args: {
|
|
136
|
+
limit: number
|
|
137
|
+
},
|
|
138
|
+
[key: string]: any
|
|
139
|
+
},
|
|
140
|
+
meta: {
|
|
141
|
+
total: boolean,
|
|
142
|
+
key: boolean,
|
|
143
|
+
name: boolean
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
offset: number,
|
|
147
|
+
limit: number,
|
|
148
|
+
loadData: (model: string, filters: any, fields: Array<any>) => void,
|
|
149
|
+
loadObjects: (model: string, filters: any, fields: Array<any>) => void,
|
|
150
|
+
setData: (data: { data: Array<{ data: any }>, meta: { total: Number, key: string, name: string } }) => void,
|
|
132
151
|
}
|
|
133
152
|
|
|
134
153
|
const emits = defineEmits<{
|
|
@@ -171,6 +190,10 @@ onMounted(() => {
|
|
|
171
190
|
}
|
|
172
191
|
})
|
|
173
192
|
|
|
193
|
+
const isServerSide = computed(() => {
|
|
194
|
+
return props.rows == undefined;
|
|
195
|
+
})
|
|
196
|
+
|
|
174
197
|
let primaryKey = ref(props.rowKey);
|
|
175
198
|
const modelName = ref(props.modelName);
|
|
176
199
|
|
|
@@ -254,95 +277,108 @@ const getData = async (
|
|
|
254
277
|
}
|
|
255
278
|
|
|
256
279
|
const onRequest = async (p: any) => {
|
|
280
|
+
if (!isServerSide.value) return;
|
|
257
281
|
|
|
258
282
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
},
|
|
264
|
-
async loadData(operation: string, filters: any = null, fields: Array<any> = []) {
|
|
283
|
+
let sort = "";
|
|
284
|
+
if (p.pagination.sortBy) {
|
|
285
|
+
sort = p.pagination.sortBy + ":" + (p.pagination.descending ? "desc" : "asc");
|
|
286
|
+
}
|
|
265
287
|
|
|
288
|
+
//fields
|
|
289
|
+
const builder = GQLFieldBuilder();
|
|
290
|
+
if (props.rowKey) {
|
|
291
|
+
builder.add(props.rowKey);
|
|
292
|
+
}
|
|
266
293
|
|
|
267
|
-
|
|
294
|
+
props.columns?.forEach((col) => {
|
|
295
|
+
if (col.gqlField) {
|
|
296
|
+
builder.add(col.gqlField);
|
|
297
|
+
}
|
|
268
298
|
|
|
269
|
-
|
|
299
|
+
if (!col.name) return;
|
|
300
|
+
if (col.name.startsWith("_")) {
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
builder.add(col.name);
|
|
270
304
|
|
|
271
|
-
|
|
272
|
-
builder.add(props.rowKey);
|
|
273
|
-
}
|
|
305
|
+
});
|
|
274
306
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
307
|
+
if (actionView) {
|
|
308
|
+
builder.add("canView");
|
|
309
|
+
}
|
|
278
310
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
}
|
|
311
|
+
if (actionDelete) {
|
|
312
|
+
builder.add("canDelete");
|
|
313
|
+
}
|
|
283
314
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
builder.add(col.name);
|
|
315
|
+
if (activeEdit) {
|
|
316
|
+
builder.add("canUpdate");
|
|
317
|
+
}
|
|
288
318
|
|
|
289
|
-
});
|
|
290
319
|
|
|
291
|
-
|
|
292
|
-
|
|
320
|
+
const callback = {
|
|
321
|
+
sort: sort,
|
|
322
|
+
fields: builder.get(),
|
|
323
|
+
offset: (p.pagination.page - 1) * p.pagination.rowsPerPage,
|
|
324
|
+
limit: p.pagination.rowsPerPage,
|
|
325
|
+
gql: {
|
|
326
|
+
__args: {
|
|
327
|
+
filters: getFilterValue(),
|
|
328
|
+
sort: sort
|
|
329
|
+
},
|
|
330
|
+
data: {
|
|
331
|
+
__args: {
|
|
332
|
+
limit: p.pagination.rowsPerPage,
|
|
333
|
+
offset: (p.pagination.page - 1) * p.pagination.rowsPerPage
|
|
334
|
+
},
|
|
335
|
+
...toQuery(builder.get())
|
|
336
|
+
},
|
|
337
|
+
meta: {
|
|
338
|
+
total: true,
|
|
339
|
+
key: true,
|
|
340
|
+
name: true
|
|
293
341
|
}
|
|
342
|
+
},
|
|
343
|
+
setData(data: { data: Array<{ data: any }>, meta: { total: Number, key: string, name: string } }) {
|
|
344
|
+
rows.value = data.data;
|
|
345
|
+
primaryKey.value = data.meta.key;
|
|
346
|
+
modelName.value = data.meta.name;
|
|
347
|
+
pagination.value.rowsNumber = data.meta.total;
|
|
294
348
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
349
|
+
pagination.value.page = p.pagination.page;
|
|
350
|
+
pagination.value.sortBy = p.pagination.sortBy;
|
|
351
|
+
pagination.value.descending = p.pagination.descending;
|
|
352
|
+
pagination.value.rowsPerPage = p.pagination.rowsPerPage;
|
|
298
353
|
|
|
299
|
-
|
|
300
|
-
builder.add("canUpdate");
|
|
301
|
-
}
|
|
354
|
+
loading.value = false;
|
|
302
355
|
|
|
303
|
-
|
|
356
|
+
validateData();
|
|
357
|
+
},
|
|
358
|
+
loadObjects(model: string, filters: any = null, fields: Array<any> = []) {
|
|
359
|
+
return this.loadData("list" + model, filters, fields);
|
|
360
|
+
},
|
|
361
|
+
async loadData(operation: string, filters: any = null, fields: Array<any> = []) {
|
|
362
|
+
fields.forEach((f) => {
|
|
363
|
+
builder.add(f);
|
|
364
|
+
})
|
|
304
365
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
console.log("local filters", getFilterValue())
|
|
308
|
-
*/ //merge the filters
|
|
366
|
+
let localFilters = getFilterValue();
|
|
309
367
|
if (filters) {
|
|
310
368
|
localFilters = {
|
|
311
369
|
...localFilters,
|
|
312
370
|
...filters
|
|
313
371
|
}
|
|
314
372
|
}
|
|
315
|
-
|
|
316
|
-
let sort = "";
|
|
317
|
-
if (p.pagination.sortBy) {
|
|
318
|
-
sort = p.pagination.sortBy + ":" + (p.pagination.descending ? "desc" : "asc");
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
|
|
322
373
|
loading.value = true;
|
|
323
|
-
const
|
|
324
|
-
|
|
325
|
-
const allData = await getData(operation, localFilters, sort, offset, limit, builder.get());
|
|
326
|
-
|
|
327
|
-
rows.value = allData.data;
|
|
328
|
-
|
|
329
|
-
//meta
|
|
330
|
-
primaryKey.value = allData.meta.key;
|
|
331
|
-
modelName.value = allData.meta.name;
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
//pagination.value.rowsPerPage = p.pagination.rowsPerPage;
|
|
335
|
-
pagination.value.page = p.pagination.page;
|
|
336
|
-
pagination.value.sortBy = p.pagination.sortBy;
|
|
337
|
-
pagination.value.descending = p.pagination.descending;
|
|
338
|
-
pagination.value.rowsNumber = allData.meta.total;
|
|
339
|
-
|
|
340
|
-
loading.value = false;
|
|
341
|
-
validateData()
|
|
374
|
+
const allData = await getData(operation, localFilters, sort, this.offset, this.limit, builder.get());
|
|
375
|
+
this.setData(allData);
|
|
342
376
|
|
|
343
377
|
}
|
|
344
378
|
}
|
|
345
379
|
|
|
380
|
+
|
|
381
|
+
loading.value = true;
|
|
346
382
|
//emits("request", p);
|
|
347
383
|
emits("request", callback);
|
|
348
384
|
|
|
@@ -469,6 +505,7 @@ const isDark = computed(() => {
|
|
|
469
505
|
rows:{{ props.rows }}
|
|
470
506
|
</template>
|
|
471
507
|
|
|
508
|
+
|
|
472
509
|
<q-table v-bind="attrs" :row-key="rowKey" :loading="loading" :rows="rows" ref="table" @request="onRequest"
|
|
473
510
|
:rows-per-page-label="$t(props.rowsPerPageLabel)" :columns="renderColumns"
|
|
474
511
|
:rows-per-page-options="rowsPerPageOptions" :selection="selection" v-model:pagination="pagination" :filter="filter"
|
|
@@ -518,7 +555,7 @@ const isDark = computed(() => {
|
|
|
518
555
|
|
|
519
556
|
|
|
520
557
|
|
|
521
|
-
<template #top-row="props" v-if="hasSearch">
|
|
558
|
+
<template #top-row="props" v-if="hasSearch && isServerSide">
|
|
522
559
|
<q-tr>
|
|
523
560
|
<q-td v-if="selection != 'none'" auto-width>
|
|
524
561
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { getObject, getModelFields } from '../../../';
|
|
2
|
+
import { getObject, getModelFields, q, getModelColumns } from '../../../';
|
|
3
3
|
const obj = await getObject(["user_id", "username", "first_name", "last_name", "email", "phone", "roles", 'status', 'join_date']);
|
|
4
4
|
|
|
5
5
|
</script>
|
|
@@ -11,7 +11,7 @@ const obj = await getObject(["user_id", "username", "first_name", "last_name", "
|
|
|
11
11
|
<l-btn to="update-role" icon="sym_o_people" permission="user.role.add" label="Update role"></l-btn>
|
|
12
12
|
</template>
|
|
13
13
|
|
|
14
|
-
<l-card>
|
|
14
|
+
<l-card class="q-mb-md">
|
|
15
15
|
<l-list v-model="obj" :fields="getModelFields('User', [
|
|
16
16
|
'username',
|
|
17
17
|
'first_name',
|
|
@@ -24,5 +24,41 @@ const obj = await getObject(["user_id", "username", "first_name", "last_name", "
|
|
|
24
24
|
])">
|
|
25
25
|
</l-list>
|
|
26
26
|
</l-card>
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
<l-tabs>
|
|
31
|
+
|
|
32
|
+
<l-tab label="Event log">
|
|
33
|
+
<l-table row-key="eventlog_id" sort-by="eventlog_id:desc"
|
|
34
|
+
:columns="getModelColumns('EventLog', ['eventlog_id', 'class', 'id', 'action', 'created_time'])"
|
|
35
|
+
@request="async (req) => {
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
const a = {
|
|
39
|
+
listUser: {
|
|
40
|
+
__args: {
|
|
41
|
+
filters: {
|
|
42
|
+
user_id: obj.user_id
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
data: {
|
|
46
|
+
__args: {
|
|
47
|
+
limit: 1
|
|
48
|
+
},
|
|
49
|
+
eventLog: req.gql
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
let resp = await q(a);
|
|
55
|
+
req.setData(resp.listUser.data[0].eventLog)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
}" />
|
|
59
|
+
</l-tab>
|
|
60
|
+
|
|
61
|
+
</l-tabs>
|
|
62
|
+
|
|
27
63
|
</l-page>
|
|
28
64
|
</template>
|