adminforth 2.26.0-next.3 → 2.26.0-next.31

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 (88) hide show
  1. package/commands/createApp/templates/package.json.hbs +1 -1
  2. package/dist/dataConnectors/baseConnector.d.ts.map +1 -1
  3. package/dist/dataConnectors/baseConnector.js +3 -0
  4. package/dist/dataConnectors/baseConnector.js.map +1 -1
  5. package/dist/dataConnectors/clickhouse.d.ts +4 -0
  6. package/dist/dataConnectors/clickhouse.d.ts.map +1 -1
  7. package/dist/dataConnectors/clickhouse.js +14 -0
  8. package/dist/dataConnectors/clickhouse.js.map +1 -1
  9. package/dist/dataConnectors/mongo.d.ts +4 -0
  10. package/dist/dataConnectors/mongo.d.ts.map +1 -1
  11. package/dist/dataConnectors/mongo.js +9 -0
  12. package/dist/dataConnectors/mongo.js.map +1 -1
  13. package/dist/dataConnectors/mysql.d.ts +4 -0
  14. package/dist/dataConnectors/mysql.d.ts.map +1 -1
  15. package/dist/dataConnectors/mysql.js +11 -0
  16. package/dist/dataConnectors/mysql.js.map +1 -1
  17. package/dist/dataConnectors/postgres.d.ts +4 -0
  18. package/dist/dataConnectors/postgres.d.ts.map +1 -1
  19. package/dist/dataConnectors/postgres.js +11 -0
  20. package/dist/dataConnectors/postgres.js.map +1 -1
  21. package/dist/dataConnectors/qdrant.d.ts +57 -0
  22. package/dist/dataConnectors/qdrant.d.ts.map +1 -0
  23. package/dist/dataConnectors/qdrant.js +469 -0
  24. package/dist/dataConnectors/qdrant.js.map +1 -0
  25. package/dist/dataConnectors/sqlite.d.ts +4 -0
  26. package/dist/dataConnectors/sqlite.d.ts.map +1 -1
  27. package/dist/dataConnectors/sqlite.js +11 -0
  28. package/dist/dataConnectors/sqlite.js.map +1 -1
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +22 -33
  31. package/dist/index.js.map +1 -1
  32. package/dist/modules/codeInjector.d.ts.map +1 -1
  33. package/dist/modules/codeInjector.js +59 -50
  34. package/dist/modules/codeInjector.js.map +1 -1
  35. package/dist/modules/configValidator.d.ts.map +1 -1
  36. package/dist/modules/configValidator.js +3 -2
  37. package/dist/modules/configValidator.js.map +1 -1
  38. package/dist/modules/restApi.d.ts +1 -0
  39. package/dist/modules/restApi.d.ts.map +1 -1
  40. package/dist/modules/restApi.js +33 -16
  41. package/dist/modules/restApi.js.map +1 -1
  42. package/dist/modules/utils.d.ts +6 -0
  43. package/dist/modules/utils.d.ts.map +1 -1
  44. package/dist/modules/utils.js +13 -0
  45. package/dist/modules/utils.js.map +1 -1
  46. package/dist/servers/express.d.ts.map +1 -1
  47. package/dist/servers/express.js +7 -1
  48. package/dist/servers/express.js.map +1 -1
  49. package/dist/spa/package-lock.json +57 -0
  50. package/dist/spa/package.json +2 -0
  51. package/dist/spa/pnpm-lock.yaml +32 -0
  52. package/dist/spa/src/adminforth.ts +17 -29
  53. package/dist/spa/src/afcl/Input.vue +1 -1
  54. package/dist/spa/src/afcl/Modal.vue +18 -3
  55. package/dist/spa/src/afcl/Select.vue +4 -2
  56. package/dist/spa/src/afcl/Table.vue +27 -13
  57. package/dist/spa/src/components/AcceptModal.vue +33 -53
  58. package/dist/spa/src/components/BreadcrumbsWithButtons.vue +4 -5
  59. package/dist/spa/src/components/ColumnValueInputWrapper.vue +11 -3
  60. package/dist/spa/src/components/ListActionsThreeDots.vue +10 -9
  61. package/dist/spa/src/components/ResourceListTable.vue +291 -144
  62. package/dist/spa/src/components/Sidebar.vue +6 -2
  63. package/dist/spa/src/components/ThreeDotsMenu.vue +10 -9
  64. package/dist/spa/src/i18n.ts +1 -1
  65. package/dist/spa/src/renderers/CountryFlag.vue +2 -2
  66. package/dist/spa/src/stores/core.ts +4 -2
  67. package/dist/spa/src/types/Back.ts +24 -5
  68. package/dist/spa/src/types/Common.ts +45 -5
  69. package/dist/spa/src/types/FrontendAPI.ts +6 -1
  70. package/dist/spa/src/utils/listUtils.ts +8 -2
  71. package/dist/spa/src/utils/utils.ts +29 -10
  72. package/dist/spa/src/views/CreateView.vue +8 -8
  73. package/dist/spa/src/views/EditView.vue +8 -7
  74. package/dist/spa/src/views/ListView.vue +14 -48
  75. package/dist/spa/src/views/LoginView.vue +13 -13
  76. package/dist/spa/src/views/PageNotFound.vue +5 -1
  77. package/dist/spa/src/views/ShowView.vue +6 -6
  78. package/dist/types/Back.d.ts +23 -6
  79. package/dist/types/Back.d.ts.map +1 -1
  80. package/dist/types/Back.js.map +1 -1
  81. package/dist/types/Common.d.ts +25 -5
  82. package/dist/types/Common.d.ts.map +1 -1
  83. package/dist/types/Common.js.map +1 -1
  84. package/dist/types/FrontendAPI.d.ts +13 -1
  85. package/dist/types/FrontendAPI.d.ts.map +1 -1
  86. package/dist/types/FrontendAPI.js.map +1 -1
  87. package/package.json +2 -1
  88. package/dist/spa/src/components/ResourceListTableVirtual.vue +0 -794
