Skip to content

Commit ee8a9fd

Browse files
committed
fix: improve doc fofr foreignInline resource
1 parent 547f75a commit ee8a9fd

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ cd adminforth
5858
npm ci
5959
npm run build
6060
61-
# create link to built "adminforth" package in local system
62-
npm link
6361
6462
# this will install all official plugins and link adminforth package, if plugin installed it will git pull and npm ci
6563
npm run install-plugins

adminforth/documentation/docs/tutorial/05-Plugins/03-ForeignInlineList.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,27 @@ import { AdminForthResource, AdminForthResourceColumn } from 'adminforth';
1717

1818

1919
In [Getting Started](<../001-gettingStarted.md>) we created a `'aparts'` resource which has a field `'realtor_id'`.
20-
This field refers to record from `'users'` resource. This means that we can display a list of apartments in the user's show view.
20+
This field refers to record from `'users'` resource. To remind you, we configured this relation using `foreignResource` setting in the column configuration:
21+
22+
```typescript title="./resources/apartments.ts"
23+
//
24+
export default {
25+
resourceId: 'aparts',
26+
...
27+
columns: [
28+
...
29+
{
30+
name: 'realtor_id',
31+
foreignResource: {
32+
resourceId: 'users', // this means that aparts.realtor_id refers to primary key of 'users' resource
33+
// this is Many-To-One relatin: many aparts can refer to one user
34+
}
35+
}
36+
],
37+
}
38+
```
39+
40+
This means that we can display a list of apartments in the user's show view.
2141

2242
Add to your `'users'` resource configuration the plugin instance:
2343

@@ -56,4 +76,5 @@ You can use `modifyTableResourceConfig` callback to modify what columns to show
5676

5777
![alt text](ForeignInlineList.png)
5878

59-
<!-- See [API Reference](/docs/api/plugins/foreign-inline-list/types/type-aliases/PluginOptions) for more all options. -->
79+
> 👆 To make plugin work, the specified resource (defined with `foreignResourceId`) should have one (and only one) column that refers to the current resource on which you add a plugin.
80+
> In our case we add plugin to `users` resource, so the `aparts` resource should have one column with `foreignResource.resourceId` equal to `users` resourceId.

0 commit comments

Comments
 (0)