adminforth 1.3.54-next.8 → 1.3.55-next.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 (250) hide show
  1. package/dist/auth.d.ts +31 -0
  2. package/dist/auth.d.ts.map +1 -0
  3. package/dist/auth.js +42 -56
  4. package/dist/auth.js.map +1 -0
  5. package/dist/basePlugin.d.ts +18 -0
  6. package/dist/basePlugin.d.ts.map +1 -0
  7. package/dist/basePlugin.js +1 -0
  8. package/dist/basePlugin.js.map +1 -0
  9. package/dist/dataConnectors/baseConnector.d.ts +94 -0
  10. package/dist/dataConnectors/baseConnector.d.ts.map +1 -0
  11. package/dist/dataConnectors/baseConnector.js +108 -122
  12. package/dist/dataConnectors/baseConnector.js.map +1 -0
  13. package/dist/dataConnectors/clickhouse.d.ts +92 -0
  14. package/dist/dataConnectors/clickhouse.d.ts.map +1 -0
  15. package/dist/dataConnectors/clickhouse.js +132 -149
  16. package/dist/dataConnectors/clickhouse.js.map +1 -0
  17. package/dist/dataConnectors/mongo.d.ts +93 -0
  18. package/dist/dataConnectors/mongo.d.ts.map +1 -0
  19. package/dist/dataConnectors/mongo.js +75 -101
  20. package/dist/dataConnectors/mongo.js.map +1 -0
  21. package/dist/dataConnectors/postgres.d.ts +71 -0
  22. package/dist/dataConnectors/postgres.d.ts.map +1 -0
  23. package/dist/dataConnectors/postgres.js +124 -143
  24. package/dist/dataConnectors/postgres.js.map +1 -0
  25. package/dist/dataConnectors/sqlite.d.ts +67 -0
  26. package/dist/dataConnectors/sqlite.d.ts.map +1 -0
  27. package/dist/dataConnectors/sqlite.js +113 -130
  28. package/dist/dataConnectors/sqlite.js.map +1 -0
  29. package/dist/index.d.ts +92 -0
  30. package/dist/index.d.ts.map +1 -0
  31. package/dist/index.js +197 -217
  32. package/dist/index.js.map +1 -0
  33. package/dist/modules/codeInjector.d.ts +35 -0
  34. package/dist/modules/codeInjector.d.ts.map +1 -0
  35. package/dist/modules/codeInjector.js +480 -486
  36. package/dist/modules/codeInjector.js.map +1 -0
  37. package/dist/modules/configValidator.d.ts +12 -0
  38. package/dist/modules/configValidator.d.ts.map +1 -0
  39. package/dist/modules/configValidator.js +31 -22
  40. package/dist/modules/configValidator.js.map +1 -0
  41. package/dist/modules/operationalResource.d.ts +17 -0
  42. package/dist/modules/operationalResource.d.ts.map +1 -0
  43. package/dist/modules/operationalResource.js +50 -70
  44. package/dist/modules/operationalResource.js.map +1 -0
  45. package/dist/modules/restApi.d.ts +10 -0
  46. package/dist/modules/restApi.d.ts.map +1 -0
  47. package/dist/modules/restApi.js +104 -116
  48. package/dist/modules/restApi.js.map +1 -0
  49. package/dist/modules/styleGenerator.d.ts +9 -0
  50. package/dist/modules/styleGenerator.d.ts.map +1 -0
  51. package/dist/modules/styleGenerator.js +1 -0
  52. package/dist/modules/styleGenerator.js.map +1 -0
  53. package/dist/modules/styles.d.ts +96 -0
  54. package/dist/modules/styles.d.ts.map +1 -0
  55. package/dist/modules/styles.js +1 -0
  56. package/dist/modules/styles.js.map +1 -0
  57. package/dist/modules/utils.d.ts +39 -0
  58. package/dist/modules/utils.d.ts.map +1 -0
  59. package/dist/modules/utils.js +1 -0
  60. package/dist/modules/utils.js.map +1 -0
  61. package/dist/plugins/audit-log/types.d.ts +35 -0
  62. package/dist/plugins/audit-log/types.d.ts.map +1 -0
  63. package/dist/plugins/audit-log/types.js +2 -0
  64. package/dist/plugins/audit-log/types.js.map +1 -0
  65. package/dist/plugins/chat-gpt/types.d.ts +82 -0
  66. package/dist/plugins/chat-gpt/types.d.ts.map +1 -0
  67. package/dist/plugins/chat-gpt/types.js +2 -0
  68. package/dist/plugins/chat-gpt/types.js.map +1 -0
  69. package/dist/plugins/email-password-reset/types.d.ts +28 -0
  70. package/dist/plugins/email-password-reset/types.d.ts.map +1 -0
  71. package/dist/plugins/email-password-reset/types.js +2 -0
  72. package/dist/plugins/email-password-reset/types.js.map +1 -0
  73. package/dist/plugins/foreign-inline-list/types.d.ts +19 -0
  74. package/dist/plugins/foreign-inline-list/types.d.ts.map +1 -0
  75. package/dist/plugins/foreign-inline-list/types.js +2 -0
  76. package/dist/plugins/foreign-inline-list/types.js.map +1 -0
  77. package/dist/plugins/import-export/types.d.ts +3 -0
  78. package/dist/plugins/import-export/types.d.ts.map +1 -0
  79. package/dist/plugins/import-export/types.js +2 -0
  80. package/dist/plugins/import-export/types.js.map +1 -0
  81. package/dist/plugins/rich-editor/custom/async-queue.d.ts +8 -0
  82. package/dist/plugins/rich-editor/custom/async-queue.d.ts.map +1 -0
  83. package/dist/plugins/rich-editor/custom/async-queue.js +29 -0
  84. package/dist/plugins/rich-editor/custom/async-queue.js.map +1 -0
  85. package/dist/plugins/rich-editor/dist/custom/async-queue.d.ts +8 -0
  86. package/dist/plugins/rich-editor/dist/custom/async-queue.d.ts.map +1 -0
  87. package/dist/plugins/rich-editor/dist/custom/async-queue.js +29 -0
  88. package/dist/plugins/rich-editor/dist/custom/async-queue.js.map +1 -0
  89. package/dist/plugins/rich-editor/types.d.ts +153 -0
  90. package/dist/plugins/rich-editor/types.d.ts.map +1 -0
  91. package/dist/plugins/rich-editor/types.js +16 -0
  92. package/dist/plugins/rich-editor/types.js.map +1 -0
  93. package/dist/plugins/two-factors-auth/types.d.ts +18 -0
  94. package/dist/plugins/two-factors-auth/types.d.ts.map +1 -0
  95. package/dist/plugins/two-factors-auth/types.js +2 -0
  96. package/dist/plugins/two-factors-auth/types.js.map +1 -0
  97. package/dist/plugins/upload/types.d.ts +132 -0
  98. package/dist/plugins/upload/types.d.ts.map +1 -0
  99. package/dist/plugins/upload/types.js +2 -0
  100. package/dist/plugins/upload/types.js.map +1 -0
  101. package/dist/servers/express.d.ts +18 -0
  102. package/dist/servers/express.d.ts.map +1 -0
  103. package/dist/servers/express.js +30 -42
  104. package/dist/servers/express.js.map +1 -0
  105. package/dist/types/AdminForthConfig.d.ts +1619 -0
  106. package/dist/types/AdminForthConfig.d.ts.map +1 -0
  107. package/dist/types/AdminForthConfig.js +1 -0
  108. package/dist/types/AdminForthConfig.js.map +1 -0
  109. package/{types/FrontendAPI.ts → dist/types/FrontendAPI.d.ts} +27 -52
  110. package/dist/types/FrontendAPI.d.ts.map +1 -0
  111. package/dist/types/FrontendAPI.js +1 -0
  112. package/dist/types/FrontendAPI.js.map +1 -0
  113. package/package.json +15 -5
  114. package/auth.ts +0 -140
  115. package/basePlugin.ts +0 -70
  116. package/dataConnectors/baseConnector.ts +0 -216
  117. package/dataConnectors/clickhouse.ts +0 -338
  118. package/dataConnectors/mongo.ts +0 -202
  119. package/dataConnectors/postgres.ts +0 -306
  120. package/dataConnectors/sqlite.ts +0 -254
  121. package/dist/spa/.eslintrc.cjs +0 -14
  122. package/dist/spa/README.md +0 -39
  123. package/dist/spa/env.d.ts +0 -1
  124. package/dist/spa/index.html +0 -23
  125. package/dist/spa/package-lock.json +0 -4573
  126. package/dist/spa/package.json +0 -49
  127. package/dist/spa/postcss.config.js +0 -6
  128. package/dist/spa/public/assets/favicon.png +0 -0
  129. package/dist/spa/src/App.vue +0 -314
  130. package/dist/spa/src/assets/base.css +0 -2
  131. package/dist/spa/src/assets/logo.svg +0 -19
  132. package/dist/spa/src/components/AcceptModal.vue +0 -45
  133. package/dist/spa/src/components/Breadcrumbs.vue +0 -41
  134. package/dist/spa/src/components/BreadcrumbsWithButtons.vue +0 -26
  135. package/dist/spa/src/components/CustomDatePicker.vue +0 -176
  136. package/dist/spa/src/components/CustomDateRangePicker.vue +0 -218
  137. package/dist/spa/src/components/CustomRangePicker.vue +0 -152
  138. package/dist/spa/src/components/Dropdown.vue +0 -168
  139. package/dist/spa/src/components/Filters.vue +0 -222
  140. package/dist/spa/src/components/HelloWorld.vue +0 -17
  141. package/dist/spa/src/components/MenuLink.vue +0 -24
  142. package/dist/spa/src/components/ResourceForm.vue +0 -294
  143. package/dist/spa/src/components/ResourceListTable.vue +0 -394
  144. package/dist/spa/src/components/SingleSkeletLoader.vue +0 -13
  145. package/dist/spa/src/components/SkeleteLoader.vue +0 -23
  146. package/dist/spa/src/components/Toast.vue +0 -77
  147. package/dist/spa/src/components/ValueRenderer.vue +0 -66
  148. package/dist/spa/src/components/icons/IconCalendar.vue +0 -5
  149. package/dist/spa/src/components/icons/IconCommunity.vue +0 -7
  150. package/dist/spa/src/components/icons/IconDocumentation.vue +0 -7
  151. package/dist/spa/src/components/icons/IconEcosystem.vue +0 -7
  152. package/dist/spa/src/components/icons/IconSupport.vue +0 -7
  153. package/dist/spa/src/components/icons/IconTime.vue +0 -5
  154. package/dist/spa/src/components/icons/IconTooling.vue +0 -19
  155. package/dist/spa/src/composables/useFrontendApi.ts +0 -26
  156. package/dist/spa/src/composables/useStores.ts +0 -127
  157. package/dist/spa/src/index.scss +0 -27
  158. package/dist/spa/src/main.ts +0 -18
  159. package/dist/spa/src/router/index.ts +0 -63
  160. package/dist/spa/src/spa_types/core.ts +0 -51
  161. package/dist/spa/src/stores/core.ts +0 -144
  162. package/dist/spa/src/stores/filters.ts +0 -22
  163. package/dist/spa/src/stores/modal.ts +0 -48
  164. package/dist/spa/src/stores/toast.ts +0 -15
  165. package/dist/spa/src/stores/user.ts +0 -72
  166. package/dist/spa/src/types/AdminForthConfig.ts +0 -1477
  167. package/dist/spa/src/types/FrontendAPI.ts +0 -121
  168. package/dist/spa/src/utils.ts +0 -103
  169. package/dist/spa/src/views/CreateView.vue +0 -156
  170. package/dist/spa/src/views/EditView.vue +0 -157
  171. package/dist/spa/src/views/ListView.vue +0 -258
  172. package/dist/spa/src/views/LoginView.vue +0 -160
  173. package/dist/spa/src/views/ResourceParent.vue +0 -17
  174. package/dist/spa/src/views/ShowView.vue +0 -184
  175. package/dist/spa/tailwind.config.js +0 -17
  176. package/dist/spa/tsconfig.app.json +0 -14
  177. package/dist/spa/tsconfig.json +0 -11
  178. package/dist/spa/tsconfig.node.json +0 -19
  179. package/dist/spa/vite.config.ts +0 -56
  180. package/index.ts +0 -428
  181. package/modules/codeInjector.ts +0 -736
  182. package/modules/configValidator.ts +0 -571
  183. package/modules/operationalResource.ts +0 -98
  184. package/modules/restApi.ts +0 -718
  185. package/modules/styleGenerator.ts +0 -55
  186. package/modules/styles.ts +0 -126
  187. package/modules/utils.ts +0 -472
  188. package/servers/express.ts +0 -259
  189. package/spa/.eslintrc.cjs +0 -14
  190. package/spa/README.md +0 -39
  191. package/spa/env.d.ts +0 -1
  192. package/spa/index.html +0 -23
  193. package/spa/package-lock.json +0 -4602
  194. package/spa/package.json +0 -51
  195. package/spa/postcss.config.js +0 -6
  196. package/spa/public/assets/favicon.png +0 -0
  197. package/spa/src/App.vue +0 -418
  198. package/spa/src/assets/base.css +0 -2
  199. package/spa/src/assets/logo.svg +0 -19
  200. package/spa/src/components/AcceptModal.vue +0 -45
  201. package/spa/src/components/Breadcrumbs.vue +0 -41
  202. package/spa/src/components/BreadcrumbsWithButtons.vue +0 -26
  203. package/spa/src/components/CustomDatePicker.vue +0 -176
  204. package/spa/src/components/CustomDateRangePicker.vue +0 -218
  205. package/spa/src/components/CustomRangePicker.vue +0 -156
  206. package/spa/src/components/Dropdown.vue +0 -168
  207. package/spa/src/components/Filters.vue +0 -222
  208. package/spa/src/components/HelloWorld.vue +0 -17
  209. package/spa/src/components/MenuLink.vue +0 -27
  210. package/spa/src/components/ResourceForm.vue +0 -290
  211. package/spa/src/components/ResourceListTable.vue +0 -466
  212. package/spa/src/components/SingleSkeletLoader.vue +0 -13
  213. package/spa/src/components/SkeleteLoader.vue +0 -23
  214. package/spa/src/components/ThreeDotsMenu.vue +0 -43
  215. package/spa/src/components/Toast.vue +0 -78
  216. package/spa/src/components/ValueRenderer.vue +0 -114
  217. package/spa/src/components/icons/IconCalendar.vue +0 -5
  218. package/spa/src/components/icons/IconCommunity.vue +0 -7
  219. package/spa/src/components/icons/IconDocumentation.vue +0 -7
  220. package/spa/src/components/icons/IconEcosystem.vue +0 -7
  221. package/spa/src/components/icons/IconSupport.vue +0 -7
  222. package/spa/src/components/icons/IconTime.vue +0 -5
  223. package/spa/src/components/icons/IconTooling.vue +0 -19
  224. package/spa/src/composables/useFrontendApi.ts +0 -26
  225. package/spa/src/composables/useStores.ts +0 -131
  226. package/spa/src/index.scss +0 -31
  227. package/spa/src/main.ts +0 -18
  228. package/spa/src/renderers/CompactUUID.vue +0 -48
  229. package/spa/src/renderers/CountryFlag.vue +0 -69
  230. package/spa/src/router/index.ts +0 -59
  231. package/spa/src/spa_types/core.ts +0 -53
  232. package/spa/src/stores/core.ts +0 -148
  233. package/spa/src/stores/filters.ts +0 -27
  234. package/spa/src/stores/modal.ts +0 -48
  235. package/spa/src/stores/toast.ts +0 -31
  236. package/spa/src/stores/user.ts +0 -72
  237. package/spa/src/utils.ts +0 -160
  238. package/spa/src/views/CreateView.vue +0 -167
  239. package/spa/src/views/EditView.vue +0 -170
  240. package/spa/src/views/ListView.vue +0 -352
  241. package/spa/src/views/LoginView.vue +0 -192
  242. package/spa/src/views/ResourceParent.vue +0 -17
  243. package/spa/src/views/ShowView.vue +0 -186
  244. package/spa/tailwind.config.js +0 -17
  245. package/spa/tsconfig.app.json +0 -14
  246. package/spa/tsconfig.json +0 -11
  247. package/spa/tsconfig.node.json +0 -19
  248. package/spa/vite.config.ts +0 -56
  249. package/tsconfig.json +0 -112
  250. package/types/AdminForthConfig.ts +0 -1762
