Skip to content

Commit 8a45480

Browse files
committed
feat: don't allow to change foreighn record in create form launched from plugin
1 parent c1ea2bc commit 8a45480

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

custom/InlineList.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@
6969

7070
{{ `${action.label} (${checkboxes.length})` }}
7171
</button>
72-
7372
<RouterLink v-if="createIsAllowed"
7473
:to="{
7574
name: 'resource-create',
7675
params: { resourceId: listResource.resourceId },
7776
query: {
7877
values: encodeURIComponent(JSON.stringify({[listResourceRefColumn.name]: props.record[selfPrimaryKeyColumn.name]})),
78+
readonlyColumns: encodeURIComponent(JSON.stringify([listResourceRefColumn.name])),
7979
returnTo: $route.fullPath,
8080
},
8181
}"

index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type {
33
IAdminForth,
44
IHttpServer,
55
} from "adminforth";
6+
import clone from 'clone';
67

78
import { AdminForthPlugin, AdminForthResourcePages, suggestIfTypo } from "adminforth";
89
import { PluginOptions } from "./types.js";
@@ -33,7 +34,7 @@ export default class ForeignInlineListPlugin extends AdminForthPlugin {
3334
return { error: `Resource ${this.options.foreignResourceId} not found` };
3435
}
3536
// exclude "plugins" key
36-
const resourceCopy = JSON.parse(JSON.stringify({ ...resource, plugins: undefined }));
37+
const resourceCopy = clone({ ...resource, plugins: undefined });
3738

3839
if (this.options.modifyTableResourceConfig) {
3940
this.options.modifyTableResourceConfig(resourceCopy);

package-lock.json

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
22
"name": "@adminforth/foreign-inline-list",
3-
"version": "1.0.27",
3+
"version": "1.0.27",
44
"description": "AdminForth plugin for adding list of children items to the parent item show page",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",
77
"type": "module",
88
"homepage": "https://adminforth.dev/docs/tutorial/Plugins/ForeignInlineList/",
99
"scripts": {
1010
"build": "tsc && rsync -av --exclude 'node_modules' custom dist/",
11-
"prepare": "npm link adminforth"
11+
"prepare": "npm link adminforth"
1212
},
1313
"repository": {
1414
"type": "git",
@@ -49,5 +49,8 @@
4949
"prerelease": true
5050
}
5151
]
52+
},
53+
"dependencies": {
54+
"clone": "^2.1.2"
5255
}
5356
}

0 commit comments

Comments
 (0)