Skip to content

Commit

Permalink
fix(agenda2): 🐛 create time task error
Browse files Browse the repository at this point in the history
  • Loading branch information
haydenull committed Nov 12, 2023
1 parent 764d279 commit 08508c3
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 19 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
},
"scripts": {
"dev": "vite --mode web",
"start": "vite",
"build:plugin": "tsc && vite build --mode plugin",
"build:web": "tsc && vite build --mode web",
"preview": "vite preview",
Expand Down Expand Up @@ -140,4 +139,4 @@
"vuepress": "2.0.0-beta.60",
"vuepress-plugin-copy-code2": "2.0.0-beta.173"
}
}
}
1 change: 1 addition & 0 deletions src/pages/NewDashboard/components/Calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ const Calendar = ({ onCalendarTitleChange }: CalendarProps, ref) => {
weekNumbers
weekNumberClassNames="text-xs"
defaultTimedEventDuration="00:30"
firstDay={1}
fixedWeekCount={false}
ref={calendarRef}
height="100%"
Expand Down
10 changes: 8 additions & 2 deletions src/pages/NewDashboard/components/FullScreenModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { Button } from 'antd'
import React, { useState } from 'react'
import { createPortal } from 'react-dom'

import { cn } from '@/util/util'

const FullScreenModal = ({
open,
children,
Expand All @@ -14,9 +16,13 @@ const FullScreenModal = ({
}) => {
if (!open) return null
return createPortal(
<div className="w-screen h-screen fixed top-0 left-0 z-50 bg-gray-100">
<div
className={cn('w-screen h-screen fixed top-0 left-0 z-50 bg-gray-50', {
'pt-[30px]': import.meta.env.VITE_MODE === 'plugin',
})}
>
{children}
<div className="absolute right-2 top-2">
<div className={cn('absolute right-2', import.meta.env.VITE_MODE === 'plugin' ? 'top-[38px]' : 'top-2')}>
<Button icon={<CloseOutlined />} onClick={onClose}>
Exit
</Button>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/NewDashboard/components/PlannerModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const PlannerModal = ({ children, triggerClassName }: { children: React.ReactNod
{children}
</span>
<FullScreenModal open={open} onClose={() => setOpen(false)}>
<div className="w-screen h-screen p-8 flex gap-8 overflow-auto bg-gray-50">
<div className="w-screen h-full p-8 flex gap-8 overflow-auto bg-gray-50 pr-[330px]">
<div className="w-[265px] shrink-0 mt-2 flex flex-col">
<div className="flex items-center justify-center mb-2">
<div className="text-2xl relative">
Expand Down Expand Up @@ -390,7 +390,7 @@ const PlannerModal = ({ children, triggerClassName }: { children: React.ReactNod
)
})}

<div className="absolute top-0 right-0 h-screen pt-12">
<div className="absolute top-0 right-0 h-screen pt-8">
<Backlog bindCalendar={false} />
</div>
</div>
Expand Down
5 changes: 4 additions & 1 deletion src/pages/NewDashboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import useAgendaTasks from '@/hooks/useAgendaTasks'
import useNewProjects from '@/hooks/useNewProjects'
import { appAtom } from '@/newModel/app'
import { logseqAtom } from '@/newModel/logseq'
import initializeDayjs from '@/register/dayjs'
import { cn } from '@/util/util'

import Backlog from './components/Backlog'
Expand All @@ -26,6 +27,7 @@ const Dashboard = () => {
const [connectionErrorModal, setConnectionErrorModal] = useState(false)

const loadData = async () => {
initializeDayjs(1)
refreshTasks().catch(() => {
setConnectionErrorModal(true)
})
Expand Down Expand Up @@ -59,10 +61,11 @@ const Dashboard = () => {
return (
<div
className={cn(
"flex w-screen h-screen bg-gray-100 before:absolute before:pointer-events-none before:h-[180px] before:w-[240px] before:left-1/2 before:top-1/2 before:bg-gradient-conic before:from-sky-200 before:via-blue-200 before:blur-2xl before:content-[''] before:dark:from-sky-900 before:dark:via-[#0141ff] before:dark:opacity-40",
"flex w-screen h-screen bg-gray-100 before:absolute before:pointer-events-none before:h-[180px] before:w-[240px] before:bg-gradient-conic before:from-sky-200 before:via-blue-200 before:blur-2xl before:content-[''] before:dark:from-sky-900 before:dark:via-[#0141ff] before:dark:opacity-40 before:transition-all",
{
'pt-[30px]': import.meta.env.VITE_MODE === 'plugin',
},
app.view === 'calendar' ? 'before:left-1/4 before:top-2/3' : 'before:left-1/2 before:top-1/2',
)}
>
{/* ========== projects sidebar ========== */}
Expand Down
10 changes: 5 additions & 5 deletions src/util/__tests__/task.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('util/task.ts', () => {
{
start,
end: sameDayEnd,
isAllDay: true,
allDay: true,
},
'markdown',
),
Expand All @@ -49,7 +49,7 @@ describe('util/task.ts', () => {
{
start,
end: sameDayEnd,
isAllDay: true,
allDay: true,
},
'org',
),
Expand All @@ -61,7 +61,7 @@ describe('util/task.ts', () => {
{
start,
end: sameDayEnd,
isAllDay: false,
allDay: false,
},
'markdown',
),
Expand All @@ -75,7 +75,7 @@ describe('util/task.ts', () => {
{
start,
end: notSameDayEnd,
isAllDay: true,
allDay: true,
},
'markdown',
),
Expand All @@ -87,7 +87,7 @@ describe('util/task.ts', () => {
{
start,
end: notSameDayEnd,
isAllDay: false,
allDay: false,
},
'markdown',
),
Expand Down
14 changes: 7 additions & 7 deletions src/util/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,25 @@ export const genTaskTimeLinkText = (
{
start,
end,
isAllDay = true,
allDay = true,
}: {
start: Dayjs
end: Dayjs
isAllDay?: boolean
allDay?: boolean
},
logseqFormat: AppUserConfigs['preferredFormat'] = 'markdown',
) => {
const url = new URL('agenda://')
url.searchParams.append('start', '' + start.valueOf())
url.searchParams.append('end', '' + end.valueOf())
if (isAllDay === false) url.searchParams.append('allDay', 'false')
if (allDay === false) url.searchParams.append('allDay', 'false')

const startText = isAllDay ? start.format(DATE_FORMATTER) : start.format(DATE_TIME_FORMATTER)
let endText = isAllDay ? end.format(DATE_FORMATTER) : end.format(DATE_TIME_FORMATTER)
const startText = allDay ? start.format(DATE_FORMATTER) : start.format(DATE_TIME_FORMATTER)
let endText = allDay ? end.format(DATE_FORMATTER) : end.format(DATE_TIME_FORMATTER)

const isSingleDayTask = start.isSame(end, 'day')
if (isSingleDayTask && isAllDay) endText = ''
if (isSingleDayTask && !isAllDay) endText = end.format('HH:mm')
if (isSingleDayTask && allDay) endText = ''
if (isSingleDayTask && !allDay) endText = end.format('HH:mm')

const showText = startText + (endText ? ` - ${endText}` : '')
const time = logseqFormat === 'org' ? `>[[#${url.toString()}][${showText}]]` : `>[${showText}](#${url.toString()})`
Expand Down

0 comments on commit 08508c3

Please sign in to comment.