@hostlink/nuxt-light 0.0.43 → 0.0.44

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.43"
4
+ "version": "0.0.44"
5
5
  }
@@ -10,8 +10,6 @@ const errors = ref<InstanceType<any>>([]);
10
10
 
11
11
  const light = useLight();
12
12
 
13
-
14
-
15
13
  const props = defineProps({
16
14
  columns: {
17
15
  type: Array<{
@@ -22,8 +20,7 @@ const props = defineProps({
22
20
  searchable?: boolean,
23
21
  searchType?: string,
24
22
  field?: string | Object,
25
- }>,
26
- required: true
23
+ }>
27
24
  },
28
25
  actions: {
29
26
  type: Array,
@@ -41,11 +38,28 @@ const props = defineProps({
41
38
  type: String,
42
39
  default: "Records per page:"
43
40
  },
41
+ rows: {
42
+ type: Array,
43
+ default: () => []
44
+ },
45
+ rowKey: {
46
+ type: String,
47
+ default: null
48
+ },
49
+ modelName: {
50
+ type: String,
51
+ default: null
52
+ }, pagination: {
53
+ type: Boolean,
54
+ default: true
55
+ }
44
56
  })
45
57
 
58
+ const hideBottom = ref(false)
59
+
46
60
 
47
61
  //apply all aligns to the columns
48
- props.columns.forEach((col) => {
62
+ props.columns?.forEach((col) => {
49
63
  if (!col.align) {
50
64
  col.align = "left";
51
65
  }
@@ -57,6 +71,8 @@ props.columns.forEach((col) => {
57
71
  })
58
72
 
59
73
  const renderColumns = computed(() => {
74
+ if (!props.columns) return null;
75
+
60
76
  let cols = [];
61
77
  if (props.actions.length > 0) {
62
78
  cols = [
@@ -64,7 +80,7 @@ const renderColumns = computed(() => {
64
80
  name: "_actions",
65
81
  align: "left"
66
82
  },
67
- ...props.columns
83
+ ...props.columns ?? []
68
84
  ]
69
85
  } else {
70
86
  cols = props.columns;
@@ -108,7 +124,7 @@ if (props.sortBy) {
108
124
  }
109
125
 
110
126
  const hasSearch = computed(() => {
111
- return props.columns.some((col) => {
127
+ return props.columns?.some((col) => {
112
128
  return col.searchable;
113
129
  })
114
130
  })
@@ -116,7 +132,7 @@ const hasSearch = computed(() => {
116
132
  const table = ref<InstanceType<typeof QTable>>();
117
133
 
118
134
  const filters = ref<InstanceType<any>>({});
119
- const rows = ref<InstanceType<any>>([]);
135
+ const rows = ref<InstanceType<any>>(props.rows);
120
136
 
121
137
  onMounted(() => {
122
138
  if (table.value) {
@@ -124,8 +140,8 @@ onMounted(() => {
124
140
  }
125
141
  })
126
142
 
127
- let primaryKey = ref(null);
128
- const modelName = ref("");
143
+ let primaryKey = ref(props.rowKey);
144
+ const modelName = ref(props.modelName);
129
145
 
130
146
 
131
147
  const validateData = () => {
@@ -202,7 +218,7 @@ const onRequest = async (p: any) => {
202
218
  localFields.push(f);
203
219
  });
204
220
 
205
- props.columns.forEach((col) => {
221
+ props.columns?.forEach((col) => {
206
222
  if (col.name.startsWith("_")) {
207
223
  return;
208
224
  }
@@ -273,7 +289,7 @@ const onRequest = async (p: any) => {
273
289
  const getFilterValue = () => {
274
290
  let f: any = {};
275
291
 
276
- props.columns.forEach((col) => {
292
+ props.columns?.forEach((col) => {
277
293
  if (col.searchable) {
278
294
  if (filters.value[col.name]) {
279
295
 
@@ -337,6 +353,14 @@ const onDelete = async (id: any) => {
337
353
  const dense = light.getStyle("tableDense", false);
338
354
  const flat = light.getStyle("tableFlat", true);
339
355
  const bordered = light.getStyle("tableBorder", true);
356
+
357
+ let rowsPerPageOptions = [3, 5, 7, 10, 15, 20, 25, 50, 0];
358
+ if (props.pagination == false) {
359
+ hideBottom.value = true;
360
+ pagination.value = null;
361
+ rowsPerPageOptions = [0]
362
+ }
363
+
340
364
  </script>
341
365
  <template>
342
366
  <template v-if="errors.length > 0">
@@ -346,9 +370,12 @@ const bordered = light.getStyle("tableBorder", true);
346
370
  </ul>
347
371
  </div>
348
372
  </template>
349
- <q-table :flat="flat" :bordered="bordered" :dense="dense" :columns="renderColumns" v-model:pagination="pagination"
350
- ref="table" :loading="loading" @request="onRequest" :selection="selection" :rows="rows"
351
- :rows-per-page-label="t(props.rowsPerPageLabel)">
373
+
374
+ <q-table :flat="flat" :bordered="bordered" :dense="dense" v-model:pagination="pagination" ref="table" :loading="loading"
375
+ @request="onRequest" :selection="selection" :rows="rows" :rows-per-page-label="t(props.rowsPerPageLabel)"
376
+ :hide-bottom="hideBottom" :columns="renderColumns"
377
+ :rows-per-page-options="rowsPerPageOptions"
378
+ >
352
379
 
353
380
  <template v-for="s in ss" v-slot:[s]="props">
354
381
  <slot :name="s" v-bind="props"></slot>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hostlink/nuxt-light",
3
- "version": "0.0.43",
3
+ "version": "0.0.44",
4
4
  "description": "HostLink Nuxt Light Framework",
5
5
  "repository": "@hostlink/nuxt-light",
6
6
  "license": "MIT",