fix(editor): revise date-picker opending conditions

Releated #8238
This commit is contained in:
Andelf
2023-01-13 01:45:14 +08:00
parent acda57e1b1
commit 6f01b40f24
3 changed files with 38 additions and 31 deletions

View File

@@ -144,24 +144,23 @@
(contains? #{"deadline" "scheduled"}
(string/lower-case current-command)))
date (state/sub :date-picker/date)]
(when (= :datepicker (state/sub :editor/action))
[:div#date-time-picker.flex.flex-row {:on-click (fn [e] (util/stop e))
:on-mouse-down (fn [e] (.stopPropagation e))}
(ui/datepicker
date
{:deadline-or-schedule? deadline-or-schedule?
:on-change
(fn [e date]
(util/stop e)
(let [date (t/to-default-time-zone date)
journal (date/journal-name date)]
(when-not deadline-or-schedule?
[:div#date-time-picker.flex.flex-row {:on-click (fn [e] (util/stop e))
:on-mouse-down (fn [e] (.stopPropagation e))}
(ui/datepicker
date
{:deadline-or-schedule? deadline-or-schedule?
:on-change
(fn [e date]
(util/stop e)
(let [date (t/to-default-time-zone date)
journal (date/journal-name date)]
(when-not deadline-or-schedule?
;; similar to page reference
(editor-handler/insert-command! id
(page-ref/->page-ref journal)
format
{:command :page-ref})
(state/clear-editor-action!)
(reset! commands/*current-command nil))))})
(when deadline-or-schedule?
(time-repeater))])))
(editor-handler/insert-command! id
(page-ref/->page-ref journal)
format
{:command :page-ref})
(state/clear-editor-action!)
(reset! commands/*current-command nil))))})
(when deadline-or-schedule?
(time-repeater))]))