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

META-INF.resources.js.components.ObjectDetails.ObjectDataContainer.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 {FormError, Input, Toggle} from '@liferay/object-js-components-web';
import {InputLocalized} from 'frontend-js-components-web';
import {sub} from 'frontend-js-web';
import React, {ChangeEventHandler, useState} from 'react';

import {defaultLanguageId} from '../../utils/constants';

interface ObjectDataContainerProps {
	dbTableName: string | undefined;
	errors: FormError;
	handleChange: ChangeEventHandler;
	hasUpdateObjectDefinitionPermission: boolean;
	isApproved: boolean;
	isLinkedObjectDefinition?: boolean;
	onSubmit?: (editedObjectDefinition?: Partial) => void;
	setValues: (values: Partial) => void;
	values: Partial;
}

export function ObjectDataContainer({
	dbTableName,
	errors,
	handleChange,
	hasUpdateObjectDefinitionPermission,
	isApproved,
	isLinkedObjectDefinition,
	onSubmit,
	setValues,
	values,
}: ObjectDataContainerProps) {
	const [selectedLocale, setSelectedLocale] =
		useState(defaultLanguageId);

	const isReadOnly = !values.modifiable && values.system;

	const noPermissionOrLinked =
		!hasUpdateObjectDefinitionPermission || isLinkedObjectDefinition;

	return (
		<>
			 {
					event.stopPropagation();

					if (onSubmit) {
						onSubmit();
					}
				}}
				onChange={handleChange}
				required
				value={values.name}
			/>

			 {
					event.stopPropagation();

					if (onSubmit) {
						onSubmit();
					}
				}}
				onChange={(label) => setValues({label})}
				onSelectedLocaleChange={setSelectedLocale}
				required
				selectedLocale={selectedLocale}
				translations={values.label as LocalizedValue}
			/>

			 {
					event.stopPropagation();

					if (onSubmit) {
						onSubmit();
					}
				}}
				onChange={(pluralLabel) => setValues({pluralLabel})}
				onSelectedLocaleChange={setSelectedLocale}
				required
				selectedLocale={selectedLocale}
				translations={values.pluralLabel as LocalizedValue}
			/>

			

			
				 {
						event.stopPropagation();

						if (onSubmit) {
							onSubmit();
						}
					}}
					onToggle={() => setValues({active: !values.active})}
					toggled={values.active}
				/>
			
		
	);
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy