mirror of https://github.com/logseq/logseq
Update repeater timestamp when the task was checked
parent
6c2403f3a3
commit
b4270e057e
|
@ -39,7 +39,8 @@
|
|||
(db/get-date-scheduled-or-deadlines (string/capitalize page-name))
|
||||
nil)
|
||||
n-ref (count ref-blocks)]
|
||||
(when (> n-ref 0)
|
||||
(when (or (> n-ref 0)
|
||||
(seq scheduled-or-deadlines))
|
||||
[:div.references.mt-6.flex-1.flex-row
|
||||
[:div.content
|
||||
(when (seq scheduled-or-deadlines)
|
||||
|
|
|
@ -205,7 +205,7 @@
|
|||
;; enable scroll
|
||||
(let [main (d/by-id "main-content")]
|
||||
(d/remove-class! main "overflow-hidden")
|
||||
(d/add-class! main "overflow-y-auto"))
|
||||
(d/add-class! main "overflow-y-scroll"))
|
||||
(if-not (state/get-selection-start-block)
|
||||
(editor-handler/clear-selection! e)
|
||||
(state/set-selection-start-block! nil))))
|
||||
|
@ -413,7 +413,7 @@
|
|||
(state/toggle-sidebar-open?!))}
|
||||
(svg/menu)]]]]
|
||||
|
||||
[:div#main-content.flex.wrapper.overflow-y-auto {:style {:height "100vh"}}
|
||||
[:div#main-content.flex.wrapper.overflow-y-scroll {:style {:height "100vh"}}
|
||||
(when-not config/mobile?
|
||||
[:div#sidebar-nav-wrapper.flex-col.pt-4
|
||||
{:style {:flex (if (state/get-left-sidebar-open)
|
||||
|
|
|
@ -192,4 +192,4 @@
|
|||
|
||||
;; :date 2020-05-31
|
||||
;; :rfc822 Sun, 31 May 2020 03:00:57 Z
|
||||
)
|
||||
)
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
[medley.core :as medley]
|
||||
[frontend.text :as text]
|
||||
[frontend.date :as date]
|
||||
[frontend.handler.repeated :as repeated]
|
||||
[clojure.core.async :as async]))
|
||||
|
||||
;; TODO: refactor the state, it is already too complex.
|
||||
|
@ -756,13 +757,24 @@
|
|||
:blocks-container-id (:id config)
|
||||
:current-page (state/get-current-page)})))
|
||||
|
||||
|
||||
;; TODO: utf8 encode performance
|
||||
|
||||
(defn update-timestamps-content!
|
||||
[{:block/keys [repeated? scheduled-ast deadline-ast marker]} content]
|
||||
(if repeated?
|
||||
(some->> (filter repeated/repeated? [scheduled-ast deadline-ast])
|
||||
(map (fn [ts]
|
||||
[(repeated/timestamp->text ts)
|
||||
(repeated/next-timestamp-text ts)]))
|
||||
(reduce (fn [content [old new]]
|
||||
(string/replace content old new))
|
||||
content))
|
||||
content))
|
||||
|
||||
(defn check
|
||||
[{:block/keys [uuid marker content meta file dummy?] :as block}]
|
||||
(let [new-content (string/replace-first content marker "DONE")]
|
||||
[{:block/keys [uuid marker content meta file dummy? repeated?] :as block}]
|
||||
(let [new-content (string/replace-first content marker "DONE")
|
||||
new-content (if repeated?
|
||||
(update-timestamps-content! block content)
|
||||
new-content)]
|
||||
(save-block-if-changed! block new-content)))
|
||||
|
||||
(defn uncheck
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
(ns frontend.handler.repeated
|
||||
(:require [cljs-time.core :as t]
|
||||
[cljs-time.local :as tl]
|
||||
[cljs-time.format :as tf]
|
||||
[frontend.util :as util]))
|
||||
|
||||
(def custom-formatter (tf/formatter "yyyy-MM-dd EEE"))
|
||||
|
||||
(defn repeated?
|
||||
[timestamp]
|
||||
(some? (:repetition timestamp)))
|
||||
|
||||
(defn- get-duration-f-and-text
|
||||
[duration]
|
||||
(case duration
|
||||
"Hour"
|
||||
[t/hours "h"]
|
||||
"Day"
|
||||
[t/days "d"]
|
||||
"Week"
|
||||
[t/weeks "w"]
|
||||
"Month"
|
||||
[t/months "m"]
|
||||
"Year"
|
||||
[t/years "y"]
|
||||
nil))
|
||||
|
||||
(defn timestamp->text
|
||||
([timestamp]
|
||||
(timestamp->text timestamp nil))
|
||||
([{:keys [date wday repetition time active]} start-time]
|
||||
(let [{:keys [year month day]} date
|
||||
{:keys [hour min]
|
||||
:or {hour 0 min 0}} time
|
||||
[hour min] (if start-time
|
||||
[(t/hour start-time)
|
||||
(t/minute start-time)]
|
||||
[hour min])
|
||||
[[kind] [duration] num] repetition
|
||||
start-time (or start-time (t/local-date-time year month day hour min))
|
||||
[duration-f d] (get-duration-f-and-text duration)
|
||||
kind (case kind
|
||||
"Plus"
|
||||
"+"
|
||||
"Dotted"
|
||||
".+"
|
||||
"++")
|
||||
repeater (str kind num d)
|
||||
time-repeater (if time
|
||||
(str (util/zero-pad hour) ":" (util/zero-pad min) " " repeater)
|
||||
repeater)]
|
||||
(util/format "<%s %s>"
|
||||
(tf/unparse custom-formatter start-time)
|
||||
time-repeater))))
|
||||
|
||||
(defn next-timestamp-text
|
||||
[{:keys [date wday repetition time active] :as timestamp}]
|
||||
(let [{:keys [year month day]} date
|
||||
{:keys [hour min]
|
||||
:or {hour 0 min 0}} time
|
||||
[[kind] [duration] num] repetition
|
||||
start-time (if (= kind "Plus")
|
||||
(t/local-date-time year month day hour min)
|
||||
(tl/local-now))
|
||||
[duration-f _] (get-duration-f-and-text duration)
|
||||
start-time' (t/plus start-time (duration-f num))]
|
||||
(timestamp->text timestamp start-time')))
|
Loading…
Reference in New Issue