refactor(ui): refactor all of the classical datepicker codes with the shui calendar

This commit is contained in:
charlie
2024-04-22 17:24:27 +08:00
parent d71e0163c4
commit 52bc99738a
11 changed files with 64 additions and 576 deletions

View File

@@ -76,63 +76,7 @@
(is (= (m+ 3 5) 8))
(is (= @actual-ops 4))
(is (= (m+ 3 5) 8))
(is (= @actual-ops 4))))
(testing "memoize-last nested mapping test"
(let [actual-ops (atom 0)
flatten-f (util/memoize-last (fn [& args]
(swap! actual-ops inc) ;; side effect for counting
(apply #'shortcut-data-helper/flatten-bindings-by-id (conj (vec args) nil true))))
target (atom {:part1 {:date-picker/complete {:binding "enter"
:fn "ui-handler/shortcut-complete"}
:date-picker/prev-day {:binding "left"
:fn "ui-handler/shortcut-prev-day"}}
:part2 {:date-picker/next-day {:binding "right"
:fn "ui-handler/shortcut-next-day"}
:date-picker/prev-week {:binding ["up" "ctrl+p"]
:fn "ui-handler/shortcut-prev-week"}}})]
(is (= (flatten-f @target) {:date-picker/complete "enter"
:date-picker/prev-day "left"
:date-picker/next-day "right"
:date-picker/prev-week ["up" "ctrl+p"]}))
(is (= @actual-ops 1))
(is (= (flatten-f @target) {:date-picker/complete "enter"
:date-picker/prev-day "left"
:date-picker/next-day "right"
:date-picker/prev-week ["up" "ctrl+p"]}))
(is (= @actual-ops 1))
;; edit value
(swap! target assoc-in [:part1 :date-picker/complete :binding] "tab")
(is (= (flatten-f @target) {:date-picker/complete "tab"
:date-picker/prev-day "left"
:date-picker/next-day "right"
:date-picker/prev-week ["up" "ctrl+p"]}))
(is (= @actual-ops 2))
(is (= (flatten-f @target) {:date-picker/complete "tab"
:date-picker/prev-day "left"
:date-picker/next-day "right"
:date-picker/prev-week ["up" "ctrl+p"]}))
(is (= @actual-ops 2))
(is (= (flatten-f @target) {:date-picker/complete "tab"
:date-picker/prev-day "left"
:date-picker/next-day "right"
:date-picker/prev-week ["up" "ctrl+p"]}))
(is (= @actual-ops 2))
;; edit key
(swap! target assoc :part3 {:date-picker/next-week {:binding "down"
:fn "ui-handler/shortcut-next-week"}})
(is (= (flatten-f @target) {:date-picker/complete "tab"
:date-picker/prev-day "left"
:date-picker/next-day "right"
:date-picker/prev-week ["up" "ctrl+p"]
:date-picker/next-week "down"}))
(is (= @actual-ops 3))
(is (= (flatten-f @target) {:date-picker/complete "tab"
:date-picker/prev-day "left"
:date-picker/next-day "right"
:date-picker/prev-week ["up" "ctrl+p"]
:date-picker/next-week "down"}))
(is (= @actual-ops 3)))))
(is (= @actual-ops 4)))))
(deftest test-media-format-from-input
(testing "predicate file type from ext (html5 supported)"