|
@@ -43,10 +43,10 @@
|
|
|
(swap! data-atom conj {:row r :col c :value value})
|
|
|
(swap! data-atom (fn [d] (map #(if (and (= r (:row %)) (= c (:col %))) (assoc % :value value) %) d)))))
|
|
|
(defn update-display [c r display]
|
|
|
- (println (str "trying to update " c r " to " display))
|
|
|
- (swap! data-atom (fn [d] (map #(if (and (= r (:row %)) (= c (:col %))) (assoc % :display display) %) d))))
|
|
|
+ (println (str " trying to update " c r " to " display))
|
|
|
+ (swap! data-atom (fn [d] (map #(if (and (= r (:row %)) (= c (:col %)) (= (first (:value %)) "=")) (assoc % :display display) %) d))))
|
|
|
(defn toggle-display [c r view-mode]
|
|
|
- (println (str "toggling " c r " to " view-mode))
|
|
|
+ (println (str " toggling " c r " to " view-mode))
|
|
|
(swap! data-atom (fn [d] (map #(if (and (= r (:row %)) (= c (:col %))) (assoc % :view view-mode) %) d))))
|
|
|
|
|
|
; CALCULATION / FORMULA EVALUATION FUNCTIONS
|
|
@@ -67,6 +67,7 @@
|
|
|
c (re-find #"^[A-Z]+" w)
|
|
|
r (.parseInt js/window (re-find #"[0-9]+$" w))]
|
|
|
(do
|
|
|
+ (println "looking at cell " c r)
|
|
|
(update-display c r v)
|
|
|
)
|
|
|
)
|
|
@@ -105,6 +106,30 @@
|
|
|
)
|
|
|
)
|
|
|
|
|
|
+;TODO: figure out how to re-evaluate only when the cell modified affects other cells
|
|
|
+(defn re-evaluate-data []
|
|
|
+ (let [rt (temp1 @data-atom)
|
|
|
+ new-data (temp2 (:evaluated rt) (:remaining rt))
|
|
|
+ update-results (map temp3 new-data)
|
|
|
+ ]
|
|
|
+ (do
|
|
|
+ (println rt)
|
|
|
+ (println new-data)
|
|
|
+ (println "updating sheet data with above new data")
|
|
|
+ (println update-results)
|
|
|
+ (println "done")
|
|
|
+ )))
|
|
|
+
|
|
|
+
|
|
|
+(defn on-enter-cell [c r e]
|
|
|
+ (println (str "entering cell " c r))
|
|
|
+ (toggle-display c r :value))
|
|
|
+(defn on-leave-cell [c r e]
|
|
|
+ (println (str "leaving cell " c r))
|
|
|
+ (toggle-display c r :display)
|
|
|
+ (re-evaluate-data))
|
|
|
+
|
|
|
+
|
|
|
;; -------------------------
|
|
|
;; Views
|
|
|
|
|
@@ -112,8 +137,8 @@
|
|
|
(let [datum (some #(if (and (= c (:col %)) (= r (:row %))) %) data)]
|
|
|
^{:key (str c r)} [:td [:input {:value (if (= (get datum :view nil) :value) (get datum :value "") (get datum :display (get datum :value "")))
|
|
|
:on-change #(update-value c r datum (.. % -target -value))
|
|
|
- :on-blur (fn [e] (println (str "blur! " c r)) (toggle-display c r :display))
|
|
|
- :on-focus (fn [e] (println (str "focus! " c r)) (toggle-display c r :value))}]]
|
|
|
+ :on-blur (partial on-leave-cell c r)
|
|
|
+ :on-focus (partial on-enter-cell c r)}]]
|
|
|
)
|
|
|
)
|
|
|
(defn row [r cols data]
|