adminforth
Advanced tools
Comparing version
@@ -416,4 +416,4 @@ import fs from 'fs'; | ||
} | ||
if (col.foreignResource) { | ||
errors.push(`Resource "${res.resourceId}" column "${col.name}" isArray cannot be used for a foreignResource column`); | ||
if (col.foreignResource && col.foreignResource.polymorphicResources) { | ||
errors.push(`Resource "${res.resourceId}" column "${col.name}" isArray cannot be used for a polymorphic foreignResource column`); | ||
} | ||
@@ -420,0 +420,0 @@ if (!col.type || col.type !== AdminForthDataTypes.JSON) { |
@@ -530,3 +530,14 @@ import { ADMINFORTH_VERSION, listify } from './utils.js'; | ||
const targetResourcePkField = targetResource.columns.find((col) => col.primaryKey).name; | ||
const pksUnique = [...new Set(data.data.map((item) => item[col.name]))]; | ||
const pksUnique = [...new Set(data.data.reduce((pks, item) => { | ||
var _a, _b; | ||
if ((_a = col.isArray) === null || _a === void 0 ? void 0 : _a.enabled) { | ||
if ((_b = item[col.name]) === null || _b === void 0 ? void 0 : _b.length) { | ||
pks = pks.concat(item[col.name]); | ||
} | ||
} | ||
else { | ||
pks.push(item[col.name]); | ||
} | ||
return pks; | ||
}, []))]; | ||
if (pksUnique.length === 0) { | ||
@@ -537,3 +548,3 @@ return; | ||
resource: targetResource, | ||
limit: limit, | ||
limit: pksUnique.length, | ||
offset: 0, | ||
@@ -603,3 +614,11 @@ filters: [ | ||
data.data.forEach((item) => { | ||
item[col.name] = targetDataMap[item[col.name]]; | ||
var _a, _b; | ||
if ((_a = col.isArray) === null || _a === void 0 ? void 0 : _a.enabled) { | ||
if ((_b = item[col.name]) === null || _b === void 0 ? void 0 : _b.length) { | ||
item[col.name] = item[col.name].map((i) => targetDataMap[i]); | ||
} | ||
} | ||
else { | ||
item[col.name] = targetDataMap[item[col.name]]; | ||
} | ||
if (!item[col.name]) { | ||
@@ -606,0 +625,0 @@ if (col.foreignResource && col.foreignResource.polymorphicResources) { |
{ | ||
"name": "adminforth", | ||
"version": "1.13.0-next.23", | ||
"version": "1.13.0-next.25", | ||
"description": "OpenSource Vue3 powered forth-generation admin panel", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1288367
0.21%18540
0.1%