warns about how many are visible

This commit is contained in:
Bryce Covert
2019-09-19 20:18:09 -07:00
parent dbe4c7b9c4
commit b535f73e33
2 changed files with 53 additions and 50 deletions

View File

@@ -52,7 +52,6 @@
(re-frame/reg-event-db
::change
(fn [db [_ form & path-pairs]]
(println "CHANGING" path-pairs)
(reduce
(fn [db [path value]]
(assoc-in db (into [::forms form :data] path) value))

View File

@@ -120,55 +120,59 @@
include-headers (r/atom true)
table-form (r/atom nil)]
(fn [{:keys [headings value on-change row-filter]}]
[:form.form
(if value
[:div
[:table.table
[:thead
[:tr
(list
(for [[heading-name _] headings]
[:th heading-name]))
(list
(for [[heading-name _] read-only-headings]
[:th heading-name]))]]
(list
(for [[index row] (map vector (range )value)
:when (row-filter row)]
[:tr
(list
(for [[_ k] headings]
[:td
[:input.input {:on-change (fn [x]
(.preventDefault x)
(on-change
(assoc-in value [index k] (.. x -target -value))))
:value (get row k)}]]))
(list
(for [[_ k] read-only-headings]
[:td.expandable
(get row k)]))]))]
children]
[:div
[:div.field
[:p.help "Paste manual ledger entries below."]
[:textarea.textarea {:on-change #(reset! text-form (.. % -target -value))} @text-form]]
[:div.field
[:label.checkbox
[:input {:type "checkbox" :checked @include-headers :on-change #(swap! include-headers (fn [x] (not x)))}
]
" Contains Header Row"]]
[:button.button.is-medium {:on-click (fn [e]
(.preventDefault e)
(on-change
(cond->> (str/split @text-form #"\n")
@include-headers (drop 1)
true (mapv #(->> (str/split % "\t")
(map (fn [[_ k] v] [k v]) headings)
(into {}))))))}
"Parse"]
])])))
[:div
(when (> (count value) 100)
[:div.notification "Showing first 100 of " (count value)])
[:form.form
(if value
[:div
[:table.table
[:thead
[:tr
(list
(for [[heading-name _] headings]
^{:key heading-name}[:th heading-name]))
(list
(for [[heading-name _] read-only-headings]
^{:key heading-name} [:th heading-name]))]]
[:tbody
(list
(for [[index row] (map vector (range ) (take 100 value))
:when (row-filter row)]
^{:key index} [:tr
(list
(for [[_ k] headings]
^{:key k} [:td
[:input.input {:on-change (fn [x]
(.preventDefault x)
(on-change
(assoc-in value [index k] (.. x -target -value))))
:value (get row k)}]]))
(list
(for [[_ k] read-only-headings]
^{:key k} [:td.expandable
(get row k)]))]))]]
children]
[:div
[:div.field
[:p.help "Paste manual ledger entries below."]
[:textarea.textarea {:on-change #(reset! text-form (.. % -target -value))} @text-form]]
[:div.field
[:label.checkbox
[:input {:type "checkbox" :checked @include-headers :on-change #(swap! include-headers (fn [x] (not x)))}
]
" Contains Header Row"]]
[:button.button.is-medium {:on-click (fn [e]
(.preventDefault e)
(on-change
(cond->> (str/split @text-form #"\n")
@include-headers (drop 1)
true (mapv #(->> (str/split % "\t")
(map (fn [[_ k] v] [k v]) headings)
(into {}))))))}
"Parse"]
])]])))
(def balance-sheet-content
(with-meta