@hostlink/nuxt-light 1.0.4 → 1.0.5
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
|
@@ -180,7 +180,7 @@ onMounted(() => {
|
|
|
180
180
|
</script>
|
|
181
181
|
|
|
182
182
|
<template>
|
|
183
|
-
<q-card bordered flat style="min-width:360px
|
|
183
|
+
<q-card bordered flat style="min-width:360px" class="fixed-center">
|
|
184
184
|
<q-card-section>
|
|
185
185
|
<q-img :src="light.getCompanyLogo()" class="full-width">
|
|
186
186
|
<template v-slot:error>
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { useQuasar, QTable } from 'quasar';
|
|
2
|
+
import { useQuasar, QTable, type QTableColumn, type QTableProps } from 'quasar';
|
|
3
|
+
|
|
3
4
|
import { ref, computed, onMounted, useSlots, useAttrs } from "vue";
|
|
4
5
|
import { t, q, useLight, GQLFieldBuilder, model } from '../';
|
|
5
6
|
import { toQuery } from '@hostlink/light';
|
|
6
|
-
|
|
7
|
+
|
|
7
8
|
|
|
8
9
|
// extends QTableColumn
|
|
9
10
|
export interface LTableColumn extends QTableColumn {
|
|
@@ -17,66 +18,37 @@ export interface LTableColumn extends QTableColumn {
|
|
|
17
18
|
|
|
18
19
|
const errors = ref<InstanceType<any>>([]);
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
rows: {
|
|
42
|
-
type: Array
|
|
43
|
-
},
|
|
44
|
-
rowKey: {
|
|
45
|
-
type: String,
|
|
46
|
-
default: null
|
|
47
|
-
},
|
|
48
|
-
modelName: {
|
|
49
|
-
type: String,
|
|
50
|
-
default: null
|
|
51
|
-
},
|
|
52
|
-
selection: {
|
|
53
|
-
type: String,
|
|
54
|
-
default: "none"
|
|
55
|
-
},
|
|
56
|
-
rowsPerPageOptions: {
|
|
57
|
-
type: Array,
|
|
58
|
-
default: () => [3, 5, 7, 10, 15, 20, 25, 50, 0]
|
|
59
|
-
}, pagination: {
|
|
60
|
-
type: Object,
|
|
61
|
-
default: () => {
|
|
62
|
-
return {
|
|
63
|
-
sortBy: "",
|
|
64
|
-
descending: true,
|
|
65
|
-
page: 1,
|
|
66
|
-
rowsPerPage: 10,
|
|
67
|
-
}
|
|
21
|
+
export interface LTableProps extends QTableProps {
|
|
22
|
+
columns?: Array<LTableColumn>,
|
|
23
|
+
actions?: Array<string>,
|
|
24
|
+
sortBy?: string | null | undefined,
|
|
25
|
+
rowKey?: string,
|
|
26
|
+
modelName?: string | null | undefined,
|
|
27
|
+
searchable?: boolean | null | undefined,
|
|
28
|
+
selected?: Array<any>,
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const props = withDefaults(defineProps<LTableProps>(), {
|
|
32
|
+
actions: () => [],
|
|
33
|
+
rowsPerPageLabel: "Records per page:",
|
|
34
|
+
selection: "none",
|
|
35
|
+
rowsPerPageOptions: () => [3, 5, 7, 10, 15, 20, 25, 50, 0],
|
|
36
|
+
pagination: () => {
|
|
37
|
+
return {
|
|
38
|
+
sortBy: null,
|
|
39
|
+
descending: true,
|
|
40
|
+
page: 1,
|
|
41
|
+
rowsPerPage: 10,
|
|
68
42
|
}
|
|
69
43
|
},
|
|
70
|
-
fullscreen:
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
default: false
|
|
77
|
-
}
|
|
78
|
-
})
|
|
44
|
+
fullscreen: false,
|
|
45
|
+
searchable: false,
|
|
46
|
+
selected: () => [],
|
|
47
|
+
loadingLabel: "Loading...",
|
|
48
|
+
noDataLabel: "No data available",
|
|
49
|
+
});
|
|
79
50
|
|
|
51
|
+
const light = useLight();
|
|
80
52
|
|
|
81
53
|
const pagination = ref(props.pagination);
|
|
82
54
|
|
|
@@ -133,7 +105,8 @@ export interface LTableRequest {
|
|
|
133
105
|
}
|
|
134
106
|
|
|
135
107
|
const emits = defineEmits<{
|
|
136
|
-
request: [p: LTableRequest]
|
|
108
|
+
request: [p: LTableRequest],
|
|
109
|
+
"update:selected": [p: Array<any>]
|
|
137
110
|
}>()
|
|
138
111
|
|
|
139
112
|
const loading = ref(false);
|
|
@@ -181,8 +154,13 @@ const modelName = ref(props.modelName);
|
|
|
181
154
|
|
|
182
155
|
|
|
183
156
|
const validateData = () => {
|
|
157
|
+
if (primaryKey.value == null) return;
|
|
158
|
+
|
|
184
159
|
if (props.actions.includes("edit")) {
|
|
185
160
|
if (rows.value.length > 0) {
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
186
164
|
//get first row
|
|
187
165
|
let row = rows.value[0];
|
|
188
166
|
//check has primary key
|
|
@@ -416,6 +394,7 @@ const ss = Object.entries(slots).map(([key, value]) => {
|
|
|
416
394
|
|
|
417
395
|
const qua = useQuasar();
|
|
418
396
|
const onDelete = async (id: any) => {
|
|
397
|
+
if (modelName.value == null) return;
|
|
419
398
|
|
|
420
399
|
try {
|
|
421
400
|
await model(modelName.value).delete(id);
|
|
@@ -439,7 +418,14 @@ const attrs = {
|
|
|
439
418
|
bordered: light.getStyle("tableBorder"),
|
|
440
419
|
separator: light.getStyle("tableSeparator"),
|
|
441
420
|
},
|
|
442
|
-
...useAttrs()
|
|
421
|
+
...useAttrs(),
|
|
422
|
+
title: props.title,
|
|
423
|
+
loadingLabel: t(props.loadingLabel),
|
|
424
|
+
noDataLabel: t(props.noDataLabel),
|
|
425
|
+
rowsPerPageOptions: props.rowsPerPageOptions,
|
|
426
|
+
rowsPerPageLabel: t(props.rowsPerPageLabel),
|
|
427
|
+
selection: props.selection,
|
|
428
|
+
rowKey: props.rowKey,
|
|
443
429
|
}
|
|
444
430
|
|
|
445
431
|
const filter = ref('');
|
|
@@ -499,6 +485,16 @@ const getCellClass = (col: any, row: any) => {
|
|
|
499
485
|
return cl;
|
|
500
486
|
}
|
|
501
487
|
|
|
488
|
+
const localSelected = computed({
|
|
489
|
+
get() {
|
|
490
|
+
return props.selected;
|
|
491
|
+
},
|
|
492
|
+
set(val) {
|
|
493
|
+
console.log(val)
|
|
494
|
+
emits("update:selected", val);
|
|
495
|
+
}
|
|
496
|
+
});
|
|
497
|
+
|
|
502
498
|
</script>
|
|
503
499
|
|
|
504
500
|
|
|
@@ -509,33 +505,14 @@ const getCellClass = (col: any, row: any) => {
|
|
|
509
505
|
</div>
|
|
510
506
|
</template>
|
|
511
507
|
|
|
512
|
-
<
|
|
513
|
-
|
|
514
|
-
primaryKey:{{ primaryKey }}
|
|
515
|
-
modelName:{{ modelName }}
|
|
516
|
-
filters:{{ filters }}
|
|
517
|
-
pagination:{{ pagination }}
|
|
518
|
-
actionView:{{ actionView }}
|
|
519
|
-
actionDelete:{{ actionDelete }}
|
|
520
|
-
activeEdit:{{ activeEdit }}
|
|
521
|
-
attrs:{{ attrs }}
|
|
522
|
-
$attrs:{{ $attrs }}
|
|
523
|
-
</pre>
|
|
524
|
-
rows:{{ props.rows }}
|
|
525
|
-
</template>
|
|
526
|
-
|
|
527
|
-
<q-table v-bind="attrs" :row-key="rowKey" :loading="loading" :rows="rows" ref="table" @request="onRequest"
|
|
528
|
-
:rows-per-page-label="$t(props.rowsPerPageLabel)" :columns="columns" :rows-per-page-options="rowsPerPageOptions"
|
|
529
|
-
:selection="selection" v-model:pagination="pagination" :filter="filter" :no-data-label="$t('No data available')"
|
|
530
|
-
:loading-label="$t('Loading...')">
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
<!-- template v-for="s in ss" v-slot:[s]="props">
|
|
534
|
-
<slot :name="s" v-bind="props"></slot>
|
|
535
|
-
</template -->
|
|
508
|
+
<q-table v-bind="attrs" :loading="loading" :rows="rows" ref="table" @request="onRequest" :columns="columns"
|
|
509
|
+
v-model:pagination="pagination" :filter="filter" v-model:selected="localSelected">
|
|
536
510
|
|
|
537
511
|
<template #header="props">
|
|
538
512
|
<q-tr :props="props">
|
|
513
|
+
<q-td v-if="selection != 'none'" auto-width>
|
|
514
|
+
<q-checkbox v-model="props.selected" />
|
|
515
|
+
</q-td>
|
|
539
516
|
<q-th v-if="hasRowExpand" auto-width></q-th>
|
|
540
517
|
<q-th v-if="hasActions" auto-width></q-th>
|
|
541
518
|
<q-th v-for="col in props.cols" :key="col.name" :props="props">{{ col.label }}</q-th>
|
|
@@ -544,6 +521,9 @@ const getCellClass = (col: any, row: any) => {
|
|
|
544
521
|
|
|
545
522
|
<template #body="props">
|
|
546
523
|
<q-tr :props="props">
|
|
524
|
+
<q-td v-if="selection != 'none'" auto-width>
|
|
525
|
+
<q-checkbox v-model="props.selected" />
|
|
526
|
+
</q-td>
|
|
547
527
|
<q-td v-if="hasRowExpand" auto-width>
|
|
548
528
|
<q-btn :class="{ 'text-grey-8': !isDark }" flat round dense
|
|
549
529
|
:icon="props.expand ? 'sym_o_expand_more' : 'sym_o_expand_less'"
|
|
@@ -551,7 +531,7 @@ const getCellClass = (col: any, row: any) => {
|
|
|
551
531
|
</q-td>
|
|
552
532
|
|
|
553
533
|
<q-td v-if="hasActions" auto-width>
|
|
554
|
-
<div :class="{ 'text-grey-8': !isDark }">
|
|
534
|
+
<div :class="{ 'text-grey-8': !isDark }" v-if="primaryKey">
|
|
555
535
|
|
|
556
536
|
<l-view-btn v-if="actionView && props.row.canView"
|
|
557
537
|
:to="`/${modelName}/${props.row[primaryKey]}/view`" />
|
|
@@ -7,11 +7,13 @@ const onRequest = async (request) => {
|
|
|
7
7
|
};
|
|
8
8
|
const columns = model("User").columns(["username", "first_name", "label_name", "email", "phone", "join_date", "status"]);
|
|
9
9
|
const status = ref("0");
|
|
10
|
+
const selected = ref([]);
|
|
10
11
|
</script>
|
|
11
12
|
|
|
12
13
|
<template>
|
|
13
14
|
<l-page>
|
|
14
15
|
|
|
16
|
+
|
|
15
17
|
<l-tabs v-model="status">
|
|
16
18
|
<l-tab label="Active" name="0">
|
|
17
19
|
<l-table row-key="user_id" @request="onRequest" :columns="columns"
|