@hostlink/nuxt-light 1.0.3 → 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
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "light",
3
3
  "configKey": "light",
4
- "version": "1.0.3"
4
+ "version": "1.0.5"
5
5
  }
@@ -1,7 +1,7 @@
1
1
 
2
2
  <script setup>
3
3
  import * as XLSX from "xlsx";
4
- import { computed, ref, useAttrs, useSlots } from "vue";
4
+ import { ref, useAttrs, } from "vue";
5
5
  import { useLight } from "#imports"
6
6
 
7
7
  const emit = defineEmits(["update:modelValue"]);
@@ -50,7 +50,7 @@ const showView = ref(false);
50
50
  </script>
51
51
 
52
52
  <template>
53
- <q-field v-bind="attrs" :loading="loading" :model-value="localData" @update:model-value="onClear" :clearable="hasFile">
53
+ <q-field v-bind="attrs" :loading="loading" :model-value="localData" @update:model-value="onClear">
54
54
  <template v-slot:control>
55
55
  <template v-if="!hasFile">
56
56
  <input type="file" accept=".xlsx" @change="onChange" ref="file" />
@@ -66,10 +66,15 @@ const showView = ref(false);
66
66
  <q-icon name="sym_o_table_view" @click="showView = true" class="cursor-pointer" />
67
67
  </template>
68
68
 
69
+
70
+ <template v-slot:append v-if="hasFile">
71
+ <q-icon name="cancel" @click="onClear" class="cursor-pointer" />
72
+ </template>
73
+
69
74
  <q-dialog v-model="showView" full-width>
70
75
  <q-card>
71
76
  <q-card-section>
72
- <q-table :rows="localData" />
77
+ <q-table :rows="localData" dense separator="cell" flat bordered/>
73
78
  </q-card-section>
74
79
  </q-card>
75
80
  </q-dialog>
@@ -180,7 +180,7 @@ onMounted(() => {
180
180
  </script>
181
181
 
182
182
  <template>
183
- <q-card bordered flat style="min-width:360px;max-width: 400px;" class="fixed-center">
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
- import { type QTableColumn } from 'quasar';
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
- const light = useLight();
21
- const props = defineProps({
22
- debug: {
23
- type: Boolean,
24
- default: false
25
- },
26
- columns: {
27
- type: Array<LTableColumn>
28
- },
29
- actions: {
30
- type: Array,
31
- default: () => []
32
- },
33
- sortBy: {
34
- type: String,
35
- default: null
36
- },
37
- rowsPerPageLabel: {
38
- type: String,
39
- default: "Records per page:"
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
- type: Boolean,
72
- default: false
73
- },
74
- searchable: {
75
- type: Boolean,
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
- <template v-if="debug">
513
- <pre>
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`" />
@@ -104,22 +104,20 @@ if (obj.mode != 'prod') {
104
104
  <q-separator />
105
105
 
106
106
  <FormKit label="Auth lockout duration" type="l-input" name="auth_lockout_duration"
107
- hint="The number of minutes the user is locked out after the maximum number of failed login attempts. Default is 15 minutes." />
107
+ hint="The number of minutes the user is locked out after the maximum number of failed login attempts. Default is 15 minutes."
108
+ validation="required" />
108
109
 
109
110
  <FormKit label="Auth lockout attempts" type="l-input" name="auth_lockout_attempts"
110
- hint="The number of failed login attempts before the user is locked out. Default is 5 attempts." />
111
-
112
-
111
+ hint="The number of failed login attempts before the user is locked out. Default is 5 attempts."
112
+ validation="required" />
113
113
 
114
114
  <FormKit label="Access token expiration" type="l-input" name="access_token_expire"
115
- hint="The access token expiration time in seconds. Default is 28800 seconds (8 hours)." />
116
-
117
-
118
-
115
+ hint="The access token expiration time in seconds. Default is 28800 seconds (8 hours)."
116
+ validation="required" />
119
117
 
120
118
  <q-separator />
121
119
 
122
- <FormKit label="Copyright name" type="l-input" name="copyright_name" />
120
+ <FormKit label="Copyright name" type="l-input" name="copyright_name" validation="required" />
123
121
  <FormKit label="Copyright year" type="l-input" name="copyright_year" validation="required" />
124
122
 
125
123
 
@@ -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"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hostlink/nuxt-light",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "HostLink Nuxt Light Framework",
5
5
  "repository": "@hostlink/nuxt-light",
6
6
  "license": "MIT",