Hi there I’m trying to wrap my head around how the panel-dialog works inside a vue component’s method for my plugin.
I’ve set it up like this, and the dialog opens as expected, but somehow the files field is not able to select images from the current page… At this point I thought some help from the forum would help me move forward.
openDialog() {
this.$panel.dialog.open({
component: "k-form-dialog",
props: {
fields: {
files: {
type: "files",
label: "Files",
multiple: false,
endpoint: "/api/pages/" + this.$api.pages.current.id + "/files",
},
},
},
on: {
submit: (files) => {
// Convert selected files to the expected format
const newImages = files.map((file) => ({
files: [file],
// additional fields, since the images are stored as a structured element.
positionx: "50", // Default position for x
positiony: "50", // Default position for y
}));
// Update the content
this.update({
images: [...(this.content.images || []), ...newImages],
});
},
},
});
},
update(data) {
this.$emit("update", {
...this.content,
...data,
});
},
```