Merge branch 'master' into port-datomic-cloud

This commit is contained in:
2023-04-07 14:10:15 -07:00
2 changed files with 50 additions and 42 deletions

View File

@@ -436,14 +436,14 @@ NOTE: Please review the transactions we may have question for you here: https://
(when (:warning report)
[:div.notification.is-warning.is-light
(:warning report)])
[rtable/table {:widths (into [20] (take (dec (rtable/cell-count table))
(mapcat identity
(repeat
(if (-> pnl-data :args :include-deltas)
[13 6 13]
[13 6])))))
[rtable/table {:widths (into [20] (take (dec (rtable/cell-count table))
(mapcat identity
(repeat
(if (-> pnl-data :args :include-deltas)
[13 6 13]
[13 6])))))
:click-event ::investigate-clicked
:table table}]]))
:table table}]]))
(defn profit-and-loss-content []

View File

@@ -3,7 +3,7 @@
[clojure.string :as str]
[auto-ap.views.utils :refer [->$ ->% dispatch-event]]))
(defn cell [{:keys [width click-event]} c]
(defn cell [{:keys [width click-event other-style]} c]
(let [cell-contents (cond
(= :dollar (:format c))
@@ -19,7 +19,8 @@
cell-contents]
cell-contents)]
[:td
(cond-> {:style {:width (str width "em")}}
(cond-> {:style (cond-> {:width (str width "em")}
other-style (merge other-style))}
(:border c) (update :style
(fn [s]
@@ -38,9 +39,9 @@
(str/join ","
(:color c))
")"))
(:bg-color c) (assoc-in [:style :background-color] (str "rgb("
true (assoc-in [:style :background-color] (str "rgb("
(str/join ","
(:bg-color c))
(or (:bg-color c) [255 255 255]))
")")))
cell-contents]))
@@ -53,38 +54,45 @@
(defn table [{:keys [table widths click-event]}]
(let [cell-count (cell-count table)]
(-> [:table.table.compact.balance-sheet {:style nil}
(map
(fn [i header]
(into ^{:key i}
[:tr]
(map
(fn [w header i]
^{:key i} [cell {:width w :click-event click-event} header])
widths
header
(range))))
(range)
(:header table))]
[:div {:style {:height "70vh"
:overflow-y "auto"}}
(-> [:table.table.compact.balance-sheet
(map
(fn [header-row header]
(into ^{:key header-row}
[:tr]
(map
(fn [w header i]
^{:key i} [cell {:width w :click-event click-event
:other-style {:position "sticky"
:top (* header-row (+ 22 18))}} header])
widths
header
(range))))
(range)
(:header table))]
(into
(for [[i row] (map vector (range) (:rows table))]
^{:key i}
[:tr
(for [[i c] (map vector (range) (take cell-count
(reduce
(fn [[acc cnt] cur]
(if (>= (+ cnt (:colspan cur 1)) cell-count)
(reduced (conj acc cur))
[(conj acc cur) (+ cnt (:colspan cur 1))]))
[[] 0]
(concat row (repeat nil)))))]
^{:key i}
[cell {:click-event click-event} c])]))
(conj ^{:key "last"}
[:tr (for [i (range cell-count)]
^{:key i}
[cell {:click-event click-event} {:value " "}])]))))
(conj
(-> [:tbody {:style {}}]
(into
(for [[i row] (map vector (range) (:rows table))]
^{:key i}
[:tr
(for [[i c] (map vector (range) (take cell-count
(reduce
(fn [[acc cnt] cur]
(if (>= (+ cnt (:colspan cur 1)) cell-count)
(reduced (conj acc cur))
[(conj acc cur) (+ cnt (:colspan cur 1))]))
[[] 0]
(concat row (repeat nil)))))]
^{:key i}
[cell {:click-event click-event} c])]))
(conj ^{:key "last"}
[:tr (for [i (range cell-count)]
^{:key i}
[cell {:click-event click-event} {:value " "}])])))
)]))
(defn concat-tables [tables]
(let [[first & rest] tables]