@@ -1,5 +1,5 @@
1
1
  <template >
2
- <div class="relative" v-if="threeDotsDropdownItems?.length || customActions?.length || (bulkActions?.some((action: AdminForthBulkActionCommon) => action.showInThreeDotsDropdown))">
2
+ <div class="relative" v-if="threeDotsDropdownItems?.length || customActions?.length || (bulkActions?.some((action: AdminForthBulkActionFront) => action.showInThreeDotsDropdown))">
3
3
  <button
4
4
  ref="buttonTriggerRef"
5
5
  @click="toggleDropdownVisibility"
@@ -46,11 +46,12 @@
46
46
  <li v-for="action in customActions" :key="action.id">
47
47
  <div class="wrapper">
48
48
  <component
49
- :is="(action.customComponent && getCustomComponent(action.customComponent)) || CallActionWrapper"
50
- :meta="action.customComponent?.meta"
49
+ v-if="action.customComponent"
50
+ :is="(action.customComponent && getCustomComponent(formatComponent(action.customComponent))) || CallActionWrapper"
51
+ :meta="formatComponent(action.customComponent).meta"
51
52
  @callAction="(payload? : Object) => handleActionClick(action, payload)"
52
53
  >
53
- <a href="#" @click.prevent class="block px-4 py-2 hover:text-lightThreeDotsMenuBodyTextHover hover:bg-lightThreeDotsMenuBodyBackgroundHover dark:hover:bg-darkThreeDotsMenuBodyBackgroundHover dark:hover:text-darkThreeDotsMenuBodyTextHover">
54
+ <a @click.prevent class="block px-4 py-2 hover:text-lightThreeDotsMenuBodyTextHover hover:bg-lightThreeDotsMenuBodyBackgroundHover dark:hover:bg-darkThreeDotsMenuBodyBackgroundHover dark:hover:text-darkThreeDotsMenuBodyTextHover">
54
55
  <div class="flex items-center gap-2">
55
56
  <component
56
57
  v-if="action.icon"
@@ -64,7 +65,7 @@
64
65
  </div>
65
66
  </li>
66
67
  <li v-for="action in (bulkActions ?? []).filter(a => a.showInThreeDotsDropdown)" :key="action.id">
67
- <a href="#" @click.prevent="startBulkAction(action.id)"
68
+ <a @click.prevent="startBulkAction(action.id)"
68
69
  class="block px-4 py-2 hover:text-lightThreeDotsMenuBodyTextHover hover:bg-lightThreeDotsMenuBodyBackgroundHover dark:hover:bg-darkThreeDotsMenuBodyBackgroundHover dark:hover:text-darkThreeDotsMenuBodyTextHover"
69
70
  :class="{
70
71
  'pointer-events-none': checkboxes && checkboxes.length === 0,
@@ -88,14 +89,14 @@
88
89
 
89
90
 
90
91
  <script setup lang="ts">
91
- import { getCustomComponent, getIcon } from '@/utils';
92
+ import { getCustomComponent, getIcon, formatComponent } from '@/utils';
92
93
  import { useCoreStore } from '@/stores/core';
93
94
  import { useAdminforth } from '@/adminforth';
94
95
  import { callAdminForthApi } from '@/utils';
95
96
  import { useRoute, useRouter } from 'vue-router';
96
97
  import CallActionWrapper from '@/components/CallActionWrapper.vue'
97
98
  import { ref, type ComponentPublicInstance, onMounted, onUnmounted } from 'vue';
98
- import type { AdminForthBulkActionCommon, AdminForthComponentDeclarationFull } from '@/types/Common';
99
+ import type { AdminForthActionFront, AdminForthBulkActionFront, AdminForthComponentDeclarationFull } from '@/types/Common';
99
100
  import type { AdminForthActionInput } from '@/types/Back';
100
101
 
101
102
  const { list, alert} = useAdminforth();
@@ -109,8 +110,8 @@ const buttonTriggerRef = ref<HTMLElement | null>(null);
109
110
 
110
111
  const props = defineProps({
111
112
  threeDotsDropdownItems: Array<AdminForthComponentDeclarationFull>,
112
- customActions: Array<AdminForthActionInput>,
113
- bulkActions: Array<AdminForthBulkActionCommon>,
113
+ customActions: Array<AdminForthActionFront>,
114
+ bulkActions: Array<AdminForthBulkActionFront>,
114
115
  checkboxes: Array,
115
116
  updateList: {
116
117
  type: Function,
@@ -51,6 +51,6 @@ export function initI18n(app: ReturnType<typeof createApp>) {
51
51
  },
52
52
  });
53
53
  app.use(i18n);
54
- i18nInstance = i18n
54
+ i18nInstance = i18n as typeof i18nInstance
55
55
  return i18n
56
56
  }
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <Tooltip>
2
+ <component :is="shouldShowTooltip ? Tooltip : 'span'">
3
3
  <span class="flex items-center">
