0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-11-29 01:22:07 +01:00

Populate MultipleChooserPanel from modal results

This commit is contained in:
Matt Westcott 2023-01-13 00:49:41 +00:00
parent 67ff655111
commit 78b88a605a

View File

@ -16,8 +16,15 @@ export class MultipleChooserPanel extends InlinePanel {
$(`#${opts.formsetPrefix}-OPEN_MODAL`).on('click', () => {
this.chooserWidgetFactory.openModal(
(result) => {
// eslint-disable-next-line no-console
console.log(result);
result.forEach((item) => {
this.addForm();
const formIndex = this.formCount - 1;
const formPrefix = `${opts.formsetPrefix}-${formIndex}`;
const chooserFieldId = `${formPrefix}-${opts.chooserFieldName}`;
const chooserWidget =
this.chooserWidgetFactory.getById(chooserFieldId);
chooserWidget.setStateFromModalData(item);
});
},
{ multiple: true },
);