adminforth 2.27.0-next.3 → 2.27.0-next.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/commands/callTsProxy.js +10 -5
- package/commands/proxy.ts +18 -10
- package/dist/commands/proxy.js +14 -10
- package/dist/commands/proxy.js.map +1 -1
- package/dist/modules/configValidator.d.ts.map +1 -1
- package/dist/modules/configValidator.js +16 -9
- package/dist/modules/configValidator.js.map +1 -1
- package/dist/modules/restApi.d.ts.map +1 -1
- package/dist/modules/restApi.js +77 -4
- package/dist/modules/restApi.js.map +1 -1
- package/dist/modules/styles.js +1 -1
- package/dist/servers/express.d.ts.map +1 -1
- package/dist/servers/express.js +4 -0
- package/dist/servers/express.js.map +1 -1
- package/dist/spa/package-lock.json +41 -0
- package/dist/spa/package.json +3 -0
- package/dist/spa/pnpm-lock.yaml +38 -0
- package/dist/spa/src/App.vue +77 -76
- package/dist/spa/src/afcl/Button.vue +2 -3
- package/dist/spa/src/afcl/Dialog.vue +1 -1
- package/dist/spa/src/afcl/Input.vue +1 -1
- package/dist/spa/src/afcl/Select.vue +8 -2
- package/dist/spa/src/afcl/Spinner.vue +1 -1
- package/dist/spa/src/components/CallActionWrapper.vue +1 -1
- package/dist/spa/src/components/ColumnValueInput.vue +16 -3
- package/dist/spa/src/components/ColumnValueInputWrapper.vue +25 -2
- package/dist/spa/src/components/CustomRangePicker.vue +16 -14
- package/dist/spa/src/components/Filters.vue +95 -63
- package/dist/spa/src/components/GroupsTable.vue +9 -6
- package/dist/spa/src/components/MenuLink.vue +2 -2
- package/dist/spa/src/components/ResourceForm.vue +100 -6
- package/dist/spa/src/components/ResourceListTable.vue +13 -7
- package/dist/spa/src/components/ShowTable.vue +1 -1
- package/dist/spa/src/components/Sidebar.vue +2 -2
- package/dist/spa/src/components/ThreeDotsMenu.vue +19 -9
- package/dist/spa/src/spa_types/core.ts +32 -0
- package/dist/spa/src/stores/filters.ts +16 -12
- package/dist/spa/src/types/Back.ts +20 -4
- package/dist/spa/src/types/Common.ts +24 -5
- package/dist/spa/src/types/adapters/StorageAdapter.ts +12 -0
- package/dist/spa/src/utils/createEditUtils.ts +65 -0
- package/dist/spa/src/utils/index.ts +2 -1
- package/dist/spa/src/utils/utils.ts +44 -9
- package/dist/spa/src/utils.ts +2 -1
- package/dist/spa/src/views/CreateView.vue +22 -49
- package/dist/spa/src/views/EditView.vue +20 -38
- package/dist/spa/src/views/ListView.vue +22 -32
- package/dist/spa/src/views/ShowView.vue +67 -12
- package/dist/types/Back.d.ts +20 -15
- package/dist/types/Back.d.ts.map +1 -1
- package/dist/types/Back.js.map +1 -1
- package/dist/types/Common.d.ts +31 -5
- package/dist/types/Common.d.ts.map +1 -1
- package/dist/types/Common.js.map +1 -1
- package/dist/types/adapters/StorageAdapter.d.ts +11 -0
- package/dist/types/adapters/StorageAdapter.d.ts.map +1 -1
- package/package.json +5 -3
|
@@ -20,11 +20,9 @@
|
|
|
20
20
|
<button
|
|
21
21
|
@click="() => saveRecord()"
|
|
22
22
|
class="af-save-button h-[34px] af-button-shadow flex items-center py-1 px-3 text-sm font-medium rounded-default text-lightCreateViewSaveButtonText focus:outline-none bg-lightCreateViewButtonBackground rounded border border-lightCreateViewButtonBorder hover:bg-lightCreateViewButtonBackgroundHover hover:text-lightCreateViewSaveButtonTextHover focus:z-10 focus:ring-4 focus:ring-lightCreateViewButtonFocusRing dark:focus:ring-darkCreateViewButtonFocusRing dark:bg-darkCreateViewButtonBackground dark:text-darkCreateViewSaveButtonText dark:border-darkCreateViewButtonBorder dark:hover:text-darkCreateViewSaveButtonTextHover dark:hover:bg-darkCreateViewButtonBackgroundHover disabled:opacity-50 gap-1"
|
|
23
|
-
:disabled="saving || (
|
|
23
|
+
:disabled="saving || (validatingMode && !isValid) || resourceFormRef?.isValidating"
|
|
24
24
|
>
|
|
25
|
-
<
|
|
26
|
-
aria-hidden="true" class="w-4 h-4 mr-1 text-gray-200 animate-spin dark:text-gray-600 fill-lightCreateViewSaveButtonText" 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
|
-
|
|
25
|
+
<Spinner v-if="saving || resourceFormRef?.isValidating" class="w-4 h-4" />
|
|
28
26
|
<IconFloppyDiskSolid v-else class="w-4 h-4" />
|
|
29
27
|
{{ $t('Save') }}
|
|
30
28
|
</button>
|
|
@@ -54,7 +52,7 @@
|
|
|
54
52
|
:resource="coreStore.resource!"
|
|
55
53
|
@update:record="onUpdateRecord"
|
|
56
54
|
@update:isValid="isValid = $event"
|
|
57
|
-
:
|
|
55
|
+
:validatingMode="validatingMode"
|
|
58
56
|
:source="'create'"
|
|
59
57
|
:readonlyColumns="readonlyColumns"
|
|
60
58
|
>
|
|
@@ -81,18 +79,18 @@ import SingleSkeletLoader from '@/components/SingleSkeletLoader.vue';
|
|
|
81
79
|
import { useCoreStore } from '@/stores/core';
|
|
82
80
|
import { callAdminForthApi, getCustomComponent,checkAcessByAllowedActions, initThreeDotsDropdown, checkShowIf, compareOldAndNewRecord, onBeforeRouteLeaveCreateEditViewGuard, leaveGuardActiveClass, formatComponent } from '@/utils';
|
|
83
81
|
import { IconFloppyDiskSolid } from '@iconify-prerendered/vue-flowbite';
|
|
84
|
-
import { onMounted, onBeforeMount, onBeforeUnmount, ref
|
|
85
|
-
import { useRoute, useRouter
|
|
86
|
-
import { computed } from 'vue';
|
|
82
|
+
import { onMounted, onBeforeMount, onBeforeUnmount, ref } from 'vue';
|
|
83
|
+
import { useRoute, useRouter } from 'vue-router';
|
|
87
84
|
import { showErrorTost } from '@/composables/useFrontendApi';
|
|
88
85
|
import ThreeDotsMenu from '@/components/ThreeDotsMenu.vue';
|
|
89
86
|
import { useAdminforth } from '@/adminforth';
|
|
90
87
|
import { useI18n } from 'vue-i18n';
|
|
91
88
|
import { type AdminForthComponentDeclaration, type AdminForthComponentDeclarationFull } from '@/types/Common.js';
|
|
92
|
-
import
|
|
89
|
+
import { saveRecordPreparations } from '@/utils';
|
|
90
|
+
import { Spinner } from '@/afcl'
|
|
93
91
|
|
|
94
92
|
const isValid = ref(false);
|
|
95
|
-
const
|
|
93
|
+
const validatingMode = ref(false);
|
|
96
94
|
|
|
97
95
|
const loading = ref(true);
|
|
98
96
|
const saving = ref(false);
|
|
@@ -195,28 +193,22 @@ onMounted(async () => {
|
|
|
195
193
|
});
|
|
196
194
|
|
|
197
195
|
async function saveRecord() {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
196
|
+
const interceptorsResult = await saveRecordPreparations(
|
|
197
|
+
'create',
|
|
198
|
+
validatingMode,
|
|
199
|
+
resourceFormRef,
|
|
200
|
+
isValid,
|
|
201
|
+
t,
|
|
202
|
+
saving,
|
|
203
|
+
runSaveInterceptors,
|
|
204
|
+
record,
|
|
205
|
+
coreStore,
|
|
206
|
+
route
|
|
207
|
+
);
|
|
208
|
+
|
|
206
209
|
const requiredColumns = coreStore.resource?.columns.filter(c => c.required?.create === true) || [];
|
|
207
210
|
const requiredColumnsToSkip = requiredColumns.filter(c => checkShowIf(c, record.value, coreStore.resource?.columns || []) === false);
|
|
208
|
-
|
|
209
|
-
const interceptorsResult = await runSaveInterceptors({
|
|
210
|
-
action: 'create',
|
|
211
|
-
values: record.value,
|
|
212
|
-
resource: coreStore.resource,
|
|
213
|
-
resourceId: route.params.resourceId as string,
|
|
214
|
-
});
|
|
215
|
-
if (!interceptorsResult.ok) {
|
|
216
|
-
saving.value = false;
|
|
217
|
-
if (interceptorsResult.error) showErrorTost(interceptorsResult.error);
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
211
|
+
|
|
220
212
|
const interceptorConfirmationResult = (interceptorsResult.extra as Record<string, any>)?.confirmationResult;
|
|
221
213
|
const response = await callAdminForthApi({
|
|
222
214
|
method: 'POST',
|
|
@@ -254,23 +246,4 @@ async function saveRecord() {
|
|
|
254
246
|
saving.value = false;
|
|
255
247
|
}
|
|
256
248
|
|
|
257
|
-
function scrollToInvalidField() {
|
|
258
|
-
let columnsWithErrors: {column: AdminForthResourceColumn, error: string}[] = [];
|
|
259
|
-
for (const column of resourceFormRef.value?.editableColumns || []) {
|
|
260
|
-
const error = resourceFormRef.value?.columnError(column);
|
|
261
|
-
if (error) {
|
|
262
|
-
columnsWithErrors.push({column, error});
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
const errorMessage = t('Failed to save. Please fix errors for the following fields:') + '<ul class="mt-2 list-disc list-inside">' + columnsWithErrors.map(c => `<li><strong>${c.column.label || c.column.name}</strong>: ${c.error}</li>`).join('') + '</ul>';
|
|
266
|
-
alert({
|
|
267
|
-
messageHtml: errorMessage,
|
|
268
|
-
variant: 'danger'
|
|
269
|
-
});
|
|
270
|
-
const firstInvalidElement = document.querySelector('.af-invalid-field-message');
|
|
271
|
-
if (firstInvalidElement) {
|
|
272
|
-
firstInvalidElement.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
|
|
276
249
|
</script>
|
|
@@ -19,9 +19,10 @@
|
|
|
19
19
|
<button
|
|
20
20
|
@click="() => saveRecord()"
|
|
21
21
|
class="flex items-center h-[34px] af-button-shadow py-1 px-3 text-sm font-medium rounded-default text-lightEditViewSaveButtonText focus:outline-none bg-lightEditViewButtonBackground rounded border border-lightEditViewButtonBorder hover:bg-lightEditViewButtonBackgroundHover hover:text-lightEditViewSaveButtonTextHover focus:z-10 focus:ring-4 focus:ring-lightEditViewButtonFocusRing dark:focus:ring-darkEditViewButtonFocusRing dark:bg-darkEditViewButtonBackground dark:text-darkEditViewSaveButtonText dark:border-darkEditViewButtonBorder dark:hover:text-darkEditViewSaveButtonTextHover dark:hover:bg-darkEditViewButtonBackgroundHover disabled:opacity-50 gap-1"
|
|
22
|
-
:disabled="saving || (
|
|
22
|
+
:disabled="saving || (validatingMode && !isValid) || resourceFormRef?.isValidating"
|
|
23
23
|
>
|
|
24
|
-
<
|
|
24
|
+
<Spinner v-if="saving || resourceFormRef?.isValidating" class="w-4 h-4" />
|
|
25
|
+
<IconFloppyDiskSolid v-else class="w-4 h-4" />
|
|
25
26
|
{{ $t('Save') }}
|
|
26
27
|
</button>
|
|
27
28
|
|
|
@@ -50,7 +51,7 @@
|
|
|
50
51
|
:adminUser="coreStore.adminUser"
|
|
51
52
|
@update:record="onUpdateRecord"
|
|
52
53
|
@update:isValid="isValid = $event"
|
|
53
|
-
:
|
|
54
|
+
:validatingMode="validatingMode"
|
|
54
55
|
:source="'edit'"
|
|
55
56
|
>
|
|
56
57
|
</ResourceForm>
|
|
@@ -85,13 +86,15 @@ import { useI18n } from 'vue-i18n';
|
|
|
85
86
|
import { formatComponent } from '@/utils';
|
|
86
87
|
import { type AdminForthComponentDeclaration, type AdminForthComponentDeclarationFull } from '@/types/Common.js';
|
|
87
88
|
import type { AdminForthResourceColumn } from '@/types/Back';
|
|
89
|
+
import { scrollToInvalidField, saveRecordPreparations } from '@/utils';
|
|
90
|
+
import { Spinner } from '@/afcl'
|
|
88
91
|
|
|
89
92
|
const { t } = useI18n();
|
|
90
93
|
const coreStore = useCoreStore();
|
|
91
94
|
const { clearSaveInterceptors, runSaveInterceptors, alert, confirm } = useAdminforth();
|
|
92
95
|
|
|
93
96
|
const isValid = ref(false);
|
|
94
|
-
const
|
|
97
|
+
const validatingMode = ref(false);
|
|
95
98
|
|
|
96
99
|
const route = useRoute();
|
|
97
100
|
const router = useRouter();
|
|
@@ -180,22 +183,20 @@ onMounted(async () => {
|
|
|
180
183
|
});
|
|
181
184
|
|
|
182
185
|
async function saveRecord() {
|
|
183
|
-
if (!isValid.value) {
|
|
184
|
-
validating.value = true;
|
|
185
|
-
await nextTick();
|
|
186
|
-
scrollToInvalidField();
|
|
187
|
-
return;
|
|
188
|
-
} else {
|
|
189
|
-
validating.value = false;
|
|
190
|
-
}
|
|
191
186
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
187
|
+
const interceptorsResult = await saveRecordPreparations(
|
|
188
|
+
'edit',
|
|
189
|
+
validatingMode,
|
|
190
|
+
resourceFormRef,
|
|
191
|
+
isValid,
|
|
192
|
+
t,
|
|
193
|
+
saving,
|
|
194
|
+
runSaveInterceptors,
|
|
195
|
+
record,
|
|
196
|
+
coreStore,
|
|
197
|
+
route
|
|
198
|
+
);
|
|
199
|
+
|
|
199
200
|
if (!interceptorsResult.ok) {
|
|
200
201
|
saving.value = false;
|
|
201
202
|
if (interceptorsResult.error) showErrorTost(interceptorsResult.error);
|
|
@@ -256,23 +257,4 @@ async function saveRecord() {
|
|
|
256
257
|
saving.value = false;
|
|
257
258
|
}
|
|
258
259
|
|
|
259
|
-
function scrollToInvalidField() {
|
|
260
|
-
let columnsWithErrors: {column: AdminForthResourceColumn, error: string}[] = [];
|
|
261
|
-
for (const column of resourceFormRef.value?.editableColumns || []) {
|
|
262
|
-
const error = resourceFormRef.value?.columnError(column);
|
|
263
|
-
if (error) {
|
|
264
|
-
columnsWithErrors.push({column, error});
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
const errorMessage = t('Failed to save. Please fix errors for the following fields:') + '<ul class="mt-2 list-disc list-inside">' + columnsWithErrors.map(c => `<li><strong>${c.column.label || c.column.name}</strong>: ${c.error}</li>`).join('') + '</ul>';
|
|
268
|
-
alert({
|
|
269
|
-
messageHtml: errorMessage,
|
|
270
|
-
variant: 'danger'
|
|
271
|
-
});
|
|
272
|
-
const firstInvalidElement = document.querySelector('.af-invalid-field-message');
|
|
273
|
-
if (firstInvalidElement) {
|
|
274
|
-
firstInvalidElement.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
|
|
278
260
|
</script>
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
<div class="relative flex flex-col max-w-full w-full">
|
|
3
3
|
<Teleport to="body">
|
|
4
4
|
<Filters
|
|
5
|
-
:columns="coreStore.resource?.columns"
|
|
5
|
+
:columns="coreStore.resource?.columns as AdminForthResourceColumnCommon[] || []"
|
|
6
6
|
:columnsMinMax="columnsMinMax"
|
|
7
7
|
:show="filtersShow"
|
|
8
8
|
@hide="filtersShow = false"
|
|
9
|
+
:filtersStore="filtersStore"
|
|
9
10
|
/>
|
|
10
11
|
</Teleport>
|
|
11
12
|
|
|
@@ -69,19 +70,10 @@
|
|
|
69
70
|
v-if="action.icon && !bulkActionLoadingStates[action.id!]"
|
|
70
71
|
:is="getIcon(action.icon)"
|
|
71
72
|
class="w-5 h-5 transition duration-75 group-hover:text-gray-900 dark:group-hover:text-white"></component>
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
viewBox="0 0 100 101"
|
|
77
|
-
fill="none"
|
|
78
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
79
|
-
>
|
|
80
|
-
<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"/>
|
|
81
|
-
<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"/>
|
|
82
|
-
</svg>
|
|
83
|
-
<span class="sr-only">Loading...</span>
|
|
84
|
-
</div>
|
|
73
|
+
<Spinner
|
|
74
|
+
v-if="bulkActionLoadingStates[action.id!]"
|
|
75
|
+
class="w-5 h-5 text-gray-200 dark:text-gray-500 fill-gray-500 dark:fill-gray-300"
|
|
76
|
+
/>
|
|
85
77
|
{{ `${action.label} (${checkboxes.length})` }}
|
|
86
78
|
<div v-if="action.badge" class="text-white bg-gradient-to-r from-purple-500
|
|
87
79
|
via-purple-600 to-purple-700 hover:bg-gradient-to-br focus:ring-4 focus:outline-none
|
|
@@ -98,25 +90,22 @@
|
|
|
98
90
|
<button
|
|
99
91
|
:key="action.id"
|
|
100
92
|
@click="startCustomBulkActionInner(action.id!)"
|
|
101
|
-
class="flex gap-1 items-center py-1 px-3 text-sm font-medium text-lightListViewButtonText
|
|
93
|
+
class="flex gap-1 items-center py-1 px-3 text-sm font-medium text-lightListViewButtonText
|
|
94
|
+
focus:outline-none bg-lightListViewButtonBackground rounded-default border h-[34px]
|
|
95
|
+
border-lightListViewButtonBorder hover:bg-lightListViewButtonBackgroundHover
|
|
96
|
+
hover:text-lightListViewButtonTextHover focus:z-10 focus:ring-4 af-button-shadow
|
|
97
|
+
focus:ring-lightListViewButtonFocusRing dark:focus:ring-darkListViewButtonFocusRing
|
|
98
|
+
dark:bg-darkListViewButtonBackground dark:text-darkListViewButtonText dark:border-darkListViewButtonBorder
|
|
99
|
+
dark:hover:text-darkListViewButtonTextHover dark:hover:bg-darkListViewButtonBackgroundHover"
|
|
102
100
|
>
|
|
103
101
|
<component
|
|
104
102
|
v-if="action.icon && !customActionLoadingStates[action.id!]"
|
|
105
103
|
:is="getIcon(action.icon)"
|
|
106
104
|
class="w-5 h-5 transition duration-75 group-hover:text-gray-900 dark:group-hover:text-white"></component>
|
|
107
|
-
<
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
viewBox="0 0 100 101"
|
|
112
|
-
fill="none"
|
|
113
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
114
|
-
>
|
|
115
|
-
<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"/>
|
|
116
|
-
<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"/>
|
|
117
|
-
</svg>
|
|
118
|
-
<span class="sr-only">Loading...</span>
|
|
119
|
-
</div>
|
|
105
|
+
<Spinner
|
|
106
|
+
v-if="customActionLoadingStates[action.id!]"
|
|
107
|
+
class="w-5 h-5 text-gray-200 dark:text-gray-500 fill-gray-500 dark:fill-gray-300"
|
|
108
|
+
/>
|
|
120
109
|
{{ `${action.name} (${checkboxes.length})` }}
|
|
121
110
|
</button>
|
|
122
111
|
</div>
|
|
@@ -233,8 +222,8 @@ import { computed, onMounted, onUnmounted, ref, watch, type Ref } from 'vue';
|
|
|
233
222
|
import { useRoute } from 'vue-router';
|
|
234
223
|
import { getCustomComponent, initThreeDotsDropdown, getList, startBulkAction } from '@/utils';
|
|
235
224
|
import ThreeDotsMenu from '@/components/ThreeDotsMenu.vue';
|
|
236
|
-
import { Tooltip } from '@/afcl'
|
|
237
|
-
import type { AdminForthComponentDeclaration, AdminForthComponentDeclarationFull } from '@/types/Common';
|
|
225
|
+
import { Tooltip, Spinner } from '@/afcl'
|
|
226
|
+
import type { AdminForthComponentDeclaration, AdminForthComponentDeclarationFull, AdminForthFilterOperators, AdminForthResourceColumnCommon } from '@/types/Common';
|
|
238
227
|
|
|
239
228
|
|
|
240
229
|
import {
|
|
@@ -344,6 +333,7 @@ async function startCustomBulkActionInner(actionId: string | number) {
|
|
|
344
333
|
resourceId: route.params.resourceId as string,
|
|
345
334
|
recordIds: checkboxes.value,
|
|
346
335
|
confirmMessage: action?.bulkConfirmationMessage,
|
|
336
|
+
resource: coreStore.resource!,
|
|
347
337
|
setLoadingState: (loading: boolean) => {
|
|
348
338
|
customActionLoadingStates.value[actionId] = loading;
|
|
349
339
|
},
|
|
@@ -354,7 +344,7 @@ async function startCustomBulkActionInner(actionId: string | number) {
|
|
|
354
344
|
const successResults = results.filter(r => r?.successMessage);
|
|
355
345
|
if (successResults.length > 0) {
|
|
356
346
|
alert({
|
|
357
|
-
message: action?.bulkSuccessMessage
|
|
347
|
+
message: action?.bulkSuccessMessage ? action.bulkSuccessMessage : action?.hasBulkHandler ? successResults[0].successMessage : `${successResults.length} out of ${results.length} items processed successfully`,
|
|
358
348
|
variant: 'success'
|
|
359
349
|
});
|
|
360
350
|
}
|
|
@@ -413,7 +403,7 @@ async function init() {
|
|
|
413
403
|
const [_, field, operator] = k.split('__');
|
|
414
404
|
return {
|
|
415
405
|
field,
|
|
416
|
-
operator,
|
|
406
|
+
operator: operator as AdminForthFilterOperators,
|
|
417
407
|
value: JSON.parse((route.query[k] as string))
|
|
418
408
|
}
|
|
419
409
|
});
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
<BreadcrumbsWithButtons>
|
|
13
13
|
<template v-if="coreStore.resource?.options?.actions">
|
|
14
14
|
|
|
15
|
-
<
|
|
15
|
+
<div class="flex gap-1" v-for="action in coreStore.resource.options.actions.filter(a => a.showIn?.showButton)" :key="action.id">
|
|
16
16
|
<component
|
|
17
17
|
:is="action?.customComponent ? getCustomComponent(formatComponent(action.customComponent)) : CallActionWrapper"
|
|
18
18
|
:meta="action.customComponent ? formatComponent(action.customComponent).meta : undefined"
|
|
@@ -25,14 +25,18 @@
|
|
|
25
25
|
class="flex items-center af-button-shadow h-[34px] py-1 px-3 text-sm font-medium text-gray-900 focus:outline-none bg-white rounded-default border border-gray-300 hover:bg-gray-100 hover:text-lightPrimary 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"
|
|
26
26
|
>
|
|
27
27
|
<component
|
|
28
|
-
v-if="action.icon"
|
|
28
|
+
v-if="action.icon && !actionLoadingStates[action.id!]"
|
|
29
29
|
:is="getIcon(action.icon)"
|
|
30
30
|
class="w-4 h-4 me-2 text-lightPrimary dark:text-darkPrimary"
|
|
31
31
|
/>
|
|
32
|
+
<Spinner
|
|
33
|
+
v-if="actionLoadingStates[action.id!]"
|
|
34
|
+
class="w-5 h-5 me-2 text-gray-200 dark:text-gray-500 fill-gray-500 dark:fill-gray-300"
|
|
35
|
+
/>
|
|
32
36
|
{{ action.name }}
|
|
33
37
|
</button>
|
|
34
38
|
</component>
|
|
35
|
-
</
|
|
39
|
+
</div>
|
|
36
40
|
</template>
|
|
37
41
|
<RouterLink v-if="coreStore.resource?.options?.allowedActions?.create"
|
|
38
42
|
:to="{ name: 'resource-create', params: { resourceId: $route.params.resourceId } }"
|
|
@@ -72,14 +76,52 @@
|
|
|
72
76
|
:adminUser="coreStore.adminUser"
|
|
73
77
|
/>
|
|
74
78
|
|
|
75
|
-
<div
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
<div
|
|
80
|
+
v-if="loading"
|
|
81
|
+
role="status"
|
|
82
|
+
class="animate-pulse overflow-x-auto shadow-resourseFormShadow dark:shadow-darkResourseFormShadow rounded-lg overflow-hidden border border-lightShowTableBodyBorder dark:border-darkShowTableBodyBorder"
|
|
83
|
+
>
|
|
84
|
+
<div
|
|
85
|
+
v-if="groups && groups.length > 0"
|
|
86
|
+
class="text-md font-semibold px-6 py-3 flex flex-1 items-center bg-lightShowTableHeadingBackground dark:bg-darkShowTableHeadingBackground dark:text-darkShowTableHeadingText border-b border-lightShowTableBodyBorder dark:border-darkShowTableBodyBorder"
|
|
87
|
+
>
|
|
88
|
+
<div class="h-4 bg-gray-300 dark:bg-gray-600 rounded-full w-32"></div>
|
|
89
|
+
</div>
|
|
90
|
+
|
|
91
|
+
<table class="w-full text-sm text-left table-fixed border-collapse">
|
|
92
|
+
<thead class="bg-lightShowTableUnderHeadingBackground dark:bg-darkShowTableUnderHeadingBackground block md:table-row-group">
|
|
93
|
+
<tr class="block md:table-row">
|
|
94
|
+
<th scope="col" class="px-6 py-3 text-xs uppercase hidden md:w-52 md:table-cell text-lightShowTableUnderHeadingText dark:text-darkShowTableUnderHeadingText">
|
|
95
|
+
{{ $t('Field') }}
|
|
96
|
+
</th>
|
|
97
|
+
<th scope="col" class="px-6 py-3 text-xs uppercase hidden md:table-cell text-lightShowTableUnderHeadingText dark:text-darkShowTableUnderHeadingText">
|
|
98
|
+
{{ $t('Value') }}
|
|
99
|
+
</th>
|
|
100
|
+
</tr>
|
|
101
|
+
</thead>
|
|
102
|
+
|
|
103
|
+
<tbody>
|
|
104
|
+
<tr
|
|
105
|
+
v-for="i in skeletonRowsCount"
|
|
106
|
+
:key="i"
|
|
107
|
+
class="bg-lightShowTablesBodyBackground border-t border-lightShowTableBodyBorder dark:bg-darkShowTablesBodyBackground dark:border-darkShowTableBodyBorder block md:table-row"
|
|
108
|
+
>
|
|
109
|
+
<td class="px-6 py-[15.5px] relative block md:table-cell pb-0 md:pb-[15.5px]">
|
|
110
|
+
<div class="md:absolute md:inset-0 flex items-center px-6 py-[15.5px]">
|
|
111
|
+
<div class="h-2.5 bg-gray-200 dark:bg-gray-700 rounded-full w-24"></div>
|
|
112
|
+
</div>
|
|
113
|
+
</td>
|
|
114
|
+
|
|
115
|
+
<td class="px-6 py-[15.5px] whitespace-pre-wrap block md:table-cell">
|
|
116
|
+
<div class="flex items-center h-full min-h-[21px]">
|
|
117
|
+
<div class="h-2.5 bg-gray-200 dark:bg-gray-700 rounded-full w-full max-w-[280px]"></div>
|
|
118
|
+
</div>
|
|
119
|
+
</td>
|
|
120
|
+
</tr>
|
|
121
|
+
</tbody>
|
|
122
|
+
</table>
|
|
123
|
+
|
|
124
|
+
<span class="sr-only">{{ $t('Loading...') }}</span>
|
|
83
125
|
</div>
|
|
84
126
|
<div
|
|
85
127
|
v-else-if="coreStore.record"
|
|
@@ -150,6 +192,7 @@ import { useI18n } from 'vue-i18n';
|
|
|
150
192
|
import { getIcon } from '@/utils';
|
|
151
193
|
import { type AdminForthComponentDeclarationFull, type AdminForthResourceColumnCommon, type FieldGroup } from '@/types/Common.js';
|
|
152
194
|
import CallActionWrapper from '@/components/CallActionWrapper.vue'
|
|
195
|
+
import { Spinner } from '@/afcl';
|
|
153
196
|
|
|
154
197
|
const route = useRoute();
|
|
155
198
|
const router = useRouter();
|
|
@@ -164,6 +207,18 @@ const customActions = computed(() => {
|
|
|
164
207
|
return coreStore.resource?.options?.actions?.filter((a: any) => a.showIn?.showThreeDotsMenu) || [];
|
|
165
208
|
});
|
|
166
209
|
|
|
210
|
+
const skeletonRowsCount = computed(() => {
|
|
211
|
+
const allCols = coreStore.resource?.columns || [];
|
|
212
|
+
|
|
213
|
+
const isEnabledInConfig = (col: any) => {
|
|
214
|
+
return col.showIn?.list !== false;
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
const finalCount = allCols.filter(isEnabledInConfig).length;
|
|
218
|
+
|
|
219
|
+
return finalCount > 0 ? finalCount : 10;
|
|
220
|
+
});
|
|
221
|
+
|
|
167
222
|
onMounted(async () => {
|
|
168
223
|
loading.value = true;
|
|
169
224
|
await coreStore.fetchResourceFull({
|
|
@@ -203,7 +258,7 @@ const groups = computed(() => {
|
|
|
203
258
|
});
|
|
204
259
|
|
|
205
260
|
const allColumns = computed(() => {
|
|
206
|
-
return coreStore.resource?.columns
|
|
261
|
+
return coreStore.resource?.columns?.filter(col => col.showIn?.show);
|
|
207
262
|
});
|
|
208
263
|
|
|
209
264
|
const otherColumns = computed(() => {
|
package/dist/types/Back.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Express, Request, Response } from 'express';
|
|
2
2
|
import type { Writable } from 'stream';
|
|
3
|
-
import { ActionCheckSource, AdminForthFilterOperators, AdminForthSortDirections, AllowedActionsEnum, AdminForthResourcePages, type AdminForthComponentDeclaration, type AdminUser, type AllowedActionsResolved, type AdminForthBulkActionCommon, type AdminForthForeignResourceCommon, type AdminForthResourceColumnCommon, type AdminForthResourceInputCommon, type AdminForthComponentDeclarationFull, type AdminForthConfigMenuItem, type AnnouncementBadgeResponse, type AdminForthResourceColumnInputCommon } from './Common.js';
|
|
3
|
+
import { ActionCheckSource, AdminForthFilterOperators, AdminForthSortDirections, AllowedActionsEnum, AdminForthResourcePages, type AdminForthComponentDeclaration, type AdminUser, type AllowedActionsResolved, type AdminForthBulkActionCommon, type AdminForthForeignResourceCommon, type AdminForthResourceColumnCommon, type AdminForthResourceInputCommon, type AdminForthComponentDeclarationFull, type AdminForthConfigMenuItem, type AnnouncementBadgeResponse, type AdminForthResourceColumnInputCommon, type ColumnMinMaxValue } from './Common.js';
|
|
4
4
|
export interface ICodeInjector {
|
|
5
5
|
srcFoldersToSync: Object;
|
|
6
6
|
allComponentNames: Object;
|
|
@@ -206,12 +206,7 @@ export interface IAdminForthDataSourceConnector {
|
|
|
206
206
|
getMinMaxForColumnsWithOriginalTypes({ resource, columns }: {
|
|
207
207
|
resource: AdminForthResource;
|
|
208
208
|
columns: AdminForthResourceColumn[];
|
|
209
|
-
}): Promise<
|
|
210
|
-
[key: string]: {
|
|
211
|
-
min: any;
|
|
212
|
-
max: any;
|
|
213
|
-
};
|
|
214
|
-
}>;
|
|
209
|
+
}): Promise<ColumnMinMaxValue>;
|
|
215
210
|
/**
|
|
216
211
|
* Used to create record in database. Should return value of primary key column of created record.
|
|
217
212
|
*/
|
|
@@ -274,12 +269,7 @@ export interface IAdminForthDataSourceConnectorBase extends IAdminForthDataSourc
|
|
|
274
269
|
getMinMaxForColumns({ resource, columns }: {
|
|
275
270
|
resource: AdminForthResource;
|
|
276
271
|
columns: AdminForthResourceColumn[];
|
|
277
|
-
}): Promise<
|
|
278
|
-
[key: string]: {
|
|
279
|
-
min: any;
|
|
280
|
-
max: any;
|
|
281
|
-
};
|
|
282
|
-
}>;
|
|
272
|
+
}): Promise<ColumnMinMaxValue>;
|
|
283
273
|
deleteMany?({ resource, recordIds }: {
|
|
284
274
|
resource: AdminForthResource;
|
|
285
275
|
recordIds: any[];
|
|
@@ -1205,6 +1195,19 @@ export interface AdminForthActionInput {
|
|
|
1205
1195
|
standardAllowedActions: AllowedActions;
|
|
1206
1196
|
}) => boolean;
|
|
1207
1197
|
url?: string;
|
|
1198
|
+
bulkHandler?: (params: {
|
|
1199
|
+
adminforth: IAdminForth;
|
|
1200
|
+
resource: AdminForthResource;
|
|
1201
|
+
recordIds: (string | number)[];
|
|
1202
|
+
adminUser: AdminUser;
|
|
1203
|
+
response: IAdminForthHttpResponse;
|
|
1204
|
+
extra?: HttpExtra;
|
|
1205
|
+
tr: ITranslateFunction;
|
|
1206
|
+
}) => Promise<{
|
|
1207
|
+
ok: boolean;
|
|
1208
|
+
error?: string;
|
|
1209
|
+
successMessage?: string;
|
|
1210
|
+
}>;
|
|
1208
1211
|
action?: (params: {
|
|
1209
1212
|
adminforth: IAdminForth;
|
|
1210
1213
|
resource: AdminForthResource;
|
|
@@ -1212,14 +1215,14 @@ export interface AdminForthActionInput {
|
|
|
1212
1215
|
adminUser: AdminUser;
|
|
1213
1216
|
response: IAdminForthHttpResponse;
|
|
1214
1217
|
extra?: HttpExtra;
|
|
1215
|
-
tr:
|
|
1218
|
+
tr: ITranslateFunction;
|
|
1216
1219
|
}) => Promise<{
|
|
1217
1220
|
ok: boolean;
|
|
1218
1221
|
error?: string;
|
|
1219
1222
|
message?: string;
|
|
1220
1223
|
}>;
|
|
1221
1224
|
icon?: string;
|
|
1222
|
-
id
|
|
1225
|
+
id?: string;
|
|
1223
1226
|
customComponent?: AdminForthComponentDeclaration;
|
|
1224
1227
|
}
|
|
1225
1228
|
export interface AdminForthResourceInput extends Omit<NonNullable<AdminForthResourceInputCommon>, 'columns' | 'hooks' | 'options'> {
|
|
@@ -1597,6 +1600,8 @@ export interface ResourceOptionsInput extends Omit<NonNullable<AdminForthResourc
|
|
|
1597
1600
|
/**
|
|
1598
1601
|
* Custom bulk actions list. Bulk actions available in list view when user selects multiple records by
|
|
1599
1602
|
* using checkboxes.
|
|
1603
|
+
* @deprecated Since 2.26.5. Will be removed in 3.0.0. Use `actions` instead.
|
|
1604
|
+
|
|
1600
1605
|
*/
|
|
1601
1606
|
bulkActions?: Array<AdminForthBulkAction>;
|
|
1602
1607
|
/**
|