feat: implement checklist

pull/5418/head
Arik Chakma 8 months ago
parent 1d9adf742b
commit b1fad87eb6
  1. 8
      src/components/CustomRoadmap/CustomRoadmap.tsx
  2. 28
      src/components/CustomRoadmap/FlowRoadmapRenderer.tsx
  3. 2
      src/lib/resource-progress.ts

@ -1,17 +1,11 @@
import { useEffect, useState } from 'react';
import { getUrlParams } from '../../lib/browser';
import {
type AppError,
type FetchError,
httpGet,
httpPost,
} from '../../lib/http';
import { type AppError, type FetchError, httpGet } from '../../lib/http';
import { RoadmapHeader } from './RoadmapHeader';
import { TopicDetail } from '../TopicDetail/TopicDetail';
import type { RoadmapDocument } from './CreateRoadmap/CreateRoadmapModal';
import { currentRoadmap } from '../../stores/roadmap';
import { RestrictedPage } from './RestrictedPage';
import { isLoggedIn } from '../../lib/jwt';
import { FlowRoadmapRenderer } from './FlowRoadmapRenderer';
export const allowedLinkTypes = [

@ -125,6 +125,32 @@ export function FlowRoadmapRenderer(props: FlowRoadmapRendererProps) {
}
}, []);
const handleChecklistCheckboxClick = useCallback(
(e: MouseEvent, checklistId: string) => {
const target = e?.currentTarget as HTMLDivElement;
if (!target) {
return;
}
const isCurrentStatusDone = target?.classList.contains('done');
updateTopicStatus(checklistId, isCurrentStatusDone ? 'pending' : 'done');
},
[],
);
const handleChecklistLabelClick = useCallback(
(e: MouseEvent, checklistId: string) => {
const target = e?.currentTarget as HTMLDivElement;
if (!target) {
return;
}
const isCurrentStatusDone = target?.classList.contains('done');
updateTopicStatus(checklistId, isCurrentStatusDone ? 'pending' : 'done');
},
[],
);
return (
<>
{hideRenderer && (
@ -162,6 +188,8 @@ export function FlowRoadmapRenderer(props: FlowRoadmapRendererProps) {
onTopicAltClick={handleTopicAltClick}
onButtonNodeClick={handleLinkClick}
onLinkClick={handleLinkClick}
onChecklistCheckboxClick={handleChecklistCheckboxClick}
onChecklistLableClick={handleChecklistLabelClick}
fontFamily="Balsamiq Sans"
fontURL="/fonts/balsamiq.woff2"
/>

@ -229,6 +229,8 @@ export function topicSelectorAll(
`[data-group-id="check:${topicId}"]`, // Matching "check:XXXX" box of the topic
`[data-node-id="${topicId}"]`, // Matching custom roadmap nodes
`[data-id="${topicId}"]`, // Matching custom roadmap nodes
`[data-checklist-checkbox][data-checklist-id="${topicId}"]`, // Matching checklist checkboxes
`[data-checklist-label][data-checklist-id="${topicId}"]`, // Matching checklist labels
],
parentElement,
).forEach((element) => {

Loading…
Cancel
Save