-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
196c4ed
commit d97a0f9
Showing
9 changed files
with
244 additions
and
136 deletions.
There are no files selected for viewing
130 changes: 25 additions & 105 deletions
130
...odules/object-record/object-filter-dropdown/components/MultipleFiltersDropdownContent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
132 changes: 132 additions & 0 deletions
132
...dules/object-record/object-filter-dropdown/components/ObjectFilterDropdownFilterInput.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
import { useRecoilValue } from 'recoil'; | ||
|
||
import { ObjectFilterDropdownDateInput } from '@/object-record/object-filter-dropdown/components/ObjectFilterDropdownDateInput'; | ||
import { ObjectFilterDropdownNumberInput } from '@/object-record/object-filter-dropdown/components/ObjectFilterDropdownNumberInput'; | ||
import { ObjectFilterDropdownOperandButton } from '@/object-record/object-filter-dropdown/components/ObjectFilterDropdownOperandButton'; | ||
import { ObjectFilterDropdownOperandSelect } from '@/object-record/object-filter-dropdown/components/ObjectFilterDropdownOperandSelect'; | ||
import { ObjectFilterDropdownOptionSelect } from '@/object-record/object-filter-dropdown/components/ObjectFilterDropdownOptionSelect'; | ||
import { ObjectFilterDropdownRatingInput } from '@/object-record/object-filter-dropdown/components/ObjectFilterDropdownRatingInput'; | ||
import { ObjectFilterDropdownRecordSelect } from '@/object-record/object-filter-dropdown/components/ObjectFilterDropdownRecordSelect'; | ||
import { ObjectFilterDropdownSearchInput } from '@/object-record/object-filter-dropdown/components/ObjectFilterDropdownSearchInput'; | ||
import { ObjectFilterDropdownSourceSelect } from '@/object-record/object-filter-dropdown/components/ObjectFilterDropdownSourceSelect'; | ||
import { ObjectFilterDropdownTextSearchInput } from '@/object-record/object-filter-dropdown/components/ObjectFilterDropdownTextSearchInput'; | ||
import { useFilterDropdown } from '@/object-record/object-filter-dropdown/hooks/useFilterDropdown'; | ||
import { isActorSourceCompositeFilter } from '@/object-record/object-filter-dropdown/utils/isActorSourceCompositeFilter'; | ||
import { DropdownMenuSeparator } from '@/ui/layout/dropdown/components/DropdownMenuSeparator'; | ||
import { ViewFilterOperand } from '@/views/types/ViewFilterOperand'; | ||
import styled from '@emotion/styled'; | ||
import { isDefined } from 'twenty-ui'; | ||
|
||
const StyledOperandSelectContainer = styled.div` | ||
background: ${({ theme }) => theme.background.secondary}; | ||
box-shadow: ${({ theme }) => theme.boxShadow.light}; | ||
border-radius: ${({ theme }) => theme.border.radius.md}; | ||
left: 10px; | ||
position: absolute; | ||
top: 10px; | ||
width: 100%; | ||
z-index: 1000; | ||
`; | ||
|
||
type ObjectFilterDropdownFilterInputProps = { | ||
filterDropdownId?: string; | ||
}; | ||
|
||
export const ObjectFilterDropdownFilterInput = ({ | ||
filterDropdownId, | ||
}: ObjectFilterDropdownFilterInputProps) => { | ||
const { | ||
filterDefinitionUsedInDropdownState, | ||
selectedOperandInDropdownState, | ||
isObjectFilterDropdownOperandSelectUnfoldedState, | ||
} = useFilterDropdown({ filterDropdownId }); | ||
|
||
const isObjectFilterDropdownOperandSelectUnfolded = useRecoilValue( | ||
isObjectFilterDropdownOperandSelectUnfoldedState, | ||
); | ||
|
||
const filterDefinitionUsedInDropdown = useRecoilValue( | ||
filterDefinitionUsedInDropdownState, | ||
); | ||
|
||
const selectedOperandInDropdown = useRecoilValue( | ||
selectedOperandInDropdownState, | ||
); | ||
|
||
const isConfigurable = | ||
selectedOperandInDropdown && | ||
[ | ||
ViewFilterOperand.Is, | ||
ViewFilterOperand.IsNotNull, | ||
ViewFilterOperand.IsNot, | ||
ViewFilterOperand.LessThan, | ||
ViewFilterOperand.GreaterThan, | ||
ViewFilterOperand.IsBefore, | ||
ViewFilterOperand.IsAfter, | ||
ViewFilterOperand.Contains, | ||
ViewFilterOperand.DoesNotContain, | ||
ViewFilterOperand.IsRelative, | ||
].includes(selectedOperandInDropdown); | ||
|
||
if (!isDefined(filterDefinitionUsedInDropdown)) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<> | ||
<ObjectFilterDropdownOperandButton /> | ||
{isObjectFilterDropdownOperandSelectUnfolded && ( | ||
<StyledOperandSelectContainer> | ||
<ObjectFilterDropdownOperandSelect /> | ||
</StyledOperandSelectContainer> | ||
)} | ||
{isConfigurable && selectedOperandInDropdown && ( | ||
<> | ||
{[ | ||
'TEXT', | ||
'EMAIL', | ||
'EMAILS', | ||
'PHONE', | ||
'FULL_NAME', | ||
'LINK', | ||
'LINKS', | ||
'ADDRESS', | ||
'ACTOR', | ||
'ARRAY', | ||
'PHONES', | ||
].includes(filterDefinitionUsedInDropdown.type) && | ||
!isActorSourceCompositeFilter(filterDefinitionUsedInDropdown) && ( | ||
<ObjectFilterDropdownTextSearchInput /> | ||
)} | ||
{['NUMBER', 'CURRENCY'].includes( | ||
filterDefinitionUsedInDropdown.type, | ||
) && <ObjectFilterDropdownNumberInput />} | ||
{filterDefinitionUsedInDropdown.type === 'RATING' && ( | ||
<ObjectFilterDropdownRatingInput /> | ||
)} | ||
{['DATE_TIME', 'DATE'].includes( | ||
filterDefinitionUsedInDropdown.type, | ||
) && <ObjectFilterDropdownDateInput />} | ||
{filterDefinitionUsedInDropdown.type === 'RELATION' && ( | ||
<> | ||
<ObjectFilterDropdownSearchInput /> | ||
<ObjectFilterDropdownRecordSelect /> | ||
</> | ||
)} | ||
{isActorSourceCompositeFilter(filterDefinitionUsedInDropdown) && ( | ||
<> | ||
<DropdownMenuSeparator /> | ||
<ObjectFilterDropdownSourceSelect /> | ||
</> | ||
)} | ||
{filterDefinitionUsedInDropdown.type === 'SELECT' && ( | ||
<> | ||
<ObjectFilterDropdownSearchInput /> | ||
<ObjectFilterDropdownOptionSelect /> | ||
</> | ||
)} | ||
</> | ||
)} | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.