diff --git a/frontend/src/v5/store/tickets/card/ticketsCard.redux.ts b/frontend/src/v5/store/tickets/card/ticketsCard.redux.ts index 7e3ced9031..cde4018fcb 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, FilterPropertiesByModule } from '../tickets.types'; import { TeamspaceProjectAndModel } from '../../store.types'; -import { TicketCardFilter, TicketFilterDescription } from '@components/viewer/cards/cardFilters/cardFilters.types'; +import { TicketCardFilter, TicketCardFilterDescription } from '@components/viewer/cards/cardFilters/cardFilters.types'; import { get, isEmpty, set, unset } from 'lodash'; export const { Types: TicketsCardTypes, Creators: TicketsCardActions } = createActions({ @@ -166,7 +166,7 @@ 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 UpsertFilterAction = Action<'UPSERT_FILTER'> & { filter: TicketCardFilter }; -export type DeleteFilterAction = Action<'DELETE_FILTER'> & { filter: TicketFilterDescription }; +export type DeleteFilterAction = Action<'DELETE_FILTER'> & { filter: TicketCardFilterDescription }; 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 }; @@ -185,7 +185,7 @@ export interface ITicketsCardActionCreators { setSelectedTicketPin: (pinId: string) => SetSelectedTicketPinAction, setPinToDrop: (pinToDrop: string) => SetPinToDropAction, upsertFilter: (filter: TicketCardFilter) => UpsertFilterAction, - deleteFilter: (filter: TicketFilterDescription) => DeleteFilterAction, + deleteFilter: (filter: TicketCardFilterDescription) => 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 b36ced5567..70bcb86043 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 { FilterTypesByProperty } from '@components/viewer/cards/cardFilters/cardFilters.types'; +import { BaseFilter, CardFilterType } 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,6 +213,11 @@ export type OverridesDicts = { transparencies: MeshIdTransparencyDict, }; +export type FilterTypesByProperty = { + [property in string]: { + [type in CardFilterType]?: BaseFilter; + }; +}; export type FilterPropertiesByModule = { [module in string]?: FilterTypesByProperty; }; 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 6512145699..0750006162 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 @@ -19,11 +19,6 @@ export type CardFilterOperator = 'ex' | 'nex' | 'eq' | 'neq' | 'ss' | 'nss' | 'r export type CardFilterType = 'text' | 'longText' | 'date' | 'pastDate' | 'sequencing' | 'oneOf' | 'manyOf' | 'boolean' | 'number' | 'ticketTitle' | 'ticketId' | 'template'; export type CardFilterValue = string | number | Date; export type BaseFilter = { operator: CardFilterOperator, values: CardFilterValue[] }; -export type FilterTypesByProperty = { - [property in string]: { - [type in CardFilterType]?: BaseFilter; - }; -}; export type CardFilter = { property: string, @@ -31,4 +26,4 @@ export type CardFilter = { filter: BaseFilter, }; export type TicketCardFilter = CardFilter & { module: string }; -export type TicketFilterDescription = Omit; \ No newline at end of file +export type TicketCardFilterDescription = Omit; \ No newline at end of file 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 95e24a5a50..0cf7e10175 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 { TicketFilterDescription } from '@components/viewer/cards/cardFilters/cardFilters.types'; +import { TicketCardFilterDescription } 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 = TicketFilterDescription & { +type TicketFiltersSelectionItemProps = TicketCardFilterDescription & { 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 e7d3b8c241..4cc0451f08 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 { TicketFilterDescription } from '../../../cardFilters.types'; +import { TicketCardFilterDescription } 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/ticketFilters.helpers.ts b/frontend/src/v5/ui/components/viewer/cards/cardFilters/filtersSelection/tickets/ticketFilters.helpers.ts index 62ba4f3b98..aed55442b8 100644 --- a/frontend/src/v5/ui/components/viewer/cards/cardFilters/filtersSelection/tickets/ticketFilters.helpers.ts +++ b/frontend/src/v5/ui/components/viewer/cards/cardFilters/filtersSelection/tickets/ticketFilters.helpers.ts @@ -16,7 +16,7 @@ */ import { formatMessage } from '@/v5/services/intl'; -import { ITemplate, FilterPropertiesByModule } from '@/v5/store/tickets/tickets.types'; +import { ITemplate, FilterPropertiesByModule, FilterTypesByProperty } from '@/v5/store/tickets/tickets.types'; import BooleanIcon from '@assets/icons/filters/boolean.svg'; import ListIcon from '@assets/icons/filters/list.svg'; import NumberIcon from '@assets/icons/filters/number.svg'; @@ -24,7 +24,7 @@ import TemplateIcon from '@assets/icons/filters/template.svg'; import TextIcon from '@assets/icons/filters/text.svg'; import CalendarIcon from '@assets/icons/outlined/calendar-outlined.svg'; import { sortBy, uniqBy } from 'lodash'; -import { CardFilter, CardFilterType, FilterTypesByProperty, BaseFilter, TicketFilterDescription } from '../../cardFilters.types'; +import { CardFilter, CardFilterType, BaseFilter, TicketCardFilterDescription } from '../../cardFilters.types'; export const TYPE_TO_ICON: Record = { 'template': TemplateIcon, @@ -43,27 +43,27 @@ export const TYPE_TO_ICON: Record = { const VALID_FILTERING_PROPERTY_TYPES = Object.keys(TYPE_TO_ICON); -const DEFAULT_FILTERS: TicketFilterDescription[] = [ +const DEFAULT_FILTERS: TicketCardFilterDescription[] = [ { module: '', type: 'ticketTitle', property: formatMessage({ defaultMessage: 'Ticket title', id: 'viewer.card.filters.element.ticketTitle' }) }, { module: '', type: 'ticketId', property: formatMessage({ defaultMessage: 'Ticket ID', id: 'viewer.card.filters.element.ticketId' }) }, { module: '', type: 'template', property: formatMessage({ defaultMessage: 'Ticket template', id: 'viewer.card.filters.element.ticketTemplate' }) }, ]; -const propertiesToValidFilters = (properties: { name: string, type: string }[], module: string = ''): TicketFilterDescription[] => properties +const propertiesToValidFilters = (properties: { name: string, type: string }[], module: string = ''): TicketCardFilterDescription[] => properties .filter(({ type }) => VALID_FILTERING_PROPERTY_TYPES.includes(type)) .map(({ name, type }) => ({ module, property: name, type, - }) as TicketFilterDescription); + }) as TicketCardFilterDescription); -const templateToFilters = (template: ITemplate): TicketFilterDescription[] => [ +const templateToFilters = (template: ITemplate): TicketCardFilterDescription[] => [ ...propertiesToValidFilters(template.properties, ''), ...template.modules.flatMap(({ properties, name, type }) => propertiesToValidFilters(properties, name || type)), ]; -export const templatesToFilters = (templates: ITemplate[]): TicketFilterDescription[] => { - let filters: TicketFilterDescription[] = [...templates.flatMap(templateToFilters)]; +export const templatesToFilters = (templates: ITemplate[]): TicketCardFilterDescription[] => { + let filters: TicketCardFilterDescription[] = [...templates.flatMap(templateToFilters)]; filters = uniqBy(filters, (f) => f.module + f.property + f.type); filters = sortBy(filters, 'module'); 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 63fa1a066a..b685dd9f97 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 { TicketFilterDescription } from '../../cardFilters.types'; +import { TicketCardFilterDescription } 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;