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

META-INF.resources.js.FormFragmentsConfiguration.js Maven / Gradle / Ivy

There is a newer version: 4.0.119
Show 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
 */

import ClayButton from '@clayui/button';
import ClayForm, {ClayInput} from '@clayui/form';
import ClayLayout from '@clayui/layout';
import ClayTable from '@clayui/table';
import {
	createPortletURL,
	getPortletId,
	openSelectionModal,
	sub,
} from 'frontend-js-web';
import React, {useState} from 'react';

export default function FormFragmentsConfiguration({
	formTypes,
	portletNamespace,
	selectFragmentEntryURL,
	updateInputFragmentEntriesURL,
}) {
	const [values, setValues] = useState({});

	const onClick = ({inputType, name}) => {
		openSelectionModal({
			onSelect: ({fragmententrykey, fragmententryname, groupkey}) => {
				setValues((previousValues) => ({
					...previousValues,
					[name]: {
						fragmentEntryName: fragmententryname,
						groupKey: groupkey,
						key: fragmententrykey,
					},
				}));
			},
			selectEventName: 'selectFragment',
			title: sub(
				Liferay.Language.get('select-x'),
				Liferay.Language.get('fragment')
			),
			url: createPortletURL(selectFragmentEntryURL, {
				inputType,
				p_p_id: getPortletId(portletNamespace),
			}),
		});
	};

	return (
		
			
				

{Liferay.Language.get('form-fragments')}

{Liferay.Language.get( 'define-the-default-form-fragments-for-this-site' )} {Liferay.Language.get( 'the-selected-fragments-are-displayed-in-the-forms-created-on-the-pages-by-default' )}

{Liferay.Language.get('field-type')} {Liferay.Language.get('form-fragment')} {formTypes.map( ({fragmentName, inputType, label, name}) => ( {label} onClick({ inputType, name, }) } readOnly value={ values[name] ?.fragmentEntryName || fragmentName } /> onClick({ inputType, name, }) } size="sm" > {Liferay.Language.get( 'select' )} ) )}
{Liferay.Language.get('save')} {Liferay.Language.get('cancel')}
); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy