Fix filter and sort chips in view bar (#12455)
This PR fixes the filter and sort chips in the view bar. Fixes https://github.com/twentyhq/core-team-issues/issues/1002 Fixes https://github.com/twentyhq/core-team-issues/issues/1003
This commit is contained in:
@ -35,6 +35,7 @@ export const ConfigVariableFilterContainer = ({
|
|||||||
onRemove={chip.onRemove}
|
onRemove={chip.onRemove}
|
||||||
labelValue={chip.source ?? ''}
|
labelValue={chip.source ?? ''}
|
||||||
variant={chip.variant}
|
variant={chip.variant}
|
||||||
|
type="filter"
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</StyledChipContainer>
|
</StyledChipContainer>
|
||||||
|
|||||||
@ -113,6 +113,7 @@ export const AdvancedFilterChip = () => {
|
|||||||
Icon={IconFilter}
|
Icon={IconFilter}
|
||||||
onRemove={handleRemoveClick}
|
onRemove={handleRemoveClick}
|
||||||
variant={hasAnyDeletedAtFilterInAdvancedFilters ? 'danger' : 'default'}
|
variant={hasAnyDeletedAtFilterInAdvancedFilters ? 'danger' : 'default'}
|
||||||
|
type="filter"
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -50,8 +50,8 @@ export const EditableFilterChip = ({
|
|||||||
|
|
||||||
const recordFilterIsEmpty = isRecordFilterConsideredEmpty(recordFilter);
|
const recordFilterIsEmpty = isRecordFilterConsideredEmpty(recordFilter);
|
||||||
|
|
||||||
const labelKey = `${fieldNameLabel}${!operandIsEmptiness && !recordFilterIsEmpty ? operandLabelShort : operandIsEmptiness ? ` ${operandLabelShort}` : ''}`;
|
const labelKey = `${fieldNameLabel}`;
|
||||||
const labelValue = operandIsEmptiness ? '' : recordFilter.displayValue;
|
const labelValue = `${!operandIsEmptiness && !recordFilterIsEmpty ? operandLabelShort : operandIsEmptiness ? ` ${operandLabelShort}` : ''} ${operandIsEmptiness ? '' : recordFilter.displayValue}`;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SortOrFilterChip
|
<SortOrFilterChip
|
||||||
@ -62,6 +62,7 @@ export const EditableFilterChip = ({
|
|||||||
Icon={FieldMetadataItemIcon}
|
Icon={FieldMetadataItemIcon}
|
||||||
onRemove={onRemove}
|
onRemove={onRemove}
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
|
type="filter"
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -39,6 +39,7 @@ export const EditableSortChip = ({ recordSort }: EditableSortChipProps) => {
|
|||||||
Icon={recordSort.direction === 'desc' ? IconArrowDown : IconArrowUp}
|
Icon={recordSort.direction === 'desc' ? IconArrowDown : IconArrowUp}
|
||||||
onRemove={handleRemoveClick}
|
onRemove={handleRemoveClick}
|
||||||
onClick={handleClick}
|
onClick={handleClick}
|
||||||
|
type="sort"
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -38,6 +38,7 @@ export const SoftDeleteFilterChip = ({
|
|||||||
labelValue={recordFilter.label ?? ''}
|
labelValue={recordFilter.label ?? ''}
|
||||||
Icon={ChipIcon}
|
Icon={ChipIcon}
|
||||||
onRemove={handleRemoveClick}
|
onRemove={handleRemoveClick}
|
||||||
|
type="filter"
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -33,7 +33,7 @@ const StyledChip = styled.div<{ variant: SortOrFilterChipVariant }>`
|
|||||||
return theme.color.blue;
|
return theme.color.blue;
|
||||||
}
|
}
|
||||||
}};
|
}};
|
||||||
height: 26px;
|
height: 24px;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
display: flex;
|
display: flex;
|
||||||
@ -87,8 +87,18 @@ const StyledLabelKey = styled.div`
|
|||||||
font-weight: ${({ theme }) => theme.font.weight.medium};
|
font-weight: ${({ theme }) => theme.font.weight.medium};
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
const StyledFilterValue = styled.span`
|
||||||
|
font-weight: ${({ theme }) => theme.font.weight.regular};
|
||||||
|
`;
|
||||||
|
|
||||||
|
const StyledSortValue = styled.span`
|
||||||
|
font-weight: ${({ theme }) => theme.font.weight.medium};
|
||||||
|
`;
|
||||||
|
|
||||||
export type SortOrFilterChipVariant = 'default' | 'danger';
|
export type SortOrFilterChipVariant = 'default' | 'danger';
|
||||||
|
|
||||||
|
export type SortOrFilterChipType = 'sort' | 'filter';
|
||||||
|
|
||||||
type SortOrFilterChipProps = {
|
type SortOrFilterChipProps = {
|
||||||
labelKey?: string;
|
labelKey?: string;
|
||||||
labelValue: string;
|
labelValue: string;
|
||||||
@ -97,6 +107,7 @@ type SortOrFilterChipProps = {
|
|||||||
onRemove: () => void;
|
onRemove: () => void;
|
||||||
onClick?: () => void;
|
onClick?: () => void;
|
||||||
testId?: string;
|
testId?: string;
|
||||||
|
type: SortOrFilterChipType;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const SortOrFilterChip = ({
|
export const SortOrFilterChip = ({
|
||||||
@ -107,6 +118,7 @@ export const SortOrFilterChip = ({
|
|||||||
onRemove,
|
onRemove,
|
||||||
testId,
|
testId,
|
||||||
onClick,
|
onClick,
|
||||||
|
type,
|
||||||
}: SortOrFilterChipProps) => {
|
}: SortOrFilterChipProps) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
|
||||||
@ -123,7 +135,11 @@ export const SortOrFilterChip = ({
|
|||||||
</StyledIcon>
|
</StyledIcon>
|
||||||
)}
|
)}
|
||||||
{labelKey && <StyledLabelKey>{labelKey}</StyledLabelKey>}
|
{labelKey && <StyledLabelKey>{labelKey}</StyledLabelKey>}
|
||||||
{labelValue}
|
{type === 'sort' ? (
|
||||||
|
<StyledSortValue>{labelValue}</StyledSortValue>
|
||||||
|
) : (
|
||||||
|
<StyledFilterValue>{labelValue}</StyledFilterValue>
|
||||||
|
)}
|
||||||
<StyledDelete
|
<StyledDelete
|
||||||
variant={variant}
|
variant={variant}
|
||||||
onClick={handleDeleteClick}
|
onClick={handleDeleteClick}
|
||||||
|
|||||||
Reference in New Issue
Block a user