Fix inline cell height issue and allow field settings update (#11248)
In this PR: - allow to update settings on fields metadata (regression introduced by a recent refactoring of fields-metadata update) - revert changes introduced by https://github.com/twentyhq/twenty/pull/11221
This commit is contained in:
@ -38,6 +38,7 @@ const StyledLabelAndIconContainer = styled.div`
|
|||||||
display: flex;
|
display: flex;
|
||||||
gap: ${({ theme }) => theme.spacing(1)};
|
gap: ${({ theme }) => theme.spacing(1)};
|
||||||
height: 18px;
|
height: 18px;
|
||||||
|
padding-top: 3px;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const StyledValueContainer = styled.div`
|
const StyledValueContainer = styled.div`
|
||||||
@ -53,16 +54,11 @@ const StyledLabelContainer = styled.div<{ width?: number }>`
|
|||||||
width: ${({ width }) => width}px;
|
width: ${({ width }) => width}px;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const StyledInlineCellBaseContainer = styled.div<{
|
const StyledInlineCellBaseContainer = styled.div`
|
||||||
isDisplayModeFixHeight?: boolean;
|
|
||||||
}>`
|
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
line-height: ${({ isDisplayModeFixHeight }) =>
|
height: fit-content;
|
||||||
isDisplayModeFixHeight ? `24px` : `18px`};
|
|
||||||
height: ${({ isDisplayModeFixHeight }) =>
|
|
||||||
isDisplayModeFixHeight ? `24px` : `18px`};
|
|
||||||
gap: ${({ theme }) => theme.spacing(1)};
|
gap: ${({ theme }) => theme.spacing(1)};
|
||||||
user-select: none;
|
user-select: none;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@ -74,14 +70,8 @@ export const StyledSkeletonDiv = styled.div`
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
export const RecordInlineCellContainer = () => {
|
export const RecordInlineCellContainer = () => {
|
||||||
const {
|
const { readonly, IconLabel, label, labelWidth, showLabel } =
|
||||||
readonly,
|
useRecordInlineCellContext();
|
||||||
IconLabel,
|
|
||||||
label,
|
|
||||||
labelWidth,
|
|
||||||
showLabel,
|
|
||||||
isDisplayModeFixHeight,
|
|
||||||
} = useRecordInlineCellContext();
|
|
||||||
|
|
||||||
const { recordId, fieldDefinition } = useContext(FieldContext);
|
const { recordId, fieldDefinition } = useContext(FieldContext);
|
||||||
|
|
||||||
@ -111,7 +101,6 @@ export const RecordInlineCellContainer = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledInlineCellBaseContainer
|
<StyledInlineCellBaseContainer
|
||||||
isDisplayModeFixHeight={isDisplayModeFixHeight}
|
|
||||||
onMouseEnter={handleContainerMouseEnter}
|
onMouseEnter={handleContainerMouseEnter}
|
||||||
onMouseLeave={handleContainerMouseLeave}
|
onMouseLeave={handleContainerMouseLeave}
|
||||||
>
|
>
|
||||||
|
|||||||
@ -44,6 +44,8 @@ const StyledRecordInlineCellNormalModeInnerContainer = styled.div`
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
color: ${({ theme }) => theme.font.color.primary};
|
color: ${({ theme }) => theme.font.color.primary};
|
||||||
height: fit-content;
|
height: fit-content;
|
||||||
|
padding-top: 3px;
|
||||||
|
padding-bottom: 3px;
|
||||||
|
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
|
|||||||
@ -75,7 +75,12 @@ export class BeforeUpdateOneField<T extends UpdateFieldInput>
|
|||||||
locale?: keyof typeof APP_LOCALES,
|
locale?: keyof typeof APP_LOCALES,
|
||||||
): UpdateOneInputType<T> {
|
): UpdateOneInputType<T> {
|
||||||
const update: StandardFieldUpdate = {};
|
const update: StandardFieldUpdate = {};
|
||||||
const updatableFields = ['isActive', 'isLabelSyncedWithName', 'options'];
|
const updatableFields = [
|
||||||
|
'isActive',
|
||||||
|
'isLabelSyncedWithName',
|
||||||
|
'options',
|
||||||
|
'settings',
|
||||||
|
];
|
||||||
const overridableFields = ['label', 'icon', 'description'];
|
const overridableFields = ['label', 'icon', 'description'];
|
||||||
|
|
||||||
const nonUpdatableFields = Object.keys(instance.update).filter(
|
const nonUpdatableFields = Object.keys(instance.update).filter(
|
||||||
@ -110,6 +115,7 @@ export class BeforeUpdateOneField<T extends UpdateFieldInput>
|
|||||||
this.handleLabelSyncedWithNameField(instance, update);
|
this.handleLabelSyncedWithNameField(instance, update);
|
||||||
this.handleStandardOverrides(instance, fieldMetadata, update, locale);
|
this.handleStandardOverrides(instance, fieldMetadata, update, locale);
|
||||||
this.handleOptionsField(instance, update);
|
this.handleOptionsField(instance, update);
|
||||||
|
this.handleSettingsField(instance, update);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: instance.id,
|
id: instance.id,
|
||||||
@ -128,6 +134,17 @@ export class BeforeUpdateOneField<T extends UpdateFieldInput>
|
|||||||
update.options = instance.update.options;
|
update.options = instance.update.options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private handleSettingsField(
|
||||||
|
instance: UpdateOneInputType<T>,
|
||||||
|
update: StandardFieldUpdate,
|
||||||
|
): void {
|
||||||
|
if (!isDefined(instance.update.settings)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
update.settings = instance.update.settings;
|
||||||
|
}
|
||||||
|
|
||||||
private handleActiveField(
|
private handleActiveField(
|
||||||
instance: UpdateOneInputType<T>,
|
instance: UpdateOneInputType<T>,
|
||||||
update: StandardFieldUpdate,
|
update: StandardFieldUpdate,
|
||||||
|
|||||||
Reference in New Issue
Block a user