mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
filtering
This commit is contained in:
parent
cf34d4afbc
commit
70fe830151
@ -1,5 +1,5 @@
|
|||||||
import React, { FC, useState } from "react";
|
import React, { FC, useState } from "react";
|
||||||
import { Tooltip, CustomMenu, ContextMenu } from "components/ui";
|
import { observer } from "mobx-react-lite";
|
||||||
// lib
|
// lib
|
||||||
import { useMobxStore } from "lib/mobx/store-provider";
|
import { useMobxStore } from "lib/mobx/store-provider";
|
||||||
import { IIssue } from "types";
|
import { IIssue } from "types";
|
||||||
@ -15,6 +15,7 @@ import {
|
|||||||
PaperClipIcon,
|
PaperClipIcon,
|
||||||
} from "@heroicons/react/24/outline";
|
} from "@heroicons/react/24/outline";
|
||||||
// components
|
// components
|
||||||
|
import { Tooltip, CustomMenu, ContextMenu } from "components/ui";
|
||||||
import { LayerDiagonalIcon } from "components/icons";
|
import { LayerDiagonalIcon } from "components/icons";
|
||||||
import {
|
import {
|
||||||
ViewAssigneeSelect,
|
ViewAssigneeSelect,
|
||||||
@ -25,25 +26,36 @@ import {
|
|||||||
ViewStartDateSelect,
|
ViewStartDateSelect,
|
||||||
ViewStateSelect,
|
ViewStateSelect,
|
||||||
} from "components/issues";
|
} from "components/issues";
|
||||||
|
import { IssuePrioritySelect } from "../properties";
|
||||||
|
|
||||||
export interface IIssueListItem {
|
export interface IIssueListItem {
|
||||||
issue: IIssue;
|
issue: IIssue;
|
||||||
|
groupId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const IssueListItem: FC<IIssueListItem> = (props) => {
|
export const IssueListItem: FC<IIssueListItem> = observer((props) => {
|
||||||
const { issue } = props;
|
const { issue, groupId } = props;
|
||||||
// store
|
// store
|
||||||
const { user: userStore, issueFilters: issueFilterStore } = useMobxStore();
|
const { user: userStore, issueFilters: issueFilterStore, issueDetail: issueDetailStore } = useMobxStore();
|
||||||
const displayProperties = issueFilterStore.userFilters?.display_properties;
|
const displayProperties = issueFilterStore.userFilters?.display_properties;
|
||||||
|
const workspaceId = issueFilterStore.workspaceId;
|
||||||
|
const projectId = issueFilterStore.projectId;
|
||||||
|
const issueId = issue.id;
|
||||||
|
const user = userStore.currentUser;
|
||||||
console.log("userStore", userStore);
|
console.log("userStore", userStore);
|
||||||
// context menu
|
// context menu
|
||||||
const [contextMenu, setContextMenu] = useState(false);
|
const [contextMenu, setContextMenu] = useState(false);
|
||||||
const [contextMenuPosition, setContextMenuPosition] = useState<React.MouseEvent | null>(null);
|
const [contextMenuPosition, setContextMenuPosition] = useState<React.MouseEvent | null>(null);
|
||||||
const { user: userAuth } = useUserAuth();
|
|
||||||
|
|
||||||
|
const isNotAllowed = false;
|
||||||
// const isNotAllowed =
|
// const isNotAllowed =
|
||||||
// userAuth?.isGuest || userAuth?.isViewer || disableUserActions || isArchivedIssues;
|
// userAuth?.isGuest || userAuth?.isViewer || disableUserActions || isArchivedIssues;
|
||||||
|
|
||||||
|
const partialUpdateIssue = (data: any) => {
|
||||||
|
// console.log("data", data);
|
||||||
|
if (workspaceId && projectId && issueId) issueDetailStore.updateIssueAsync(workspaceId, projectId, issueId, data);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<>
|
<>
|
||||||
@ -112,20 +124,21 @@ export const IssueListItem: FC<IIssueListItem> = (props) => {
|
|||||||
|
|
||||||
<div className={`flex flex-shrink-0 items-center gap-2 text-xs `}>
|
<div className={`flex flex-shrink-0 items-center gap-2 text-xs `}>
|
||||||
{displayProperties?.priority && (
|
{displayProperties?.priority && (
|
||||||
<ViewPrioritySelect
|
// <ViewPrioritySelect
|
||||||
issue={issue}
|
// issue={issue}
|
||||||
partialUpdateIssue={partialUpdateIssue}
|
// partialUpdateIssue={partialUpdateIssue}
|
||||||
position="right"
|
// position="right"
|
||||||
user={user}
|
// user={user as any}
|
||||||
isNotAllowed={isNotAllowed}
|
// isNotAllowed={isNotAllowed}
|
||||||
/>
|
// />
|
||||||
|
<IssuePrioritySelect issue={issue} groupId={groupId} />
|
||||||
)}
|
)}
|
||||||
{displayProperties?.state && (
|
{displayProperties?.state && (
|
||||||
<ViewStateSelect
|
<ViewStateSelect
|
||||||
issue={issue}
|
issue={issue}
|
||||||
partialUpdateIssue={partialUpdateIssue}
|
partialUpdateIssue={partialUpdateIssue}
|
||||||
position="right"
|
position="right"
|
||||||
user={user}
|
user={user as any}
|
||||||
isNotAllowed={isNotAllowed}
|
isNotAllowed={isNotAllowed}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@ -133,7 +146,7 @@ export const IssueListItem: FC<IIssueListItem> = (props) => {
|
|||||||
<ViewStartDateSelect
|
<ViewStartDateSelect
|
||||||
issue={issue}
|
issue={issue}
|
||||||
partialUpdateIssue={partialUpdateIssue}
|
partialUpdateIssue={partialUpdateIssue}
|
||||||
user={user}
|
user={user as any}
|
||||||
isNotAllowed={isNotAllowed}
|
isNotAllowed={isNotAllowed}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@ -141,19 +154,17 @@ export const IssueListItem: FC<IIssueListItem> = (props) => {
|
|||||||
<ViewDueDateSelect
|
<ViewDueDateSelect
|
||||||
issue={issue}
|
issue={issue}
|
||||||
partialUpdateIssue={partialUpdateIssue}
|
partialUpdateIssue={partialUpdateIssue}
|
||||||
user={user}
|
user={user as any}
|
||||||
isNotAllowed={isNotAllowed}
|
isNotAllowed={isNotAllowed}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{displayProperties?.labels && (
|
{displayProperties?.labels && <ViewIssueLabel labelDetails={issue.label_details} maxRender={3} />}
|
||||||
<ViewIssueLabel labelDetails={issue.label_details} maxRender={3} />
|
|
||||||
)}
|
|
||||||
{displayProperties?.assignee && (
|
{displayProperties?.assignee && (
|
||||||
<ViewAssigneeSelect
|
<ViewAssigneeSelect
|
||||||
issue={issue}
|
issue={issue}
|
||||||
partialUpdateIssue={partialUpdateIssue}
|
partialUpdateIssue={partialUpdateIssue}
|
||||||
position="right"
|
position="right"
|
||||||
user={user}
|
user={user as any}
|
||||||
isNotAllowed={isNotAllowed}
|
isNotAllowed={isNotAllowed}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@ -162,7 +173,7 @@ export const IssueListItem: FC<IIssueListItem> = (props) => {
|
|||||||
issue={issue}
|
issue={issue}
|
||||||
partialUpdateIssue={partialUpdateIssue}
|
partialUpdateIssue={partialUpdateIssue}
|
||||||
position="right"
|
position="right"
|
||||||
user={user}
|
user={user as any}
|
||||||
isNotAllowed={isNotAllowed}
|
isNotAllowed={isNotAllowed}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@ -231,4 +242,4 @@ export const IssueListItem: FC<IIssueListItem> = (props) => {
|
|||||||
</>
|
</>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
});
|
||||||
|
@ -4,14 +4,15 @@ import { IssueListItem } from "./item";
|
|||||||
|
|
||||||
export interface IIssueListView {
|
export interface IIssueListView {
|
||||||
issues: IIssue[];
|
issues: IIssue[];
|
||||||
|
groupId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const IssueListView: FC<IIssueListView> = (props) => {
|
export const IssueListView: FC<IIssueListView> = (props) => {
|
||||||
const { issues = [] } = props;
|
const { issues = [], groupId } = props;
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{issues.map((issue) => (
|
{issues.map((issue) => (
|
||||||
<IssueListItem issue={issue} />
|
<IssueListItem issue={issue} groupId={groupId} />
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -31,7 +31,7 @@ export const IssueListViewRoot = observer(() => {
|
|||||||
/>
|
/>
|
||||||
</Disclosure.Button>
|
</Disclosure.Button>
|
||||||
<Disclosure.Panel className="px-4 pt-4 pb-2">
|
<Disclosure.Panel className="px-4 pt-4 pb-2">
|
||||||
<IssueListView issues={issueViewStore?.getIssues?.[groupId]}></IssueListView>
|
<IssueListView issues={issueViewStore?.getIssues?.[groupId]} groupId={groupId}></IssueListView>
|
||||||
</Disclosure.Panel>
|
</Disclosure.Panel>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
1
web/components/issue-layouts/properties/index.ts
Normal file
1
web/components/issue-layouts/properties/index.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export * from "./priority-select";
|
61
web/components/issue-layouts/properties/priority-select.tsx
Normal file
61
web/components/issue-layouts/properties/priority-select.tsx
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
import { FC, Fragment, useState } from "react";
|
||||||
|
import { Listbox, Transition } from "@headlessui/react";
|
||||||
|
import { CheckIcon, ChevronUpDownIcon } from "@heroicons/react/20/solid";
|
||||||
|
import { useMobxStore } from "lib/mobx/store-provider";
|
||||||
|
import { IIssue } from "types";
|
||||||
|
|
||||||
|
export interface IIssuePrioritySelect {
|
||||||
|
issue: IIssue;
|
||||||
|
groupId: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const IssuePrioritySelect: FC<IIssuePrioritySelect> = (props) => {
|
||||||
|
const { issue, groupId } = props;
|
||||||
|
|
||||||
|
const { issueFilters: issueFilterStore } = useMobxStore();
|
||||||
|
const priorityList = issueFilterStore.issueRenderFilters.priority;
|
||||||
|
|
||||||
|
const selected = priorityList.find((p) => p.key === issue.priority);
|
||||||
|
|
||||||
|
const changePriority = (selectedPriority: any) => {
|
||||||
|
console.log("selectedPriority", selectedPriority);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Listbox value={selected} onChange={changePriority}>
|
||||||
|
<div className="relative mt-1">
|
||||||
|
<Listbox.Button className="relative w-full cursor-default rounded-lg bg-white py-2 pl-3 pr-3 text-left shadow-md focus:outline-none focus-visible:border-indigo-500 focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-opacity-75 focus-visible:ring-offset-2 focus-visible:ring-offset-orange-300 sm:text-sm">
|
||||||
|
<span className="block truncate text-xs">{selected?.title || "None"}</span>
|
||||||
|
</Listbox.Button>
|
||||||
|
<Transition as={Fragment} leave="transition ease-in duration-100" leaveFrom="opacity-100" leaveTo="opacity-0">
|
||||||
|
<Listbox.Options className="absolute mt-1 max-h-60 w-[200px] overflow-auto rounded-md bg-white py-1 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm z-10">
|
||||||
|
{priorityList.map((priority) => (
|
||||||
|
<Listbox.Option
|
||||||
|
key={priority.key}
|
||||||
|
className={({ active }) =>
|
||||||
|
`relative cursor-default select-none py-2 pl-10 pr-4 ${
|
||||||
|
active ? "bg-amber-100 text-amber-900" : "text-gray-900"
|
||||||
|
}`
|
||||||
|
}
|
||||||
|
value={priority}
|
||||||
|
>
|
||||||
|
{({ selected }) => (
|
||||||
|
<>
|
||||||
|
<span className={`block truncate ${selected ? "font-medium" : "font-normal"}`}>
|
||||||
|
{priority.title}
|
||||||
|
</span>
|
||||||
|
{selected ? (
|
||||||
|
<span className="absolute inset-y-0 left-0 flex items-center pl-3 text-amber-600">
|
||||||
|
<CheckIcon className="h-5 w-5" aria-hidden="true" />
|
||||||
|
</span>
|
||||||
|
) : null}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</Listbox.Option>
|
||||||
|
))}
|
||||||
|
</Listbox.Options>
|
||||||
|
</Transition>
|
||||||
|
</div>
|
||||||
|
</Listbox>
|
||||||
|
);
|
||||||
|
};
|
@ -134,12 +134,23 @@ class IssueViewDetailStore implements IIssueViewDetailStore {
|
|||||||
this.loader = true;
|
this.loader = true;
|
||||||
this.error = null;
|
this.error = null;
|
||||||
|
|
||||||
|
const filteredParams = this.rootStore.issueFilters.getComputedFilters(
|
||||||
|
workspaceId,
|
||||||
|
projectId,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
this.rootStore.issueFilters.issueView || "issues"
|
||||||
|
);
|
||||||
const issueResponse = await this.issueService.patchIssue(workspaceId, projectId, issueId, data, undefined);
|
const issueResponse = await this.issueService.patchIssue(workspaceId, projectId, issueId, data, undefined);
|
||||||
|
const issueList = await this.issueService.getIssuesWithParams(workspaceId, projectId, filteredParams);
|
||||||
|
console.log("issueList", issueList);
|
||||||
|
|
||||||
if (issueResponse) {
|
if (issueResponse) {
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
this.loader = false;
|
this.loader = false;
|
||||||
this.error = null;
|
this.error = null;
|
||||||
|
this.rootStore.issueView.issues[workspaceId].project_issues[projectId].issues.list = issueList;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user