Skip to content

Commit

Permalink
feat: ctrl+click on TaskCard to jump to the block
Browse files Browse the repository at this point in the history
  • Loading branch information
e-zz committed Mar 17, 2024
1 parent aa21941 commit 6f9da31
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/Agenda3/components/kanban/taskCard/TaskCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import { RiDeleteBin4Line } from 'react-icons/ri'
import { VscDebugConsole } from 'react-icons/vsc'

import { minutesToHHmm } from '@/Agenda3/helpers/fullCalendar'
import { navToLogseqBlock } from '@/Agenda3/helpers/logseq'
import useAgendaEntities from '@/Agenda3/hooks/useAgendaEntities'
import { logseqAtom } from '@/Agenda3/models/logseq'
import { settingsAtom } from '@/Agenda3/models/settings'
import { DEFAULT_ESTIMATED_TIME } from '@/constants/agenda'
import type { AgendaEntity } from '@/types/entity'
Expand All @@ -18,6 +20,7 @@ import TaskModal from '../../modals/TaskModal'
import Toolbar from './Toolbar'

const TaskCard = ({ task }: { task: AgendaTaskWithStart }) => {
const currentGraph = useAtomValue(logseqAtom).currentGraph
const settings = useAtomValue(settingsAtom)
const groupType = settings.selectedFilters?.length ? 'filter' : 'page'

Expand Down Expand Up @@ -45,6 +48,15 @@ const TaskCard = ({ task }: { task: AgendaTaskWithStart }) => {
const onRemoveDate = async (taskId: string) => {
updateEntity({ type: 'task-remove-date', id: taskId, data: null })
}
const onClickTask = (e: React.MouseEvent, task: AgendaTaskWithStart) => {
if (e.ctrlKey) {
navToLogseqBlock(task, currentGraph)
console.log(task)
} else {
setEditTaskModal({ open: true, task })
}
e.stopPropagation()
}

return (
<div
Expand Down Expand Up @@ -93,7 +105,11 @@ const TaskCard = ({ task }: { task: AgendaTaskWithStart }) => {
},
}}
>
<div onClick={() => setEditTaskModal({ open: true, task })}>
<div
onClick={(e) => {
onClickTask(e, task)
}}
>
{/* ========= Toolbar ========= */}
<Toolbar task={task} groupType={groupType} onClickMark={onClickTaskMark} />

Expand Down

0 comments on commit 6f9da31

Please sign in to comment.