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) (when (:warning report)
[:div.notification.is-warning.is-light [:div.notification.is-warning.is-light
(:warning report)]) (:warning report)])
[rtable/table {:widths (into [20] (take (dec (rtable/cell-count table)) [rtable/table {:widths (into [20] (take (dec (rtable/cell-count table))
(mapcat identity (mapcat identity
(repeat (repeat
(if (-> pnl-data :args :include-deltas) (if (-> pnl-data :args :include-deltas)
[13 6 13] [13 6 13]
[13 6]))))) [13 6])))))
:click-event ::investigate-clicked :click-event ::investigate-clicked
:table table}]])) :table table}]]))
(defn profit-and-loss-content [] (defn profit-and-loss-content []

View File

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