Liferay.Loader.define("@liferay/commerce-product-definitions-web@7.0.105/js/EditDisplayLayout",["module","exports","require","frontend-js-web"],(function(e,t,a){window;Object.defineProperty(t,"__esModule",{value:!0}),t.default=function _default({layoutItemSelectorUrl:e,layoutPageTemplateEntryItemSelectorUrl:t,portletNamespace:a,productItemSelectorUrl:o,removeIcon:c,searchContainerId:l}){const d=(0,n.getOpener)();Liferay.componentReady("".concat(a).concat(l)).then((e=>{(e=>{const t=document.getElementById("".concat(a,"selectProduct"));if(!t)return;t.addEventListener("click",(t=>{t.preventDefault(),d.Liferay.Util.openSelectionModal({onSelect:t=>{if(!t)return;const n=e.getData(),o=document.querySelector('a[data-rowid="'.concat(n,'"]'));if(o){const t=o.closest("tr");t&&e.deleteRow(t,o.dataset.rowid)}const l=[];l.push(t.name),l.push('<a class="float-right modify-link" data-rowId="'.concat(t.id,'" href="javascript:void(0);">').concat(c,"</a>"));const d=document.getElementById("".concat(a,"classPK"));d&&(d.value=t.id),e.addRow(l,t.id),e.updateDataStore()},selectEventName:"productDefinitionsSelectItem",title:(0,n.sub)(Liferay.Language.get("select-x"),Liferay.Language.get("product")),url:o})}));const l=e.get("contentBox");(0,n.delegate)(l.getDOMNode(),"click",".modify-link",(t=>{const n=t.delegateTarget,o=n.closest("tr");e.deleteRow(o,n.dataset.rowid);const c=document.getElementById("".concat(a,"classPK"));c&&(c.value=0)}))})(e)})),(()=>{const n=document.getElementById("".concat(a,"chooseLayout")),o=document.getElementById("".concat(a,"chooseLayoutPageTemplateEntry")),c=document.getElementById("".concat(a,"displayPageItemRemove")),l=document.getElementById("".concat(a,"pagesContainerInput")),i=document.getElementById("".concat(a,"displayPageNameInput"));(n||o)&&c&&l&&i&&(n&&n.addEventListener("click",(()=>{d.Liferay.Util.openSelectionModal({buttonAddLabel:Liferay.Language.get("done"),multiple:!0,onSelect:e=>{e&&(l.value=e.id,i.innerHTML=e.name,c.classList.remove("hide"))},selectEventName:"selectLayout",title:Liferay.Language.get("select-product-display-page"),url:e})})),o&&o.addEventListener("click",(()=>{d.Liferay.Util.openSelectionModal({buttonAddLabel:Liferay.Language.get("done"),onSelect:e=>{e&&(l.value=e.id,i.innerHTML=e.name,c.classList.remove("hide"))},selectEventName:"selectLayoutPageTemplateEntry",title:Liferay.Language.get("select-product-display-page"),url:t})})),c.addEventListener("click",(()=>{i.innerHTML=Liferay.Language.get("none"),l.value="",c.classList.add("hide")})))})()};var n=a("frontend-js-web")}));
//# sourceMappingURL=EditDisplayLayout.js.map