mirror of
https://github.com/kamranahmedse/developer-roadmap.git
synced 2025-07-31 22:40:19 +02:00
feat: implement checklist (#5418)
This commit is contained in:
@@ -1,17 +1,11 @@
|
|||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { getUrlParams } from '../../lib/browser';
|
import { getUrlParams } from '../../lib/browser';
|
||||||
import {
|
import { type AppError, type FetchError, httpGet } from '../../lib/http';
|
||||||
type AppError,
|
|
||||||
type FetchError,
|
|
||||||
httpGet,
|
|
||||||
httpPost,
|
|
||||||
} from '../../lib/http';
|
|
||||||
import { RoadmapHeader } from './RoadmapHeader';
|
import { RoadmapHeader } from './RoadmapHeader';
|
||||||
import { TopicDetail } from '../TopicDetail/TopicDetail';
|
import { TopicDetail } from '../TopicDetail/TopicDetail';
|
||||||
import type { RoadmapDocument } from './CreateRoadmap/CreateRoadmapModal';
|
import type { RoadmapDocument } from './CreateRoadmap/CreateRoadmapModal';
|
||||||
import { currentRoadmap } from '../../stores/roadmap';
|
import { currentRoadmap } from '../../stores/roadmap';
|
||||||
import { RestrictedPage } from './RestrictedPage';
|
import { RestrictedPage } from './RestrictedPage';
|
||||||
import { isLoggedIn } from '../../lib/jwt';
|
|
||||||
import { FlowRoadmapRenderer } from './FlowRoadmapRenderer';
|
import { FlowRoadmapRenderer } from './FlowRoadmapRenderer';
|
||||||
|
|
||||||
export const allowedLinkTypes = [
|
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 (
|
return (
|
||||||
<>
|
<>
|
||||||
{hideRenderer && (
|
{hideRenderer && (
|
||||||
@@ -162,6 +188,8 @@ export function FlowRoadmapRenderer(props: FlowRoadmapRendererProps) {
|
|||||||
onTopicAltClick={handleTopicAltClick}
|
onTopicAltClick={handleTopicAltClick}
|
||||||
onButtonNodeClick={handleLinkClick}
|
onButtonNodeClick={handleLinkClick}
|
||||||
onLinkClick={handleLinkClick}
|
onLinkClick={handleLinkClick}
|
||||||
|
onChecklistCheckboxClick={handleChecklistCheckboxClick}
|
||||||
|
onChecklistLableClick={handleChecklistLabelClick}
|
||||||
fontFamily="Balsamiq Sans"
|
fontFamily="Balsamiq Sans"
|
||||||
fontURL="/fonts/balsamiq.woff2"
|
fontURL="/fonts/balsamiq.woff2"
|
||||||
/>
|
/>
|
||||||
|
@@ -112,11 +112,11 @@ export async function getResourceProgress(
|
|||||||
return loadFreshProgress(resourceType, resourceId);
|
return loadFreshProgress(resourceType, resourceId);
|
||||||
} else {
|
} else {
|
||||||
setResourceProgress(
|
setResourceProgress(
|
||||||
resourceType,
|
resourceType,
|
||||||
resourceId,
|
resourceId,
|
||||||
progress?.done || [],
|
progress?.done || [],
|
||||||
progress?.learning || [],
|
progress?.learning || [],
|
||||||
progress?.skipped || [],
|
progress?.skipped || [],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,6 +229,8 @@ export function topicSelectorAll(
|
|||||||
`[data-group-id="check:${topicId}"]`, // Matching "check:XXXX" box of the topic
|
`[data-group-id="check:${topicId}"]`, // Matching "check:XXXX" box of the topic
|
||||||
`[data-node-id="${topicId}"]`, // Matching custom roadmap nodes
|
`[data-node-id="${topicId}"]`, // Matching custom roadmap nodes
|
||||||
`[data-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,
|
parentElement,
|
||||||
).forEach((element) => {
|
).forEach((element) => {
|
||||||
|
Reference in New Issue
Block a user