4
4
  <CountryFlag class="w-[1.6rem] h-[1.2rem]" :countryCode="countryIsoLow" />
5
5
  <span v-if="meta.showCountryName" class="ms-2">{{ countryName }}</span>
@@ -8,7 +8,7 @@
8
8
  <template v-if="shouldShowTooltip" #tooltip>
9
9
  {{ countryName }}
10
10
  </template>
11
- </Tooltip>
11
+ </component>
12
12
  </template>
13
13
 
14
14
  <script setup>
@@ -4,9 +4,11 @@ import { callAdminForthApi } from '@/utils';
4
4
  import websocket from '@/websocket';
5
5
  import { useAdminforth } from '@/adminforth';
6
6
 
7
- import type { AdminForthResourceCommon, AdminForthResourceColumnCommon, GetBaseConfigResponse, ResourceVeryShort, AdminUser, UserData, AdminForthConfigMenuItem, AdminForthConfigForFrontend } from '@/types/Common';
7
+ import type { AdminForthResourceCommon, AdminForthResourceColumnCommon, GetBaseConfigResponse, ResourceVeryShort, AdminUser, UserData, AdminForthConfigMenuItem, AdminForthConfigForFrontend, AdminForthResourceFrontend } from '@/types/Common';
8
8
  import type { Ref } from 'vue'
9
9
 
10
+
11
+
10
12
  export const useCoreStore = defineStore('core', () => {
11
13
  const { alert } = useAdminforth();
12
14
  const resourceById: Ref<Record<string, ResourceVeryShort>> = ref({});
@@ -15,7 +17,7 @@ export const useCoreStore = defineStore('core', () => {
15
17
  const menu: Ref<AdminForthConfigMenuItem[]> = ref([]);
16
18
  const config: Ref<AdminForthConfigForFrontend | null> = ref(null);
17
19
  const record: Ref<any | null> = ref({});
18
- const resource: Ref<AdminForthResourceCommon | null> = ref(null);
20
+ const resource: Ref<AdminForthResourceFrontend | null> = ref(null);
19
21
  const userData: Ref<UserData | null> = ref(null);
20
22
  const isResourceFetching = ref(false);
21
23
  const isInternetError = ref(false);
@@ -1,4 +1,4 @@
1
- import type { Express, Request } from 'express';
1
+ import type { Express, Request, Response } from 'express';
2
2
  import type { Writable } from 'stream';
3
3
 
4
4
  import { ActionCheckSource, AdminForthFilterOperators, AdminForthSortDirections, AllowedActionsEnum, AdminForthResourcePages,
@@ -67,6 +67,10 @@ export interface IHttpServer {
67
67
  headers: {[key: string]: string},
68
68
  cookies: {[key: string]: string},
69
69
  response: IAdminForthHttpResponse,
70
+ requestUrl: string,
71
+ abortSignal: AbortSignal,
72
+ _raw_express_req: Request,
73
+ _raw_express_res: Response,
70
74
  ) => void,
71
75
  }): void;
72
76
 
@@ -183,9 +187,23 @@ export interface IAdminForthDataSourceConnector {
183
187
  * For string fields:
184
188
  * - {@link AdminForthResourceColumn.maxLength}
185
189
  * For numbers:
190
+ * // min/max are used inside getMinMaxForColumns from base connector
186
191
  * - {@link AdminForthResourceColumn.min}
187
192
  * - {@link AdminForthResourceColumn.max}
188
- * - {@link AdminForthResourceColumn.minValue}, {@link AdminForthResourceColumn.maxValue}, {@link AdminForthResourceColumn.enum}, {@link AdminForthResourceColumn.foreignResource}, {@link AdminForthResourceColumn.sortable}, {@link AdminForthResourceColumn.backendOnly}, {@link AdminForthResourceColumn.masked}, {@link AdminForthResourceColumn.virtual}, {@link AdminForthResourceColumn.components}, {@link AdminForthResourceColumn.allowMinMaxQuery}, {@link AdminForthResourceColumn.editingNote}, {@link AdminForthResourceColumn.showIn}, {@link AdminForthResourceColumn.isUnique}, {@link AdminForthResourceColumn.validation})
193
+ * - {@link AdminForthResourceColumn.minValue},
194
+ * - {@link AdminForthResourceColumn.maxValue},
195
+ * - {@link AdminForthResourceColumn.enum},
196
+ * - {@link AdminForthResourceColumn.foreignResource},
197
+ * - {@link AdminForthResourceColumn.sortable},
198
+ * - {@link AdminForthResourceColumn.backendOnly},
199
+ * - {@link AdminForthResourceColumn.masked},
200
+ * - {@link AdminForthResourceColumn.virtual},
201
+ * - {@link AdminForthResourceColumn.components},
202
+ * - {@link AdminForthResourceColumn.allowMinMaxQuery},
203
+ * - {@link AdminForthResourceColumn.editingNote},
204
+ * - {@link AdminForthResourceColumn.showIn},
205
+ * - {@link AdminForthResourceColumn.isUnique},
206
+ * - {@link AdminForthResourceColumn.validation})
189
207
  * Also you can additionally save original column type to {@link AdminForthResourceColumn._underlineType}. This might be later used
190
208
  * in {@link IAdminForthDataSourceConnector.getFieldValue} and {@link IAdminForthDataSourceConnector.setFieldValue} methods.
191
209
  *
@@ -292,6 +310,8 @@ export interface IAdminForthDataSourceConnectorBase extends IAdminForthDataSourc
292
310
  }): Promise<{ok: boolean, error?: string}>;
