fix profile issue filters and kanban

This commit is contained in:
rahulramesha 2023-11-27 17:05:08 +05:30
parent 2bf7e63625
commit edd1f6e423
4 changed files with 68 additions and 39 deletions

View File

@ -18,6 +18,7 @@ export const ProfileIssuesAppliedFiltersRoot: React.FC = observer(() => {
const { const {
workspace: { workspaceLabels }, workspace: { workspaceLabels },
workspaceProfileIssuesFilter: { issueFilters, updateFilters }, workspaceProfileIssuesFilter: { issueFilters, updateFilters },
projectMember: { projectMembers },
} = useMobxStore(); } = useMobxStore();
const userFilters = issueFilters?.filters; const userFilters = issueFilters?.filters;
@ -64,7 +65,7 @@ export const ProfileIssuesAppliedFiltersRoot: React.FC = observer(() => {
handleClearAllFilters={handleClearAllFilters} handleClearAllFilters={handleClearAllFilters}
handleRemoveFilter={handleRemoveFilter} handleRemoveFilter={handleRemoveFilter}
labels={workspaceLabels ?? []} labels={workspaceLabels ?? []}
members={[]} members={projectMembers?.map((m) => m.member)}
states={[]} states={[]}
/> />
</div> </div>

View File

@ -5,6 +5,7 @@ import { IIssueDisplayFilterOptions, IIssueDisplayProperties, IIssueFilterOption
import { EFilterType } from "store/issues/types"; import { EFilterType } from "store/issues/types";
import { handleIssueQueryParamsByLayout } from "helpers/issue.helper"; import { handleIssueQueryParamsByLayout } from "helpers/issue.helper";
import { IssueFilterBaseStore } from "../project-issues/base-issue-filter.store"; import { IssueFilterBaseStore } from "../project-issues/base-issue-filter.store";
import { isEmpty } from "lodash";
interface IProjectIssuesFiltersOptions { interface IProjectIssuesFiltersOptions {
filters: IIssueFilterOptions; filters: IIssueFilterOptions;
@ -121,12 +122,18 @@ export class GlobalIssuesFilterStore extends IssueFilterBaseStore implements IGl
let _projectIssueFilters = this.projectIssueFilters; let _projectIssueFilters = this.projectIssueFilters;
if (!_projectIssueFilters) _projectIssueFilters = {}; if (!_projectIssueFilters) _projectIssueFilters = {};
if (!_projectIssueFilters[workspaceSlug]) if (!_projectIssueFilters[workspaceSlug]) {
_projectIssueFilters[workspaceSlug] = { filters: {}, displayFilters: {}, displayProperties: {} }; _projectIssueFilters[workspaceSlug] = { displayProperties: {} } as IProjectIssuesDisplayOptions;
}
if (
isEmpty(_projectIssueFilters[workspaceSlug].filters) ||
isEmpty(_projectIssueFilters[workspaceSlug].displayFilters)
) {
_projectIssueFilters[workspaceSlug] = { _projectIssueFilters[workspaceSlug] = {
..._projectIssueFilters[workspaceSlug], ..._projectIssueFilters[workspaceSlug],
...issueFilters, ...issueFilters,
}; };
}
runInAction(() => { runInAction(() => {
this.projectIssueFilters = _projectIssueFilters; this.projectIssueFilters = _projectIssueFilters;
@ -192,15 +199,15 @@ export class GlobalIssuesFilterStore extends IssueFilterBaseStore implements IGl
fetchDisplayProperties = async (workspaceSlug: string) => { fetchDisplayProperties = async (workspaceSlug: string) => {
try { try {
const displayProperties: IIssueDisplayProperties = { const displayProperties: IIssueDisplayProperties = {
assignee: false, assignee: true,
start_date: false, start_date: true,
due_date: false, due_date: true,
labels: false, labels: false,
key: false, key: false,
priority: false, priority: true,
state: false, state: false,
sub_issue_count: false, sub_issue_count: true,
link: false, link: true,
attachment_count: false, attachment_count: false,
estimate: false, estimate: false,
created_on: false, created_on: false,
@ -209,12 +216,15 @@ export class GlobalIssuesFilterStore extends IssueFilterBaseStore implements IGl
let _projectIssueFilters = { ...this.projectIssueFilters }; let _projectIssueFilters = { ...this.projectIssueFilters };
if (!_projectIssueFilters) _projectIssueFilters = {}; if (!_projectIssueFilters) _projectIssueFilters = {};
if (!_projectIssueFilters[workspaceSlug]) if (!_projectIssueFilters[workspaceSlug]) {
_projectIssueFilters[workspaceSlug] = { filters: {}, displayFilters: {}, displayProperties: {} }; _projectIssueFilters[workspaceSlug] = { filters: {}, displayFilters: {} } as IProjectIssuesDisplayOptions;
}
if (isEmpty(_projectIssueFilters[workspaceSlug].displayProperties)) {
_projectIssueFilters[workspaceSlug] = { _projectIssueFilters[workspaceSlug] = {
..._projectIssueFilters[workspaceSlug], ..._projectIssueFilters[workspaceSlug],
displayProperties: displayProperties, displayProperties: displayProperties,
}; };
}
runInAction(() => { runInAction(() => {
this.projectIssueFilters = _projectIssueFilters; this.projectIssueFilters = _projectIssueFilters;

View File

@ -5,6 +5,7 @@ import { IIssueDisplayFilterOptions, IIssueDisplayProperties, IIssueFilterOption
import { EFilterType } from "store/issues/types"; import { EFilterType } from "store/issues/types";
import { handleIssueQueryParamsByLayout } from "helpers/issue.helper"; import { handleIssueQueryParamsByLayout } from "helpers/issue.helper";
import { IssueFilterBaseStore } from "../project-issues/base-issue-filter.store"; import { IssueFilterBaseStore } from "../project-issues/base-issue-filter.store";
import { isEmpty } from "lodash";
interface IProjectIssuesFiltersOptions { interface IProjectIssuesFiltersOptions {
filters: IIssueFilterOptions; filters: IIssueFilterOptions;
@ -121,12 +122,18 @@ export class ProfileIssuesFilterStore extends IssueFilterBaseStore implements IP
let _projectIssueFilters = this.projectIssueFilters; let _projectIssueFilters = this.projectIssueFilters;
if (!_projectIssueFilters) _projectIssueFilters = {}; if (!_projectIssueFilters) _projectIssueFilters = {};
if (!_projectIssueFilters[workspaceSlug]) if (!_projectIssueFilters[workspaceSlug]) {
_projectIssueFilters[workspaceSlug] = { filters: {}, displayFilters: {}, displayProperties: {} }; _projectIssueFilters[workspaceSlug] = { displayProperties: {} } as IProjectIssuesDisplayOptions;
}
if (
isEmpty(_projectIssueFilters[workspaceSlug].filters) ||
isEmpty(_projectIssueFilters[workspaceSlug].displayFilters)
) {
_projectIssueFilters[workspaceSlug] = { _projectIssueFilters[workspaceSlug] = {
..._projectIssueFilters[workspaceSlug], ..._projectIssueFilters[workspaceSlug],
...issueFilters, ...issueFilters,
}; };
}
runInAction(() => { runInAction(() => {
this.projectIssueFilters = _projectIssueFilters; this.projectIssueFilters = _projectIssueFilters;
@ -184,7 +191,6 @@ export class ProfileIssuesFilterStore extends IssueFilterBaseStore implements IP
return _filters; return _filters;
} catch (error) { } catch (error) {
this.fetchDisplayFilters(workspaceSlug);
throw error; throw error;
} }
}; };
@ -192,15 +198,15 @@ export class ProfileIssuesFilterStore extends IssueFilterBaseStore implements IP
fetchDisplayProperties = async (workspaceSlug: string) => { fetchDisplayProperties = async (workspaceSlug: string) => {
try { try {
const displayProperties: IIssueDisplayProperties = { const displayProperties: IIssueDisplayProperties = {
assignee: false, assignee: true,
start_date: false, start_date: true,
due_date: false, due_date: true,
labels: false, labels: false,
key: false, key: false,
priority: false, priority: true,
state: false, state: false,
sub_issue_count: false, sub_issue_count: true,
link: false, link: true,
attachment_count: false, attachment_count: false,
estimate: false, estimate: false,
created_on: false, created_on: false,
@ -209,12 +215,15 @@ export class ProfileIssuesFilterStore extends IssueFilterBaseStore implements IP
let _projectIssueFilters = { ...this.projectIssueFilters }; let _projectIssueFilters = { ...this.projectIssueFilters };
if (!_projectIssueFilters) _projectIssueFilters = {}; if (!_projectIssueFilters) _projectIssueFilters = {};
if (!_projectIssueFilters[workspaceSlug]) if (!_projectIssueFilters[workspaceSlug]) {
_projectIssueFilters[workspaceSlug] = { filters: {}, displayFilters: {}, displayProperties: {} }; _projectIssueFilters[workspaceSlug] = { filters: {}, displayFilters: {} } as IProjectIssuesDisplayOptions;
}
if (isEmpty(_projectIssueFilters[workspaceSlug].displayProperties)) {
_projectIssueFilters[workspaceSlug] = { _projectIssueFilters[workspaceSlug] = {
..._projectIssueFilters[workspaceSlug], ..._projectIssueFilters[workspaceSlug],
displayProperties: displayProperties, displayProperties: displayProperties,
}; };
}
runInAction(() => { runInAction(() => {
this.projectIssueFilters = _projectIssueFilters; this.projectIssueFilters = _projectIssueFilters;
@ -242,7 +251,6 @@ export class ProfileIssuesFilterStore extends IssueFilterBaseStore implements IP
return properties; return properties;
} catch (error) { } catch (error) {
this.fetchDisplayProperties(workspaceSlug);
throw error; throw error;
} }
}; };

View File

@ -102,6 +102,7 @@ export class ProfileIssuesStore extends IssueBaseStore implements IProfileIssues
const displayFilters = this.rootStore?.workspaceProfileIssuesFilter?.issueFilters?.displayFilters; const displayFilters = this.rootStore?.workspaceProfileIssuesFilter?.issueFilters?.displayFilters;
if (!displayFilters) return undefined; if (!displayFilters) return undefined;
const subGroupBy = displayFilters?.sub_group_by;
const groupBy = displayFilters?.group_by; const groupBy = displayFilters?.group_by;
const orderBy = displayFilters?.order_by; const orderBy = displayFilters?.order_by;
const layout = displayFilters?.layout; const layout = displayFilters?.layout;
@ -113,6 +114,15 @@ export class ProfileIssuesStore extends IssueBaseStore implements IProfileIssues
if (layout === "list" && orderBy) { if (layout === "list" && orderBy) {
if (groupBy) issues = this.groupedIssues(groupBy, orderBy, this.issues[currentUserId][this.currentUserIssueTab]); if (groupBy) issues = this.groupedIssues(groupBy, orderBy, this.issues[currentUserId][this.currentUserIssueTab]);
else issues = this.unGroupedIssues(orderBy, this.issues[currentUserId][this.currentUserIssueTab]); else issues = this.unGroupedIssues(orderBy, this.issues[currentUserId][this.currentUserIssueTab]);
} else if (layout === "kanban" && groupBy && orderBy) {
if (subGroupBy)
issues = this.subGroupedIssues(
subGroupBy,
groupBy,
orderBy,
this.issues[currentUserId][this.currentUserIssueTab]
);
else issues = this.groupedIssues(groupBy, orderBy, this.issues[currentUserId][this.currentUserIssueTab]);
} }
return issues; return issues;