Skip to content

Commit

Permalink
ISSUE #5257 - simplify data types names
Browse files Browse the repository at this point in the history
  • Loading branch information
Amantini1997 committed Nov 27, 2024
1 parent 3ef462e commit 8445326
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 26 deletions.
10 changes: 5 additions & 5 deletions frontend/src/v5/store/tickets/card/ticketsCard.redux.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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<CardFilter, 'filter'> };
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 };
Expand All @@ -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<CardFilter, 'filter'>) => DeleteFilterAction,
upsertFilter: (filter: TicketCardFilter) => UpsertFilterAction,
deleteFilter: (filter: TicketFilterDescription) => DeleteFilterAction,
resetFilters: () => ResetFiltersAction,
fetchTicketsList: (
teamspace: string,
Expand Down
7 changes: 4 additions & 3 deletions frontend/src/v5/store/tickets/tickets.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -213,5 +213,6 @@ export type OverridesDicts = {
transparencies: MeshIdTransparencyDict,
};

type FilterPropertiesByModule = Record<string, Partial<FilterOperatorsByProperty>>;
export type TicketsCardFilters = Record<string, Partial<FilterPropertiesByModule>>;
export type TicketsCardFilters = {
[module in string]?: TypesByProperty;
};
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,20 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

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<Record<CardFilterType, FormFilter>>;
export type FilterOperatorsByProperty = Record<CardFilterOperator, CardFiltersByType>;
export type TicketCardFilter = CardFilter & { module: string };
export type TicketFilterDescription = Omit<TicketCardFilter, 'filter'>;
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -32,7 +32,7 @@ type FilterFormProps = {
module: string,
property: string,
type: CardFilterType,
filter?: FormFilter,
filter?: BaseFilter,
onSubmit: (newFilter: CardFilter) => void,
onCancel: () => void,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

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';
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) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<SearchContextType<TicketFilterListItemType>>(SearchContext);
const { filteredItems, query } = useContext<SearchContextType<TicketFilterDescription>>(SearchContext);

if (!filteredItems.length) return (
<EmptyListMessage>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<TicketFilterListItemType>(null);
const [selectedFilter, setSelectedFilter] = useState<TicketFilterDescription>(null);
const tickets = TicketsCardHooksSelectors.selectCurrentTickets();
const unusedFilters = TicketsCardHooksSelectors.selectAvailableTemplatesFilters();
const showFiltersList = !selectedFilter?.property;
Expand Down

0 comments on commit 8445326

Please sign in to comment.