@hostlink/nuxt-light 0.0.40 → 0.0.41

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.40"
4
+ "version": "0.0.41"
5
5
  }
@@ -73,10 +73,8 @@ if (props.addBtn) {
73
73
 
74
74
  //const title = props.title || route.path.split("/")[1];
75
75
 
76
- //title split by Capital letter
77
- const title = props.title || route.path.split("/")[1].split(/(?=[A-Z])/).join(" ");
78
-
79
-
76
+ //title split by Capital letter, but if Captial letter is followed by another Capital letter, it is not split
77
+ const title = props.title || route.path.split("/")[1].replace(/([A-Z])(?=[A-Z])/g, '$1 ').replace(/([a-z])(?=[A-Z])/g, '$1 ');
80
78
 
81
79
  const module = route.path.split("/")[1];
82
80
  const onDelete = async () => {
@@ -0,0 +1,6 @@
1
+ <script setup>
2
+
3
+ </script>
4
+ <template>
5
+ <q-tab></q-tab>
6
+ </template>
@@ -25,9 +25,9 @@ const props = defineProps({
25
25
  }>,
26
26
  required: true
27
27
  },
28
- showActions: {
29
- type: [Boolean, Array],
30
- default: false
28
+ actions: {
29
+ type: Array,
30
+ default: () => []
31
31
  },
32
32
  selection: {
33
33
  type: String,
@@ -58,7 +58,7 @@ props.columns.forEach((col) => {
58
58
 
59
59
  const renderColumns = computed(() => {
60
60
  let cols = [];
61
- if (props.showActions) {
61
+ if (props.actions.length > 0) {
62
62
  cols = [
63
63
  {
64
64
  name: "_actions",
@@ -86,10 +86,10 @@ const loading = ref(false);
86
86
  let activeEdit = false;
87
87
  let actionView = false;
88
88
  let actionDelete = false;
89
- if (props.showActions && props.showActions instanceof Array) {
90
- actionView = props.showActions.includes("view");
91
- activeEdit = props.showActions.includes("edit");
92
- actionDelete = props.showActions.includes("delete");
89
+ if (props.actions.length > 0) {
90
+ actionView = props.actions.includes("view");
91
+ activeEdit = props.actions.includes("edit");
92
+ actionDelete = props.actions.includes("delete");
93
93
  }
94
94
 
95
95
 
@@ -129,31 +129,28 @@ const modelName = ref("");
129
129
 
130
130
 
131
131
  const validateData = () => {
132
- if (props.showActions) {
133
- if (props.showActions.includes("edit")) {
134
- if (rows.value.length > 0) {
135
- //get first row
136
- let row = rows.value[0];
137
- //check has primary key
138
-
139
- if (!primaryKey.value) {
140
- errors.value.push("[edit] Primary key not found in the data");
141
- }
132
+ if (props.actions.includes("edit")) {
133
+ if (rows.value.length > 0) {
134
+ //get first row
135
+ let row = rows.value[0];
136
+ //check has primary key
137
+
138
+ if (!primaryKey.value) {
139
+ errors.value.push("[edit] Primary key not found in the data");
142
140
  }
143
141
  }
142
+ }
144
143
 
145
- if (props.showActions.includes("delete")) {
146
- if (rows.value.length > 0) {
147
- //get first row
148
- let row = rows.value[0];
149
- //check has primary key
144
+ if (props.actions.includes("delete")) {
145
+ if (rows.value.length > 0) {
146
+ //get first row
147
+ let row = rows.value[0];
148
+ //check has primary key
150
149
 
151
- if (!row[primaryKey.value]) {
152
- errors.value.push("[delete] Primary key not found in the data");
153
- }
150
+ if (!row[primaryKey.value]) {
151
+ errors.value.push("[delete] Primary key not found in the data");
154
152
  }
155
153
  }
156
-
157
154
  }
158
155
 
159
156
  }
@@ -336,7 +333,6 @@ const onDelete = async (id: any) => {
336
333
  }
337
334
 
338
335
 
339
-
340
336
  //style
341
337
  const dense = light.getStyle("tableDense", false);
342
338
  const flat = light.getStyle("tableFlat", true);
@@ -385,12 +381,19 @@ const bordered = light.getStyle("tableBorder", true);
385
381
  </q-td>
386
382
  <q-td v-for="col in props.cols">
387
383
  <template v-if="col.searchable">
384
+
385
+ <template v-if="col.searchType == 'select'">
386
+ <q-select dense v-model="filters[col.name]" @update:model-value="onFilters" clearable
387
+ :options="col.searchOptions" @clear="onFilters" emit-value />
388
+
389
+ </template>
390
+
388
391
  <template v-if="col.searchType == 'date'">
389
392
  <l-date-picker hide-bottom-space v-model="filters[col.name]" dense
390
393
  @update:model-value="onFilters" clearable range @clear="onFilters" />
391
394
  </template>
392
395
 
393
- <template v-else>
396
+ <template v-if="!col.searchType">
394
397
  <q-input dense clearable v-model="filters[col.name]" @keydown.enter.prevent="onFilters"
395
398
  @clear="onFilters"></q-input>
396
399
 
@@ -1,5 +1,35 @@
1
+ <script setup>
2
+ import { useSlots, computed } from 'vue';
3
+
4
+ const props = defineProps(["modelValue"])
5
+ const emit = defineEmits(["update:modelValue"])
6
+ const slots = useSlots();
7
+ const defaultSlots = slots.default();
8
+
9
+ //get the tabs from the default slot
10
+ const tabContents = defaultSlots.map((slot) => {
11
+ return {
12
+ label: slot.props.label,
13
+ content: slot.children,
14
+ name: slot.props.name
15
+ }
16
+ })
17
+
18
+ const localValue = computed({
19
+ get: () => props.modelValue,
20
+ set: (val) => emit("update:modelValue", val)
21
+ })
22
+ </script>
23
+
1
24
  <template>
2
- <q-tabs class="text-grey" active-color="primary" indicator-color="primary" align="justify">
3
- <slot></slot>
4
- </q-tabs>
25
+ <l-card>
26
+ <q-tabs class="text-grey" active-color="primary" indicator-color="primary" align="justify" v-model="localValue">
27
+ <q-tab v-for="tab in tabContents" :label="tab.label" :name="tab.name"></q-tab>
28
+ </q-tabs>
29
+ <q-tab-panels v-model="localValue">
30
+ <q-tab-panel v-for="tab in tabContents" :name="tab.name">
31
+ <component :is="tab.content.default"></component>
32
+ </q-tab-panel>
33
+ </q-tab-panels>
34
+ </l-card>
5
35
  </template>
@@ -43,7 +43,7 @@ const columns = [
43
43
  <template>
44
44
  <l-page>
45
45
  <l-table @request="$event.loadObjects('EventLog')" :columns="columns" sort-by="eventlog_id:desc"
46
- :show-actions="['view']">
46
+ :actions="['view']">
47
47
 
48
48
  </l-table>
49
49
  </l-page>
@@ -21,6 +21,6 @@ const columns = [
21
21
  </script>
22
22
  <template>
23
23
  <l-page add-btn>
24
- <l-table @request="onRequest" :columns="columns" :show-actions="['delete']"></l-table>
24
+ <l-table @request="onRequest" :columns="columns" :actions="['delete']"></l-table>
25
25
  </l-page>
26
26
  </template>
@@ -1,9 +1,11 @@
1
1
  <script setup>
2
-
2
+ import { ref } from 'vue'
3
3
  const onRequest = async (request) => {
4
4
  //listData("User", params, ["canDelete", "canUpdate", "canRead", "user_id"]);
5
5
 
6
- request.loadObjects("User", null, ["user_id"]);
6
+ request.loadObjects("User", {
7
+ status: status.value
8
+ }, ["user_id"]);
7
9
  };
8
10
 
9
11
  const columns = [
@@ -42,13 +44,22 @@ const columns = [
42
44
  searchType: "date"
43
45
  }
44
46
  ]
45
-
47
+ const status = ref("0");
46
48
  </script>
47
49
 
48
50
  <template>
49
51
  <l-page>
50
- <l-table @request="onRequest" :columns="columns" :show-actions="['view', 'edit', 'delete']">
51
- </l-table>
52
+
53
+ <l-tabs v-model="status">
54
+ <l-tab label="Active" name="0">
55
+ <l-table @request="onRequest" :columns="columns" :actions="['view', 'edit', 'delete']">
56
+ </l-table>
57
+ </l-tab>
58
+ <l-tab label="Inactive" name="1">
59
+ <l-table @request="onRequest" :columns="columns" :actions="['view', 'edit', 'delete']">
60
+ </l-table>
61
+ </l-tab>
62
+ </l-tabs>
52
63
 
53
64
  </l-page>
54
65
  </template>
@@ -26,6 +26,17 @@ const columns = [
26
26
  name: "result",
27
27
  sortable: true,
28
28
  searchable: true,
29
+ searchType: "select",
30
+ searchOptions: [
31
+ {
32
+ label: "SUCCESS",
33
+ value: "SUCCESS"
34
+ },
35
+ {
36
+ label: "FAIL",
37
+ value: "FAIL"
38
+ }
39
+ ]
29
40
  }, {
30
41
  label: "User agent",
31
42
  name: "user_agent",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hostlink/nuxt-light",
3
- "version": "0.0.40",
3
+ "version": "0.0.41",
4
4
  "description": "HostLink Nuxt Light Framework",
5
5
  "repository": "@hostlink/nuxt-light",
6
6
  "license": "MIT",