From 3b0e31614cddf285748b402d79c760b6b2944d13 Mon Sep 17 00:00:00 2001 From: alex <48489896+devnaumov@users.noreply.github.com> Date: Tue, 26 Sep 2023 15:03:41 +0200 Subject: [PATCH 1/9] CB-4017 make boolean fields larger (#2021) Co-authored-by: EvgeniaBzzz <139753579+EvgeniaBzzz@users.noreply.github.com> --- .../ObjectPropertyInfoForm.tsx | 4 +- .../ObjectPropertyInfoForm/RenderField.tsx | 37 +++++-------------- .../getPropertyControlType.ts | 28 ++++++++++++++ webapp/packages/core-blocks/src/index.ts | 1 + .../Options/ProviderPropertiesForm.tsx | 6 +-- 5 files changed, 44 insertions(+), 32 deletions(-) create mode 100644 webapp/packages/core-blocks/src/ObjectPropertyInfo/ObjectPropertyInfoForm/getPropertyControlType.ts diff --git a/webapp/packages/core-blocks/src/ObjectPropertyInfo/ObjectPropertyInfoForm/ObjectPropertyInfoForm.tsx b/webapp/packages/core-blocks/src/ObjectPropertyInfo/ObjectPropertyInfoForm/ObjectPropertyInfoForm.tsx index e800f7d690..facee09188 100644 --- a/webapp/packages/core-blocks/src/ObjectPropertyInfo/ObjectPropertyInfoForm/ObjectPropertyInfoForm.tsx +++ b/webapp/packages/core-blocks/src/ObjectPropertyInfo/ObjectPropertyInfoForm/ObjectPropertyInfoForm.tsx @@ -32,6 +32,7 @@ interface ObjectPropertyFormProps extends ILayoutSizeProps { hideEmptyPlaceholder?: boolean; canShowPassword?: boolean; isSaved?: (property: ObjectPropertyInfo) => boolean; + geLayoutSize?: (property: ObjectPropertyInfo) => ILayoutSizeProps; onFocus?: (name: string) => void; } @@ -49,6 +50,7 @@ export const ObjectPropertyInfoForm = observer(function hideEmptyPlaceholder, canShowPassword, isSaved, + geLayoutSize, onFocus, ...rest }) { @@ -77,7 +79,7 @@ export const ObjectPropertyInfoForm = observer(function return ( ) => void; } -type ControlType = 'checkbox' | 'combobox' | 'link' | 'input' | 'textarea' | 'file'; - -function getControlTypeFor(property: ObjectPropertyInfo): ControlType { - const dataType = property.dataType?.toLowerCase(); - - if (dataType === 'boolean') { - return 'checkbox'; - } else if (property.validValues && property.validValues.length > 0) { - return 'combobox'; - } else if (property.features.includes('href')) { - return 'link'; - } else if (dataType === 'string' && property.length === 'MULTILINE') { - return 'textarea'; - } else if (property.features.includes('file')) { - return 'file'; - } - - return 'input'; -} - function getValue(value: any, controlType: ControlType) { const checkbox = controlType === 'checkbox'; @@ -87,15 +68,15 @@ export const RenderField = observer(function RenderField({ }) { const translate = useTranslate(); - const controltype = getControlTypeFor(property); + const controlType = getPropertyControlType(property); const password = property.features.includes('password'); - const value = getValue(property.value, controltype); - const defaultValue = getValue(property.defaultValue, controltype); + const value = getValue(property.value, controlType); + const defaultValue = getValue(property.defaultValue, controlType); const passwordSaved = showRememberTip && ((password && !!property.value) || saved); const description = passwordSaved ? translate('ui_processing_saved') : undefined; - if (controltype === 'file' && state) { + if (controlType === 'file' && state) { return ( (function RenderField({ ); } - if (controltype === 'link') { + if (controlType === 'link') { return ( @@ -133,7 +114,7 @@ export const RenderField = observer(function RenderField({ ); } - if (controltype === 'checkbox') { + if (controlType === 'checkbox') { if (state !== undefined) { return ( (function RenderField({ ); } - if (controltype === 'combobox') { + if (controlType === 'combobox') { if (state !== undefined) { return ( (function RenderField({ ); } - if (controltype === 'textarea') { + if (controlType === 'textarea') { if (state !== undefined) { return (