adminforth 1.0.39 → 1.0.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +14 -1
- package/dist/spa/spa/src/components/Dropdown.vue +4 -0
- package/dist/spa/spa/src/components/ResourceForm.vue +1 -0
- package/dist/spa/spa/src/views/EditView.vue +14 -2
- package/index.ts +15 -1
- package/package.json +1 -1
- package/spa/src/components/Dropdown.vue +4 -0
- package/spa/src/components/ResourceForm.vue +1 -0
- package/spa/src/views/EditView.vue +14 -2
package/dist/index.js
CHANGED
|
@@ -221,6 +221,20 @@ class AdminForth {
|
|
|
221
221
|
if (errors.length > 0) {
|
|
222
222
|
throw new Error(`Invalid AdminForth config: ${errors.join(', ')}`);
|
|
223
223
|
}
|
|
224
|
+
// check is all custom components files exists
|
|
225
|
+
for (const resource of this.config.resources) {
|
|
226
|
+
for (const column of resource.columns) {
|
|
227
|
+
if (column.component) {
|
|
228
|
+
for (const [key, value] of Object.entries(column.component)) {
|
|
229
|
+
// console.log(`${key}: ${value}`);
|
|
230
|
+
const path = value.replace('@@', this.config.customization.customComponentsDir);
|
|
231
|
+
if (!fs.existsSync(path)) {
|
|
232
|
+
throw new Error(`Component file ${path} does not exist`);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
224
238
|
}
|
|
225
239
|
postProcessAfterDiscover(resource) {
|
|
226
240
|
resource.columns.forEach((column) => {
|
|
@@ -675,7 +689,6 @@ class AdminForth {
|
|
|
675
689
|
path: '/update_record',
|
|
676
690
|
handler: (_7) => __awaiter(this, [_7], void 0, function* ({ body, adminUser }) {
|
|
677
691
|
var _8, _9, _10, _11, _12, _13, _14, _15;
|
|
678
|
-
console.log('update_record', body);
|
|
679
692
|
const resource = this.config.resources.find((res) => res.resourceId == body['resourceId']);
|
|
680
693
|
if (!resource) {
|
|
681
694
|
return { error: `Resource '${body['resourceId']}' not found` };
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
|
|
24
24
|
<ResourceForm
|
|
25
25
|
v-else
|
|
26
|
-
:record="
|
|
26
|
+
:record="editableRecord"
|
|
27
27
|
:resourceColumns="coreStore.resourceColumns"
|
|
28
28
|
@update:record="onUpdateRecord"
|
|
29
29
|
@update:isValid="isValid = $event"
|
|
@@ -43,7 +43,7 @@ import SingleSkeletLoader from '@/components/SingleSkeletLoader.vue';
|
|
|
43
43
|
import { useCoreStore } from '@/stores/core';
|
|
44
44
|
import { callAdminForthApi } from '@/utils';
|
|
45
45
|
import { IconFloppyDiskSolid } from '@iconify-prerendered/vue-flowbite';
|
|
46
|
-
import { defineAsyncComponent, onMounted, ref } from 'vue';
|
|
46
|
+
import { defineAsyncComponent, onMounted, ref, computed } from 'vue';
|
|
47
47
|
import { useRoute, useRouter } from 'vue-router';
|
|
48
48
|
|
|
49
49
|
const coreStore = useCoreStore();
|
|
@@ -65,6 +65,18 @@ async function onUpdateRecord(newRecord) {
|
|
|
65
65
|
record.value = newRecord;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
const editableRecord = computed(() => {
|
|
69
|
+
const newRecord = { ...coreStore.record };
|
|
70
|
+
if (!coreStore.resourceColumns) {
|
|
71
|
+
return {};
|
|
72
|
+
}
|
|
73
|
+
coreStore.resourceColumns.forEach(column => {
|
|
74
|
+
if (column.foreignResource) {
|
|
75
|
+
newRecord[column.name] = newRecord[column.name]?.pk
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
return newRecord;
|
|
79
|
+
})
|
|
68
80
|
|
|
69
81
|
onMounted(async () => {
|
|
70
82
|
loading.value = true;
|
package/index.ts
CHANGED
|
@@ -267,6 +267,21 @@ class AdminForth {
|
|
|
267
267
|
if (errors.length > 0) {
|
|
268
268
|
throw new Error(`Invalid AdminForth config: ${errors.join(', ')}`);
|
|
269
269
|
}
|
|
270
|
+
|
|
271
|
+
// check is all custom components files exists
|
|
272
|
+
for (const resource of this.config.resources) {
|
|
273
|
+
for (const column of resource.columns) {
|
|
274
|
+
if (column.component) {
|
|
275
|
+
for (const [key, value] of Object.entries(column.component)) {
|
|
276
|
+
// console.log(`${key}: ${value}`);
|
|
277
|
+
const path = value.replace('@@', this.config.customization.customComponentsDir);
|
|
278
|
+
if (!fs.existsSync(path)) {
|
|
279
|
+
throw new Error(`Component file ${path} does not exist`);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
270
285
|
}
|
|
271
286
|
|
|
272
287
|
postProcessAfterDiscover(resource) {
|
|
@@ -754,7 +769,6 @@ class AdminForth {
|
|
|
754
769
|
method: 'POST',
|
|
755
770
|
path: '/update_record',
|
|
756
771
|
handler: async ({ body, adminUser }) => {
|
|
757
|
-
console.log('update_record', body);
|
|
758
772
|
const resource = this.config.resources.find((res) => res.resourceId == body['resourceId']);
|
|
759
773
|
if (!resource) {
|
|
760
774
|
return { error: `Resource '${body['resourceId']}' not found` };
|
package/package.json
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
|
|
24
24
|
<ResourceForm
|
|
25
25
|
v-else
|
|
26
|
-
:record="
|
|
26
|
+
:record="editableRecord"
|
|
27
27
|
:resourceColumns="coreStore.resourceColumns"
|
|
28
28
|
@update:record="onUpdateRecord"
|
|
29
29
|
@update:isValid="isValid = $event"
|
|
@@ -43,7 +43,7 @@ import SingleSkeletLoader from '@/components/SingleSkeletLoader.vue';
|
|
|
43
43
|
import { useCoreStore } from '@/stores/core';
|
|
44
44
|
import { callAdminForthApi } from '@/utils';
|
|
45
45
|
import { IconFloppyDiskSolid } from '@iconify-prerendered/vue-flowbite';
|
|
46
|
-
import { defineAsyncComponent, onMounted, ref } from 'vue';
|
|
46
|
+
import { defineAsyncComponent, onMounted, ref, computed } from 'vue';
|
|
47
47
|
import { useRoute, useRouter } from 'vue-router';
|
|
48
48
|
|
|
49
49
|
const coreStore = useCoreStore();
|
|
@@ -65,6 +65,18 @@ async function onUpdateRecord(newRecord) {
|
|
|
65
65
|
record.value = newRecord;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
const editableRecord = computed(() => {
|
|
69
|
+
const newRecord = { ...coreStore.record };
|
|
70
|
+
if (!coreStore.resourceColumns) {
|
|
71
|
+
return {};
|
|
72
|
+
}
|
|
73
|
+
coreStore.resourceColumns.forEach(column => {
|
|
74
|
+
if (column.foreignResource) {
|
|
75
|
+
newRecord[column.name] = newRecord[column.name]?.pk
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
return newRecord;
|
|
79
|
+
})
|
|
68
80
|
|
|
69
81
|
onMounted(async () => {
|
|
70
82
|
loading.value = true;
|