adminforth 1.0.48 → 1.0.50
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 +1 -7
- package/dist/modules/codeInjector.js +3 -2
- package/dist/modules/utils.js +3 -0
- package/dist/spa/spa/src/router/index.ts +0 -1
- package/dist/spa/spa/src/utils.ts +4 -2
- package/dist/spa/spa/src/views/CreateView.vue +2 -2
- package/dist/spa/spa/src/views/EditView.vue +2 -2
- package/dist/spa/spa/src/views/ListView.vue +2 -2
- package/dist/spa/spa/src/views/ShowView.vue +1 -1
- package/index.ts +1 -9
- package/modules/codeInjector.ts +3 -2
- package/modules/utils.ts +5 -1
- package/package.json +1 -1
- package/spa/src/router/index.ts +0 -1
- package/spa/src/utils.ts +4 -2
- package/spa/src/views/CreateView.vue +2 -2
- package/spa/src/views/EditView.vue +2 -2
- package/spa/src/views/ListView.vue +2 -2
- package/spa/src/views/ShowView.vue +1 -1
- package/spa/src/views/HomeView.vue +0 -8
package/dist/index.js
CHANGED
|
@@ -544,13 +544,6 @@ class AdminForth {
|
|
|
544
544
|
data.data.forEach((item) => {
|
|
545
545
|
item[col.name] = targetDataMap[item[col.name]];
|
|
546
546
|
});
|
|
547
|
-
data.data.forEach((item) => {
|
|
548
|
-
Object.keys(item).forEach((key) => {
|
|
549
|
-
if (!targetResource.columns.find((col) => col.name === key) || targetResource.columns.find((col) => col.name === key && col.backendOnly)) {
|
|
550
|
-
delete item[key];
|
|
551
|
-
}
|
|
552
|
-
});
|
|
553
|
-
});
|
|
554
547
|
})));
|
|
555
548
|
data.data.forEach((item) => {
|
|
556
549
|
item._label = resource.itemLabel(item);
|
|
@@ -572,6 +565,7 @@ class AdminForth {
|
|
|
572
565
|
}
|
|
573
566
|
});
|
|
574
567
|
});
|
|
568
|
+
console.log('data', data);
|
|
575
569
|
return Object.assign(Object.assign({}, data), { options: resource === null || resource === void 0 ? void 0 : resource.options });
|
|
576
570
|
}),
|
|
577
571
|
});
|
|
@@ -16,6 +16,7 @@ import os from 'os';
|
|
|
16
16
|
import path from 'path';
|
|
17
17
|
import { promisify } from 'util';
|
|
18
18
|
import { ADMIN_FORTH_ABSOLUTE_PATH } from './utils.js';
|
|
19
|
+
import { getComponentNameFromPath } from './utils.js';
|
|
19
20
|
let TMP_DIR;
|
|
20
21
|
try {
|
|
21
22
|
TMP_DIR = os.tmpdir();
|
|
@@ -167,7 +168,7 @@ class CodeInjector {
|
|
|
167
168
|
return;
|
|
168
169
|
}
|
|
169
170
|
if (data.isFile()) {
|
|
170
|
-
const componentName = filePath
|
|
171
|
+
const componentName = getComponentNameFromPath(filePath);
|
|
171
172
|
customComponentsImports += `import ${componentName} from '@/custom/${filePath}';\n`;
|
|
172
173
|
}
|
|
173
174
|
});
|
|
@@ -192,7 +193,7 @@ class CodeInjector {
|
|
|
192
193
|
return;
|
|
193
194
|
}
|
|
194
195
|
if (data.isFile()) {
|
|
195
|
-
const componentName = filePath
|
|
196
|
+
const componentName = getComponentNameFromPath(filePath);
|
|
196
197
|
customComponentsComponents += `app.component('${componentName}', ${componentName});\n`;
|
|
197
198
|
}
|
|
198
199
|
});
|
package/dist/modules/utils.js
CHANGED
|
@@ -22,3 +22,6 @@ if (__dirname.endsWith('dist')) {
|
|
|
22
22
|
export const ADMIN_FORTH_ABSOLUTE_PATH = __dirname;
|
|
23
23
|
const package_json = JSON.parse(fs.readFileSync(path.join(ADMIN_FORTH_ABSOLUTE_PATH, 'package.json'), 'utf8'));
|
|
24
24
|
export const ADMINFORTH_VERSION = package_json.version;
|
|
25
|
+
export function getComponentNameFromPath(filePath) {
|
|
26
|
+
return filePath.replace(/@/g, '').replace(/\./g, '').replace(/\//g, '');
|
|
27
|
+
}
|
|
@@ -29,8 +29,10 @@ export async function callAdminForthApi({ path, method, body=undefined }) {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
export function getCustomComponent(
|
|
33
|
-
|
|
32
|
+
export function getCustomComponent(filePath: string) {
|
|
33
|
+
const name = filePath.replace(/@/g, '').replace(/\./g, '').replace(/\//g, '');
|
|
34
|
+
console.log('resolving name', name);
|
|
35
|
+
return resolveComponent(name);
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
export function getIcon(icon: string) {
|
|
@@ -75,8 +75,8 @@ onMounted(async () => {
|
|
|
75
75
|
resourceId: route.params.resourceId
|
|
76
76
|
});
|
|
77
77
|
createComponentsPerColumn = coreStore.resourceColumns.reduce((acc, column) => {
|
|
78
|
-
if (column.component?.
|
|
79
|
-
acc[column.name] = getCustomComponent(column.component.create
|
|
78
|
+
if (column.component?.create) {
|
|
79
|
+
acc[column.name] = getCustomComponent(column.component.create);
|
|
80
80
|
}
|
|
81
81
|
return acc;
|
|
82
82
|
}, {});
|
|
@@ -90,8 +90,8 @@ onMounted(async () => {
|
|
|
90
90
|
});
|
|
91
91
|
|
|
92
92
|
editComponentsPerColumn = coreStore.resourceColumns.reduce((acc, column) => {
|
|
93
|
-
if (column.component?.
|
|
94
|
-
acc[column.name] = getCustomComponent(column.component.edit
|
|
93
|
+
if (column.component?.edit) {
|
|
94
|
+
acc[column.name] = getCustomComponent(column.component.edit);
|
|
95
95
|
}
|
|
96
96
|
return acc;
|
|
97
97
|
}, {});
|
|
@@ -432,8 +432,8 @@ async function getList() {
|
|
|
432
432
|
}
|
|
433
433
|
});
|
|
434
434
|
listComponentsPerColumn = coreStore.resourceColumns.reduce((acc, column) => {
|
|
435
|
-
if (column.component?.
|
|
436
|
-
acc[column.name] = getCustomComponent(column.component.list
|
|
435
|
+
if (column.component?.list) {
|
|
436
|
+
acc[column.name] = getCustomComponent(column.component.list);
|
|
437
437
|
}
|
|
438
438
|
return acc;
|
|
439
439
|
}, {});
|
|
@@ -94,7 +94,7 @@ onMounted(async () => {
|
|
|
94
94
|
});
|
|
95
95
|
showComponentsPerColumn = coreStore.resourceColumns.reduce((acc, column) => {
|
|
96
96
|
if (column.component?.show) {
|
|
97
|
-
acc[column.name] = getCustomComponent(column.component.show
|
|
97
|
+
acc[column.name] = getCustomComponent(column.component.show);
|
|
98
98
|
}
|
|
99
99
|
return acc;
|
|
100
100
|
}, {});
|
package/index.ts
CHANGED
|
@@ -617,15 +617,6 @@ class AdminForth {
|
|
|
617
617
|
data.data.forEach((item) => {
|
|
618
618
|
item[col.name] = targetDataMap[item[col.name]];
|
|
619
619
|
});
|
|
620
|
-
|
|
621
|
-
data.data.forEach((item) => {
|
|
622
|
-
Object.keys(item).forEach((key) => {
|
|
623
|
-
if (!targetResource.columns.find((col) => col.name === key) || targetResource.columns.find((col) => col.name === key && col.backendOnly)) {
|
|
624
|
-
delete item[key];
|
|
625
|
-
}
|
|
626
|
-
})
|
|
627
|
-
});
|
|
628
|
-
|
|
629
620
|
})
|
|
630
621
|
);
|
|
631
622
|
|
|
@@ -653,6 +644,7 @@ class AdminForth {
|
|
|
653
644
|
}
|
|
654
645
|
})
|
|
655
646
|
});
|
|
647
|
+
console.log('data', data);
|
|
656
648
|
|
|
657
649
|
return {...data, options: resource?.options };
|
|
658
650
|
},
|
package/modules/codeInjector.ts
CHANGED
|
@@ -8,6 +8,7 @@ import path from 'path';
|
|
|
8
8
|
import { promisify } from 'util';
|
|
9
9
|
import AdminForth from '../index.js';
|
|
10
10
|
import { ADMIN_FORTH_ABSOLUTE_PATH } from './utils.js';
|
|
11
|
+
import { getComponentNameFromPath } from './utils.js';
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
let TMP_DIR;
|
|
@@ -185,7 +186,7 @@ class CodeInjector {
|
|
|
185
186
|
return;
|
|
186
187
|
}
|
|
187
188
|
if (data.isFile()) {
|
|
188
|
-
const componentName = filePath
|
|
189
|
+
const componentName = getComponentNameFromPath(filePath);
|
|
189
190
|
customComponentsImports += `import ${componentName} from '@/custom/${filePath}';\n`;
|
|
190
191
|
}
|
|
191
192
|
})
|
|
@@ -212,7 +213,7 @@ class CodeInjector {
|
|
|
212
213
|
return;
|
|
213
214
|
}
|
|
214
215
|
if (data.isFile()) {
|
|
215
|
-
const componentName = filePath
|
|
216
|
+
const componentName = getComponentNameFromPath(filePath);
|
|
216
217
|
customComponentsComponents += `app.component('${componentName}', ${componentName});\n`;
|
|
217
218
|
}
|
|
218
219
|
})
|
package/modules/utils.ts
CHANGED
|
@@ -26,4 +26,8 @@ export const ADMIN_FORTH_ABSOLUTE_PATH = __dirname;
|
|
|
26
26
|
|
|
27
27
|
const package_json = JSON.parse(fs.readFileSync(path.join(ADMIN_FORTH_ABSOLUTE_PATH, 'package.json'), 'utf8'));
|
|
28
28
|
|
|
29
|
-
export const ADMINFORTH_VERSION = package_json.version;
|
|
29
|
+
export const ADMINFORTH_VERSION: string = package_json.version;
|
|
30
|
+
|
|
31
|
+
export function getComponentNameFromPath(filePath) {
|
|
32
|
+
return filePath.replace(/@/g, '').replace(/\./g, '').replace(/\//g, '');
|
|
33
|
+
}
|
package/package.json
CHANGED
package/spa/src/router/index.ts
CHANGED
package/spa/src/utils.ts
CHANGED
|
@@ -29,8 +29,10 @@ export async function callAdminForthApi({ path, method, body=undefined }) {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
export function getCustomComponent(
|
|
33
|
-
|
|
32
|
+
export function getCustomComponent(filePath: string) {
|
|
33
|
+
const name = filePath.replace(/@/g, '').replace(/\./g, '').replace(/\//g, '');
|
|
34
|
+
console.log('resolving name', name);
|
|
35
|
+
return resolveComponent(name);
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
export function getIcon(icon: string) {
|
|
@@ -75,8 +75,8 @@ onMounted(async () => {
|
|
|
75
75
|
resourceId: route.params.resourceId
|
|
76
76
|
});
|
|
77
77
|
createComponentsPerColumn = coreStore.resourceColumns.reduce((acc, column) => {
|
|
78
|
-
if (column.component?.
|
|
79
|
-
acc[column.name] = getCustomComponent(column.component.create
|
|
78
|
+
if (column.component?.create) {
|
|
79
|
+
acc[column.name] = getCustomComponent(column.component.create);
|
|
80
80
|
}
|
|
81
81
|
return acc;
|
|
82
82
|
}, {});
|
|
@@ -90,8 +90,8 @@ onMounted(async () => {
|
|
|
90
90
|
});
|
|
91
91
|
|
|
92
92
|
editComponentsPerColumn = coreStore.resourceColumns.reduce((acc, column) => {
|
|
93
|
-
if (column.component?.
|
|
94
|
-
acc[column.name] = getCustomComponent(column.component.edit
|
|
93
|
+
if (column.component?.edit) {
|
|
94
|
+
acc[column.name] = getCustomComponent(column.component.edit);
|
|
95
95
|
}
|
|
96
96
|
return acc;
|
|
97
97
|
}, {});
|
|
@@ -432,8 +432,8 @@ async function getList() {
|
|
|
432
432
|
}
|
|
433
433
|
});
|
|
434
434
|
listComponentsPerColumn = coreStore.resourceColumns.reduce((acc, column) => {
|
|
435
|
-
if (column.component?.
|
|
436
|
-
acc[column.name] = getCustomComponent(column.component.list
|
|
435
|
+
if (column.component?.list) {
|
|
436
|
+
acc[column.name] = getCustomComponent(column.component.list);
|
|
437
437
|
}
|
|
438
438
|
return acc;
|
|
439
439
|
}, {});
|
|
@@ -94,7 +94,7 @@ onMounted(async () => {
|
|
|
94
94
|
});
|
|
95
95
|
showComponentsPerColumn = coreStore.resourceColumns.reduce((acc, column) => {
|
|
96
96
|
if (column.component?.show) {
|
|
97
|
-
acc[column.name] = getCustomComponent(column.component.show
|
|
97
|
+
acc[column.name] = getCustomComponent(column.component.show);
|
|
98
98
|
}
|
|
99
99
|
return acc;
|
|
100
100
|
}, {});
|