forked from github/plane
chore: fixing up store
This commit is contained in:
commit
e96bc77215
@ -212,13 +212,12 @@ class IssueFilterStore implements IIssueFilterStore {
|
|||||||
|
|
||||||
// computed
|
// computed
|
||||||
issueLayout: computed,
|
issueLayout: computed,
|
||||||
projectDisplayProperties: computed,
|
|
||||||
userFilters: computed,
|
userFilters: computed,
|
||||||
|
|
||||||
// actions
|
// actions
|
||||||
getComputedFilters: action,
|
getComputedFilters: action,
|
||||||
|
|
||||||
handleUserFilter: action,
|
handleIssueFilter: action,
|
||||||
|
|
||||||
// getWorkspaceMyIssuesFilters: action,
|
// getWorkspaceMyIssuesFilters: action,
|
||||||
// updateWorkspaceMyIssuesFilters: action,
|
// updateWorkspaceMyIssuesFilters: action,
|
||||||
@ -265,287 +264,40 @@ class IssueFilterStore implements IIssueFilterStore {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
get projectDisplayProperties() {
|
|
||||||
// if (!this.workspaceId || !this.projectId) return null;
|
|
||||||
// return this.issueFilters?.[this.workspaceId]?.project_issue_properties?.[this.projectId]?.display_properties as any;
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
get userFilters() {
|
get userFilters() {
|
||||||
if (!this.projectId) return null;
|
const projectId = this.rootStore?.project?.projectId;
|
||||||
if (this.issueView === "my_issues")
|
const moduleId = this.rootStore?.module?.moduleId;
|
||||||
return {
|
const cycleId = this.rootStore?.cycle?.cycleId;
|
||||||
...this.issueFilters?.[this.workspaceId]?.my_issue_properties,
|
const viewId = this.rootStore?.view?.viewId;
|
||||||
display_properties_id: null,
|
const _issueView = this.issueView;
|
||||||
};
|
|
||||||
|
|
||||||
if (!this.projectId) return null;
|
if (!projectId || !_issueView) return null;
|
||||||
let _issueFilters: {
|
const currentIssueViewId: string | null =
|
||||||
|
_issueView === "issues" && projectId
|
||||||
|
? projectId
|
||||||
|
: _issueView === "modules" && moduleId
|
||||||
|
? moduleId
|
||||||
|
: _issueView === "cycles" && cycleId
|
||||||
|
? cycleId
|
||||||
|
: _issueView === "cycles" && viewId
|
||||||
|
? viewId
|
||||||
|
: null;
|
||||||
|
|
||||||
|
if (!currentIssueViewId) return null;
|
||||||
|
const _issueFilters: {
|
||||||
filters: IIssueFilter | null;
|
filters: IIssueFilter | null;
|
||||||
display_filters: IIssueDisplayFilters;
|
display_filters: IIssueDisplayFilters;
|
||||||
display_properties_id: string;
|
display_properties_id: string;
|
||||||
display_properties: IIssueDisplayProperties;
|
display_properties: IIssueDisplayProperties;
|
||||||
} = {
|
} = {
|
||||||
filters: null,
|
filters: this.issueFilters?.[projectId]?.[_issueView]?.[currentIssueViewId]?.filters,
|
||||||
display_filters:
|
display_filters: this.issueFilters?.[projectId]?.display_filters,
|
||||||
this.issueFilters?.[this.workspaceId]?.project_issue_properties?.[this.projectId]?.issues?.display_filters,
|
display_properties_id: this.issueFilters?.[projectId]?.display_properties_id,
|
||||||
display_properties_id:
|
display_properties: this.issueFilters?.[projectId]?.display_properties,
|
||||||
this.issueFilters?.[this.workspaceId]?.project_issue_properties?.[this.projectId]?.display_properties_id,
|
|
||||||
display_properties:
|
|
||||||
this.issueFilters?.[this.workspaceId]?.project_issue_properties?.[this.projectId]?.display_properties,
|
|
||||||
};
|
|
||||||
|
|
||||||
if (this.issueView === "issues") {
|
|
||||||
_issueFilters = {
|
|
||||||
..._issueFilters,
|
|
||||||
filters: this.issueFilters?.[this.workspaceId]?.project_issue_properties?.[this.projectId]?.issues?.filters,
|
|
||||||
};
|
};
|
||||||
return _issueFilters;
|
return _issueFilters;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.issueView === "modules" && this.moduleId) {
|
|
||||||
_issueFilters = {
|
|
||||||
..._issueFilters,
|
|
||||||
filters:
|
|
||||||
this.issueFilters?.[this.workspaceId]?.project_issue_properties?.[this.projectId]?.modules?.[this.moduleId]
|
|
||||||
?.filters,
|
|
||||||
};
|
|
||||||
return _issueFilters;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.issueView === "cycles" && this.cycleId) {
|
|
||||||
_issueFilters = {
|
|
||||||
..._issueFilters,
|
|
||||||
filters:
|
|
||||||
this.issueFilters?.[this.workspaceId]?.project_issue_properties?.[this.projectId]?.cycles?.[this.cycleId]
|
|
||||||
?.filters,
|
|
||||||
};
|
|
||||||
return _issueFilters;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.issueView === "views" && this.viewId) {
|
|
||||||
_issueFilters = {
|
|
||||||
..._issueFilters,
|
|
||||||
filters:
|
|
||||||
this.issueFilters?.[this.workspaceId]?.project_issue_properties?.[this.projectId]?.views?.[this.viewId]
|
|
||||||
?.filters,
|
|
||||||
};
|
|
||||||
return _issueFilters;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
handleUserFilter = (
|
|
||||||
filter_type: "filters" | "display_filters" | "display_properties",
|
|
||||||
filter_key: string,
|
|
||||||
value: any
|
|
||||||
) => {
|
|
||||||
// if (!this.workspaceId) return null;
|
|
||||||
// if (this.issueView === "my_issues") {
|
|
||||||
// this.issueFilters = {
|
|
||||||
// ...this.issueFilters,
|
|
||||||
// [this.workspaceId]: {
|
|
||||||
// ...this.issueFilters?.[this.workspaceId],
|
|
||||||
// my_issue_properties: {
|
|
||||||
// ...this.issueFilters?.[this.workspaceId]?.my_issue_properties,
|
|
||||||
// [filter_type]: {
|
|
||||||
// ...this.issueFilters?.[this.workspaceId]?.my_issue_properties?.[filter_type],
|
|
||||||
// [filter_key]: value,
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// };
|
|
||||||
// this.updateWorkspaceMyIssuesFilters(this.workspaceId, this.userFilters);
|
|
||||||
// }
|
|
||||||
// if (!this.projectId) return null;
|
|
||||||
// if (filter_type === "display_properties") {
|
|
||||||
// this.issueFilters = {
|
|
||||||
// ...this.issueFilters,
|
|
||||||
// [this.workspaceId]: {
|
|
||||||
// ...this.issueFilters?.[this.workspaceId],
|
|
||||||
// project_issue_properties: {
|
|
||||||
// ...this.issueFilters?.[this.workspaceId]?.project_issue_properties,
|
|
||||||
// [this.projectId]: {
|
|
||||||
// ...this.issueFilters?.[this.workspaceId]?.project_issue_properties?.[this.projectId],
|
|
||||||
// display_properties: {
|
|
||||||
// ...this.issueFilters?.[this.workspaceId]?.project_issue_properties?.[this.projectId]
|
|
||||||
// ?.display_properties,
|
|
||||||
// [filter_key]: value,
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// };
|
|
||||||
// if (this.userFilters?.display_properties_id) {
|
|
||||||
// this.updateProjectDisplayProperties(
|
|
||||||
// this.workspaceId,
|
|
||||||
// this.projectId,
|
|
||||||
// this.userFilters?.display_properties_id,
|
|
||||||
// this.userFilters?.display_properties
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if (filter_type === "display_filters") {
|
|
||||||
// this.issueFilters = {
|
|
||||||
// ...this.issueFilters,
|
|
||||||
// [this.workspaceId]: {
|
|
||||||
// ...this.issueFilters?.[this.workspaceId],
|
|
||||||
// project_issue_properties: {
|
|
||||||
// ...this.issueFilters?.[this.workspaceId]?.project_issue_properties,
|
|
||||||
// [this.projectId]: {
|
|
||||||
// ...this.issueFilters?.[this.workspaceId]?.project_issue_properties?.[this.projectId],
|
|
||||||
// issues: {
|
|
||||||
// ...this.issueFilters?.[this.workspaceId]?.project_issue_properties?.[this.projectId]?.issues,
|
|
||||||
// [filter_type]: {
|
|
||||||
// ...this.issueFilters?.[this.workspaceId]?.project_issue_properties?.[this.projectId]?.issues?.[
|
|
||||||
// filter_type
|
|
||||||
// ],
|
|
||||||
// [filter_key]: value,
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// };
|
|
||||||
// this.updateProjectDisplayFilters(this.workspaceId, this.projectId, {
|
|
||||||
// filters: this.userFilters?.filters,
|
|
||||||
// display_filters: this.userFilters?.display_filters,
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// if (filter_type === "filters") {
|
|
||||||
// if (this.issueView === "issues") {
|
|
||||||
// this.issueFilters = {
|
|
||||||
// ...this.issueFilters,
|
|
||||||
// [this.workspaceId]: {
|
|
||||||
// ...this.issueFilters?.[this.workspaceId],
|
|
||||||
// project_issue_properties: {
|
|
||||||
// ...this.issueFilters?.[this.workspaceId]?.project_issue_properties,
|
|
||||||
// [this.projectId]: {
|
|
||||||
// ...this.issueFilters?.[this.workspaceId]?.project_issue_properties?.[this.projectId],
|
|
||||||
// issues: {
|
|
||||||
// ...this.issueFilters?.[this.workspaceId]?.project_issue_properties?.[this.projectId]?.issues,
|
|
||||||
// [filter_type]: {
|
|
||||||
// ...this.issueFilters?.[this.workspaceId]?.project_issue_properties?.[this.projectId]?.issues?.[
|
|
||||||
// filter_type
|
|
||||||
// ],
|
|
||||||
// [filter_key]: value,
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// };
|
|
||||||
// this.updateProjectDisplayFilters(this.workspaceId, this.projectId, {
|
|
||||||
// filters: this.userFilters?.filters,
|
|
||||||
// display_filters: this.userFilters?.display_filters,
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// if (this.issueView === "modules" && this.moduleId) {
|
|
||||||
// this.issueFilters = {
|
|
||||||
// ...this.issueFilters,
|
|
||||||
// [this.workspaceId]: {
|
|
||||||
// ...this.issueFilters?.[this.workspaceId],
|
|
||||||
// project_issue_properties: {
|
|
||||||
// ...this.issueFilters?.[this.workspaceId]?.project_issue_properties,
|
|
||||||
// [this.projectId]: {
|
|
||||||
// ...this.issueFilters?.[this.workspaceId]?.project_issue_properties?.[this.projectId],
|
|
||||||
// modules: {
|
|
||||||
// ...this.issueFilters?.[this.workspaceId]?.project_issue_properties?.[this.projectId]?.modules,
|
|
||||||
// [this.moduleId]: {
|
|
||||||
// ...this.issueFilters?.[this.workspaceId]?.project_issue_properties?.[this.projectId]?.modules?.[
|
|
||||||
// this.moduleId
|
|
||||||
// ],
|
|
||||||
// [filter_type]: {
|
|
||||||
// ...this.issueFilters?.[this.workspaceId]?.project_issue_properties?.[this.projectId]?.modules?.[
|
|
||||||
// this.moduleId
|
|
||||||
// ]?.[filter_type],
|
|
||||||
// [filter_key]: value,
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// };
|
|
||||||
// this.updateProjectIssueModuleFilters(
|
|
||||||
// this.workspaceId,
|
|
||||||
// this.projectId,
|
|
||||||
// this.moduleId,
|
|
||||||
// this.userFilters?.filters
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// if (this.issueView === "cycles" && this.cycleId) {
|
|
||||||
// this.issueFilters = {
|
|
||||||
// ...this.issueFilters,
|
|
||||||
// [this.workspaceId]: {
|
|
||||||
// ...this.issueFilters?.[this.workspaceId],
|
|
||||||
// project_issue_properties: {
|
|
||||||
// ...this.issueFilters?.[this.workspaceId]?.project_issue_properties,
|
|
||||||
// [this.projectId]: {
|
|
||||||
// ...this.issueFilters?.[this.workspaceId]?.project_issue_properties?.[this.projectId],
|
|
||||||
// cycles: {
|
|
||||||
// ...this.issueFilters?.[this.workspaceId]?.project_issue_properties?.[this.projectId]?.cycles,
|
|
||||||
// [this.cycleId]: {
|
|
||||||
// ...this.issueFilters?.[this.workspaceId]?.project_issue_properties?.[this.projectId]?.cycles?.[
|
|
||||||
// this.cycleId
|
|
||||||
// ],
|
|
||||||
// [filter_type]: {
|
|
||||||
// ...this.issueFilters?.[this.workspaceId]?.project_issue_properties?.[this.projectId]?.cycles?.[
|
|
||||||
// this.cycleId
|
|
||||||
// ]?.[filter_type],
|
|
||||||
// [filter_key]: value,
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// };
|
|
||||||
// this.updateProjectIssueCyclesFilters(this.workspaceId, this.projectId, this.cycleId, this.userFilters?.filters);
|
|
||||||
// }
|
|
||||||
// if (this.issueView === "views" && this.viewId) {
|
|
||||||
// this.issueFilters = {
|
|
||||||
// ...this.issueFilters,
|
|
||||||
// [this.workspaceId]: {
|
|
||||||
// ...this.issueFilters?.[this.workspaceId],
|
|
||||||
// project_issue_properties: {
|
|
||||||
// ...this.issueFilters?.[this.workspaceId]?.project_issue_properties,
|
|
||||||
// [this.projectId]: {
|
|
||||||
// ...this.issueFilters?.[this.workspaceId]?.project_issue_properties?.[this.projectId],
|
|
||||||
// views: {
|
|
||||||
// ...this.issueFilters?.[this.workspaceId]?.project_issue_properties?.[this.projectId]?.views,
|
|
||||||
// [this.viewId]: {
|
|
||||||
// ...this.issueFilters?.[this.workspaceId]?.project_issue_properties?.[this.projectId]?.views?.[
|
|
||||||
// this.viewId
|
|
||||||
// ],
|
|
||||||
// [filter_type]: {
|
|
||||||
// ...this.issueFilters?.[this.workspaceId]?.project_issue_properties?.[this.projectId]?.views?.[
|
|
||||||
// this.viewId
|
|
||||||
// ]?.[filter_type],
|
|
||||||
// [filter_key]: value,
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// };
|
|
||||||
// this.updateProjectIssueViewsFilters(this.workspaceId, this.projectId, this.viewId, this.userFilters?.filters);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if (this.issueView === "my_issues")
|
|
||||||
// this.rootStore?.issueView?.getProjectIssuesAsync(this.workspaceId, this.projectId, false);
|
|
||||||
// if (this.issueView === "issues")
|
|
||||||
// this.rootStore?.issueView?.getProjectIssuesAsync(this.workspaceId, this.projectId, false);
|
|
||||||
// if (this.issueView === "modules" && this.moduleId)
|
|
||||||
// this.rootStore?.issueView?.getIssuesForModulesAsync(this.workspaceId, this.projectId, this.moduleId, false);
|
|
||||||
// if (this.issueView === "cycles" && this.cycleId)
|
|
||||||
// this.rootStore?.issueView?.getIssuesForCyclesAsync(this.workspaceId, this.projectId, this.cycleId, false);
|
|
||||||
// if (this.issueView === "views" && this.viewId)
|
|
||||||
// this.rootStore?.issueView?.getIssuesForViewsAsync(this.workspaceId, this.projectId, this.viewId, false);
|
|
||||||
};
|
|
||||||
|
|
||||||
computedFilter = (filters: any, filteredParams: any) => {
|
computedFilter = (filters: any, filteredParams: any) => {
|
||||||
const computedFilters: any = {};
|
const computedFilters: any = {};
|
||||||
Object.keys(filters).map((key) => {
|
Object.keys(filters).map((key) => {
|
||||||
@ -566,25 +318,24 @@ class IssueFilterStore implements IIssueFilterStore {
|
|||||||
) => {
|
) => {
|
||||||
this.issueView = _issueView;
|
this.issueView = _issueView;
|
||||||
|
|
||||||
// const _layout = this.userFilters?.display_filters?.layout;
|
const _layout = this.userFilters?.display_filters?.layout;
|
||||||
const _layout = "";
|
|
||||||
|
|
||||||
let filteredRouteParams: any = {
|
let filteredRouteParams: any = {
|
||||||
// priority: this.userFilters?.filters?.priority || undefined,
|
priority: this.userFilters?.filters?.priority || undefined,
|
||||||
// state_group: this.userFilters?.filters?.state_group || undefined,
|
state_group: this.userFilters?.filters?.state_group || undefined,
|
||||||
// state: this.userFilters?.filters?.state || undefined,
|
state: this.userFilters?.filters?.state || undefined,
|
||||||
// assignees: this.userFilters?.filters?.assignees || undefined,
|
assignees: this.userFilters?.filters?.assignees || undefined,
|
||||||
// created_by: this.userFilters?.filters?.created_by || undefined,
|
created_by: this.userFilters?.filters?.created_by || undefined,
|
||||||
// labels: this.userFilters?.filters?.labels || undefined,
|
labels: this.userFilters?.filters?.labels || undefined,
|
||||||
// start_date: this.userFilters?.filters?.start_date || undefined,
|
start_date: this.userFilters?.filters?.start_date || undefined,
|
||||||
// target_date: this.userFilters?.filters?.target_date || undefined,
|
target_date: this.userFilters?.filters?.target_date || undefined,
|
||||||
// group_by: this.userFilters?.display_filters?.group_by || "state",
|
group_by: this.userFilters?.display_filters?.group_by || "state",
|
||||||
// order_by: this.userFilters?.display_filters?.order_by || "-created_at",
|
order_by: this.userFilters?.display_filters?.order_by || "-created_at",
|
||||||
// type: this.userFilters?.display_filters?.type || undefined,
|
type: this.userFilters?.display_filters?.type || undefined,
|
||||||
// sub_issue: this.userFilters?.display_filters?.sub_issue || true,
|
sub_issue: this.userFilters?.display_filters?.sub_issue || true,
|
||||||
// show_empty_groups: this.userFilters?.display_filters?.show_empty_groups || true,
|
show_empty_groups: this.userFilters?.display_filters?.show_empty_groups || true,
|
||||||
// calendar_date_range: this.userFilters?.display_filters?.calendar_date_range || undefined,
|
calendar_date_range: this.userFilters?.display_filters?.calendar_date_range || undefined,
|
||||||
// start_target_date: this.userFilters?.display_filters?.start_target_date || true,
|
start_target_date: this.userFilters?.display_filters?.start_target_date || true,
|
||||||
};
|
};
|
||||||
|
|
||||||
// start date and target date we have to construct the format here
|
// start date and target date we have to construct the format here
|
||||||
@ -602,16 +353,16 @@ class IssueFilterStore implements IIssueFilterStore {
|
|||||||
filter_type: "filters" | "display_filters" | "display_properties" | "display_properties_id",
|
filter_type: "filters" | "display_filters" | "display_properties" | "display_properties_id",
|
||||||
value: any
|
value: any
|
||||||
) => {
|
) => {
|
||||||
const projectId = this.rootStore?.project?.projectId || null;
|
const projectId = this.rootStore?.project?.projectId;
|
||||||
const moduleId = this.rootStore?.module?.moduleId || null;
|
const moduleId = this.rootStore?.module?.moduleId;
|
||||||
const cycleId = this.rootStore?.cycle?.cycleId || null;
|
const cycleId = this.rootStore?.cycle?.cycleId;
|
||||||
const viewId = this.rootStore?.view?.viewId || null;
|
const viewId = this.rootStore?.view?.viewId;
|
||||||
const currentView = this.issueView || null;
|
const _issueView = this.issueView;
|
||||||
|
|
||||||
console.log("filter_type", filter_type);
|
console.log("filter_type", filter_type);
|
||||||
console.log("value", value);
|
console.log("value", value);
|
||||||
|
|
||||||
if (!currentView || !projectId || !moduleId || !cycleId || !viewId) return null;
|
if (!_issueView || !projectId || !moduleId || !cycleId || !viewId) return null;
|
||||||
|
|
||||||
// let _issueFilters: IIssueFilters = {
|
// let _issueFilters: IIssueFilters = {
|
||||||
// ...this.issueFilters,
|
// ...this.issueFilters,
|
||||||
@ -621,6 +372,17 @@ class IssueFilterStore implements IIssueFilterStore {
|
|||||||
// };
|
// };
|
||||||
|
|
||||||
// console.log("_issueFilters", _issueFilters);
|
// console.log("_issueFilters", _issueFilters);
|
||||||
|
|
||||||
|
// if (this.issueView === "my_issues")
|
||||||
|
// this.rootStore?.issueView?.getProjectIssuesAsync(this.workspaceId, this.projectId, false);
|
||||||
|
// if (this.issueView === "issues")
|
||||||
|
// this.rootStore?.issueView?.getProjectIssuesAsync(this.workspaceId, this.projectId, false);
|
||||||
|
// if (this.issueView === "modules" && this.moduleId)
|
||||||
|
// this.rootStore?.issueView?.getIssuesForModulesAsync(this.workspaceId, this.projectId, this.moduleId, false);
|
||||||
|
// if (this.issueView === "cycles" && this.cycleId)
|
||||||
|
// this.rootStore?.issueView?.getIssuesForCyclesAsync(this.workspaceId, this.projectId, this.cycleId, false);
|
||||||
|
// if (this.issueView === "views" && this.viewId)
|
||||||
|
// this.rootStore?.issueView?.getIssuesForViewsAsync(this.workspaceId, this.projectId, this.viewId, false);
|
||||||
};
|
};
|
||||||
|
|
||||||
// services
|
// services
|
||||||
|
Loading…
Reference in New Issue
Block a user