@hostlink/nuxt-light 1.27.7 → 1.28.0

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.
Files changed (276) hide show
  1. package/dist/module.d.mts +2 -1
  2. package/dist/module.json +3 -3
  3. package/dist/module.mjs +40 -42
  4. package/dist/runtime/components/L/CustomField/Add.vue +41 -52
  5. package/dist/runtime/components/L/CustomField/Add.vue.d.ts +2 -0
  6. package/dist/runtime/components/L/CustomField/List.vue +26 -30
  7. package/dist/runtime/components/L/CustomField/List.vue.d.ts +2 -0
  8. package/dist/runtime/components/L/Database/create-table-dialog.vue +22 -38
  9. package/dist/runtime/components/L/Database/create-table-dialog.vue.d.ts +2 -0
  10. package/dist/runtime/components/L/Fieldset.vue +19 -23
  11. package/dist/runtime/components/L/Fieldset.vue.d.ts +2 -0
  12. package/dist/runtime/components/L/ForgetPasswordDialog.vue +39 -41
  13. package/dist/runtime/components/L/ForgetPasswordDialog.vue.d.ts +2 -0
  14. package/dist/runtime/components/L/Revision.vue +101 -137
  15. package/dist/runtime/components/L/Revision.vue.d.ts +2 -0
  16. package/dist/runtime/components/L/Storage.vue +26 -30
  17. package/dist/runtime/components/L/Storage.vue.d.ts +2 -0
  18. package/dist/runtime/components/L/System/Setting/authentication.vue +22 -44
  19. package/dist/runtime/components/L/System/Setting/authentication.vue.d.ts +2 -0
  20. package/dist/runtime/components/L/System/Setting/developer.vue +43 -59
  21. package/dist/runtime/components/L/System/Setting/developer.vue.d.ts +2 -0
  22. package/dist/runtime/components/L/System/Setting/forget-password.vue +42 -58
  23. package/dist/runtime/components/L/System/Setting/forget-password.vue.d.ts +2 -0
  24. package/dist/runtime/components/L/System/Setting/general.vue +29 -41
  25. package/dist/runtime/components/L/System/Setting/general.vue.d.ts +2 -0
  26. package/dist/runtime/components/L/System/Setting/mail.vue +39 -42
  27. package/dist/runtime/components/L/System/Setting/mail.vue.d.ts +2 -0
  28. package/dist/runtime/components/L/System/Setting/modules.vue +9 -9
  29. package/dist/runtime/components/L/System/Setting/modules.vue.d.ts +2 -0
  30. package/dist/runtime/components/L/System/Setting/security.vue +20 -39
  31. package/dist/runtime/components/L/System/Setting/security.vue.d.ts +2 -0
  32. package/dist/runtime/components/L/User/eventlog.vue +26 -26
  33. package/dist/runtime/components/L/User/eventlog.vue.d.ts +2 -0
  34. package/dist/runtime/components/L/User/overview.vue +25 -27
  35. package/dist/runtime/components/L/User/overview.vue.d.ts +2 -0
  36. package/dist/runtime/components/L/User/userlog.vue +22 -28
  37. package/dist/runtime/components/L/User/userlog.vue.d.ts +2 -0
  38. package/dist/runtime/components/L/ValidationInput.vue +68 -91
  39. package/dist/runtime/components/L/ValidationInput.vue.d.ts +2 -0
  40. package/dist/runtime/components/MyTest.vue +8 -7
  41. package/dist/runtime/components/MyTest.vue.d.ts +2 -0
  42. package/dist/runtime/components/l-add-btn.vue +13 -12
  43. package/dist/runtime/components/l-add-btn.vue.d.ts +2 -0
  44. package/dist/runtime/components/l-alert.vue +25 -29
  45. package/dist/runtime/components/l-alert.vue.d.ts +2 -0
  46. package/dist/runtime/components/l-app-main.vue +226 -294
  47. package/dist/runtime/components/l-app-main.vue.d.ts +2 -0
  48. package/dist/runtime/components/l-app.vue +76 -89
  49. package/dist/runtime/components/l-app.vue.d.ts +2 -0
  50. package/dist/runtime/components/l-audit-card.vue +8 -14
  51. package/dist/runtime/components/l-audit-card.vue.d.ts +2 -0
  52. package/dist/runtime/components/l-back-btn.vue.d.ts +2 -0
  53. package/dist/runtime/components/l-banner.vue +28 -34
  54. package/dist/runtime/components/l-banner.vue.d.ts +2 -0
  55. package/dist/runtime/components/l-bar.vue +21 -25
  56. package/dist/runtime/components/l-bar.vue.d.ts +2 -0
  57. package/dist/runtime/components/l-btn.vue +62 -39
  58. package/dist/runtime/components/l-btn.vue.d.ts +2 -0
  59. package/dist/runtime/components/l-card.vue +90 -141
  60. package/dist/runtime/components/l-card.vue.d.ts +2 -0
  61. package/dist/runtime/components/l-checkbox.vue +30 -7
  62. package/dist/runtime/components/l-checkbox.vue.d.ts +2 -0
  63. package/dist/runtime/components/l-col.vue +21 -29
  64. package/dist/runtime/components/l-col.vue.d.ts +2 -0
  65. package/dist/runtime/components/l-customizer.vue +84 -100
  66. package/dist/runtime/components/l-customizer.vue.d.ts +2 -0
  67. package/dist/runtime/components/l-date-picker.vue +101 -147
  68. package/dist/runtime/components/l-date-picker.vue.d.ts +2 -0
  69. package/dist/runtime/components/l-delete-btn.vue +22 -27
  70. package/dist/runtime/components/l-delete-btn.vue.d.ts +2 -0
  71. package/dist/runtime/components/l-dialog-database-field-add.vue +19 -36
  72. package/dist/runtime/components/l-dialog-database-field-add.vue.d.ts +2 -0
  73. package/dist/runtime/components/l-drag-drop-container.vue +44 -62
  74. package/dist/runtime/components/l-drag-drop-container.vue.d.ts +2 -0
  75. package/dist/runtime/components/l-drag-drop-group.vue +49 -70
  76. package/dist/runtime/components/l-drag-drop-group.vue.d.ts +2 -0
  77. package/dist/runtime/components/l-drag-drop.vue +33 -44
  78. package/dist/runtime/components/l-drag-drop.vue.d.ts +2 -0
  79. package/dist/runtime/components/l-edit-btn.vue.d.ts +2 -0
  80. package/dist/runtime/components/l-editor.vue +185 -172
  81. package/dist/runtime/components/l-editor.vue.d.ts +2 -0
  82. package/dist/runtime/components/l-facebook-button.vue +18 -26
  83. package/dist/runtime/components/l-facebook-button.vue.d.ts +2 -0
  84. package/dist/runtime/components/l-fav-menu.vue +19 -24
  85. package/dist/runtime/components/l-fav-menu.vue.d.ts +2 -0
  86. package/dist/runtime/components/l-field.vue +49 -18
  87. package/dist/runtime/components/l-field.vue.d.ts +2 -0
  88. package/dist/runtime/components/l-file-manager-labels.vue +46 -48
  89. package/dist/runtime/components/l-file-manager-labels.vue.d.ts +2 -0
  90. package/dist/runtime/components/l-file-manager-move.vue +53 -68
  91. package/dist/runtime/components/l-file-manager-move.vue.d.ts +2 -0
  92. package/dist/runtime/components/l-file-manager-preview.vue +46 -81
  93. package/dist/runtime/components/l-file-manager-preview.vue.d.ts +2 -0
  94. package/dist/runtime/components/l-file-manager.vue +498 -640
  95. package/dist/runtime/components/l-file-manager.vue.d.ts +2 -0
  96. package/dist/runtime/components/l-file-upload.vue +80 -109
  97. package/dist/runtime/components/l-file-upload.vue.d.ts +2 -0
  98. package/dist/runtime/components/l-file.vue +37 -61
  99. package/dist/runtime/components/l-file.vue.d.ts +2 -0
  100. package/dist/runtime/components/l-form-dialog.vue +71 -83
  101. package/dist/runtime/components/l-form-dialog.vue.d.ts +2 -0
  102. package/dist/runtime/components/l-form.vue +82 -96
  103. package/dist/runtime/components/l-form.vue.d.ts +2 -0
  104. package/dist/runtime/components/l-group-select.vue +59 -94
  105. package/dist/runtime/components/l-group-select.vue.d.ts +2 -0
  106. package/dist/runtime/components/l-icon-picker.vue +3265 -3274
  107. package/dist/runtime/components/l-icon-picker.vue.d.ts +2 -0
  108. package/dist/runtime/components/l-input-xlsx.vue +30 -38
  109. package/dist/runtime/components/l-input-xlsx.vue.d.ts +2 -0
  110. package/dist/runtime/components/l-input.vue +142 -126
  111. package/dist/runtime/components/l-input.vue.d.ts +2 -0
  112. package/dist/runtime/components/l-item.vue +30 -21
  113. package/dist/runtime/components/l-item.vue.d.ts +2 -0
  114. package/dist/runtime/components/l-link.vue +16 -15
  115. package/dist/runtime/components/l-link.vue.d.ts +2 -0
  116. package/dist/runtime/components/l-list.vue +27 -35
  117. package/dist/runtime/components/l-list.vue.d.ts +2 -0
  118. package/dist/runtime/components/l-login.vue +246 -287
  119. package/dist/runtime/components/l-login.vue.d.ts +2 -0
  120. package/dist/runtime/components/l-menu.vue +45 -54
  121. package/dist/runtime/components/l-menu.vue.d.ts +2 -0
  122. package/dist/runtime/components/l-microsoft-button.vue +42 -52
  123. package/dist/runtime/components/l-microsoft-button.vue.d.ts +2 -0
  124. package/dist/runtime/components/l-page.vue +48 -67
  125. package/dist/runtime/components/l-page.vue.d.ts +2 -0
  126. package/dist/runtime/components/l-row.vue +8 -13
  127. package/dist/runtime/components/l-row.vue.d.ts +2 -0
  128. package/dist/runtime/components/l-save-btn.vue.d.ts +2 -0
  129. package/dist/runtime/components/l-select.vue +150 -76
  130. package/dist/runtime/components/l-select.vue.d.ts +2 -0
  131. package/dist/runtime/components/l-small-box.vue +18 -31
  132. package/dist/runtime/components/l-small-box.vue.d.ts +2 -0
  133. package/dist/runtime/components/l-statistic.vue +17 -23
  134. package/dist/runtime/components/l-statistic.vue.d.ts +2 -0
  135. package/dist/runtime/components/l-tab.vue +20 -15
  136. package/dist/runtime/components/l-tab.vue.d.ts +2 -0
  137. package/dist/runtime/components/l-table.vue +444 -560
  138. package/dist/runtime/components/l-table.vue.d.ts +2 -0
  139. package/dist/runtime/components/l-tabs.vue +34 -16
  140. package/dist/runtime/components/l-tabs.vue.d.ts +2 -0
  141. package/dist/runtime/components/l-test2.vue +10 -9
  142. package/dist/runtime/components/l-test2.vue.d.ts +2 -0
  143. package/dist/runtime/components/l-time-picker.vue +53 -68
  144. package/dist/runtime/components/l-time-picker.vue.d.ts +2 -0
  145. package/dist/runtime/components/l-view-btn.vue.d.ts +2 -0
  146. package/dist/runtime/composables/mytest.d.ts +2 -0
  147. package/dist/runtime/composables/mytest.js +3 -0
  148. package/dist/runtime/formkit/Checkbox.vue +15 -18
  149. package/dist/runtime/formkit/Checkbox.vue.d.ts +2 -0
  150. package/dist/runtime/formkit/DatePicker.vue +15 -18
  151. package/dist/runtime/formkit/DatePicker.vue.d.ts +2 -0
  152. package/dist/runtime/formkit/Editor.vue +15 -18
  153. package/dist/runtime/formkit/Editor.vue.d.ts +2 -0
  154. package/dist/runtime/formkit/File.vue +30 -37
  155. package/dist/runtime/formkit/File.vue.d.ts +2 -0
  156. package/dist/runtime/formkit/FilePicker.vue +22 -25
  157. package/dist/runtime/formkit/FilePicker.vue.d.ts +2 -0
  158. package/dist/runtime/formkit/FileUpload.vue +22 -25
  159. package/dist/runtime/formkit/FileUpload.vue.d.ts +2 -0
  160. package/dist/runtime/formkit/Form.vue +79 -100
  161. package/dist/runtime/formkit/Form.vue.d.ts +2 -0
  162. package/dist/runtime/formkit/GroupSelect.vue +21 -27
  163. package/dist/runtime/formkit/GroupSelect.vue.d.ts +2 -0
  164. package/dist/runtime/formkit/Input.vue +53 -61
  165. package/dist/runtime/formkit/Input.vue.d.ts +2 -0
  166. package/dist/runtime/formkit/InputXlsx.vue +15 -18
  167. package/dist/runtime/formkit/InputXlsx.vue.d.ts +2 -0
  168. package/dist/runtime/formkit/OptionGroup.vue +20 -26
  169. package/dist/runtime/formkit/OptionGroup.vue.d.ts +2 -0
  170. package/dist/runtime/formkit/Radio.vue +15 -18
  171. package/dist/runtime/formkit/Radio.vue.d.ts +2 -0
  172. package/dist/runtime/formkit/Repeater.vue +62 -76
  173. package/dist/runtime/formkit/Repeater.vue.d.ts +2 -0
  174. package/dist/runtime/formkit/Select.vue +21 -29
  175. package/dist/runtime/formkit/Select.vue.d.ts +2 -0
  176. package/dist/runtime/formkit/TimePicker.vue +15 -19
  177. package/dist/runtime/formkit/TimePicker.vue.d.ts +2 -0
  178. package/dist/runtime/formkit/Toggle.vue +13 -16
  179. package/dist/runtime/formkit/Toggle.vue.d.ts +2 -0
  180. package/dist/runtime/light.d.ts +1129 -6
  181. package/dist/runtime/pages/CustomField/[custom_field_id]/edit.vue +24 -26
  182. package/dist/runtime/pages/CustomField/[custom_field_id]/edit.vue.d.ts +2 -0
  183. package/dist/runtime/pages/CustomField/index.vue +22 -29
  184. package/dist/runtime/pages/CustomField/index.vue.d.ts +2 -0
  185. package/dist/runtime/pages/EventLog/_eventlog_id/view.vue +8 -8
  186. package/dist/runtime/pages/EventLog/_eventlog_id/view.vue.d.ts +2 -0
  187. package/dist/runtime/pages/EventLog/index.vue +7 -6
  188. package/dist/runtime/pages/EventLog/index.vue.d.ts +2 -0
  189. package/dist/runtime/pages/FileManager/index.vue.d.ts +2 -0
  190. package/dist/runtime/pages/MailLog/index.vue +7 -6
  191. package/dist/runtime/pages/MailLog/index.vue.d.ts +2 -0
  192. package/dist/runtime/pages/Permission/add.vue +26 -29
  193. package/dist/runtime/pages/Permission/add.vue.d.ts +2 -0
  194. package/dist/runtime/pages/Permission/all.vue +57 -73
  195. package/dist/runtime/pages/Permission/all.vue.d.ts +2 -0
  196. package/dist/runtime/pages/Permission/export.vue +49 -62
  197. package/dist/runtime/pages/Permission/export.vue.d.ts +2 -0
  198. package/dist/runtime/pages/Permission/index.vue +19 -20
  199. package/dist/runtime/pages/Permission/index.vue.d.ts +2 -0
  200. package/dist/runtime/pages/Role/_name/update-child.vue +12 -14
  201. package/dist/runtime/pages/Role/_name/update-child.vue.d.ts +2 -0
  202. package/dist/runtime/pages/Role/add.vue +13 -15
  203. package/dist/runtime/pages/Role/add.vue.d.ts +2 -0
  204. package/dist/runtime/pages/Role/add2.vue +27 -38
  205. package/dist/runtime/pages/Role/add2.vue.d.ts +2 -0
  206. package/dist/runtime/pages/Role/index.vue +100 -127
  207. package/dist/runtime/pages/Role/index.vue.d.ts +2 -0
  208. package/dist/runtime/pages/System/database/backup.vue +28 -36
  209. package/dist/runtime/pages/System/database/backup.vue.d.ts +2 -0
  210. package/dist/runtime/pages/System/database/process.vue +33 -43
  211. package/dist/runtime/pages/System/database/process.vue.d.ts +2 -0
  212. package/dist/runtime/pages/System/database/table.vue +168 -205
  213. package/dist/runtime/pages/System/database/table.vue.d.ts +2 -0
  214. package/dist/runtime/pages/System/fs.vue +95 -107
  215. package/dist/runtime/pages/System/fs.vue.d.ts +2 -0
  216. package/dist/runtime/pages/System/index.vue +30 -31
  217. package/dist/runtime/pages/System/index.vue.d.ts +2 -0
  218. package/dist/runtime/pages/System/mailtest.vue +29 -35
  219. package/dist/runtime/pages/System/mailtest.vue.d.ts +2 -0
  220. package/dist/runtime/pages/System/menu/index.vue +175 -223
  221. package/dist/runtime/pages/System/menu/index.vue.d.ts +2 -0
  222. package/dist/runtime/pages/System/package.vue +21 -21
  223. package/dist/runtime/pages/System/package.vue.d.ts +2 -0
  224. package/dist/runtime/pages/System/phpinfo.vue +11 -10
  225. package/dist/runtime/pages/System/phpinfo.vue.d.ts +2 -0
  226. package/dist/runtime/pages/System/setting.vue +42 -59
  227. package/dist/runtime/pages/System/setting.vue.d.ts +2 -0
  228. package/dist/runtime/pages/System/test.vue.d.ts +2 -0
  229. package/dist/runtime/pages/System/view_as.vue +65 -68
  230. package/dist/runtime/pages/System/view_as.vue.d.ts +2 -0
  231. package/dist/runtime/pages/SystemValue/_systemvalue_id/edit.vue +7 -7
  232. package/dist/runtime/pages/SystemValue/_systemvalue_id/edit.vue.d.ts +2 -0
  233. package/dist/runtime/pages/SystemValue/add.vue.d.ts +2 -0
  234. package/dist/runtime/pages/SystemValue/index.vue +7 -6
  235. package/dist/runtime/pages/SystemValue/index.vue.d.ts +2 -0
  236. package/dist/runtime/pages/Translate/index.vue +81 -100
  237. package/dist/runtime/pages/Translate/index.vue.d.ts +2 -0
  238. package/dist/runtime/pages/User/_user_id/change-password.vue +38 -45
  239. package/dist/runtime/pages/User/_user_id/change-password.vue.d.ts +2 -0
  240. package/dist/runtime/pages/User/_user_id/edit.vue +35 -26
  241. package/dist/runtime/pages/User/_user_id/edit.vue.d.ts +2 -0
  242. package/dist/runtime/pages/User/_user_id/update-role.vue +33 -43
  243. package/dist/runtime/pages/User/_user_id/update-role.vue.d.ts +2 -0
  244. package/dist/runtime/pages/User/_user_id/view.vue +35 -37
  245. package/dist/runtime/pages/User/_user_id/view.vue.d.ts +2 -0
  246. package/dist/runtime/pages/User/add.vue +52 -60
  247. package/dist/runtime/pages/User/add.vue.d.ts +2 -0
  248. package/dist/runtime/pages/User/index.vue +23 -32
  249. package/dist/runtime/pages/User/index.vue.d.ts +2 -0
  250. package/dist/runtime/pages/User/profile.vue +52 -58
  251. package/dist/runtime/pages/User/profile.vue.d.ts +2 -0
  252. package/dist/runtime/pages/User/setting/bio-auth.vue +85 -95
  253. package/dist/runtime/pages/User/setting/bio-auth.vue.d.ts +2 -0
  254. package/dist/runtime/pages/User/setting/index.vue +27 -28
  255. package/dist/runtime/pages/User/setting/index.vue.d.ts +2 -0
  256. package/dist/runtime/pages/User/setting/information.vue +28 -27
  257. package/dist/runtime/pages/User/setting/information.vue.d.ts +2 -0
  258. package/dist/runtime/pages/User/setting/my_favorite.vue +29 -35
  259. package/dist/runtime/pages/User/setting/my_favorite.vue.d.ts +2 -0
  260. package/dist/runtime/pages/User/setting/open_id.vue +140 -165
  261. package/dist/runtime/pages/User/setting/open_id.vue.d.ts +2 -0
  262. package/dist/runtime/pages/User/setting/password.vue +37 -44
  263. package/dist/runtime/pages/User/setting/password.vue.d.ts +2 -0
  264. package/dist/runtime/pages/User/setting/style.vue +84 -102
  265. package/dist/runtime/pages/User/setting/style.vue.d.ts +2 -0
  266. package/dist/runtime/pages/User/setting/two-factor-auth.vue +51 -61
  267. package/dist/runtime/pages/User/setting/two-factor-auth.vue.d.ts +2 -0
  268. package/dist/runtime/pages/User/setting.vue +9 -9
  269. package/dist/runtime/pages/User/setting.vue.d.ts +2 -0
  270. package/dist/runtime/pages/UserLog/index.vue +7 -6
  271. package/dist/runtime/pages/UserLog/index.vue.d.ts +2 -0
  272. package/dist/types.d.mts +3 -1
  273. package/package.json +9 -11
  274. package/dist/module.cjs +0 -5
  275. package/dist/module.d.ts +0 -7
  276. package/dist/types.d.ts +0 -1
