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 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.split('.')[0].replace('/', '');
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.split('.')[0].replace('/', '');
196
+ const componentName = getComponentNameFromPath(filePath);
196
197
  customComponentsComponents += `app.component('${componentName}', ${componentName});\n`;
197
198
  }
198
199
  });
@@ -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
+ }
@@ -1,5 +1,4 @@
1
1
  import { createRouter, createWebHistory } from 'vue-router'
2
- import HomeView from '../views/HomeView.vue'
3
2
  import ResourceParent from '@/views/ResourceParent.vue'
4
3
  import ListView from '@/views/ListView.vue'
5
4
  import ShowView from '@/views/ShowView.vue'
@@ -29,8 +29,10 @@ export async function callAdminForthApi({ path, method, body=undefined }) {
29
29
  }
30
30
  }
31
31
 
32
- export function getCustomComponent(name) {
33
- return resolveComponent(name);
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?.show) {
79
- acc[column.name] = getCustomComponent(column.component.create.replace('@@', '').replace('./custom/', '')).split('.')[0];
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?.show) {
94
- acc[column.name] = getCustomComponent(column.component.edit.replace('@@', '').replace('./custom/', '')).split('.')[0];
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?.show) {
436
- acc[column.name] = getCustomComponent(column.component.list.replace('@@', '').replace('./custom/', '')).split('.')[0];
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.replace('@@', '').replace('./custom/', '')).split('.')[0];
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
  },
@@ -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.split('.')[0].replace('/', '');
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.split('.')[0].replace('/', '');
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adminforth",
3
- "version": "1.0.48",
3
+ "version": "1.0.50",
4
4
  "description": "OpenSource Vue3 powered forth-generation admin panel",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,5 +1,4 @@
1
1
  import { createRouter, createWebHistory } from 'vue-router'
2
- import HomeView from '../views/HomeView.vue'
3
2
  import ResourceParent from '@/views/ResourceParent.vue'
4
3
  import ListView from '@/views/ListView.vue'
5
4
  import ShowView from '@/views/ShowView.vue'
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(name) {
33
- return resolveComponent(name);
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?.show) {
79
- acc[column.name] = getCustomComponent(column.component.create.replace('@@', '').replace('./custom/', '')).split('.')[0];
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?.show) {
94
- acc[column.name] = getCustomComponent(column.component.edit.replace('@@', '').replace('./custom/', '')).split('.')[0];
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?.show) {
436
- acc[column.name] = getCustomComponent(column.component.list.replace('@@', '').replace('./custom/', '')).split('.')[0];
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.replace('@@', '').replace('./custom/', '')).split('.')[0];
97
+ acc[column.name] = getCustomComponent(column.component.show);
98
98
  }
99
99
  return acc;
100
100
  }, {});
@@ -1,8 +0,0 @@
1
- <script setup lang="ts">
2
- </script>
3
-
4
- <template>
5
- <main>
6
- 123
7
- </main>
8
- </template>