293
311
 
294
312
  getMinMaxForColumns({ resource, columns }: { resource: AdminForthResource, columns: AdminForthResourceColumn[] }): Promise<{ [key: string]: { min: any, max: any } }>;
313
+
314
+ deleteMany?({resource, recordIds}:{resource: AdminForthResource, recordIds: any[]}): Promise<number>;
295
315
  }
296
316
 
297
317
 
@@ -1621,7 +1641,7 @@ export interface AdminForthConfigCustomization extends Omit<AdminForthInputConfi
1621
1641
 
1622
1642
  loginPageInjections: {
1623
1643
  underInputs: Array<AdminForthComponentDeclarationFull>,
1624
- underLoginButton?: AdminForthComponentDeclaration | Array<AdminForthComponentDeclaration>,
1644
+ underLoginButton: Array<AdminForthComponentDeclarationFull>,
1625
1645
  panelHeader: Array<AdminForthComponentDeclarationFull>,
1626
1646
  },
1627
1647
 
@@ -1809,9 +1829,8 @@ export type AllowedActions = {
1809
1829
  /**
1810
1830
  * General options for resource.
1811
1831
  */
1812
- export interface ResourceOptionsInput extends Omit<NonNullable<AdminForthResourceInputCommon['options']>, 'allowedActions' | 'bulkActions'> {
1832
+ export interface ResourceOptionsInput extends Omit<NonNullable<AdminForthResourceInputCommon['options']>, 'allowedActions' | 'bulkActions' | 'actions'> {
1813
1833
 
1814
- baseActionsAsQuickIcons?: ('show' | 'edit' | 'delete')[],
1815
1834
  /**
1816
1835
  * Custom bulk actions list. Bulk actions available in list view when user selects multiple records by
1817
1836
  * using checkboxes.
@@ -314,6 +314,25 @@ export type FieldGroup = {
314
314
  noTitle?: boolean;
315
315
  };
316
316
 
317
+ export interface AdminForthActionFront extends Omit<AdminForthActionInput, 'id'> {
318
+ id: string;
319
+ }
320
+
321
+ export interface AdminForthBulkActionFront extends Omit<AdminForthBulkActionCommon, 'id'> {
322
+ id: string,
323
+ }
324
+
325
+ type AdminforthOptionsCommon = NonNullable<AdminForthResourceCommon['options']>;
326
+
327
+ export interface AdminForthOptionsForFrontend extends Omit<AdminforthOptionsCommon, 'actions' | 'bulkActions'> {
328
+ actions?: AdminForthActionFront[],
329
+ bulkActions?: AdminForthBulkActionFront[],
330
+ }
331
+
332
+ export interface AdminForthResourceFrontend extends Omit<AdminForthResourceCommon, 'options'> {
333
+ options: AdminForthOptionsForFrontend;
334
+ }
335
+
317
336
  /**
318
337
  * Resource describes one table or collection in database.
319
338
  * AdminForth generates set of pages for 'list', 'show', 'edit', 'create', 'filter' operations for each resource.
@@ -361,16 +380,24 @@ export interface AdminForthResourceInputCommon {
361
380
  recordLabel?: (item: any) => string,
362
381
 
363
382
 
364
- /**
365
- * If true, user will not see warning about unsaved changes when tries to leave edit or create page with unsaved changes.
366
- * default is false
367
- */
368
- dontShowWarningAboutUnsavedChanges?: boolean,
369
383
 
370
384
  /**
371
385
  * General options for resource.
372
386
  */
373
387
  options?: {
388
+
389
+ /**
390
+ * If true, user will not see warning about unsaved changes when tries to leave edit or create page with unsaved changes.
391
+ * default is false
392
+ */
393
+ dontShowWarningAboutUnsavedChanges?: boolean,
394
+
395
+ /**
396
+ * Show quick action icons for base actions (show, edit, delete) in list view.
397
+ * By default, they are inside three dots dropdown menu.
398
+ */
399
+ baseActionsAsQuickIcons?: ('show' | 'edit' | 'delete')[],
400
+
374
401
 
375
402
  /**
376
403
  * Default sort for list view.
@@ -956,6 +983,18 @@ export interface AdminForthResourceColumnCommon extends AdminForthResourceColumn
956
983
 
957
984
  editingNote?: { create?: string, edit?: string },
958
985
 
986
+ /*
987
+ ______________________________________________
988
+ | |
989
+ | Min and max values are used |
990
+ | in getMinMaxForColumns from base connector |
991
+ |_____________________________________________|
992
+ |
993
+ |
994
+ |
995
+ |
996
+ V
997
+ */
959
998
  /**
960
999
  * Minimal value stored in this field.
961
1000
  */
@@ -1152,6 +1191,7 @@ export interface AdminForthConfigForFrontend {
1152
1191
  loginPageInjections: {
1153
1192
  underInputs: Array<AdminForthComponentDeclaration>,
1154
1193
  panelHeader: Array<AdminForthComponentDeclaration>,
1194
+ underLoginButton: Array<AdminForthComponentDeclaration>,
1155
1195
  },
1156
1196
  rememberMeDuration: string,
1157
1197
  showBrandNameInSidebar: boolean,
@@ -144,7 +144,7 @@ export interface FrontendAPIInterface {
144
144
  /**
145
145
  * Run save interceptors for a specific resource or all resources if no resourceId is provided
146
146
  */
147
- runSaveInterceptors(params: { action: 'create'|'edit'; values: any; resource: any; resourceId: string; }): Promise<{ ok: boolean; error?: string | null; extra?: object; }>;
147
+ runSaveInterceptors(params: { action: 'create'|'edit'; values: any; resource: any; resourceId: string; }): Promise<{ ok: boolean; error?: string | null; extra?: any; }>;
148
148
 
149
149
  /**
150
150
  * Clear save interceptors for a specific resource or all resources if no resourceId is provided
@@ -152,6 +152,11 @@ export interface FrontendAPIInterface {
152
152
  * @param resourceId - The resource ID to clear interceptors for
153
153
  */
154
154
  clearSaveInterceptors(resourceId?: string): void;
155
+
156
+ /**
157
+ * Register a save interceptor for a specific resource
158
+ */
159
+ registerSaveInterceptor(handler: (ctx: { action: 'create'|'edit'; values: any; resource: any; }) => Promise<{ ok: boolean; error?: string | null; extra?: any; }>): void;
155
160
  }
156
161
 
157
162
  export type ConfirmParams = {
@@ -4,13 +4,18 @@ import { type AdminForthResourceCommon } from '../types/Common';
4
4
  import { useAdminforth } from '@/adminforth';
5
5
  import { showErrorTost } from '@/composables/useFrontendApi'
6
6
 
7
-
7
+ let getResourceDataLastAbortController: AbortController | null = null;
8
8
  export async function getList(resource: AdminForthResourceCommon, isPageLoaded: boolean, page: number | null , pageSize: number, sort: any, checkboxes:{ value: any[] }, filters: any = [] ) {
9
9
  let rows: any[] = [];
10
10
  let totalRows: number | null = null;
11
11
  if (!isPageLoaded) {
12
12
  return;
13
13
  }
14
+ const abortController = new AbortController();
15
+ if (getResourceDataLastAbortController) {
16
+ getResourceDataLastAbortController.abort();
17
+ }
18
+ getResourceDataLastAbortController = abortController;
14
19
  const data = await callAdminForthApi({
15
20
  path: '/get_resource_data',
16
21
  method: 'POST',
@@ -21,7 +26,8 @@ export async function getList(resource: AdminForthResourceCommon, isPageLoaded:
21
26
  offset: ((page || 1) - 1) * pageSize,
22
27
  filters: filters,
23
28
  sort: sort,
24
- }
29
+ },
30
+ abortSignal: abortController.signal
25
31
  });
26
32
  if (data.error) {
27
33
  showErrorTost(data.error);
@@ -1,6 +1,6 @@
1
1
  import { nextTick, onMounted, ref, resolveComponent } from 'vue';
2
2
  import type { CoreConfig } from '../spa_types/core';
3
- import type { ValidationObject } from '../types/Common.js';
3
+ import type { AdminForthComponentDeclaration, AdminForthComponentDeclarationFull, ValidationObject } from '../types/Common.js';
4
4
  import router from "../router";
5
5
  import { useCoreStore } from '../stores/core';
6
6
  import { useUserStore } from '../stores/user';
@@ -19,11 +19,12 @@ const LS_LANG_KEY = `afLanguage`;
19
19
  const MAX_CONSECUTIVE_EMPTY_RESULTS = 2;
20
20
  const ITEMS_PER_PAGE_LIMIT = 100;
21
21
 
22
- export async function callApi({path, method, body, headers, silentError = false}: {
22
+ export async function callApi({path, method, body, headers, silentError = false, abortSignal}: {
23
23
  path: string, method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH'
24
24
  body?: any
25
25
  headers?: Record<string, string>
26
26
  silentError?: boolean
27
+ abortSignal?: AbortSignal
27
28
  }): Promise<any> {
28
29
  const t = i18nInstance?.global.t || ((s: string) => s)
29
30
  const options = {
@@ -34,6 +35,7 @@ export async function callApi({path, method, body, headers, silentError = false}
34
35
  ...headers
35
36
  },
36
37
  body: JSON.stringify(body),
38
+ signal: abortSignal
37
39
  };
38
40
  const fullPath = `${import.meta.env.VITE_ADMINFORTH_PUBLIC_PATH || ''}${path}`;
39
41
  try {
@@ -68,28 +70,45 @@ export async function callApi({path, method, body, headers, silentError = false}
68
70
  return null;
69
71
  }
70
72
 
71
- if (!silentError) {
73
+ if (!silentError && !(e instanceof DOMException && e.name === 'AbortError')) {
72
74
  adminforth.alert({variant:'danger', message: t('Something went wrong, please try again later'),})
73
75
  }
74
76
  console.error(`error in callApi ${path}`, e);
75
77
  }
76
78
  }
77
79
 
78
- export async function callAdminForthApi({ path, method, body=undefined, headers=undefined, silentError = false }: {
79
- path: string,
80
- method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH',
81
- body?: any,
82
- headers?: Record<string, string>,
83
- silentError?: boolean
80
+ export async function callAdminForthApi(
81
+ {
82
+ path,
83
+ method,
84
+ body=undefined,
85
+ headers=undefined,
86
+ silentError = false,
87
+ abortSignal = undefined
88
+ }: {
89
+ path: string,
90
+ method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH',
91
+ body?: any,
92
+ headers?: Record<string, string>,
93
+ silentError?: boolean,
94
+ abortSignal?: AbortSignal
84
95
  }): Promise<any> {
85
96
  try {
86
- return callApi({path: `/adminapi/v1${path}`, method, body, headers, silentError} );
97
+ return callApi({path: `/adminapi/v1${path}`, method, body, headers, silentError, abortSignal} );
87
98
  } catch (e) {
88
99
  console.error('error', e);
89
100
  return { error: `Unexpected error: ${e}` };
90
101
  }
91
102
  }
92
103
 
104
+ export function formatComponent(component: AdminForthComponentDeclaration): AdminForthComponentDeclarationFull {
105
+ if (typeof component === 'string') {
106
+ return { file: component, meta: {} };
107
+ } else {
108
+ return { file: component.file, meta: component.meta };
109
+ }
110
+ }
111
+
93
112
  export function getCustomComponent({ file, meta }: { file: string, meta?: any }) {
94
113
  const name = file.replace(/@/g, '').replace(/\./g, '').replace(/\//g, '');
95
114
  return resolveComponent(name);
@@ -2,8 +2,8 @@
2
2
  <div class="relative w-full">
3
3
 
4
4
  <component
5
- v-for="c in coreStore?.resourceOptions?.pageInjections?.create?.beforeBreadcrumbs || []"
6
- :is="getCustomComponent(c)"
5
+ v-for="c in coreStore?.resourceOptions?.pageInjections?.create?.beforeBreadcrumbs as AdminForthComponentDeclaration[] || []"
6
+ :is="getCustomComponent(formatComponent(c))"
7
7
  :meta="(c as AdminForthComponentDeclarationFull).meta"
8
8
  :record="coreStore.record"
9
9
  :resource="coreStore.resource"
@@ -36,8 +36,8 @@
36
36
  </BreadcrumbsWithButtons>
37
37
 
38
38
  <component
39
- v-for="c in coreStore?.resourceOptions?.pageInjections?.create?.afterBreadcrumbs || []"
40
- :is="getCustomComponent(c)"
39
+ v-for="c in coreStore?.resourceOptions?.pageInjections?.create?.afterBreadcrumbs as AdminForthComponentDeclaration[] || []"
40
+ :is="getCustomComponent(formatComponent(c))"
41
41
  :meta="(c as AdminForthComponentDeclarationFull).meta"
42
42
  :record="coreStore.record"
43
43
  :resource="coreStore.resource"
@@ -61,8 +61,8 @@
61
61
  </ResourceForm>
62
62
 
63
63
  <component
64
- v-for="c in coreStore?.resourceOptions?.pageInjections?.create?.bottom || []"
65
- :is="getCustomComponent(c)"
64
+ v-for="c in coreStore?.resourceOptions?.pageInjections?.create?.bottom as AdminForthComponentDeclaration[] || []"
65
+ :is="getCustomComponent(formatComponent(c))"
66
66
  :meta="(c as AdminForthComponentDeclarationFull).meta"
67
67
  :record="coreStore.record"
68
68
  :resource="coreStore.resource"
@@ -79,7 +79,7 @@ import BreadcrumbsWithButtons from '@/components/BreadcrumbsWithButtons.vue';
79
79
  import ResourceForm from '@/components/ResourceForm.vue';
80
80
  import SingleSkeletLoader from '@/components/SingleSkeletLoader.vue';
81
81
  import { useCoreStore } from '@/stores/core';
82
- import { callAdminForthApi, getCustomComponent,checkAcessByAllowedActions, initThreeDotsDropdown, checkShowIf, compareOldAndNewRecord, onBeforeRouteLeaveCreateEditViewGuard, leaveGuardActiveClass, onBeforeRouteLeaveCreateEditView } from '@/utils';
82
+ import { callAdminForthApi, getCustomComponent,checkAcessByAllowedActions, initThreeDotsDropdown, checkShowIf, compareOldAndNewRecord, onBeforeRouteLeaveCreateEditViewGuard, leaveGuardActiveClass, formatComponent } from '@/utils';
83
83
  import { IconFloppyDiskSolid } from '@iconify-prerendered/vue-flowbite';
84
84
  import { onMounted, onBeforeMount, onBeforeUnmount, ref, watch, nextTick } from 'vue';
85
85
  import { useRoute, useRouter, onBeforeRouteLeave } from 'vue-router';
@@ -88,7 +88,7 @@ import { showErrorTost } from '@/composables/useFrontendApi';
88
88
  import ThreeDotsMenu from '@/components/ThreeDotsMenu.vue';
89
89
  import { useAdminforth } from '@/adminforth';
90
90
  import { useI18n } from 'vue-i18n';
91
- import { type AdminForthComponentDeclarationFull } from '@/types/Common.js';
91
+ import { type AdminForthComponentDeclaration, type AdminForthComponentDeclarationFull } from '@/types/Common.js';
92
92
  import type { AdminForthResourceColumn } from '@/types/Back';
93
93
 
94
94
  const isValid = ref(false);
@@ -1,8 +1,8 @@
1
1
  <template>
2
2
  <div class="relative w-full">
3
3
  <component
4
- v-for="c in coreStore?.resourceOptions?.pageInjections?.edit?.beforeBreadcrumbs || []"
5
- :is="getCustomComponent(c)"
4
+ v-for="c in coreStore?.resourceOptions?.pageInjections?.edit?.beforeBreadcrumbs as AdminForthComponentDeclaration[] || []"
5
+ :is="getCustomComponent(formatComponent(c))"
6
6
  :meta="(c as AdminForthComponentDeclarationFull).meta"
7
7
  :record="editableRecord"
8
8
  :resource="coreStore.resource"
@@ -32,8 +32,8 @@
32
32
  </BreadcrumbsWithButtons>
33
33
 
34
34
  <component
35
- v-for="c in coreStore?.resourceOptions?.pageInjections?.edit?.afterBreadcrumbs || []"
36
- :is="getCustomComponent(c)"
35
+ v-for="c in coreStore?.resourceOptions?.pageInjections?.edit?.afterBreadcrumbs as AdminForthComponentDeclaration[] || []"
36
+ :is="getCustomComponent(formatComponent(c))"
37
37
  :meta="(c as AdminForthComponentDeclarationFull).meta"
38
38
  :record="coreStore.record"
39
39
  :resource="coreStore.resource"
@@ -56,8 +56,8 @@
56
56
  </ResourceForm>
57
57
 
58
58
  <component
59
- v-for="c in coreStore?.resourceOptions?.pageInjections?.edit?.bottom || []"
60
- :is="getCustomComponent(c)"
59
+ v-for="c in coreStore?.resourceOptions?.pageInjections?.edit?.bottom as AdminForthComponentDeclaration[] || []"
60
+ :is="getCustomComponent(formatComponent(c))"
61
61
  :meta="(c as AdminForthComponentDeclarationFull).meta"
62
62
  :record="coreStore.record"
63
63
  :resource="coreStore.resource"
@@ -82,7 +82,8 @@ import { showErrorTost } from '@/composables/useFrontendApi';
82
82
  import ThreeDotsMenu from '@/components/ThreeDotsMenu.vue';
83
83
  import { useAdminforth } from '@/adminforth';
84
84
  import { useI18n } from 'vue-i18n';
85
- import { type AdminForthComponentDeclarationFull } from '@/types/Common.js';
85
+ import { formatComponent } from '@/utils';
86
+ import { type AdminForthComponentDeclaration, type AdminForthComponentDeclarationFull } from '@/types/Common.js';
86
87
  import type { AdminForthResourceColumn } from '@/types/Back';
87
88
 
88
89
  const { t } = useI18n();
@@ -11,8 +11,8 @@
11
11
 
12
12
  <component
13
13
  v-if="!coreStore.isResourceFetching && !initInProcess"
14
- v-for="c in coreStore?.resourceOptions?.pageInjections?.list?.beforeBreadcrumbs || []"
15
- :is="getCustomComponent(c)"
14
+ v-for="c in coreStore?.resourceOptions?.pageInjections?.list?.beforeBreadcrumbs as AdminForthComponentDeclaration[] || []"
15
+ :is="getCustomComponent(formatComponent(c))"
16
16
  :meta="(c as AdminForthComponentDeclarationFull).meta"
17
17
  :resource="coreStore.resource"
18
18
  :adminUser="coreStore.adminUser"
@@ -21,8 +21,8 @@
21
21
  <BreadcrumbsWithButtons>
22
22
  <component
23
23
  v-if="!coreStore.isResourceFetching && !initInProcess"
24
- v-for="c in coreStore?.resourceOptions?.pageInjections?.list?.beforeActionButtons || []"
25
- :is="getCustomComponent(c)"
24
+ v-for="c in coreStore?.resourceOptions?.pageInjections?.list?.beforeActionButtons as AdminForthComponentDeclaration[] || []"
25
+ :is="getCustomComponent(formatComponent(c))"
26
26
  :meta="(c as AdminForthComponentDeclarationFull).meta"
27
27
  :resource="coreStore.resource"
28
28
  :adminUser="coreStore.adminUser"
@@ -114,14 +114,14 @@
114
114
 
115
115
  <component
116
116
  v-if="!coreStore.isResourceFetching && !initInProcess"
117
- v-for="c in coreStore?.resourceOptions?.pageInjections?.list?.afterBreadcrumbs || []"
118
- :is="getCustomComponent(c)"
117
+ v-for="c in coreStore?.resourceOptions?.pageInjections?.list?.afterBreadcrumbs as AdminForthComponentDeclaration[] || []"
118
+ :is="getCustomComponent(formatComponent(c))"
119
119
  :meta="(c as AdminForthComponentDeclarationFull).meta"
120
120
  :resource="coreStore.resource"
121
121
  :adminUser="coreStore.adminUser"
122
122
  />
123
- <ResourceListTableVirtual
124
- v-if="isVirtualScrollEnabled && !coreStore.isResourceFetching"
123
+ <ResourceListTable
124
+ v-if="!coreStore.isResourceFetching"
125
125
  :resource="coreStore.resource"
126
126
  :rows="rows"
127
127
  :page="page"
@@ -153,49 +153,16 @@
153
153
  :tableRowReplaceInjection="Array.isArray(coreStore.resourceOptions?.pageInjections?.list?.tableRowReplace)
154
154
  ? coreStore.resourceOptions.pageInjections.list.tableRowReplace[0]
155
155
  : coreStore.resourceOptions?.pageInjections?.list?.tableRowReplace || undefined"
156
+
156
157
  :container-height="1100"
157
158
  :item-height="52.5"
158
159
  :buffer-size="listBufferSize"
159
- />
160
-
161
- <ResourceListTable
162
- v-else-if="!coreStore.isResourceFetching"
163
- :resource="coreStore.resource"
164
- :rows="rows"
165
- :page="page"
166
- @update:page="page = $event"
167
- @update:sort="sort = $event"
168
- @update:checkboxes="checkboxes = $event"
169
- @update:records="getListInner"
170
- :sort="sort"
171
- :pageSize="pageSize"
172
- :totalRows="totalRows"
173
- :checkboxes="checkboxes"
174
- :customActionsInjection="Array.isArray(coreStore.resourceOptions?.pageInjections?.list?.customActionIcons)
175
- ? coreStore.resourceOptions.pageInjections.list.customActionIcons
176
- : coreStore.resourceOptions?.pageInjections?.list?.customActionIcons
177
- ? [coreStore.resourceOptions.pageInjections.list.customActionIcons]
178
- : []
179
- "
180
- :tableBodyStartInjection="Array.isArray(coreStore.resourceOptions?.pageInjections?.list?.tableBodyStart)
181
- ? coreStore.resourceOptions.pageInjections.list.tableBodyStart
182
- : coreStore.resourceOptions?.pageInjections?.list?.tableBodyStart
183
- ? [coreStore.resourceOptions.pageInjections.list.tableBodyStart]
184
- : []
185
- "
186
- :customActionIconsThreeDotsMenuItems="Array.isArray(coreStore.resourceOptions?.pageInjections?.list?.customActionIconsThreeDotsMenuItems)
187
- ? coreStore.resourceOptions.pageInjections.list.customActionIconsThreeDotsMenuItems
188
- : coreStore.resourceOptions?.pageInjections?.list?.customActionIconsThreeDotsMenuItems
189
- ? [coreStore.resourceOptions.pageInjections.list.customActionIconsThreeDotsMenuItems]
190
- : []"
191
- :tableRowReplaceInjection="Array.isArray(coreStore.resourceOptions?.pageInjections?.list?.tableRowReplace)
192
- ? coreStore.resourceOptions.pageInjections.list.tableRowReplace[0]
193
- : coreStore.resourceOptions?.pageInjections?.list?.tableRowReplace || undefined"
160
+ :isVirtualScrollEnabled="isVirtualScrollEnabled"
194
161
  />
195
162
 
196
163
  <component
197
- v-for="c in coreStore?.resourceOptions?.pageInjections?.list?.bottom || []"
198
- :is="getCustomComponent(c)"
164
+ v-for="c in coreStore?.resourceOptions?.pageInjections?.list?.bottom as AdminForthComponentDeclaration[] || []"
165
+ :is="getCustomComponent(formatComponent(c))"
199
166
  :meta="(c as AdminForthComponentDeclarationFull).meta"
200
167
  :resource="coreStore.resource"
201
168
  :adminUser="coreStore.adminUser"
@@ -206,17 +173,16 @@
206
173
 
207
174
  <script setup lang="ts">
208
175
  import BreadcrumbsWithButtons from '@/components/BreadcrumbsWithButtons.vue';
209
- import ResourceListTableVirtual from '@/components/ResourceListTableVirtual.vue';
210
176
  import ResourceListTable from '@/components/ResourceListTable.vue';
211
177
  import { useCoreStore } from '@/stores/core';
212
178
  import { useFiltersStore } from '@/stores/filters';
213
- import { callAdminForthApi, currentQuery, getIcon, setQuery } from '@/utils';
179
+ import { callAdminForthApi, currentQuery, getIcon, setQuery, formatComponent } from '@/utils';
214
180
  import { computed, onMounted, onUnmounted, ref, watch, type Ref } from 'vue';
215
181
  import { useRoute } from 'vue-router';
216
182
  import { getCustomComponent, initThreeDotsDropdown, getList, startBulkAction } from '@/utils';
217
183
  import ThreeDotsMenu from '@/components/ThreeDotsMenu.vue';
218
184
  import { Tooltip } from '@/afcl'
219
- import type { AdminForthComponentDeclarationFull } from '@/types/Common';
185
+ import type { AdminForthComponentDeclaration, AdminForthComponentDeclarationFull } from '@/types/Common';
220
186
 
221
187
 
222
188
  import {