fix: add filter/display properties

This commit is contained in:
dakshesh14 2023-11-07 13:58:00 +05:30
parent c57c50aea8
commit 3d2d2befaf
2 changed files with 23 additions and 12 deletions

View File

@ -1,4 +1,4 @@
import { useCallback } from "react"; import { useCallback, useState } from "react";
import { useRouter } from "next/router"; import { useRouter } from "next/router";
import { DragDropContext } from "@hello-pangea/dnd"; import { DragDropContext } from "@hello-pangea/dnd";
import { observer } from "mobx-react-lite"; import { observer } from "mobx-react-lite";
@ -26,15 +26,24 @@ export const DraftIssueKanBanLayout: React.FC = observer(() => {
// derived values // derived values
const issues = draftIssuesStore.getDraftIssues; const issues = draftIssuesStore.getDraftIssues;
const display_properties = draftIssueFiltersStore?.userDisplayProperties; const displayProperties = draftIssueFiltersStore?.userDisplayProperties;
const userDisplayFilters = draftIssueFiltersStore?.userDisplayFilters; const userDisplayFilters = draftIssueFiltersStore?.userDisplayFilters;
const group_by: string | null = userDisplayFilters?.group_by || null; const group_by: string | null = userDisplayFilters?.group_by || null;
const order_by: string | null = draftIssueFiltersStore?.userDisplayFilters?.order_by || null;
const showEmptyGroup = userDisplayFilters?.show_empty_groups || false; const showEmptyGroup = userDisplayFilters?.show_empty_groups || false;
const sub_group_by: string | null = userDisplayFilters?.sub_group_by || null; const sub_group_by: string | null = userDisplayFilters?.sub_group_by || null;
const currentKanBanView = "default"; const currentKanBanView = "default";
const [isDragStarted, setIsDragStarted] = useState<boolean>(false);
const onDragStart = () => {
setIsDragStarted(true);
};
const onDragEnd = (result: any) => { const onDragEnd = (result: any) => {
setIsDragStarted(false);
if (!result) return; if (!result) return;
if ( if (
@ -85,12 +94,13 @@ export const DraftIssueKanBanLayout: React.FC = observer(() => {
return ( return (
<div className={`relative min-w-full w-max min-h-full h-max bg-custom-background-90 px-3`}> <div className={`relative min-w-full w-max min-h-full h-max bg-custom-background-90 px-3`}>
<DragDropContext onDragEnd={onDragEnd}> <DragDropContext onDragStart={onDragStart} onDragEnd={onDragEnd}>
{currentKanBanView === "default" ? ( {currentKanBanView === "default" ? (
<KanBan <KanBan
issues={issues} issues={issues}
sub_group_by={sub_group_by} sub_group_by={sub_group_by}
group_by={group_by} group_by={group_by}
order_by={order_by}
handleIssues={handleIssues} handleIssues={handleIssues}
quickActions={(sub_group_by, group_by, issue) => ( quickActions={(sub_group_by, group_by, issue) => (
<DraftIssueQuickActions <DraftIssueQuickActions
@ -98,17 +108,17 @@ export const DraftIssueKanBanLayout: React.FC = observer(() => {
handleUpdate={(issue: any, action: any) => handleIssues(sub_group_by, group_by, issue, action)} handleUpdate={(issue: any, action: any) => handleIssues(sub_group_by, group_by, issue, action)}
/> />
)} )}
displayProperties={display_properties} displayProperties={displayProperties}
kanBanToggle={issueKanBanViewStore?.kanBanToggle} kanBanToggle={issueKanBanViewStore?.kanBanToggle}
handleKanBanToggle={handleKanBanToggle} handleKanBanToggle={handleKanBanToggle}
states={states} states={states}
stateGroups={stateGroups} stateGroups={stateGroups}
order_by={orderBy}
priorities={priorities} priorities={priorities}
labels={labels} labels={labels}
members={members?.map((m) => m.member) ?? null} members={members?.map((m) => m.member) ?? null}
projects={projects} projects={projects}
showEmptyGroup={showEmptyGroup} showEmptyGroup={showEmptyGroup}
isDragStarted={isDragStarted}
/> />
) : ( ) : (
<KanBanSwimLanes <KanBanSwimLanes
@ -123,7 +133,7 @@ export const DraftIssueKanBanLayout: React.FC = observer(() => {
handleUpdate={(issue: any, action: any) => handleIssues(sub_group_by, group_by, issue, action)} handleUpdate={(issue: any, action: any) => handleIssues(sub_group_by, group_by, issue, action)}
/> />
)} )}
displayProperties={display_properties} displayProperties={displayProperties}
kanBanToggle={issueKanBanViewStore?.kanBanToggle} kanBanToggle={issueKanBanViewStore?.kanBanToggle}
handleKanBanToggle={handleKanBanToggle} handleKanBanToggle={handleKanBanToggle}
states={states} states={states}
@ -133,6 +143,7 @@ export const DraftIssueKanBanLayout: React.FC = observer(() => {
members={members?.map((m) => m.member) ?? null} members={members?.map((m) => m.member) ?? null}
projects={projects} projects={projects}
showEmptyGroup={showEmptyGroup} showEmptyGroup={showEmptyGroup}
isDragStarted={isDragStarted}
/> />
)} )}
</DragDropContext> </DragDropContext>

View File

@ -283,29 +283,29 @@ export const ISSUE_DISPLAY_FILTERS_BY_LAYOUT: {
}, },
draft_issues: { draft_issues: {
list: { list: {
filters: ["priority", "state_group", "labels", "start_date", "target_date"], filters: ["priority", "state", "assignees", "created_by", "labels", "start_date", "target_date"],
display_properties: true, display_properties: true,
display_filters: { display_filters: {
group_by: ["state_detail.group", "priority", "project", "labels", null], group_by: ["state", "priority", "labels", "assignees", "created_by", null],
order_by: ["sort_order", "-created_at", "-updated_at", "start_date", "priority"], order_by: ["sort_order", "-created_at", "-updated_at", "start_date", "priority"],
type: [null, "active", "backlog"], type: [null, "active", "backlog"],
}, },
extra_options: { extra_options: {
access: true, access: true,
values: ["show_empty_groups"], values: ["show_empty_groups", "sub_issue"],
}, },
}, },
kanban: { kanban: {
filters: ["priority", "state_group", "labels", "start_date", "target_date"], filters: ["priority", "state", "assignees", "created_by", "labels", "start_date", "target_date"],
display_properties: true, display_properties: true,
display_filters: { display_filters: {
group_by: ["state_detail.group", "priority", "project", "labels", null], group_by: ["state", "priority", "labels", "assignees", "created_by"],
order_by: ["sort_order", "-created_at", "-updated_at", "start_date", "priority"], order_by: ["sort_order", "-created_at", "-updated_at", "start_date", "priority"],
type: [null, "active", "backlog"], type: [null, "active", "backlog"],
}, },
extra_options: { extra_options: {
access: true, access: true,
values: ["show_empty_groups"], values: ["show_empty_groups", "sub_issue"],
}, },
}, },
}, },