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

META-INF.resources.js.components.ObjectAction.tabs.ConditionContainer.tsx 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
 */

import ClayForm from '@clayui/form';
import {
	Card,
	ExpressionBuilder,
	Toggle,
} from '@liferay/object-js-components-web';
import React from 'react';

import {ActionError} from '../ObjectActionContainer';

interface ConditionContainerProps {
	disabled: boolean;
	errors: ActionError;
	setValues: (values: Partial) => void;
	validateExpressionURL: string;
	values: Partial;
}

export function ConditionContainer({
	disabled,
	errors,
	setValues,
	validateExpressionURL,
	values,
}: ConditionContainerProps) {
	const handleSaveCondition = (conditionExpression?: string) => {
		setValues({conditionExpression});
	};

	return (
		
			
				
						setValues({
							conditionExpression: enable ? '' : undefined,
						})
					}
					toggled={!(values.conditionExpression === undefined)}
				/>
			

			{values.conditionExpression !== undefined && (
				
						setValues({conditionExpression: value})
					}
					onOpenModal={() => {
						const parentWindow = Liferay.Util.getOpener();

						parentWindow.Liferay.fire(
							'openExpressionBuilderModal',
							{
								onSave: handleSaveCondition,
								required: true,
								source: values.conditionExpression,
								validateExpressionURL,
							}
						);
					}}
					placeholder={Liferay.Language.get('create-an-expression')}
					value={values.conditionExpression as string}
				/>
			)}
		
	);
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy