FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: compute _label from raw foreign key values · devforth/adminforth@e0c39c9 · GitHub

Repository navigation

Commit e0c39c9

Browse files
committed
fix: compute _label from raw foreign key values
1 parent 8aafa74 commit e0c39c9

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎adminforth/modules/restApi.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,6 +1578,9 @@ export default class AdminForthRestAPI implements IAdminForthRestAPI {
15781578
}
15791579
}
15801580

1581+
// recordLabel should get raw foreign key values, not { label, pk } references added below
1582+
const rawItems = data.data.map((item) => ({ ...item }));
1583+
15811584
// for foreign keys, add references
15821585
await Promise.all(
15831586
resource.columns.filter((col) => (
@@ -1709,7 +1712,8 @@ export default class AdminForthRestAPI implements IAdminForthRestAPI {
17091712
adminforth: this.adminforth,
17101713
};
17111714

1712-
for (const item of data.data) {
1715+
for (const [i, item] of data.data.entries()) {
1716+
const rawItem = rawItems[i];
17131717
for (const key of Object.keys(item)) {
17141718
if (key === '_primaryKeyValue') {
17151719
continue;
@@ -1718,10 +1722,11 @@ export default class AdminForthRestAPI implements IAdminForthRestAPI {
17181722
const bo = col ? await isBackendOnly(col, ctx) : true;
17191723
if (!col || bo) {
17201724
delete item[key];
1725+
delete rawItem[key];
17211726
}
17221727
}
17231728
if (!selectedColumnNameSet || shouldAddListHelpers) {
1724-
item._label = resource.recordLabel(item);
1729+
item._label = resource.recordLabel(rawItem);
17251730
}
17261731
}
17271732
}

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL