diff --git a/frontend/src/v5/store/tickets/card/ticketsCard.redux.ts b/frontend/src/v5/store/tickets/card/ticketsCard.redux.ts index dc1627ef33..f2a9dc4bbc 100644 --- a/frontend/src/v5/store/tickets/card/ticketsCard.redux.ts +++ b/frontend/src/v5/store/tickets/card/ticketsCard.redux.ts @@ -22,7 +22,7 @@ import { createActions, createReducer } from 'reduxsauce'; import { Constants } from '@/v5/helpers/actions.helper'; import { EditableTicket, OverridesDicts, TicketsCardFilters } from '../tickets.types'; import { TeamspaceProjectAndModel } from '../../store.types'; -import { CardFilter } from '@components/viewer/cards/cardFilters/cardFilters.types'; +import { TicketCardFilter, TicketFilterDescription } from '@components/viewer/cards/cardFilters/cardFilters.types'; import { get, isEmpty, set, unset } from 'lodash'; export const { Types: TicketsCardTypes, Creators: TicketsCardActions } = createActions({ @@ -172,8 +172,8 @@ export type SetSelectedTemplateAction = Action<'SET_SELECTED_TEMPLATE'> & { temp export type SetSelectedTicketPinAction = Action<'SET_SELECTED_TICKET_PIN'> & { pinId: string }; export type SetPinToDropAction = Action<'SET_PIN_TO_DROP'> & { pinToDrop: string }; export type SetFiltersAction = Action<'SET_FILTERS'> & { filters: TicketsCardFilters }; -export type UpsertFilterAction = Action<'UPSERT_FILTER'> & { filter: CardFilter }; -export type DeleteFilterAction = Action<'DELETE_FILTER'> & { filter: Omit }; +export type UpsertFilterAction = Action<'UPSERT_FILTER'> & { filter: TicketCardFilter }; +export type DeleteFilterAction = Action<'DELETE_FILTER'> & { filter: TicketFilterDescription }; export type ResetFiltersAction = Action<'RESET_FILTERS'>; export type FetchTicketsListAction = Action<'FETCH_TICKETS_LIST'> & TeamspaceProjectAndModel & { isFederation: boolean }; export type SetCardViewAction = Action<'SET_CARD_VIEW'> & { view: TicketsCardViews, props?:any }; @@ -192,8 +192,8 @@ export interface ITicketsCardActionCreators { setSelectedTicketPin: (pinId: string) => SetSelectedTicketPinAction, setPinToDrop: (pinToDrop: string) => SetPinToDropAction, setFilters: (filters: TicketsCardFilters) => SetFiltersAction, - upsertFilter: (filter: CardFilter) => UpsertFilterAction, - deleteFilter: (filter: Omit) => DeleteFilterAction, + upsertFilter: (filter: TicketCardFilter) => UpsertFilterAction, + deleteFilter: (filter: TicketFilterDescription) => DeleteFilterAction, resetFilters: () => ResetFiltersAction, fetchTicketsList: ( teamspace: string, diff --git a/frontend/src/v5/store/tickets/tickets.types.ts b/frontend/src/v5/store/tickets/tickets.types.ts index 25b92b1458..4d175efaa9 100644 --- a/frontend/src/v5/store/tickets/tickets.types.ts +++ b/frontend/src/v5/store/tickets/tickets.types.ts @@ -16,7 +16,7 @@ */ import { RgbArray } from '@/v5/helpers/colors.helper'; -import { FilterOperatorsByProperty } from '@components/viewer/cards/cardFilters/cardFilters.types'; +import { TypesByProperty } from '@components/viewer/cards/cardFilters/cardFilters.types'; import { TicketStatusTypes } from '@controls/chip/chip.types'; export type PropertyTypeDefinition = 'text' | 'longText' | 'boolean' | 'number' | 'date' | 'view' | 'manyOf' | 'oneOf' | 'image' | 'imageList' | 'coords' | 'measurements'; @@ -213,5 +213,6 @@ export type OverridesDicts = { transparencies: MeshIdTransparencyDict, }; -type FilterPropertiesByModule = Record>; -export type TicketsCardFilters = Record>; +export type TicketsCardFilters = { + [module in string]?: TypesByProperty; +}; diff --git a/frontend/src/v5/ui/components/viewer/cards/cardFilters/cardFilters.types.ts b/frontend/src/v5/ui/components/viewer/cards/cardFilters/cardFilters.types.ts index ca5c0f7713..9996e1bd5c 100644 --- a/frontend/src/v5/ui/components/viewer/cards/cardFilters/cardFilters.types.ts +++ b/frontend/src/v5/ui/components/viewer/cards/cardFilters/cardFilters.types.ts @@ -15,19 +15,20 @@ * along with this program. If not, see . */ -export type TicketFilterListItemType = { module: string, property: string, type: CardFilterType }; - export type CardFilterOperator = 'ex' | 'nex' | 'eq' | 'neq' | 'ss' | 'nss' | 'rng' | 'nrng' | 'gt' | 'gte' | 'lt' | 'lte'; export type CardFilterType = 'text' | 'longText' | 'date' | 'pastDate' | 'sequencing' | 'oneOf' | 'manyOf' | 'boolean' | 'number' | 'ticketTitle' | 'ticketId' | 'template'; export type CardFilterValue = string | number | Date; -export type FormFilter = { operator: CardFilterOperator, values: CardFilterValue[] }; +export type BaseFilter = { operator: CardFilterOperator, values: CardFilterValue[] }; +export type TypesByProperty = { + [property in string]: { + [type in CardFilterType]?: BaseFilter; + }; +}; export type CardFilter = { - module: string, property: string, type: CardFilterType, - filter: FormFilter, + filter: BaseFilter, }; - -export type CardFiltersByType = Partial>; -export type FilterOperatorsByProperty = Record; \ No newline at end of file +export type TicketCardFilter = CardFilter & { module: string }; +export type TicketFilterDescription = Omit; \ No newline at end of file diff --git a/frontend/src/v5/ui/components/viewer/cards/cardFilters/filterChip/filterChip.component.tsx b/frontend/src/v5/ui/components/viewer/cards/cardFilters/filterChip/filterChip.component.tsx index 21e99bd919..bc8e5828c2 100644 --- a/frontend/src/v5/ui/components/viewer/cards/cardFilters/filterChip/filterChip.component.tsx +++ b/frontend/src/v5/ui/components/viewer/cards/cardFilters/filterChip/filterChip.component.tsx @@ -20,13 +20,13 @@ import { ChipContainer, DeleteButton, TextWrapper, OperatorIconContainer, Displa import { FILTER_OPERATOR_ICON, FILTER_OPERATOR_LABEL } from '../cardFilters.helpers'; import { Tooltip } from '@mui/material'; import { FormattedMessage } from 'react-intl'; -import { CardFilterType, FormFilter } from '../cardFilters.types'; +import { CardFilterType, BaseFilter } from '../cardFilters.types'; import { formatSimpleDate } from '@/v5/helpers/intl.helper'; type FilterChipProps = { property: string; type: CardFilterType, - filter: FormFilter, + filter: BaseFilter, selected?: boolean; onDelete: () => void; }; diff --git a/frontend/src/v5/ui/components/viewer/cards/cardFilters/filterForm/filterForm.component.tsx b/frontend/src/v5/ui/components/viewer/cards/cardFilters/filterForm/filterForm.component.tsx index 4e897fefd8..96cfcc4233 100644 --- a/frontend/src/v5/ui/components/viewer/cards/cardFilters/filterForm/filterForm.component.tsx +++ b/frontend/src/v5/ui/components/viewer/cards/cardFilters/filterForm/filterForm.component.tsx @@ -16,7 +16,7 @@ */ import { FormattedMessage } from 'react-intl'; -import { CardFilterOperator, CardFilterValue, CardFilter, CardFilterType, FormFilter } from '../cardFilters.types'; +import { CardFilterOperator, CardFilterValue, CardFilter, CardFilterType, BaseFilter } from '../cardFilters.types'; import { FILTER_OPERATOR_LABEL, getFilterFormTitle } from '../cardFilters.helpers'; import { Container, ButtonsContainer, Button } from './filterForm.styles'; import { MenuItem } from '@mui/material'; @@ -32,7 +32,7 @@ type FilterFormProps = { module: string, property: string, type: CardFilterType, - filter?: FormFilter, + filter?: BaseFilter, onSubmit: (newFilter: CardFilter) => void, onCancel: () => void, }; diff --git a/frontend/src/v5/ui/components/viewer/cards/cardFilters/filtersSelection/tickets/list/item/ticketFiltersSelectionItem.component.tsx b/frontend/src/v5/ui/components/viewer/cards/cardFilters/filtersSelection/tickets/list/item/ticketFiltersSelectionItem.component.tsx index ec4419fbb2..95e24a5a50 100644 --- a/frontend/src/v5/ui/components/viewer/cards/cardFilters/filtersSelection/tickets/list/item/ticketFiltersSelectionItem.component.tsx +++ b/frontend/src/v5/ui/components/viewer/cards/cardFilters/filtersSelection/tickets/list/item/ticketFiltersSelectionItem.component.tsx @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -import { TicketFilterListItemType } from '@components/viewer/cards/cardFilters/cardFilters.types'; +import { TicketFilterDescription } from '@components/viewer/cards/cardFilters/cardFilters.types'; import { TYPE_TO_ICON } from '../../ticketFilters.helpers'; import { ExpandIconContainer, FilterIconContainer, MenuItem } from './ticketFiltersSelectionItem.styles'; import ChevronIcon from '@assets/icons/outlined/thin_chevron-outlined.svg'; @@ -23,7 +23,7 @@ import { Highlight } from '@controls/highlight'; import { useContext } from 'react'; import { SearchContext } from '@controls/search/searchContext'; -type TicketFiltersSelectionItemProps = TicketFilterListItemType & { +type TicketFiltersSelectionItemProps = TicketFilterDescription & { onClick: () => void; }; export const TicketFiltersSelectionItem = ({ module, property, type, onClick }: TicketFiltersSelectionItemProps) => { diff --git a/frontend/src/v5/ui/components/viewer/cards/cardFilters/filtersSelection/tickets/list/ticketFiltersSelectionList.component.tsx b/frontend/src/v5/ui/components/viewer/cards/cardFilters/filtersSelection/tickets/list/ticketFiltersSelectionList.component.tsx index 9dfab7d3be..e7d3b8c241 100644 --- a/frontend/src/v5/ui/components/viewer/cards/cardFilters/filtersSelection/tickets/list/ticketFiltersSelectionList.component.tsx +++ b/frontend/src/v5/ui/components/viewer/cards/cardFilters/filtersSelection/tickets/list/ticketFiltersSelectionList.component.tsx @@ -20,13 +20,13 @@ import { useContext } from 'react'; import { TicketFiltersSelectionItem } from './item/ticketFiltersSelectionItem.component'; import { FormattedMessage } from 'react-intl'; import { MenuList, EmptyListMessage } from './ticketFiltersSelectionList.styles'; -import { TicketFilterListItemType } from '../../../cardFilters.types'; +import { TicketFilterDescription } from '../../../cardFilters.types'; type TicketFiltersSelectionListProps = { onFilterClick: (filter) => void; }; export const TicketFiltersSelectionList = ({ onFilterClick }: TicketFiltersSelectionListProps) => { - const { filteredItems, query } = useContext>(SearchContext); + const { filteredItems, query } = useContext>(SearchContext); if (!filteredItems.length) return ( diff --git a/frontend/src/v5/ui/components/viewer/cards/cardFilters/filtersSelection/tickets/ticketFiltersSelection.component.tsx b/frontend/src/v5/ui/components/viewer/cards/cardFilters/filtersSelection/tickets/ticketFiltersSelection.component.tsx index c47188c9e7..63fa1a066a 100644 --- a/frontend/src/v5/ui/components/viewer/cards/cardFilters/filtersSelection/tickets/ticketFiltersSelection.component.tsx +++ b/frontend/src/v5/ui/components/viewer/cards/cardFilters/filtersSelection/tickets/ticketFiltersSelection.component.tsx @@ -24,14 +24,14 @@ import FennelIcon from '@assets/icons/filters/fennel.svg'; import { Tooltip } from '@mui/material'; import { TicketFiltersSelectionList } from './list/ticketFiltersSelectionList.component'; import { SearchInput, DrillDownList, DrillDownItem } from './ticketFiltersSelection.styles'; -import { TicketFilterListItemType } from '../../cardFilters.types'; +import { TicketFilterDescription } from '../../cardFilters.types'; import { FilterForm } from '../../filterForm/filterForm.component'; import { CardFilterActionMenu } from '../../filterForm/filterForm.styles'; import { TicketsCardActionsDispatchers } from '@/v5/services/actionsDispatchers'; export const FilterSelection = () => { const [open, setOpen] = useState(false); - const [selectedFilter, setSelectedFilter] = useState(null); + const [selectedFilter, setSelectedFilter] = useState(null); const tickets = TicketsCardHooksSelectors.selectCurrentTickets(); const unusedFilters = TicketsCardHooksSelectors.selectAvailableTemplatesFilters(); const showFiltersList = !selectedFilter?.property;