@@ -1,121 +0,0 @@
1
-
2
- export interface FrontendAPIInterface {
3
-
4
- /**
5
- * Show a confirmation dialog
6
- *
7
- * The dialog will be displayed to the user
8
- *
9
- * Example:
10
- *
11
- * ```ts
12
- * const isConfirmed = await window.adminforth.confirm({message: 'Are you sure?', yes: 'Yes', no: 'No'})
13
- * if (isConfirmed) {
14
- * your code...
15
- * }
16
- * ```
17
- *
18
- * @param params - The parameters of the dialog
19
- * @returns A promise that resolves when the user confirms the dialog
20
- */
21
- confirm(params:ConfirmParams ): Promise<void>;
22
- /**
23
- * Show an alert
24
- *
25
- * The alert will be displayed to the user
26
- *
27
- * Example:
28
- *
29
- * ```ts
30
- * window.adminforth.alert({message: 'Hello', variant: 'success'})
31
- * ```
32
- *
33
- * @param params - The parameters of the alert
34
- */
35
- alert(params:AlertParams): void;
36
- /**
37
- * Add a filter to the list of filters.
38
- * Works only when user located on the list page.
39
- * Can be used to set filter from charts or other components in pageInjections.
40
- *
41
- * Example:
42
- *
43
- * ```ts
44
- * window.adminforth.updateListFilter({field: 'name', operator: 'ilike', value: 'john'})
45
- * ```
46
- *
47
- * @param filter - The filter to add
48
- */
49
- setListFilter(filter: any): void;
50
- /**
51
- * Update a filter in the list of filters
52
- *
53
- * Example:
54
- *
55
- * ```ts
56
- * window.adminforth.updateListFilter({field: 'name', operator: 'ilike', value: 'john'})
57
- * ```
58
- *
59
- * @param filter - The filter to update
60
- */
61
- updateListFilter(filter: any): void;
62
- /**
63
- * Clear all filters from the list
64
- */
65
- clearListFilters(): void;
66
-
67
- }
68
-
69
- export type ConfirmParams = {
70
- /**
71
- * The message to display in the dialog
72
- */
73
- message?: string;
74
- /**
75
- * The text to display in the "accept" button
76
- */
77
- yes?: string;
78
- /**
79
- * The text to display in the "cancel" button
80
- */
81
- no?: string;
82
-
83
- }
84
-
85
- export type AlertParams = {
86
- /**
87
- * The message to display in the alert
88
- */
89
- message?: string;
90
-
91
- /**
92
- * The message to display in the alert as HTML (can be used instead of message)
93
- */
94
- messageHtml?: string;
95
-
96
- /**
97
- * The variant of the alert
98
- */
99
- variant?: AlertVariant | keyof typeof AlertVariant;
100
-
101
- /**
102
- * The timeout of the alert in seconds or 'unlimited' to keep the alert open until the user closes it.
103
- * Default is 10 seconds;
104
- */
105
- timeout?: number | 'unlimited';
106
-
107
- }
108
-
109
-
110
-
111
- export enum AlertVariant {
112
- danger = 'danger',
113
- success = 'success',
114
- warning = 'warning',
115
- info = 'info'
116
- }
117
-
118
-
119
-
120
-
121
-
@@ -1,103 +0,0 @@
1
- import { onMounted, ref, resolveComponent } from 'vue';
2
- import type { CoreConfig } from './spa_types/core';
3
-
4
- import router from "./router";
5
- import { useRouter } from 'vue-router';
6
- import { useCoreStore } from './stores/core';
7
- import { useUserStore } from './stores/user';
8
-
9
- export async function callApi({path, method, body=undefined}: {
10
- path: string, method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH'
11
- body?: any
12
- }): Promise<any> {
13
- const options = {
14
- method,
15
- headers: {
16
- 'Content-Type': 'application/json',
17
- },
18
- body: JSON.stringify(body),
19
- };
20
- const fullPath = `${import.meta.env.VITE_ADMINFORTH_PUBLIC_PATH || ''}${path}`;
21
- const r = await fetch(fullPath, options);
22
- if (r.status == 401 ) {
23
- useUserStore().unauthorize();
24
- router.push({ name: 'login' });
25
- return null;
26
- }
27
- return await r.json();
28
- }
29
-
30
- export async function callAdminForthApi({ path, method, body=undefined }: {
31
- path: string,
32
- method: 'GET' | 'POST' | 'PUT' | 'DELETE',
33
- body?: any
34
- }) {
35
- try {
36
- return callApi({path: `/adminapi/v1${path}`, method, body} );
37
- } catch (e) {
38
- console.error('error', e);
39
- return { error: `Unexpected error: ${e}` };
40
- }
41
- }
42
-
43
- export function getCustomComponent({ file, meta }: { file: string, meta: any }) {
44
- const name = file.replace(/@/g, '').replace(/\./g, '').replace(/\//g, '');
45
- return resolveComponent(name);
46
- }
47
-
48
- export function getIcon(icon: string) {
49
- // icon format is "feather:icon-name". We need to get IconName in pascal case
50
- if (!icon.includes(':')) {
51
- throw new Error('Icon name should be in format "icon-set:icon-name"');
52
- }
53
- const [iconSet, iconName] = icon.split(':');
54
- const compName = 'Icon' + iconName.split('-').map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join('');
55
- return resolveComponent(compName);
56
- }
57
-
58
- export const loadFile = (file: string) => {
59
- if (file.startsWith('http')) {
60
- return file;
61
- }
62
- let path;
63
- let baseUrl = '';
64
- if (file.startsWith('@/')) {
65
- path = file.replace('@/', '');
66
- baseUrl = new URL(`./${path}`, import.meta.url).href;
67
- } else if (file.startsWith('@@/')) {
68
- path = file.replace('@@/', '');
69
- baseUrl = new URL(`./custom/${path}`, import.meta.url).href;
70
- } else {
71
- baseUrl = new URL(`./${file}`, import.meta.url).href;
72
- }
73
- return baseUrl;
74
- }
75
-
76
- export function checkEmptyValues(value: any, viewType: 'show' | 'list' ) {
77
- const config: CoreConfig | {} = useCoreStore().config;
78
- let emptyFieldPlaceholder = '';
79
- if (config.emptyFieldPlaceholder) {
80
- if(typeof config.emptyFieldPlaceholder === 'string') {
81
- emptyFieldPlaceholder = config.emptyFieldPlaceholder;
82
- } else {
83
- emptyFieldPlaceholder = config.emptyFieldPlaceholder?.[viewType] || '';
84
- }
85
- if (value === null || value === undefined || value === '') {
86
- return emptyFieldPlaceholder;
87
- }
88
- }
89
- return value;
90
- }
91
-
92
- export function checkAcessByAllowedActions(allowedActions:any, action:any ) {
93
- if (!allowedActions) {
94
- console.warn('allowedActions not set');
95
- return;
96
- }
97
- if(allowedActions[action] === false) {
98
- console.warn(`Action ${action} is not allowed`);
99
- router.back();
100
- }
101
- }
102
-
103
-
@@ -1,156 +0,0 @@
1
- <template>
2
- <div class="relative">
3
-
4
- <component
5
- v-for="c in coreStore?.resourceOptions?.pageInjections?.create?.beforeBreadcrumbs || []"
6
- :is="getCustomComponent(c)"
7
- :meta="c.meta"
8
- :record="coreStore.record"
9
- :resource="coreStore.resource"
10
- :adminUser="coreStore.adminUser"
11
- />
12
-
13
- <BreadcrumbsWithButtons>
14
- <!-- save and cancle -->
15
- <button @click="$router.back()"
16
- class="flex items-center py-1 px-3 me-2 text-sm font-medium rounded-default text-gray-900 focus:outline-none bg-white rounded border border-gray-300 hover:bg-gray-100 hover:text-blue-700 focus:z-10 focus:ring-4 focus:ring-gray-100 dark:focus:ring-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700"
17
- >
18
- Cancel
19
- </button>
20
-
21
- <button @click="saveRecord"
22
- class="flex items-center py-1 px-3 text-sm font-medium rounded-default text-red-600 focus:outline-none bg-white rounded border border-gray-300 hover:bg-gray-100 hover:text-red-700 focus:z-10 focus:ring-4 focus:ring-gray-100 dark:focus:ring-gray-700 dark:bg-gray-800 dark:text-red-500 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700 disabled:opacity-50"
23
- :disabled="saving || (validating && !isValid)"
24
- >
25
- <svg v-if="saving" x
26
- aria-hidden="true" class="w-4 h-4 mr-1 text-gray-200 animate-spin dark:text-gray-600 fill-red-600" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/><path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/></svg>
27
-
28
- <IconFloppyDiskSolid v-else class="w-4 h-4 mr-1" />
29
- Save
30
- </button>
31
-
32
- </BreadcrumbsWithButtons>
33
-
34
- <component
35
- v-for="c in coreStore?.resourceOptions?.pageInjections?.create?.afterBreadcrumbs || []"
36
- :is="getCustomComponent(c)"
37
- :meta="c.meta"
38
- :record="coreStore.record"
39
- :resource="coreStore.resource"
40
- :adminUser="coreStore.adminUser"
41
- />
42
-
43
- <SingleSkeletLoader v-if="loading"></SingleSkeletLoader>
44
-
45
-
46
- <ResourceForm
47
- v-else
48
- :record="record"
49
- :resource="coreStore.resource"
50
- @update:record="onUpdateRecord"
51
- @update:isValid="isValid = $event"
52
- :validating="validating"
53
- :source="'create'"
54
- >
55
- </ResourceForm>
56
-
57
- <component
58
- v-for="c in coreStore?.resourceOptions?.pageInjections?.create?.bottom || []"
59
- :is="getCustomComponent(c)"
60
- :meta="c.meta"
61
- :record="coreStore.record"
62
- :resource="coreStore.resource"
63
- :adminUser="coreStore.adminUser"
64
- />
65
-
66
- </div>
67
- </template>
68
-
69
-
70
- <script setup>
71
-
72
- import BreadcrumbsWithButtons from '@/components/BreadcrumbsWithButtons.vue';
73
- import ResourceForm from '@/components/ResourceForm.vue';
74
- import SingleSkeletLoader from '@/components/SingleSkeletLoader.vue';
75
- import { useCoreStore } from '@/stores/core';
76
- import { callAdminForthApi, getCustomComponent,checkAcessByAllowedActions } from '@/utils';
77
- import { IconFloppyDiskSolid } from '@iconify-prerendered/vue-flowbite';
78
- import { onMounted, ref, watch } from 'vue';
79
- import { useRoute, useRouter } from 'vue-router';
80
- import { computed } from 'vue';
81
- import { showErrorTost } from '@/composables/useFrontendApi';
82
-
83
-
84
- const isValid = ref(false);
85
- const validating = ref(false);
86
-
87
- const loading = ref(false);
88
- const saving = ref(false);
89
-
90
- const route = useRoute();
91
- const router = useRouter();
92
-
93
- const record = ref({});
94
-
95
- const coreStore = useCoreStore();
96
-
97
- const initalValues = computed(() => {
98
- if (!route.query.values) {
99
- return {};
100
- }
101
- return JSON.parse(decodeURIComponent(route.query.values));
102
- });
103
-
104
-
105
-
106
- async function onUpdateRecord(newRecord) {
107
- console.log('newRecord', newRecord);
108
- record.value = newRecord;
109
- }
110
-
111
- onMounted(async () => {
112
- loading.value = true;
113
- record.value = initalValues.value;
114
- await coreStore.fetchResourceFull({
115
- resourceId: route.params.resourceId
116
- });
117
- loading.value = false;
118
- checkAcessByAllowedActions(coreStore.resourceOptions.allowedActions,'create');
119
- });
120
-
121
- async function saveRecord() {
122
- console.log('saveRecord isValid', isValid.value);
123
- if (!isValid.value) {
124
- validating.value = true;
125
- return;
126
- } else {
127
- validating.value = false;
128
- }
129
- saving.value = true;
130
- const response = await callAdminForthApi({
131
- method: 'POST',
132
- path: `/create_record`,
133
- body: {
134
- resourceId: route.params.resourceId,
135
- record: record.value,
136
- },
137
- });
138
- if (response.error) {
139
- showErrorTost(response.error);
140
- }
141
- saving.value = false;
142
- if (route.query.returnTo) {
143
- router.push(route.query.returnTo);
144
- } else {
145
- router.push({
146
- name: 'resource-show',
147
- params: {
148
- resourceId: route.params.resourceId,
149
- primaryKey: response.newRecordId
150
- }
151
- });
152
- }
153
- }
154
-
155
-
156
- </script>
@@ -1,157 +0,0 @@
1
- <template>
2
- <div class="relative">
3
- <component
4
- v-for="c in coreStore?.resourceOptions?.pageInjections?.edit?.beforeBreadcrumbs || []"
5
- :is="getCustomComponent(c)"
6
- :meta="c.meta"
7
- :record="editableRecord"
8
- :resource="coreStore.resource"
9
- :adminUser="coreStore.adminUser"
10
- />
11
-
12
- <BreadcrumbsWithButtons>
13
- <!-- save and cancle -->
14
- <button @click="$router.back()"
15
- class="flex items-center py-1 px-3 me-2 text-sm font-medium text-gray-900 rounded-default focus:outline-none bg-white rounded border border-gray-300 hover:bg-gray-100 hover:text-blue-700 focus:z-10 focus:ring-4 focus:ring-gray-100 dark:focus:ring-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700"
16
- >
17
- Cancel
18
- </button>
19
-
20
- <button @click="saveRecord"
21
- class="flex items-center py-1 px-3 text-sm font-medium rounded-default text-red-600 focus:outline-none bg-white rounded border border-gray-300 hover:bg-gray-100 hover:text-red-700 focus:z-10 focus:ring-4 focus:ring-gray-100 dark:focus:ring-gray-700 dark:bg-gray-800 dark:text-red-500 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700"
22
- :disabled="saving || (validating && !isValid)"
23
- >
24
- <IconFloppyDiskSolid class="w-4 h-4" />
25
- Save
26
- </button>
27
-
28
- </BreadcrumbsWithButtons>
29
-
30
- <component
31
- v-for="c in coreStore?.resourceOptions?.pageInjections?.edit?.afterBreadcrumbs || []"
32
- :is="getCustomComponent(c)"
33
- :meta="c.meta"
34
- :record="coreStore.record"
35
- :resource="coreStore.resource"
36
- :adminUser="coreStore.adminUser"
37
- />
38
-
39
- <SingleSkeletLoader v-if="loading"></SingleSkeletLoader>
40
-
41
- <ResourceForm
42
- v-else
43
- :record="editableRecord"
44
- :resource="coreStore.resource"
45
- :adminUser="coreStore.adminUser"
46
- @update:record="onUpdateRecord"
47
- @update:isValid="isValid = $event"
48
- :validating="validating"
49
- :source="'edit'"
50
- >
51
- </ResourceForm>
52
-
53
- <component
54
- v-for="c in coreStore?.resourceOptions?.pageInjections?.edit?.bottom || []"
55
- :is="getCustomComponent(c)"
56
- :meta="c.meta"
57
- :record="coreStore.record"
58
- :resource="coreStore.resource"
59
- :adminUser="coreStore.adminUser"
60
- />
61
-
62
- </div>
63
- </template>
64
-
65
-
66
- <script setup>
67
-
68
- import BreadcrumbsWithButtons from '@/components/BreadcrumbsWithButtons.vue';
69
- import ResourceForm from '@/components/ResourceForm.vue';
70
- import SingleSkeletLoader from '@/components/SingleSkeletLoader.vue';
71
- import { useCoreStore } from '@/stores/core';
72
- import { callAdminForthApi, getCustomComponent,checkAcessByAllowedActions } from '@/utils';
73
- import { IconFloppyDiskSolid } from '@iconify-prerendered/vue-flowbite';
74
- import { computed, onMounted, ref } from 'vue';
75
- import { useRoute, useRouter } from 'vue-router';
76
- import { showErrorTost } from '@/composables/useFrontendApi';
77
-
78
- const coreStore = useCoreStore();
79
-
80
- const isValid = ref(false);
81
- const validating = ref(false);
82
-
83
- const route = useRoute();
84
- const router = useRouter();
85
-
86
- const loading = ref(false);
87
-
88
- const saving = ref(false);
89
-
90
- const record = ref({});
91
-
92
- async function onUpdateRecord(newRecord) {
93
- record.value = newRecord;
94
- }
95
-
96
- const editableRecord = computed(() => {
97
- const newRecord = { ...coreStore.record };
98
- if (!coreStore.resource) {
99
- return {};
100
- }
101
- coreStore.resource.columns.forEach(column => {
102
- if (column.foreignResource) {
103
- newRecord[column.name] = newRecord[column.name]?.pk
104
- }
105
- });
106
- return newRecord;
107
- })
108
-
109
- onMounted(async () => {
110
-
111
- loading.value = true;
112
-
113
- await coreStore.fetchResourceFull({
114
- resourceId: route.params.resourceId
115
- });
116
- await coreStore.fetchRecord({
117
- resourceId: route.params.resourceId,
118
- primaryKey: route.params.primaryKey,
119
- });
120
- checkAcessByAllowedActions(coreStore.resourceOptions.allowedActions,'edit');
121
- loading.value = false;
122
- });
123
-
124
- async function saveRecord() {
125
- if (!isValid.value) {
126
- validating.value = true;
127
- return;
128
- } else {
129
- validating.value = false;
130
- }
131
-
132
- saving.value = true;
133
-
134
- const updates = {};
135
- for (const key in record.value) {
136
- if (record.value[key] !== coreStore.record[key]) {
137
- updates[key] = record.value[key];
138
- }
139
- }
140
-
141
- const resp = await callAdminForthApi({
142
- method: 'POST',
143
- path: `/update_record`,
144
- body: {
145
- resourceId: route.params.resourceId,
146
- recordId: route.params.primaryKey,
147
- record: updates,
148
- },
149
- });
150
- if (resp.error) {
151
- showErrorTost(resp.error);
152
- }
153
- saving.value = false;
154
- router.push({ name: 'resource-show', params: { resourceId: route.params.resourceId, primaryKey: coreStore.record[coreStore.primaryKey] } });
155
- }
156
-
157
- </script>