ФУНКЦИИ - МЕЖПРОЕКТНАЯ КОММУНИКАЦИЯ: унификация фильтров внешнего контура с внутренним rich-filters слоем
This commit is contained in:
@@ -16,6 +16,7 @@ import { AddFilterButton } from "@/components/rich-filters/add-filters/button";
|
||||
|
||||
type TFiltersToggleProps<P extends TFilterProperty, E extends TExternalFilter> = {
|
||||
filter: IFilterInstance<P, E> | undefined;
|
||||
showAddFilterButtonWhenEmpty?: boolean;
|
||||
};
|
||||
|
||||
const COMMON_CLASSNAME =
|
||||
@@ -24,13 +25,13 @@ const COMMON_CLASSNAME =
|
||||
export const FiltersToggle = observer(function FiltersToggle<P extends TFilterProperty, E extends TExternalFilter>(
|
||||
props: TFiltersToggleProps<P, E>
|
||||
) {
|
||||
const { filter } = props;
|
||||
const { filter, showAddFilterButtonWhenEmpty = true } = props;
|
||||
// derived values
|
||||
const hasAnyConditions = (filter?.allConditionsForDisplay.length ?? 0) > 0;
|
||||
const isFilterRowVisible = filter?.isVisible ?? false;
|
||||
const hasUpdates = filter?.canUpdateView === true && filter?.hasChanges === true;
|
||||
const showFilterRowChangesPill = hasUpdates || hasAnyConditions === true;
|
||||
const showAddFilterButton = !hasAnyConditions && !isFilterRowVisible && !hasUpdates;
|
||||
const showAddFilterButton = showAddFilterButtonWhenEmpty && !hasAnyConditions && !isFilterRowVisible && !hasUpdates;
|
||||
|
||||
const handleToggleFilter = () => {
|
||||
if (!filter) {
|
||||
|
||||
@@ -9,6 +9,8 @@ const FILTER_LABEL_MAP: Record<string, string> = {
|
||||
Label: "Метка",
|
||||
Labels: "Метки",
|
||||
Project: "Проект",
|
||||
Projects: "Проекты",
|
||||
Contour: "Контур",
|
||||
"Created by": "Автор",
|
||||
"Created at": "Дата создания",
|
||||
"Updated at": "Дата обновления",
|
||||
|
||||
@@ -24,5 +24,5 @@ export const WorkItemFiltersToggle = observer(function WorkItemFiltersToggle(pro
|
||||
// derived values
|
||||
const filter = getFilter(entityType, entityId);
|
||||
|
||||
return <FiltersToggle filter={filter} />;
|
||||
return <FiltersToggle filter={filter} showAddFilterButtonWhenEmpty={false} />;
|
||||
});
|
||||
|
||||
+11
@@ -50,6 +50,7 @@ export interface IProjectExternalContoursBoardStore {
|
||||
isFiltering: boolean;
|
||||
isSortingDefault: boolean;
|
||||
clearFilters: (workspaceSlug: string, projectId: string) => Promise<void>;
|
||||
replaceFilters: (workspaceSlug: string, projectId: string, filters: Partial<TExternalContourBoardFilter>) => Promise<void>;
|
||||
updateFilters: (workspaceSlug: string, projectId: string, filters: Partial<TExternalContourBoardFilter>) => Promise<void>;
|
||||
updateSorting: (workspaceSlug: string, projectId: string, sorting: TExternalContourBoardSorting) => Promise<void>;
|
||||
upsertBoardItems: (items: TExternalContourRequest[]) => void;
|
||||
@@ -99,6 +100,7 @@ export class ProjectExternalContoursBoardStore implements IProjectExternalContou
|
||||
clearFilters: action,
|
||||
fetchBoard: action,
|
||||
handleCurrentTab: action,
|
||||
replaceFilters: action,
|
||||
updateFilters: action,
|
||||
updateSorting: action,
|
||||
upsertBoardItems: action,
|
||||
@@ -161,6 +163,15 @@ export class ProjectExternalContoursBoardStore implements IProjectExternalContou
|
||||
await this.fetchBoard(workspaceSlug, projectId);
|
||||
};
|
||||
|
||||
replaceFilters = async (
|
||||
workspaceSlug: string,
|
||||
projectId: string,
|
||||
filters: Partial<TExternalContourBoardFilter>
|
||||
) => {
|
||||
this.filters = sanitizeBoardFilters(filters);
|
||||
await this.fetchBoard(workspaceSlug, projectId);
|
||||
};
|
||||
|
||||
updateSorting = async (workspaceSlug: string, projectId: string, sorting: TExternalContourBoardSorting) => {
|
||||
this.sorting = sorting;
|
||||
await this.fetchBoard(workspaceSlug, projectId);
|
||||
|
||||
Reference in New Issue
Block a user