ФУНКЦИИ - МЕЖПРОЕКТНАЯ КОММУНИКАЦИЯ: отказ от open-closed табов и стабилизация фильтров внешних контуров

This commit is contained in:
DCCONSTRUCTIONS
2026-04-21 08:32:20 +03:00
parent c6645bb4fc
commit 91906e917e
10 changed files with 38 additions and 129 deletions
@@ -59,7 +59,7 @@ export class ProjectExternalContoursBoardStore implements IProjectExternalContou
currentProjectId = "";
currentTab: TInboxIssueCurrentTab = EInboxIssueCurrentTab.OPEN;
error: { message: string; status: "init-error" } | undefined = undefined;
filters: Partial<TExternalContourBoardFilter> = { status: [EInboxIssueCurrentTab.OPEN] };
filters: Partial<TExternalContourBoardFilter> = {};
items: Record<string, TExternalContourRequest> = {};
loader: TLoader = "init-loading";
sorting: TExternalContourBoardSorting = DEFAULT_SORTING;
@@ -145,10 +145,6 @@ export class ProjectExternalContoursBoardStore implements IProjectExternalContou
handleCurrentTab = async (workspaceSlug: string, projectId: string, tab: TInboxIssueCurrentTab) => {
this.currentTab = tab;
this.filters = sanitizeBoardFilters({
...this.filters,
status: [tab],
});
await this.fetchBoard(workspaceSlug, projectId, tab);
};
@@ -160,30 +156,26 @@ export class ProjectExternalContoursBoardStore implements IProjectExternalContou
this.filters = sanitizeBoardFilters({
...this.filters,
...filters,
status: [this.currentTab],
});
await this.fetchBoard(workspaceSlug, projectId, this.currentTab);
await this.fetchBoard(workspaceSlug, projectId);
};
updateSorting = async (workspaceSlug: string, projectId: string, sorting: TExternalContourBoardSorting) => {
this.sorting = sorting;
await this.fetchBoard(workspaceSlug, projectId, this.currentTab);
await this.fetchBoard(workspaceSlug, projectId);
};
clearFilters = async (workspaceSlug: string, projectId: string) => {
this.filters = { status: [this.currentTab] };
this.filters = {};
this.sorting = DEFAULT_SORTING;
await this.fetchBoard(workspaceSlug, projectId, this.currentTab);
await this.fetchBoard(workspaceSlug, projectId);
};
fetchBoard = async (workspaceSlug: string, projectId: string, tab = this.currentTab) => {
const hasProjectChanged = !!this.currentProjectId && this.currentProjectId !== projectId;
const isInitialLoad = this.hydratedProjectId !== projectId;
const nextFilters = sanitizeBoardFilters({
...(hasProjectChanged ? {} : this.filters),
status: [tab],
});
const nextFilters = sanitizeBoardFilters(hasProjectChanged ? {} : this.filters);
const nextSorting = hasProjectChanged ? DEFAULT_SORTING : this.sorting;
const requestId = ++this.lastIssuedRequestId;
@@ -213,16 +205,22 @@ export class ProjectExternalContoursBoardStore implements IProjectExternalContou
this.filters = sanitizeBoardFilters(response.filters || nextFilters);
this.sorting = response.sorting || nextSorting;
this.hydratedProjectId = projectId;
let openCount = 0;
let closedCount = 0;
response.columns.forEach((column) => {
this.columnIdsMap[column.key] = column.results.map((request) => request.id);
this.columnCountMap[column.key] = column.total_count;
column.results.forEach((request) => {
if (request.status === EInboxIssueCurrentTab.CLOSED) closedCount += 1;
else openCount += 1;
});
this.upsertBoardItems(column.results);
});
this.tabCountMap = {
...this.tabCountMap,
[tab]: response.columns.reduce((total, column) => total + column.total_count, 0),
[EInboxIssueCurrentTab.OPEN]: openCount,
[EInboxIssueCurrentTab.CLOSED]: closedCount,
};
this.loader = undefined;