|
@@ -43,3 +43,27 @@
|
|
|
(println "::edit-cell-value" c r value)
|
|
|
(update-in db [:table-data] #(utils/change-datum-value % c r value))))
|
|
|
|
|
|
+; handle pressing enter (move to the next cell down)
|
|
|
+; tab is taken care of natively, and is good enough
|
|
|
+(re-frame/reg-event-fx
|
|
|
+ ::press-enter-in-cell
|
|
|
+ (fn [{:keys [db]} [_ c r]]
|
|
|
+ (let [max-row? (= (utils/highest-row (:table-data db)) r)
|
|
|
+ max-col? (= (utils/highest-col (:table-data db)) c)
|
|
|
+ new-col (if max-row?
|
|
|
+ (if max-col?
|
|
|
+ "A"
|
|
|
+ (utils/next-letter c))
|
|
|
+ c)
|
|
|
+ new-row (if max-row?
|
|
|
+ 1
|
|
|
+ (inc r))]
|
|
|
+ (println "::press-enter-in-cell" c r)
|
|
|
+ {:focus-on-cell [new-col new-row]})))
|
|
|
+
|
|
|
+(re-frame/reg-fx
|
|
|
+ :focus-on-cell
|
|
|
+ (fn [[c r]]
|
|
|
+ (println "fx for :press-enter" c r)
|
|
|
+ (.focus (.getElementById js/document (str c r)))))
|
|
|
+
|