From 78b88a605a8c9cae2e424e434085f06347858dc2 Mon Sep 17 00:00:00 2001 From: Matt Westcott Date: Fri, 13 Jan 2023 00:49:41 +0000 Subject: [PATCH] Populate MultipleChooserPanel from modal results --- client/src/components/MultipleChooserPanel/index.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/client/src/components/MultipleChooserPanel/index.js b/client/src/components/MultipleChooserPanel/index.js index 2ed0ba1463..22ab8b231d 100644 --- a/client/src/components/MultipleChooserPanel/index.js +++ b/client/src/components/MultipleChooserPanel/index.js @@ -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 }, );