@@ -1,562 +1,446 @@
1
- <script setup lang="ts">
2
- import { useQuasar, QTable, Dialog } from 'quasar';
3
- import type { QTableColumn, QTableProps } from 'quasar';
4
-
5
- import { ref, computed, onMounted, useSlots, watch, } from "vue";
6
- import { useLight, GQLFieldBuilder, model } from '../';
7
- import { toQuery } from '@hostlink/light';
8
- import { collect } from "#imports"
9
- import { useI18n } from 'vue-i18n';
10
-
11
- const $q = useQuasar();
12
- const { t } = useI18n();
13
-
14
-
15
- const minimized = defineModel<boolean>("minimized", { default: false })
16
- const maximized = defineModel<boolean>("maximized", { default: false })
17
-
18
- // extends QTableColumn
19
- export interface LTableColumn extends QTableColumn {
20
- searchable?: boolean,
21
- searchType?: string,
22
- searchOptions?: Array<any> | Function,
23
- searchMultiple?: boolean,
24
- gqlField?: string | Array<string> | Object,
25
- backgroundColor?: string | Function,
26
- searchMethod?: string
27
- }
28
-
29
-
30
- const errors = ref<InstanceType<any>>([
31
- ]);
32
-
33
-
34
- export type LTableProps = QTableProps & {
35
- columns?: Array<LTableColumn>,
36
- actions?: Array<string>,
37
- sortBy?: string | null | undefined,
38
- rowKey?: string,
39
- modelName?: string | null | undefined,
40
- searchable?: boolean | null | undefined,
41
- selected?: Array<any>,
42
- maximizable?: boolean,
43
- minimizable?: boolean,
44
- onRequestData?: (request: LTableRequest) => void
45
- addComponent?: Dialog
46
- addComponentProps?: any,
47
- rows?: Array<any>,
48
- }
49
-
50
-
51
- const props = withDefaults(defineProps<LTableProps>(), {
52
- actions: () => [],
53
- rowsPerPageLabel: "Records per page:",
54
- selection: "none",
55
- rowsPerPageOptions: () => [5, 10, 20, 50, 100, 0],
56
- pagination: () => {
57
- return {
58
- sortBy: null,
59
- descending: true,
60
- page: 1,
61
- rowsPerPage: 10,
62
- }
63
- },
64
- fullscreen: false,
65
- searchable: false,
66
- maximizable: false,
67
- minimizable: false,
68
- selected: () => [],
69
- loadingLabel: "Loading...",
70
- noDataLabel: "No data available",
71
- dark: undefined,
72
- dense: undefined,
73
- bordered: undefined,
74
- flat: undefined
75
- });
76
-
77
-
78
- const isServerSide = (props.rows == undefined);
79
-
80
-
81
- const light = useLight();
82
-
83
- const pagination = ref(props.pagination);
84
-
85
- if (props.rowsPerPageOptions[0] == 0) {
86
- pagination.value.rowsPerPage = 0;
87
- }
88
-
89
- //apply all aligns to the columns
90
- props.columns?.forEach((col) => {
91
- if (!col.align) {
92
- col.align = "left";
93
- }
94
- if (!col.field && col.name) {
95
- col.field = col.name
96
- }
97
-
98
- col.label = t(col.label)
99
- })
100
-
101
- if (props.columns) {
102
- for (let i = 0; i < props.columns.length; i++) {
103
- if (props.columns[i].searchOptions) {
104
- let opts = props.columns[i].searchOptions;
105
- if (typeof opts == "function") {
106
- props.columns[i].searchOptions = await opts();
107
- }
108
-
109
-
110
- }
111
- }
112
- }
113
-
114
- export interface LTableRequest {
115
- sort: string,
116
- fields: Array<string>,
117
- gql: {
118
- __args: {
119
- filters: any,
120
- sort: string
121
- },
122
- data: {
123
- __args: {
124
- limit: number
125
- },
126
- [key: string]: any
127
- },
128
- meta: {
129
- total: boolean,
130
- key: boolean,
131
- name: boolean
132
- }
133
- },
134
- offset: number,
135
- limit: number,
136
- loadData: (model: string, filters: any, fields: Array<any>) => void,
137
- loadObjects: (model: string, filters: any, fields: Array<any>) => void,
138
- setData: (data: { data: Array<{ data: any }>, meta: { total: Number, key: string, name: string } }) => void,
139
- }
140
-
141
- const emits = defineEmits<{
142
- "request-data": [p: LTableRequest],
143
- "update:selected": [p: Array<any>]
144
- "delete": [p: any],
145
- }>()
146
-
147
-
148
- const loading = ref(false);
149
-
150
- let activeEdit = false;
151
- let actionView = false;
152
- let actionDelete = false;
153
- if (props.actions.length > 0) {
154
- actionView = props.actions.includes("view");
155
- activeEdit = props.actions.includes("edit");
156
- actionDelete = props.actions.includes("delete");
157
- }
158
-
159
-
160
-
161
- if (props.sortBy) {
162
- let [sortBy, descending] = props.sortBy.split(":");
163
- pagination.value.sortBy = sortBy;
164
- pagination.value.descending = descending == "desc";
165
- }
166
-
167
- const hasSearch = computed(() => {
168
- return props.columns?.some((col) => {
169
- return col.searchable;
170
- })
171
- })
172
-
173
- const table = ref<InstanceType<typeof QTable>>();
174
-
175
- const filters = ref<InstanceType<any>>({});
176
- const rows = ref<InstanceType<any>>(props.rows);
177
- if (rows.value == undefined) {
178
- rows.value = [];
179
- }
180
-
181
- onMounted(() => {
182
- table.value && table.value.requestServerInteraction();
183
- })
184
-
185
-
186
- let primaryKey = ref(props.rowKey);
187
- const modelName = ref(props.modelName);
188
-
189
-
190
- const validateData = () => {
191
- if (primaryKey.value == null) return;
192
-
193
- if (props.actions.includes("edit")) {
194
- if (rows.value.length > 0) {
195
- //get first row
196
- let row = rows.value[0];
197
- //check has primary key
198
-
199
- if (!row[primaryKey.value]) {
200
- errors.value.push("[edit] Primary key not found in the data");
201
- }
202
- }
203
- }
204
-
205
- if (props.actions.includes("delete")) {
206
- if (rows.value.length > 0) {
207
- //get first row
208
- let row = rows.value[0];
209
- //check has primary key
210
-
211
- if (!row[primaryKey.value]) {
212
- errors.value.push("[delete] Primary key not found in the data");
213
- }
214
- }
215
- }
216
-
217
- }
218
-
219
- const onLocalRequest = async (p: any) => {
220
- if (!isServerSide) return;
221
-
222
-
223
- let sort = "";
224
- if (p.pagination.sortBy) {
225
- sort = p.pagination.sortBy + ":" + (p.pagination.descending ? "desc" : "asc");
226
- }
227
-
228
- //fields
229
- const builder = GQLFieldBuilder();
230
- if (props.rowKey) {
231
- builder.add(props.rowKey);
232
- }
233
-
234
- props.columns?.forEach((col) => {
235
- if (col.gqlField) {
236
- builder.add(col.gqlField);
237
- return;
238
- }
239
-
240
- if (!col.name) return;
241
- if (col.name.startsWith("_")) {
242
- return;
243
- }
244
- builder.add(col.name);
245
-
246
- });
247
-
248
- if (actionView) {
249
- builder.add("canView");
250
- }
251
-
252
- if (actionDelete) {
253
- builder.add("canDelete");
254
- }
255
-
256
- if (activeEdit) {
257
- builder.add("canUpdate");
258
- }
259
-
260
-
261
- const callback: LTableRequest = {
262
- sort: sort,
263
- fields: builder.get(),
264
- offset: (p.pagination.page - 1) * p.pagination.rowsPerPage,
265
- limit: p.pagination.rowsPerPage,
266
- gql: {
267
- __args: {
268
- filters: getFilterValue(),
269
- sort: sort
270
- },
271
- data: {
272
- __args: {
273
- limit: p.pagination.rowsPerPage,
274
- offset: (p.pagination.page - 1) * p.pagination.rowsPerPage
275
- },
276
- ...toQuery(builder.get())
277
- },
278
- meta: {
279
- total: true,
280
- key: true,
281
- name: true
282
- }
283
- },
284
- setData(data: { data: Array<{ data: any }>, meta: { total: number, key: string, name: string } }) {
285
- rows.value = data.data;
286
- primaryKey.value = data.meta.key;
287
- modelName.value = data.meta.name;
288
- pagination.value.rowsNumber = data.meta.total;
289
-
290
- pagination.value.page = p.pagination.page;
291
- pagination.value.sortBy = p.pagination.sortBy;
292
- pagination.value.descending = p.pagination.descending;
293
- pagination.value.rowsPerPage = p.pagination.rowsPerPage;
294
-
295
- loading.value = false;
296
-
297
- validateData();
298
- },
299
- loadObjects(model: string, filters: any = null, fields: Array<any> = []) {
300
- return this.loadData(model, filters, fields);
301
- },
302
- async loadData(model: string, filters: any = null, fields: Array<any> = []) {
303
- fields.forEach((f) => {
304
- builder.add(f);
305
- })
306
-
307
- let localFilters = getFilterValue();
308
- if (filters) {
309
- localFilters = {
310
- ...localFilters,
311
- ...filters
312
- }
313
- }
314
- loading.value = true;
315
-
316
- try {
317
- let c = collect(model, builder.get())
318
-
319
- if (localFilters) {
320
- for (let [key, value] of Object.entries(localFilters)) {
321
- if (typeof value == "object") {
322
- if (value.contains) {
323
- c = c.whereContains(key, value.contains);
324
- }
325
- if (value.between) {
326
- c = c.whereBetween(key, value.between);
327
- }
328
- } else {
329
- c = c.where(key, value);
330
- }
331
- }
332
- }
333
-
334
- if (sort) {
335
- if (sort.split(":")[1] == "asc") {
336
- c = c.sortBy(sort.split(":")[0]);
337
- } else {
338
- c = c.sortByDesc(sort.split(":")[0]);
339
- }
340
- }
341
-
342
-
343
- if (p.pagination.rowsPerPage != 0) {
344
- c = c.forPage(p.pagination.page, p.pagination.rowsPerPage);
345
- }
346
-
347
-
348
- const data = await c.all();
349
- const allData = {
350
- data,
351
- meta: c.meta
352
- }
353
-
354
- this.setData(allData);
355
- } catch (e: any) {
356
- quasar.dialog({
357
- message: e,
358
- color: "negative"
359
- })
360
- this.setData({ data: [], meta: { total: 0, key: "", name: "" } });
361
-
362
- }
363
- }
364
- }
365
-
366
-
367
- loading.value = true;
368
- //emits("request", p);
369
- emits("request-data", callback);
370
-
371
- }
372
-
373
- const getFilterValue = () => {
374
- let f: any = {};
375
-
376
- props.columns?.forEach((col) => {
377
- if (col.searchable) {
378
- if (filters.value[col.name] !== null && filters.value[col.name] !== "" && filters.value[col.name] !== undefined) {
379
-
380
- if (col.searchType == "number") {
381
- f[col.name] = filters.value[col.name]
382
- } else if (col.searchType == "date") {
383
- if (filters.value[col.name].from) {
384
- f[col.name] = {
385
- between: [filters.value[col.name].from, filters.value[col.name].to]
386
- }
387
- }
388
- } else if (col.searchType == "select") {
389
- f[col.name] = filters.value[col.name]
390
-
391
- } else {
392
-
393
- if (col.searchMethod == "equals") {
394
- f[col.name] = filters.value[col.name]
395
- } else {
396
- f[col.name] = {
397
- contains: filters.value[col.name]
398
- }
399
- }
400
- }
401
- }
402
- }
403
- });
404
- return f;
405
- }
406
-
407
-
408
- const onFilters = () => {
409
-
410
- //clone the filters
411
- onLocalRequest({
412
- pagination: {
413
- page: 1,
414
- rowsPerPage: props.pagination.rowsPerPage,
415
- sortBy: props.pagination.sortBy,
416
- descending: props.pagination.descending
417
- }
418
- })
419
- }
420
-
421
- const slots = useSlots();
422
-
423
- const ss = Object.entries(slots).map(([key, value]) => {
424
- return key;
425
- });
426
-
427
- const quasar = useQuasar();
428
- const onDelete = async (id: any) => {
429
- if (modelName.value == null) return;
430
-
431
- try {
432
- await model(modelName.value).delete(id);
433
- } catch (e: any) {
434
- quasar.notify({
435
- message: e.message,
436
- color: "negative"
437
- })
438
- return;
439
- }
440
- // refresh the table
441
- if (table.value) {
442
- table.value.requestServerInteraction();
443
- }
444
-
445
- emits("delete", id);
446
- }
447
-
448
- const attrs = computed(() => {
449
- const a = { ...light.styles.table, ...Object.fromEntries(Object.entries(props).filter(([key, value]) => value !== undefined)) };
450
-
451
- return {
452
- ...a,
453
- loadingLabel: t(props.loadingLabel),
454
- noDataLabel: t(props.noDataLabel),
455
- rowsPerPageOptions: props.rowsPerPageOptions,
456
- rowsPerPageLabel: t(props.rowsPerPageLabel),
457
- selection: props.selection,
458
- rowKey: props.rowKey,
459
- }
460
- });
461
-
462
- const filter = ref('');
463
-
464
- const toColumns = props.columns?.filter((col: any) => {
465
- return col.to;
466
- }).map((col: any) => {
467
- col.slot_name = 'body-cell-' + col.name;
468
- return col;
469
-
470
- })
471
- /*
472
- const filterFn = (val, update, abort) {
473
- update(() => {
474
- const needle = val.toLocaleLowerCase()
475
- options.value = stringOptions.filter(v => v.toLocaleLowerCase().indexOf(needle) > -1)
476
- })
477
- },
478
- */
479
-
480
- const isDark = computed(() => {
481
- return light.theme == "dark";
482
- })
483
-
484
- const hasRowExpand = computed(() => {
485
- return ss.indexOf("row-expand") >= 0;
486
- })
487
-
488
- const hasActions = computed(() => {
489
- return props.actions.length > 0;
490
- })
491
-
492
- const getCellStyle = (col: any, row: any) => {
493
- const style: any = col.cellStyle ?? {};
494
- if (col.backgroundColor) {
495
- if (typeof col.backgroundColor == "function") {
496
- style.backgroundColor = col.backgroundColor(row);
497
- } else {
498
- style.backgroundColor = col.backgroundColor;
499
- }
500
-
501
- }
502
- return style;
503
- }
504
-
505
- const getCellClass = (col: any, row: any) => {
506
- const cl: any = [];
507
-
508
- if (col.cellClass) {
509
- if (typeof col.cellClass == "function") {
510
- cl.push(col.cellClass(row));
511
- } else {
512
- cl.push(col.cellClass);
513
- }
514
-
515
- }
516
- return cl;
517
- }
518
-
519
- const localSelected = computed({
520
- get() {
521
- return props.selected;
522
- },
523
- set(val) {
524
- emits("update:selected", val);
525
- }
526
- });
527
-
528
- watch(() => props.rows, (val) => {
529
- rows.value = val;
530
- });
531
-
532
- const computedColumns = computed(() => {
533
- return props.columns;
534
- })
535
-
536
-
537
- function requestServerInteraction() {
538
- table.value && table.value.requestServerInteraction();
539
- }
540
-
541
- defineExpose({
542
- requestServerInteraction
543
- })
544
-
545
- const onAdd = () => {
546
- if (!props.addComponent) return;
547
-
548
- $q.dialog({
549
- component: props.addComponent,
550
- componentProps: props.addComponentProps,
551
-
552
- }).onOk(() => {
553
- requestServerInteraction();
554
- })
555
- }
556
- </script>
557
-
558
-
559
- <template>
1
+ <script setup>
2
+ import { useQuasar, QTable, Dialog } from "quasar";
3
+ import { ref, computed, onMounted, useSlots, watch } from "vue";
4
+ import { useLight, GQLFieldBuilder, model } from "../";
5
+ import { toQuery } from "@hostlink/light";
6
+ import { collect } from "#imports";
7
+ import { useI18n } from "vue-i18n";
8
+ const $q = useQuasar();
9
+ const { t } = useI18n();
10
+ const minimized = defineModel("minimized", { type: Boolean, ...{ default: false } });
11
+ const maximized = defineModel("maximized", { type: Boolean, ...{ default: false } });
12
+ const errors = ref([]);
13
+ const props = defineProps({
14
+ fullscreen: { type: Boolean, required: false, skipCheck: true, default: false },
15
+ noRouteFullscreenExit: { type: Boolean, required: false, skipCheck: true },
16
+ rows: { type: Array, required: false },
17
+ rowKey: { type: [String, Function], required: false },
18
+ virtualScroll: { type: Boolean, required: false, skipCheck: true },
19
+ virtualScrollTarget: { type: null, required: false },
20
+ virtualScrollSliceSize: { type: null, required: false },
21
+ virtualScrollSliceRatioBefore: { type: null, required: false },
22
+ virtualScrollSliceRatioAfter: { type: null, required: false },
23
+ virtualScrollItemSize: { type: null, required: false },
24
+ virtualScrollStickySizeStart: { type: null, required: false },
25
+ virtualScrollStickySizeEnd: { type: null, required: false },
26
+ tableColspan: { type: null, required: false },
27
+ color: { type: null, required: false },
28
+ iconFirstPage: { type: null, required: false },
29
+ iconPrevPage: { type: null, required: false },
30
+ iconNextPage: { type: null, required: false },
31
+ iconLastPage: { type: null, required: false },
32
+ grid: { type: Boolean, required: false, skipCheck: true },
33
+ gridHeader: { type: Boolean, required: false, skipCheck: true },
34
+ dense: { type: Boolean, required: false, skipCheck: true, default: void 0 },
35
+ columns: { type: Array, required: false },
36
+ visibleColumns: { type: null, required: false },
37
+ loading: { type: Boolean, required: false, skipCheck: true },
38
+ title: { type: null, required: false },
39
+ hideHeader: { type: Boolean, required: false, skipCheck: true },
40
+ hideBottom: { type: Boolean, required: false, skipCheck: true },
41
+ hideSelectedBanner: { type: Boolean, required: false, skipCheck: true },
42
+ hideNoData: { type: Boolean, required: false, skipCheck: true },
43
+ hidePagination: { type: Boolean, required: false, skipCheck: true },
44
+ dark: { type: [Boolean, null], required: false, skipCheck: true, default: void 0 },
45
+ flat: { type: Boolean, required: false, skipCheck: true, default: void 0 },
46
+ bordered: { type: Boolean, required: false, skipCheck: true, default: void 0 },
47
+ square: { type: Boolean, required: false, skipCheck: true },
48
+ separator: { type: null, required: false },
49
+ wrapCells: { type: Boolean, required: false, skipCheck: true },
50
+ binaryStateSort: { type: Boolean, required: false, skipCheck: true },
51
+ columnSortOrder: { type: null, required: false },
52
+ noDataLabel: { type: null, required: false, default: "No data available" },
53
+ noResultsLabel: { type: null, required: false },
54
+ loadingLabel: { type: null, required: false, default: "Loading..." },
55
+ selectedRowsLabel: { type: Function, required: false, skipCheck: true },
56
+ rowsPerPageLabel: { type: null, required: false, default: "Records per page:" },
57
+ paginationLabel: { type: Function, required: false, skipCheck: true },
58
+ tableStyle: { type: null, required: false },
59
+ tableClass: { type: null, required: false },
60
+ tableHeaderStyle: { type: null, required: false },
61
+ tableHeaderClass: { type: null, required: false },
62
+ cardContainerStyle: { type: null, required: false },
63
+ cardContainerClass: { type: null, required: false },
64
+ cardStyle: { type: null, required: false },
65
+ cardClass: { type: null, required: false },
66
+ titleClass: { type: null, required: false },
67
+ filter: { type: null, required: false },
68
+ filterMethod: { type: Function, required: false, skipCheck: true },
69
+ pagination: { type: null, required: false, default: () => {
70
+ return {
71
+ sortBy: null,
72
+ descending: true,
73
+ page: 1,
74
+ rowsPerPage: 10
75
+ };
76
+ } },
77
+ rowsPerPageOptions: { type: null, required: false, default: () => [5, 10, 20, 50, 100, 0] },
78
+ selection: { type: null, required: false, default: "none" },
79
+ selected: { type: Array, required: false, default: () => [] },
80
+ expanded: { type: null, required: false },
81
+ sortMethod: { type: Function, required: false, skipCheck: true },
82
+ onFullscreen: { type: Function, required: false },
83
+ "onUpdate:fullscreen": { type: Function, required: false },
84
+ onRowClick: { type: Function, required: false },
85
+ onRowDblclick: { type: Function, required: false },
86
+ onRowContextmenu: { type: Function, required: false },
87
+ onRequest: { type: Function, required: false },
88
+ onSelection: { type: Function, required: false },
89
+ "onUpdate:pagination": { type: Function, required: false },
90
+ "onUpdate:selected": { type: Function, required: false },
91
+ "onUpdate:expanded": { type: Function, required: false },
92
+ onVirtualScroll: { type: Function, required: false },
93
+ actions: { type: Array, required: false, default: () => [] },
94
+ sortBy: { type: null, required: false },
95
+ modelName: { type: null, required: false },
96
+ searchable: { type: [Boolean, null], required: false, skipCheck: true, default: false },
97
+ maximizable: { type: Boolean, required: false, default: false },
98
+ minimizable: { type: Boolean, required: false, default: false },
99
+ onRequestData: { type: Function, required: false },
100
+ addComponent: { type: Object, required: false },
101
+ addComponentProps: { type: null, required: false }
102
+ });
103
+ const isServerSide = props.rows == void 0;
104
+ const light = useLight();
105
+ const pagination = ref(props.pagination);
106
+ if (props.rowsPerPageOptions[0] == 0) {
107
+ pagination.value.rowsPerPage = 0;
108
+ }
109
+ props.columns?.forEach((col) => {
110
+ if (!col.align) {
111
+ col.align = "left";
112
+ }
113
+ if (!col.field && col.name) {
114
+ col.field = col.name;
115
+ }
116
+ col.label = t(col.label);
117
+ });
118
+ if (props.columns) {
119
+ for (let i = 0; i < props.columns.length; i++) {
120
+ if (props.columns[i].searchOptions) {
121
+ let opts = props.columns[i].searchOptions;
122
+ if (typeof opts == "function") {
123
+ props.columns[i].searchOptions = await opts();
124
+ }
125
+ }
126
+ }
127
+ }
128
+ const emits = defineEmits(["request-data", "update:selected", "delete"]);
129
+ const loading = ref(false);
130
+ let activeEdit = false;
131
+ let actionView = false;
132
+ let actionDelete = false;
133
+ if (props.actions.length > 0) {
134
+ actionView = props.actions.includes("view");
135
+ activeEdit = props.actions.includes("edit");
136
+ actionDelete = props.actions.includes("delete");
137
+ }
138
+ if (props.sortBy) {
139
+ let [sortBy, descending] = props.sortBy.split(":");
140
+ pagination.value.sortBy = sortBy;
141
+ pagination.value.descending = descending == "desc";
142
+ }
143
+ const hasSearch = computed(() => {
144
+ return props.columns?.some((col) => {
145
+ return col.searchable;
146
+ });
147
+ });
148
+ const table = ref();
149
+ const filters = ref({});
150
+ const rows = ref(props.rows);
151
+ if (rows.value == void 0) {
152
+ rows.value = [];
153
+ }
154
+ onMounted(() => {
155
+ table.value && table.value.requestServerInteraction();
156
+ });
157
+ let primaryKey = ref(props.rowKey);
158
+ const modelName = ref(props.modelName);
159
+ const validateData = () => {
160
+ if (primaryKey.value == null) return;
161
+ if (props.actions.includes("edit")) {
162
+ if (rows.value.length > 0) {
163
+ let row = rows.value[0];
164
+ if (!row[primaryKey.value]) {
165
+ errors.value.push("[edit] Primary key not found in the data");
166
+ }
167
+ }
168
+ }
169
+ if (props.actions.includes("delete")) {
170
+ if (rows.value.length > 0) {
171
+ let row = rows.value[0];
172
+ if (!row[primaryKey.value]) {
173
+ errors.value.push("[delete] Primary key not found in the data");
174
+ }
175
+ }
176
+ }
177
+ };
178
+ const onLocalRequest = async (p) => {
179
+ if (!isServerSide) return;
180
+ let sort = "";
181
+ if (p.pagination.sortBy) {
182
+ sort = p.pagination.sortBy + ":" + (p.pagination.descending ? "desc" : "asc");
183
+ }
184
+ const builder = GQLFieldBuilder();
185
+ if (props.rowKey) {
186
+ builder.add(props.rowKey);
187
+ }
188
+ props.columns?.forEach((col) => {
189
+ if (col.gqlField) {
190
+ builder.add(col.gqlField);
191
+ return;
192
+ }
193
+ if (!col.name) return;
194
+ if (col.name.startsWith("_")) {
195
+ return;
196
+ }
197
+ builder.add(col.name);
198
+ });
199
+ if (actionView) {
200
+ builder.add("canView");
201
+ }
202
+ if (actionDelete) {
203
+ builder.add("canDelete");
204
+ }
205
+ if (activeEdit) {
206
+ builder.add("canUpdate");
207
+ }
208
+ const callback = {
209
+ sort,
210
+ fields: builder.get(),
211
+ offset: (p.pagination.page - 1) * p.pagination.rowsPerPage,
212
+ limit: p.pagination.rowsPerPage,
213
+ gql: {
214
+ __args: {
215
+ filters: getFilterValue(),
216
+ sort
217
+ },
218
+ data: {
219
+ __args: {
220
+ limit: p.pagination.rowsPerPage,
221
+ offset: (p.pagination.page - 1) * p.pagination.rowsPerPage
222
+ },
223
+ ...toQuery(builder.get())
224
+ },
225
+ meta: {
226
+ total: true,
227
+ key: true,
228
+ name: true
229
+ }
230
+ },
231
+ setData(data) {
232
+ rows.value = data.data;
233
+ primaryKey.value = data.meta.key;
234
+ modelName.value = data.meta.name;
235
+ pagination.value.rowsNumber = data.meta.total;
236
+ pagination.value.page = p.pagination.page;
237
+ pagination.value.sortBy = p.pagination.sortBy;
238
+ pagination.value.descending = p.pagination.descending;
239
+ pagination.value.rowsPerPage = p.pagination.rowsPerPage;
240
+ loading.value = false;
241
+ validateData();
242
+ },
243
+ loadObjects(model2, filters2 = null, fields = []) {
244
+ return this.loadData(model2, filters2, fields);
245
+ },
246
+ async loadData(model2, filters2 = null, fields = []) {
247
+ fields.forEach((f) => {
248
+ builder.add(f);
249
+ });
250
+ let localFilters = getFilterValue();
251
+ if (filters2) {
252
+ localFilters = {
253
+ ...localFilters,
254
+ ...filters2
255
+ };
256
+ }
257
+ loading.value = true;
258
+ try {
259
+ let c = collect(model2, builder.get());
260
+ if (localFilters) {
261
+ for (let [key, value] of Object.entries(localFilters)) {
262
+ if (typeof value == "object") {
263
+ if (value.contains) {
264
+ c = c.whereContains(key, value.contains);
265
+ }
266
+ if (value.between) {
267
+ c = c.whereBetween(key, value.between);
268
+ }
269
+ } else {
270
+ c = c.where(key, value);
271
+ }
272
+ }
273
+ }
274
+ if (sort) {
275
+ if (sort.split(":")[1] == "asc") {
276
+ c = c.sortBy(sort.split(":")[0]);
277
+ } else {
278
+ c = c.sortByDesc(sort.split(":")[0]);
279
+ }
280
+ }
281
+ if (p.pagination.rowsPerPage != 0) {
282
+ c = c.forPage(p.pagination.page, p.pagination.rowsPerPage);
283
+ }
284
+ const data = await c.all();
285
+ const allData = {
286
+ data,
287
+ meta: c.meta
288
+ };
289
+ this.setData(allData);
290
+ } catch (e) {
291
+ quasar.dialog({
292
+ message: e,
293
+ color: "negative"
294
+ });
295
+ this.setData({ data: [], meta: { total: 0, key: "", name: "" } });
296
+ }
297
+ }
298
+ };
299
+ loading.value = true;
300
+ emits("request-data", callback);
301
+ };
302
+ const getFilterValue = () => {
303
+ let f = {};
304
+ props.columns?.forEach((col) => {
305
+ if (col.searchable) {
306
+ if (filters.value[col.name] !== null && filters.value[col.name] !== "" && filters.value[col.name] !== void 0) {
307
+ if (col.searchType == "number") {
308
+ f[col.name] = filters.value[col.name];
309
+ } else if (col.searchType == "date") {
310
+ if (filters.value[col.name].from) {
311
+ f[col.name] = {
312
+ between: [filters.value[col.name].from, filters.value[col.name].to]
313
+ };
314
+ }
315
+ } else if (col.searchType == "select") {
316
+ f[col.name] = filters.value[col.name];
317
+ } else {
318
+ if (col.searchMethod == "equals") {
319
+ f[col.name] = filters.value[col.name];
320
+ } else {
321
+ f[col.name] = {
322
+ contains: filters.value[col.name]
323
+ };
324
+ }
325
+ }
326
+ }
327
+ }
328
+ });
329
+ return f;
330
+ };
331
+ const onFilters = () => {
332
+ onLocalRequest({
333
+ pagination: {
334
+ page: 1,
335
+ rowsPerPage: props.pagination.rowsPerPage,
336
+ sortBy: props.pagination.sortBy,
337
+ descending: props.pagination.descending
338
+ }
339
+ });
340
+ };
341
+ const slots = useSlots();
342
+ const ss = Object.entries(slots).map(([key, value]) => {
343
+ return key;
344
+ });
345
+ const quasar = useQuasar();
346
+ const onDelete = async (id) => {
347
+ if (modelName.value == null) return;
348
+ try {
349
+ await model(modelName.value).delete(id);
350
+ } catch (e) {
351
+ quasar.notify({
352
+ message: e.message,
353
+ color: "negative"
354
+ });
355
+ return;
356
+ }
357
+ if (table.value) {
358
+ table.value.requestServerInteraction();
359
+ }
360
+ emits("delete", id);
361
+ };
362
+ const attrs = computed(() => {
363
+ const a = { ...light.styles.table, ...Object.fromEntries(Object.entries(props).filter(([key, value]) => value !== void 0)) };
364
+ return {
365
+ ...a,
366
+ loadingLabel: t(props.loadingLabel),
367
+ noDataLabel: t(props.noDataLabel),
368
+ rowsPerPageOptions: props.rowsPerPageOptions,
369
+ rowsPerPageLabel: t(props.rowsPerPageLabel),
370
+ selection: props.selection,
371
+ rowKey: props.rowKey
372
+ };
373
+ });
374
+ const filter = ref("");
375
+ const toColumns = props.columns?.filter((col) => {
376
+ return col.to;
377
+ }).map((col) => {
378
+ col.slot_name = "body-cell-" + col.name;
379
+ return col;
380
+ });
381
+ const isDark = computed(() => {
382
+ return light.theme == "dark";
383
+ });
384
+ const hasRowExpand = computed(() => {
385
+ return ss.indexOf("row-expand") >= 0;
386
+ });
387
+ const hasActions = computed(() => {
388
+ return props.actions.length > 0;
389
+ });
390
+ const getCellStyle = (col, row) => {
391
+ const style = col.cellStyle ?? {};
392
+ if (col.backgroundColor) {
393
+ if (typeof col.backgroundColor == "function") {
394
+ style.backgroundColor = col.backgroundColor(row);
395
+ } else {
396
+ style.backgroundColor = col.backgroundColor;
397
+ }
398
+ }
399
+ return style;
400
+ };
401
+ const getCellClass = (col, row) => {
402
+ const cl = [];
403
+ if (col.cellClass) {
404
+ if (typeof col.cellClass == "function") {
405
+ cl.push(col.cellClass(row));
406
+ } else {
407
+ cl.push(col.cellClass);
408
+ }
409
+ }
410
+ return cl;
411
+ };
412
+ const localSelected = computed({
413
+ get() {
414
+ return props.selected;
415
+ },
416
+ set(val) {
417
+ emits("update:selected", val);
418
+ }
419
+ });
420
+ watch(() => props.rows, (val) => {
421
+ rows.value = val;
422
+ });
423
+ const computedColumns = computed(() => {
424
+ return props.columns;
425
+ });
426
+ function requestServerInteraction() {
427
+ table.value && table.value.requestServerInteraction();
428
+ }
429
+ defineExpose({
430
+ requestServerInteraction
431
+ });
432
+ const onAdd = () => {
433
+ if (!props.addComponent) return;
434
+ $q.dialog({
435
+ component: props.addComponent,
436
+ componentProps: props.addComponentProps
437
+ }).onOk(() => {
438
+ requestServerInteraction();
439
+ });
440
+ };
441
+ </script>
442
+
443
+ <template>
560
444
  <l-card v-bind="attrs" :maximizable="maximizable" :minimizable="minimizable" :title="title"
561
445
  v-model:minimized="minimized" v-model:maximized="maximized">
562
446
 
@@ -717,4 +601,4 @@ const onAdd = () => {
717
601
  </template>
718
602
  </q-table>
719
603
  </l-card>
720
- </template>
604
+ </template>