-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Add filters to search record action #12481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { subFieldNameUsedInDropdownComponentState } from '@/object-record/object-filter-dropdown/states/subFieldNameUsedInDropdownComponentState'; | ||
import { FormCountryCodeSelectInput } from '@/object-record/record-field/form-types/components/FormCountryCodeSelectInput'; | ||
import { FormCountrySelectInput } from '@/object-record/record-field/form-types/components/FormCountrySelectInput'; | ||
import { FormNumberFieldInput } from '@/object-record/record-field/form-types/components/FormNumberFieldInput'; | ||
import { FormTextFieldInput } from '@/object-record/record-field/form-types/components/FormTextFieldInput'; | ||
import { VariablePickerComponent } from '@/object-record/record-field/form-types/types/VariablePickerComponent'; | ||
import { RecordFilter } from '@/object-record/record-filter/types/RecordFilter'; | ||
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2'; | ||
import { JsonValue } from 'type-fest'; | ||
|
||
export const AdvancedFilterValueFormCompositeFieldInput = ({ | ||
recordFilter, | ||
VariablePicker, | ||
onChange, | ||
}: { | ||
recordFilter: RecordFilter; | ||
VariablePicker: VariablePickerComponent; | ||
onChange: (newValue: JsonValue) => void; | ||
}) => { | ||
thomtrp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const subFieldNameUsedInDropdown = useRecoilComponentValueV2( | ||
subFieldNameUsedInDropdownComponentState, | ||
); | ||
|
||
const filterType = recordFilter.type; | ||
|
||
return ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. looks like it does not work well tbh, i personally prefer the regular way to display composite fields (see general comment) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yep design is not done for now. design should match regular way but in column. Will be for another PR |
||
<> | ||
{filterType === 'ADDRESS' && | ||
(subFieldNameUsedInDropdown === 'addressCountry' ? ( | ||
<FormCountrySelectInput | ||
selectedCountryName={recordFilter.value} | ||
onChange={onChange} | ||
VariablePicker={VariablePicker} | ||
/> | ||
) : ( | ||
<FormTextFieldInput | ||
defaultValue={recordFilter.value} | ||
onChange={onChange} | ||
VariablePicker={VariablePicker} | ||
/> | ||
))} | ||
{filterType === 'CURRENCY' && | ||
(recordFilter.subFieldName === 'currencyCode' ? ( | ||
<FormCountryCodeSelectInput | ||
selectedCountryCode={recordFilter.value} | ||
onChange={onChange} | ||
VariablePicker={VariablePicker} | ||
/> | ||
) : recordFilter.subFieldName === 'amountMicros' ? ( | ||
<FormNumberFieldInput | ||
defaultValue={recordFilter.value} | ||
onChange={onChange} | ||
VariablePicker={VariablePicker} | ||
/> | ||
) : null)} | ||
</> | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { AdvancedFilterValueFormCompositeFieldInput } from '@/object-record/advanced-filter/components/AdvancedFilterValueFormCompositeFieldInput'; | ||
import { useApplyObjectFilterDropdownFilterValue } from '@/object-record/object-filter-dropdown/hooks/useApplyObjectFilterDropdownFilterValue'; | ||
import { subFieldNameUsedInDropdownComponentState } from '@/object-record/object-filter-dropdown/states/subFieldNameUsedInDropdownComponentState'; | ||
import { FormFieldInput } from '@/object-record/record-field/components/FormFieldInput'; | ||
import { VariablePickerComponent } from '@/object-record/record-field/form-types/types/VariablePickerComponent'; | ||
import { FieldMetadata } from '@/object-record/record-field/types/FieldMetadata'; | ||
import { currentRecordFiltersComponentState } from '@/object-record/record-filter/states/currentRecordFiltersComponentState'; | ||
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2'; | ||
import { FieldMetadataType } from 'twenty-shared/types'; | ||
import { isDefined } from 'twenty-shared/utils'; | ||
import { JsonValue } from 'type-fest'; | ||
|
||
export const AdvancedFilterValueFormInput = ({ | ||
recordFilterId, | ||
VariablePicker, | ||
}: { | ||
recordFilterId: string; | ||
VariablePicker: VariablePickerComponent; | ||
}) => { | ||
thomtrp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const currentRecordFilters = useRecoilComponentValueV2( | ||
currentRecordFiltersComponentState, | ||
); | ||
|
||
const subFieldNameUsedInDropdown = useRecoilComponentValueV2( | ||
subFieldNameUsedInDropdownComponentState, | ||
); | ||
|
||
const recordFilter = currentRecordFilters.find( | ||
(recordFilter) => recordFilter.id === recordFilterId, | ||
); | ||
|
||
const isDisabled = !recordFilter?.fieldMetadataId || !recordFilter.operand; | ||
|
||
const { applyObjectFilterDropdownFilterValue } = | ||
useApplyObjectFilterDropdownFilterValue(); | ||
|
||
const handleChange = (newValue: JsonValue) => { | ||
applyObjectFilterDropdownFilterValue(newValue as string); | ||
}; | ||
thomtrp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
if (isDisabled) { | ||
return null; | ||
} | ||
|
||
if (isDefined(subFieldNameUsedInDropdown)) { | ||
return ( | ||
<AdvancedFilterValueFormCompositeFieldInput | ||
recordFilter={recordFilter} | ||
VariablePicker={VariablePicker} | ||
onChange={handleChange} | ||
/> | ||
); | ||
} | ||
|
||
return ( | ||
<FormFieldInput | ||
field={{ | ||
type: recordFilter.type as FieldMetadataType, | ||
label: '', | ||
metadata: {} as FieldMetadata, | ||
}} | ||
defaultValue={recordFilter.value} | ||
onChange={handleChange} | ||
VariablePicker={VariablePicker} | ||
/> | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { createContext } from 'react'; | ||
|
||
type AdvancedFilterContextType = { | ||
onUpdate?: () => void; | ||
}; | ||
|
||
export const AdvancedFilterContext = createContext<AdvancedFilterContextType>( | ||
{} as AdvancedFilterContextType, | ||
thomtrp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
); |
Uh oh!
There was an error while loading. Please reload this page.