@hostlink/nuxt-light 0.0.66 → 0.0.68

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": "0.0.66"
4
+ "version": "0.0.68"
5
5
  }
@@ -1,15 +1,16 @@
1
1
  <script setup lang="ts">
2
2
  import { useQuasar, QTable } from 'quasar';
3
- import { useRoute } from 'vue-router';
4
3
  import { ref, computed, onMounted, useSlots, reactive, useAttrs } from "vue";
5
4
  import { t, deleteObject, q, f, useLight } from '../';
6
5
 
7
- const route = useRoute();
8
- const module = route.path.split("/")[1];
9
6
  const errors = ref<InstanceType<any>>([]);
10
7
 
11
8
  const light = useLight();
12
9
  const props = defineProps({
10
+ debug: {
11
+ type: Boolean,
12
+ default: false
13
+ },
13
14
  columns: {
14
15
  type: Array<{
15
16
  label: string,
@@ -35,8 +36,7 @@ const props = defineProps({
35
36
  default: "Records per page:"
36
37
  },
37
38
  rows: {
38
- type: Array,
39
- default: () => []
39
+ type: Array
40
40
  },
41
41
  rowKey: {
42
42
  type: String,
@@ -45,18 +45,30 @@ const props = defineProps({
45
45
  modelName: {
46
46
  type: String,
47
47
  default: null
48
- }, pagination: {
49
- type: Boolean,
50
- default: true
51
48
  },
52
49
  selection: {
53
50
  type: String,
54
51
  default: "none"
52
+ },
53
+ rowsPerPageOptions: {
54
+ type: Array,
55
+ default: () => [3, 5, 7, 10, 15, 20, 25, 50, 0]
56
+ }, pagination: {
57
+ type: Object,
58
+ default: () => {
59
+ return {
60
+ sortBy: "",
61
+ descending: true,
62
+ page: 1,
63
+ rowsPerPage: 10,
64
+ }
65
+ }
55
66
  }
56
67
  })
57
68
 
58
- const hideBottom = ref(false)
59
-
69
+ if (props.rowsPerPageOptions[0] == 0) {
70
+ props.pagination.rowsPerPage = 0;
71
+ }
60
72
 
61
73
  //apply all aligns to the columns
62
74
  props.columns?.forEach((col) => {
@@ -71,7 +83,7 @@ props.columns?.forEach((col) => {
71
83
  })
72
84
 
73
85
  const renderColumns = computed(() => {
74
- if (!props.columns) return null;
86
+ if (props.columns == undefined) return undefined;
75
87
 
76
88
  let cols = [];
77
89
  if (props.actions.length > 0) {
@@ -109,18 +121,11 @@ if (props.actions.length > 0) {
109
121
  }
110
122
 
111
123
 
112
- const pagination = ref({
113
- sortBy: "",
114
- descending: true,
115
- page: 1,
116
- rowsPerPage: 10,
117
- rowsNumber: 0
118
- })
119
124
 
120
125
  if (props.sortBy) {
121
126
  let [sortBy, descending] = props.sortBy.split(":");
122
- pagination.value.sortBy = sortBy;
123
- pagination.value.descending = descending == "desc";
127
+ props.pagination.sortBy = sortBy;
128
+ props.pagination.descending = descending == "desc";
124
129
  }
125
130
 
126
131
  const hasSearch = computed(() => {
@@ -214,6 +219,10 @@ const onRequest = async (p: any) => {
214
219
  //
215
220
  let localFields: Array<any> = [];
216
221
 
222
+ if (props.rowKey) {
223
+ localFields.push(props.rowKey);
224
+ }
225
+
217
226
  fields.forEach((f) => {
218
227
  localFields.push(f);
219
228
  });
@@ -270,11 +279,11 @@ const onRequest = async (p: any) => {
270
279
  modelName.value = allData.meta.name;
271
280
 
272
281
 
273
- pagination.value.rowsPerPage = p.pagination.rowsPerPage;
274
- pagination.value.page = p.pagination.page;
275
- pagination.value.sortBy = p.pagination.sortBy;
276
- pagination.value.descending = p.pagination.descending;
277
- pagination.value.rowsNumber = allData.meta.total;
282
+ props.pagination.rowsPerPage = p.pagination.rowsPerPage;
283
+ props.pagination.page = p.pagination.page;
284
+ props.pagination.sortBy = p.pagination.sortBy;
285
+ props.pagination.descending = p.pagination.descending;
286
+ props.pagination.rowsNumber = allData.meta.total;
278
287
  loading.value = false;
279
288
  validateData()
280
289
 
@@ -317,9 +326,9 @@ const onFilters = () => {
317
326
  onRequest({
318
327
  pagination: {
319
328
  page: 1,
320
- rowsPerPage: pagination.value.rowsPerPage,
321
- sortBy: pagination.value.sortBy,
322
- descending: pagination.value.descending
329
+ rowsPerPage: props.pagination.rowsPerPage,
330
+ sortBy: props.pagination.sortBy,
331
+ descending: props.pagination.descending
323
332
  }
324
333
  })
325
334
  }
@@ -351,14 +360,6 @@ const onDelete = async (id: any) => {
351
360
 
352
361
  //style
353
362
 
354
- let rowsPerPageOptions = [3, 5, 7, 10, 15, 20, 25, 50, 0];
355
- if (props.pagination == false) {
356
- hideBottom.value = true;
357
- pagination.value = null;
358
- rowsPerPageOptions = [0]
359
- }
360
-
361
-
362
363
  const attrs = {
363
364
  ...{
364
365
  dense: light.getStyle("tableDense", false),
@@ -368,7 +369,6 @@ const attrs = {
368
369
  ...useAttrs()
369
370
  }
370
371
 
371
-
372
372
  </script>
373
373
  <template>
374
374
  <template v-if="errors.length > 0">
@@ -379,13 +379,24 @@ const attrs = {
379
379
  </div>
380
380
  </template>
381
381
 
382
- <q-table v-bind="$attrs" :flat="attrs.flat" :dense="attrs.dense" :bordered="attrs.bordered" :row-key="rowKey"
383
- :loading="loading" :hide-bottom="hideBottom" v-model:pagination="pagination" ref="table" @request="onRequest"
384
- :rows="rows" :rows-per-page-label="$t(props.rowsPerPageLabel)" :columns="renderColumns"
385
- :rows-per-page-options="rowsPerPageOptions"
386
- :selection="selection"
387
-
388
- >
382
+ <template v-if="debug">
383
+ <pre>primaryKey:{{ primaryKey }}
384
+ modelName:{{ modelName }}
385
+ filters:{{ filters }}
386
+ pagination:{{ pagination }}
387
+ actionView:{{ actionView }}
388
+ actionDelete:{{ actionDelete }}
389
+ activeEdit:{{ activeEdit }}
390
+ attrs:{{ attrs }}
391
+ $attrs:{{ $attrs }}
392
+ </pre>
393
+ rows:{{ props.rows }}
394
+ </template>
395
+
396
+ <q-table v-bind="attrs" :row-key="rowKey" :loading="loading" :rows="rows" ref="table" @request="onRequest"
397
+ :rows-per-page-label="$t(props.rowsPerPageLabel)" :columns="renderColumns"
398
+ :rows-per-page-options="rowsPerPageOptions" :selection="selection" :pagination="pagination">
399
+
389
400
 
390
401
  <template v-for="s in ss" v-slot:[s]="props">
391
402
  <slot :name="s" v-bind="props"></slot>
@@ -397,9 +408,10 @@ const attrs = {
397
408
  <div class="text-grey-8">
398
409
 
399
410
  <l-view-btn v-if="actionView && props.row.canView"
400
- :to="`/${modelName}/${props.row[primaryKey]}/view`"></l-view-btn>
411
+ :to="`/${modelName}/${props.row[primaryKey]}/view`" />
401
412
 
402
- <l-edit-btn :to="`/${modelName}/${props.row[primaryKey]}/edit`" v-if="activeEdit"></l-edit-btn>
413
+ <l-edit-btn :to="`/${modelName}/${props.row[primaryKey]}/edit`"
414
+ v-if="activeEdit && props.row.canUpdate" />
403
415
 
404
416
  <l-delete-btn v-if="actionDelete && props.row.canDelete"
405
417
  @submit="onDelete(props.row[primaryKey])"></l-delete-btn>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hostlink/nuxt-light",
3
- "version": "0.0.66",
3
+ "version": "0.0.68",
4
4
  "description": "HostLink Nuxt Light Framework",
5
5
  "repository": "@hostlink/nuxt-light",
6
6
  "license": "MIT",