@hostlink/nuxt-light 0.0.100 → 0.0.101
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 { reactive } from 'vue'
|
|
3
2
|
import { useQuasar, QTable } 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
|
|
|
@@ -102,8 +102,8 @@ if (props.columns) {
|
|
|
102
102
|
if (typeof opts == "function") {
|
|
103
103
|
props.columns[i].searchOptions = await opts();
|
|
104
104
|
}
|
|
105
|
-
|
|
106
|
-
|
|
105
|
+
|
|
106
|
+
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
}
|
|
@@ -127,8 +127,26 @@ const renderColumns = computed(() => {
|
|
|
127
127
|
})
|
|
128
128
|
|
|
129
129
|
interface LTableRequest {
|
|
130
|
-
|
|
131
|
-
|
|
130
|
+
sort: string,
|
|
131
|
+
fields: Array<string>,
|
|
132
|
+
gql: {
|
|
133
|
+
data: {
|
|
134
|
+
__args: {
|
|
135
|
+
limit: number
|
|
136
|
+
},
|
|
137
|
+
[key: string]: any
|
|
138
|
+
},
|
|
139
|
+
meta: {
|
|
140
|
+
total: boolean,
|
|
141
|
+
key: boolean,
|
|
142
|
+
name: boolean
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
offset: number,
|
|
146
|
+
limit: number,
|
|
147
|
+
loadData: (model: string, filters: any, fields: Array<any>) => void,
|
|
148
|
+
loadObjects: (model: string, filters: any, fields: Array<any>) => void,
|
|
149
|
+
setData: (data: { data: Array<{ data: any }>, meta: { total: Number, key: string, name: string } }) => void,
|
|
132
150
|
}
|
|
133
151
|
|
|
134
152
|
const emits = defineEmits<{
|
|
@@ -255,94 +273,104 @@ const getData = async (
|
|
|
255
273
|
|
|
256
274
|
const onRequest = async (p: any) => {
|
|
257
275
|
|
|
276
|
+
let sort = "";
|
|
277
|
+
if (p.pagination.sortBy) {
|
|
278
|
+
sort = p.pagination.sortBy + ":" + (p.pagination.descending ? "desc" : "asc");
|
|
279
|
+
}
|
|
258
280
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
async loadData(operation: string, filters: any = null, fields: Array<any> = []) {
|
|
265
|
-
|
|
281
|
+
//fields
|
|
282
|
+
const builder = GQLFieldBuilder();
|
|
283
|
+
if (props.rowKey) {
|
|
284
|
+
builder.add(props.rowKey);
|
|
285
|
+
}
|
|
266
286
|
|
|
267
|
-
|
|
287
|
+
props.columns?.forEach((col) => {
|
|
288
|
+
if (col.gqlField) {
|
|
289
|
+
builder.add(col.gqlField);
|
|
290
|
+
}
|
|
268
291
|
|
|
269
|
-
|
|
292
|
+
if (col.name.startsWith("_")) {
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
builder.add(col.name);
|
|
270
296
|
|
|
271
|
-
|
|
272
|
-
builder.add(props.rowKey);
|
|
273
|
-
}
|
|
297
|
+
});
|
|
274
298
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
299
|
+
if (actionView) {
|
|
300
|
+
builder.add("canView");
|
|
301
|
+
}
|
|
278
302
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
}
|
|
303
|
+
if (actionDelete) {
|
|
304
|
+
builder.add("canDelete");
|
|
305
|
+
}
|
|
283
306
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
builder.add(col.name);
|
|
307
|
+
if (activeEdit) {
|
|
308
|
+
builder.add("canUpdate");
|
|
309
|
+
}
|
|
288
310
|
|
|
289
|
-
});
|
|
290
311
|
|
|
291
|
-
|
|
292
|
-
|
|
312
|
+
const callback = {
|
|
313
|
+
sort: sort,
|
|
314
|
+
fields: builder.get(),
|
|
315
|
+
offset: (p.pagination.page - 1) * p.pagination.rowsPerPage,
|
|
316
|
+
limit: p.pagination.rowsPerPage,
|
|
317
|
+
gql: {
|
|
318
|
+
__args: {
|
|
319
|
+
filters: getFilterValue(),
|
|
320
|
+
sort: sort
|
|
321
|
+
},
|
|
322
|
+
data: {
|
|
323
|
+
__args: {
|
|
324
|
+
limit: p.pagination.rowsPerPage,
|
|
325
|
+
offset: (p.pagination.page - 1) * p.pagination.rowsPerPage
|
|
326
|
+
},
|
|
327
|
+
...toQuery(builder.get())
|
|
328
|
+
},
|
|
329
|
+
meta: {
|
|
330
|
+
total: true,
|
|
331
|
+
key: true,
|
|
332
|
+
name: true
|
|
293
333
|
}
|
|
334
|
+
},
|
|
335
|
+
setData(data: { data: Array<{ data: any }>, meta: { total: Number, key: string, name: string } }) {
|
|
336
|
+
rows.value = data.data;
|
|
337
|
+
primaryKey.value = data.meta.key;
|
|
338
|
+
modelName.value = data.meta.name;
|
|
339
|
+
pagination.value.rowsNumber = data.meta.total;
|
|
294
340
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
341
|
+
pagination.value.page = p.pagination.page;
|
|
342
|
+
pagination.value.sortBy = p.pagination.sortBy;
|
|
343
|
+
pagination.value.descending = p.pagination.descending;
|
|
344
|
+
pagination.value.rowsPerPage = p.pagination.rowsPerPage;
|
|
298
345
|
|
|
299
|
-
|
|
300
|
-
builder.add("canUpdate");
|
|
301
|
-
}
|
|
346
|
+
loading.value = false;
|
|
302
347
|
|
|
303
|
-
|
|
348
|
+
validateData();
|
|
349
|
+
},
|
|
350
|
+
loadObjects(model: string, filters: any = null, fields: Array<any> = []) {
|
|
351
|
+
return this.loadData("list" + model, filters, fields);
|
|
352
|
+
},
|
|
353
|
+
async loadData(operation: string, filters: any = null, fields: Array<any> = []) {
|
|
354
|
+
fields.forEach((f) => {
|
|
355
|
+
builder.add(f);
|
|
356
|
+
})
|
|
304
357
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
console.log("local filters", getFilterValue())
|
|
308
|
-
*/ //merge the filters
|
|
358
|
+
let localFilters = getFilterValue();
|
|
309
359
|
if (filters) {
|
|
310
360
|
localFilters = {
|
|
311
361
|
...localFilters,
|
|
312
362
|
...filters
|
|
313
363
|
}
|
|
314
364
|
}
|
|
315
|
-
|
|
316
|
-
let sort = "";
|
|
317
|
-
if (p.pagination.sortBy) {
|
|
318
|
-
sort = p.pagination.sortBy + ":" + (p.pagination.descending ? "desc" : "asc");
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
|
|
322
365
|
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()
|
|
366
|
+
const allData = await getData(operation, localFilters, sort, this.offset, this.limit, builder.get());
|
|
367
|
+
this.setData(allData);
|
|
342
368
|
|
|
343
369
|
}
|
|
344
370
|
}
|
|
345
371
|
|
|
372
|
+
|
|
373
|
+
loading.value = true;
|
|
346
374
|
//emits("request", p);
|
|
347
375
|
emits("request", callback);
|
|
348
376
|
|
|
@@ -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>
|