mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
[WEB-1183] fix: updated global issues filter while updating global view (#4357)
* chore: Updated global issues filter while updating global view * fix: globale view modal clear all --------- Co-authored-by: gurusainath <gurusainath007@gmail.com>
This commit is contained in:
parent
527ecd7d22
commit
c96225c812
@ -96,6 +96,7 @@ export const GlobalViewsAppliedFiltersRoot = observer((props: Props) => {
|
||||
...(appliedFilters ?? {}),
|
||||
},
|
||||
}).then((res) => {
|
||||
if (res)
|
||||
captureEvent(GLOBAL_VIEW_UPDATED, {
|
||||
view_id: res.id,
|
||||
applied_filters: res.filters,
|
||||
|
@ -84,6 +84,7 @@ export const CreateUpdateWorkspaceViewModal: React.FC<Props> = observer((props)
|
||||
|
||||
await updateGlobalView(workspaceSlug.toString(), data.id, payloadData)
|
||||
.then((res) => {
|
||||
if (res) {
|
||||
captureEvent(GLOBAL_VIEW_UPDATED, {
|
||||
view_id: res.id,
|
||||
applied_filters: res.filters,
|
||||
@ -95,6 +96,7 @@ export const CreateUpdateWorkspaceViewModal: React.FC<Props> = observer((props)
|
||||
message: "View updated successfully.",
|
||||
});
|
||||
handleClose();
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
captureEvent(GLOBAL_VIEW_UPDATED, {
|
||||
|
@ -1,11 +1,16 @@
|
||||
import { set } from "lodash";
|
||||
import cloneDeep from "lodash/cloneDeep";
|
||||
import isEmpty from "lodash/isEmpty";
|
||||
import isEqual from "lodash/isEqual";
|
||||
import set from "lodash/set";
|
||||
import { observable, action, makeObservable, runInAction, computed } from "mobx";
|
||||
import { computedFn } from "mobx-utils";
|
||||
import { IIssueFilterOptions, IWorkspaceView } from "@plane/types";
|
||||
// constants
|
||||
import { EIssueFilterType } from "@/constants/issue";
|
||||
// services
|
||||
import { WorkspaceService } from "@/services/workspace.service";
|
||||
// types
|
||||
import { RootStore } from "@/store/root.store";
|
||||
import { IWorkspaceView } from "@plane/types";
|
||||
|
||||
export interface IGlobalViewStore {
|
||||
// observables
|
||||
@ -20,7 +25,11 @@ export interface IGlobalViewStore {
|
||||
fetchGlobalViewDetails: (workspaceSlug: string, viewId: string) => Promise<IWorkspaceView>;
|
||||
// crud actions
|
||||
createGlobalView: (workspaceSlug: string, data: Partial<IWorkspaceView>) => Promise<IWorkspaceView>;
|
||||
updateGlobalView: (workspaceSlug: string, viewId: string, data: Partial<IWorkspaceView>) => Promise<IWorkspaceView>;
|
||||
updateGlobalView: (
|
||||
workspaceSlug: string,
|
||||
viewId: string,
|
||||
data: Partial<IWorkspaceView>
|
||||
) => Promise<IWorkspaceView | undefined>;
|
||||
deleteGlobalView: (workspaceSlug: string, viewId: string) => Promise<any>;
|
||||
}
|
||||
|
||||
@ -139,14 +148,50 @@ export class GlobalViewStore implements IGlobalViewStore {
|
||||
workspaceSlug: string,
|
||||
viewId: string,
|
||||
data: Partial<IWorkspaceView>
|
||||
): Promise<IWorkspaceView> =>
|
||||
await this.workspaceService.updateView(workspaceSlug, viewId, data).then((response) => {
|
||||
const viewToUpdate = { ...this.getViewDetailsById(viewId), ...data };
|
||||
runInAction(() => {
|
||||
set(this.globalViewMap, viewId, viewToUpdate);
|
||||
): Promise<IWorkspaceView | undefined> => {
|
||||
const currentViewData = this.getViewDetailsById(viewId) ? cloneDeep(this.getViewDetailsById(viewId)) : undefined;
|
||||
try {
|
||||
Object.keys(data).forEach((key) => {
|
||||
const currentKey = key as keyof IWorkspaceView;
|
||||
set(this.globalViewMap, [viewId, currentKey], data[currentKey]);
|
||||
});
|
||||
return response;
|
||||
const currentView = await this.workspaceService.updateView(workspaceSlug, viewId, data);
|
||||
// applying the filters in the global view
|
||||
if (!isEqual(currentViewData?.filters || {}, currentView?.filters || {})) {
|
||||
if (isEmpty(currentView?.filters)) {
|
||||
const currentGlobalViewFilters: IIssueFilterOptions = this.rootStore.issue.workspaceIssuesFilter.filters[
|
||||
viewId
|
||||
].filters as IIssueFilterOptions;
|
||||
const newFilters: IIssueFilterOptions = {};
|
||||
Object.keys(currentGlobalViewFilters ?? {}).forEach((key) => {
|
||||
newFilters[key as keyof IIssueFilterOptions] = [];
|
||||
});
|
||||
await this.rootStore.issue.workspaceIssuesFilter.updateFilters(
|
||||
workspaceSlug,
|
||||
undefined,
|
||||
EIssueFilterType.FILTERS,
|
||||
newFilters,
|
||||
viewId
|
||||
);
|
||||
} else {
|
||||
await this.rootStore.issue.workspaceIssuesFilter.updateFilters(
|
||||
workspaceSlug,
|
||||
undefined,
|
||||
EIssueFilterType.FILTERS,
|
||||
currentView.filters,
|
||||
viewId
|
||||
);
|
||||
}
|
||||
this.rootStore.issue.workspaceIssues.fetchIssues(workspaceSlug, viewId, "mutation");
|
||||
}
|
||||
return currentView;
|
||||
} catch {
|
||||
Object.keys(data).forEach((key) => {
|
||||
const currentKey = key as keyof IWorkspaceView;
|
||||
if (currentViewData) set(this.globalViewMap, [viewId, currentKey], currentViewData[currentKey]);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @description delete global view
|
||||
|
Loading…
Reference in New Issue
Block a user