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

META-INF.resources.js.components.Layout.LayoutScreen.ObjectLayoutField.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 ClayLabel from '@clayui/label';
import {
	Panel,
	PanelSimpleBody,
	stringUtils,
} from '@liferay/object-js-components-web';
import React from 'react';

import {TYPES, useLayoutContext} from '../objectLayoutContext';
import {HeaderDropdown} from './HeaderDropdown';

interface ObjectLayoutFieldProps extends React.HTMLAttributes {
	boxIndex: number;
	columnIndex: number;
	objectFieldName: string;
	rowIndex: number;
	tabIndex: number;
}

export function ObjectLayoutField({
	boxIndex,
	columnIndex,
	objectFieldName,
	rowIndex,
	tabIndex,
}: ObjectLayoutFieldProps) {
	const [
		{creationLanguageId, objectFieldBusinessTypes, objectFields},
		dispatch,
	] = useLayoutContext();

	const objectField = objectFields.find(
		({name}) => name === objectFieldName
	)!;

	const objectFieldBusinessTypeInfo = objectFieldBusinessTypes.find(
		({businessType}) => businessType === objectField.businessType
	);

	return (
		<>
			
				 {
								dispatch({
									payload: {
										boxIndex,
										columnIndex,
										objectFieldName,
										rowIndex,
										tabIndex,
									},
									type: TYPES.DELETE_OBJECT_LAYOUT_FIELD,
								});
							}}
						/>
					}
					title={stringUtils.getLocalizableLabel({
						fallbackLabel: objectField.name,
						fallbackLanguageId: creationLanguageId,
						labels: objectField.label,
					})}
				>
					
						{objectFieldBusinessTypeInfo?.label} |{' '}
					

					
						{objectField?.required
							? Liferay.Language.get('mandatory')
							: Liferay.Language.get('optional')}
					

					{(objectField.businessType === 'AutoIncrement' ||
						objectField.readOnly === 'true' ||
						objectField.readOnly === 'conditional') && (
						
							{Liferay.Language.get('read-only')}
						
					)}
				
			
		
	);
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy