makes it possible to filter to only errors.

This commit is contained in:
Bryce Covert
2019-08-31 07:36:11 -07:00
parent 96ec3b1cf5
commit 8a9300e928

View File

@@ -84,7 +84,16 @@
[drop-down-contents
[:div
[:span.dropdown-item (error-set (line->id %)) ]]]]
))
)
:status-category
(cond (successful-set (line->id %))
:success
(existing-set (line->id %))
:existing
(error-set (line->id %))
:error))
lis))))})))
(re-frame/reg-event-fx
@@ -110,7 +119,7 @@
(let [text-form (r/atom "")
include-headers (r/atom false)
table-form (r/atom nil)]
(fn [{:keys [headings value on-change]}]
(fn [{:keys [headings value on-change row-filter]}]
[:form.form
(if value
[:div
@@ -124,14 +133,14 @@
(for [[heading-name _] read-only-headings]
[:th heading-name]))]]
(list
(for [[index row] (map vector (range )value)]
(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)
(println value)
(on-change
(assoc-in value [index k] (.. x -target -value))))
:value (get row k)}]]))
@@ -179,26 +188,41 @@
"Imported with " (count (:errors result)) " errors, " (count (:success result)) " successful."])
(if @(re-frame/subscribe [::forms/is-loading? ::form])
[:div [:i.icon.fa.fa-spin.fa-spinner]]
[:div
[:div
[:div.is-clearfix
[:div.is-pulled-right
[:label.checkbox
[bind-field
[:input {:type "checkbox"
:event [::forms/change ::form]
:subscription data
:field [:only-show-errors?]}]]
"Only show errors"]]]
[:div
[bind-field
[textarea->table {:type "textarea->table"
:field [:line-items]
:headings [["Id" :id]
["Client" :client-code]
["Source" :source]
["Vendor" :vendor-name]
["Date" :date]
["Account" :account-identifier]
["Location" :location]
["Debit" :debit]
["Credit" :credit]]
:read-only-headings
[["status" :status]]
[bind-field
[textarea->table {:type "textarea->table"
:field [:line-items]
:headings [["Id" :id]
["Client" :client-code]
["Source" :source]
["Vendor" :vendor-name]
["Date" :date]
["Account" :account-identifier]
["Location" :location]
["Debit" :debit]
["Credit" :credit]]
:read-only-headings
[["status" :status]]
:row-filter
(fn [{:keys [status-category]}]
(if (:only-show-errors? data)
(= :error status-category)
true))
:event [::forms/change ::form]
:subscription data}
]]])]))
:event [::forms/change ::form]
:subscription data}
]]]])]))
{}))
(defn external-import-page []