Skip to content

Commit

Permalink
fix: 🐛 set end time to day end
Browse files Browse the repository at this point in the history
  • Loading branch information
haydenull committed Mar 11, 2022
1 parent 08b7940 commit 8679df3
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 15 deletions.
52 changes: 46 additions & 6 deletions README-zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,24 @@

我们将带有 `"TODO" "DOING" "NOW" "LATER" "WAITING" "DONE"` 的笔记称作任务。
### 展示所有笔记中的日程
![defaultCalendar](./defaultCalendar.gif)
![defaultCalendar](./screenshots/defaultCalendar.gif)
journal 日历会收集所有设置了`scheduled``deadline`的任务,并且以`scheduled` `deadline`为开始时间。

`scheduled` `deadline` 设置了时间时, 会认为是 `time` 日程。会显示在时间线中。

否则认为是 `allday` 日程。

### 创建自己的日历
![customCalendar](./customCalendar.gif)
![customCalendar](./screenshots/customCalendar.gif)

### 展示日记中的日程
![journal](./journal.gif)
![journal](./screenshots/journal.gif)
journal 日历会收集所有 journals 中的没有 `scheduled` `deadline` 的任务,并且以 journals 的日期为任务时间。

它会被认作 `allday` 任务。

### 展示每日日志
![dailyLog](./dailyLog.gif)
![dailyLog](./screenshots/dailyLog.gif)

## 设置

Expand Down Expand Up @@ -59,7 +59,7 @@ journal 日历会收集所有 journals 中的没有 `scheduled` `deadline` 的

#### 默认日历 journal

![journalCalendar](./JournalCalendar.png)
![journalCalendar](./screenshots/JournalCalendar.png)

默认的 journal 日历将会收集以下信息并展示在日历中:
1. 所有有 scheduled 或 deadline 的任务(使用 `scheduled` `deadline` 作为任务计划时间)
Expand All @@ -71,4 +71,44 @@ journal 日历会收集所有 journals 中的没有 `scheduled` `deadline` 的

> 所有日历的 query 都是开放可修改的, 你可以根据需求自己定制
等待完善文档
那么如何定制自己的日历呢?

答案是新建日历,然后修改 [query](https://logseq.github.io/#/page/advanced%20queries)

插件会以填写的 query script 作为参数调用[logseq.DB.datascriptQuery](https://logseq.github.io/plugins/interfaces/IDBProxy.html#datascriptQuery) API, 然后将结果展示在日历中.

让我来解释一下有哪些配置项:
1. `script`: 作为 datascriptQuery 的参数, 查询所有符合要求的 block
2. `schedule start`: datascriptQuery 查询的 block 取出 `schedule start` 指定的字段作为 schedule 开始时间
3. `schedule end`: datascriptQuery 查询的 block 取出 `schedule end` 指定的字段作为 schedule 结束时间
4. `date formatter`: 日期格式, 以此为参数使用 [dayjs](https://day.js.org/docs/en/display/format)`schedule start` `schedule end` 转换为日期
5. `is milestone`: 是否是里程碑, 如果是, 则会展示在日历 Milestone 中

示例:

当前我们有一个 test-agenda 的笔记:

其中 custom calenda demo 具有 start end 属性, 我们想让它显示在日历中,而 common text 不显示.

![test-agenda](./screenshots/test-agenda.png)

我们使用如下 query script 查询位于 test-agenda 页面中的 block:

```clojure
[:find (pull ?block [*])
:where
[?block :block/properties ?p]
[(get ?p :start) ?s]
[(get ?p :end) ?e]
[?page :block/name ?pname]
[?block :block/page ?page]
[(contains? #{"test-agenda"} ?pname)]]
```

完整配置如下图:

![customQuery](./screenshots/customQuery.png)

那么最终日历中会显示以下内容:

![customCalendar](./screenshots/customQueryCalendar.png)
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ English | [简体中文](./README-zh_CN.md)
## Demo
We will call notes with `"TODO" "DOING" "NOW" "LATER" "WAITING" "DONE"` as tasks.
### show all task in your notes
![defaultCalendar](./defaultCalendar.gif)
![defaultCalendar](./screenshots/defaultCalendar.gif)
journal calendar will collect all tasks with `scheduled` or `deadline` and start time is `scheduled` or `deadline`.

When `scheduled` `deadline` set time, it will be treated as `time` agenda. It will be shown in time line.

Otherwise, it will be treated as `all day` agenda.

### create your own calendar
![customCalendar](./customCalendar.gif)
![customCalendar](./screenshots/customCalendar.gif)

### show task in your journal
![journal](./journal.gif)
![journal](./screenshots/journal.gif)

### show your daily log
![dailyLog](./dailyLog.gif)
![dailyLog](./screenshots/dailyLog.gif)

## Settings

Expand Down Expand Up @@ -53,7 +53,7 @@ There are three situations:
### Calendars

#### Default Calendar journal
![journalCalendar](./JournalCalendar.png)
![journalCalendar](./screenshots/JournalCalendar.png)

The default Journal calendar will collect the following information and display in the calendar:
1. All tasks with Scheduled or Deadline (using `scheduled`` deadline` as agenda planning time)
Expand Down
File renamed without changes
File renamed without changes
Binary file added screenshots/customQuery.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/customQueryCalendar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Binary file added screenshots/test-agenda.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/components/QueryModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const QueryModal: React.FC<Partial<{
</Row>
</Form.Item>
<div className="absolute bottom-4 right-4">
<Tooltip title="Execute this query statement in DevTool">
<Tooltip title="Execute this query statement in DevTools">
<PlayCircleOutlined onClick={() => onClickPlay(index)} />
</Tooltip>
{ index !== 0 && <MinusCircleOutlined className="ml-2" onClick={() => remove(field.name)} /> }
Expand Down
6 changes: 3 additions & 3 deletions src/util/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export const getSchedules = async () => {
let hasTime = /[Hhm]+/.test(dateFormatter || '')

let _start = start && genCalendarDate(start, dateFormatter)
let _end = end && genCalendarDate(end, dateFormatter)
let _end = end && (hasTime ? genCalendarDate(end, dateFormatter) : dayjs(end, dateFormatter).endOf('day').format())
if (start && ['scheduled', 'deadline'].includes(scheduleStart)) {
const dateString = block.content?.split('\n')?.find(l => l.startsWith(`${scheduleStart.toUpperCase()}:`))?.trim()
const time = / (\d{2}:\d{2})[ >]/.exec(dateString)?.[1] || ''
Expand Down Expand Up @@ -224,7 +224,7 @@ function genSchedule(params: {
return {
id: blockData.id,
calendarId: calendarConfig.id,
title,
title: isDone ? `✅${title}` : title,
body: blockData.content,
category,
dueDateClass: '',
Expand All @@ -235,7 +235,7 @@ function genSchedule(params: {
bgColor: calendarConfig?.bgColor,
borderColor: calendarConfig?.borderColor,
isAllDay,
customStyle: isDone ? 'opacity: 0.65;' : '',
customStyle: isDone ? 'opacity: 0.6;' : '',
}
}

Expand Down

0 comments on commit 8679df3

Please sign in to comment.