All Downloads are FREE. Search and download functionalities are using the official Maven repository.

META-INF.resources.definition_links.jsp Maven / Gradle / Ivy

The newest version!
<%--
/**
 * SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com
 * SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
 */
--%>

<%@ include file="/init.jsp" %>

<%
CPDefinitionLinkDisplayContext cpDefinitionLinkDisplayContext = (CPDefinitionLinkDisplayContext)request.getAttribute(WebKeys.PORTLET_DISPLAY_CONTEXT);

CPDefinition cpDefinition = cpDefinitionLinkDisplayContext.getCPDefinition();
long cpDefinitionId = cpDefinitionLinkDisplayContext.getCPDefinitionId();
%>


	

	
		
		
		
		
		
	

	

	
		const eventHandlers = [];
		let eventHandler;

		<%
		for (String type : cpDefinitionLinkDisplayContext.getCPDefinitionLinkTypes()) {
		%>

			eventHandler = Liferay.on(
				'addCommerceProductDefinitionLink<%= HtmlUtil.escapeJS(type) %>',
				() => {
					Liferay.Util.openSelectionModal({
						multiple: true,
						onSelect: (selectedItems) => {
							if (!selectedItems || !selectedItems.length) {
								return;
							}

							const cpDefinitionIdsInput = document.getElementById(
								'cpDefinitionIds'
							);

							if (cpDefinitionIdsInput) {
								const values = selectedItems.map((item) => item.value);

								cpDefinitionIdsInput.value = values.join(',');
							}

							const typeInput = document.getElementById(
								'type'
							);

							if (typeInput) {
								typeInput.value = '<%= HtmlUtil.escapeJS(type) %>';
							}

							const form = document.getElementById(
								'addCPDefinitionLinkFm'
							);

							if (form) {
								submitForm(form);
							}
						},
						title: '',
						url: '<%= cpDefinitionLinkDisplayContext.getItemSelectorUrl(type) %>',
					});
				}
			);

			eventHandlers.push(eventHandler);

		<%
		}
		%>

		Liferay.on('destroyPortlet', () => {
			eventHandlers.forEach((eventHandler) => {
				eventHandler.detach();
			});
		});
	




© 2015 - 2024 Weber Informatics LLC | Privacy Policy