finally sunset old binding
This commit is contained in:
@@ -2,37 +2,28 @@
|
||||
(:require
|
||||
[auto-ap.events :as events]
|
||||
[auto-ap.forms :as forms]
|
||||
[auto-ap.forms.builder :as form-builder]
|
||||
[auto-ap.status :as status]
|
||||
[auto-ap.subs :as subs]
|
||||
[auto-ap.views.components :as com]
|
||||
[auto-ap.views.components.dropdown
|
||||
:refer [drop-down drop-down-contents]]
|
||||
[auto-ap.views.components.layouts :refer [side-bar-layout]]
|
||||
[auto-ap.views.pages.ledger.side-bar :refer [ledger-side-bar]]
|
||||
[auto-ap.views.utils :refer [bind-field dispatch-event]]
|
||||
[auto-ap.views.utils :refer [dispatch-event]]
|
||||
[clojure.string :as str]
|
||||
[re-frame.core :as re-frame]
|
||||
[reagent.core :as r]))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::loading
|
||||
(fn [db]
|
||||
(-> db ::loading)))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::can-submit
|
||||
(fn [db]
|
||||
true))
|
||||
|
||||
(defn line->id [{:keys [source id client-code date vendor-name] :as line}]
|
||||
(defn line->id [{:keys [source id client-code]}]
|
||||
(str client-code "-" source "-" id))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::request
|
||||
:<- [::forms/form ::form]
|
||||
(fn [{{lines :line-items :as d} :data :as g}]
|
||||
(fn [{{lines :line-items} :data}]
|
||||
(into []
|
||||
(for [[external-id lines] (group-by line->id lines)
|
||||
:let [{:keys [source id client-code date vendor-name note cleared-against] :as line} (first lines)]]
|
||||
(for [[_ lines] (group-by line->id lines)
|
||||
:let [{:keys [source client-code date vendor-name note cleared-against] :as line} (first lines)]]
|
||||
{:source source
|
||||
:external-id (line->id line)
|
||||
:client-code client-code
|
||||
@@ -139,6 +130,8 @@
|
||||
[:form.form
|
||||
(if value
|
||||
[:div
|
||||
[:a.button {:on-click #(on-change nil)}
|
||||
"reset"]
|
||||
[:table.table {:style {:width "100%"}}
|
||||
[:thead
|
||||
[:tr
|
||||
@@ -190,68 +183,72 @@
|
||||
(def balance-sheet-content
|
||||
(with-meta
|
||||
(fn []
|
||||
(let [current-client @(re-frame/subscribe [::subs/client])
|
||||
user @(re-frame/subscribe [::subs/user])
|
||||
status @(re-frame/subscribe [::status/single ::import])
|
||||
{:keys [data result active? error id]} @(re-frame/subscribe [::forms/form ::form]) ]
|
||||
[:div
|
||||
[:div.level
|
||||
[:div.level-left
|
||||
[:h1.title "Eternal Import"]]
|
||||
|
||||
[:div.level-right
|
||||
[:button.button.is-primary.is-pulled-right.is-large {:disabled (or (not data)
|
||||
(= :loading (:state status )))
|
||||
:on-click (dispatch-event [::importing])} "Import"]]]
|
||||
[status/status-notification {:statuses [[::status/single ::import]]} ]
|
||||
(when result
|
||||
[:div.notification
|
||||
"Imported with "
|
||||
(count (:errors result)) " errors, "
|
||||
(count (:ignored result)) " ignored, "
|
||||
(count (:success result)) " successful."])
|
||||
(if (= :loading (:state status ))
|
||||
[status/big-loader status]
|
||||
[: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]
|
||||
["Note" :note]
|
||||
["Cleared against" :cleared-against]]
|
||||
:read-only-headings
|
||||
[["status" :status]]
|
||||
(let [status @(re-frame/subscribe [::status/single ::import])
|
||||
{:keys [data result]} @(re-frame/subscribe [::forms/form ::form]) ]
|
||||
[form-builder/builder {:id ::form
|
||||
:submit-event [::importing]}
|
||||
[:div
|
||||
[:div.level
|
||||
[:div.level-left
|
||||
[:h1.title "Eternal Import"]]
|
||||
|
||||
[:div.level-right
|
||||
[form-builder/submit-button "Import"]]]
|
||||
[status/status-notification {:statuses [[::status/single ::import]]} ]
|
||||
(when result
|
||||
[:div.notification
|
||||
"Imported with "
|
||||
(count (:errors result)) " errors, "
|
||||
(count (:ignored result)) " ignored, "
|
||||
(count (:success result)) " successful."])
|
||||
(if (= :loading (:state status ))
|
||||
[status/big-loader status]
|
||||
[:div
|
||||
[:div.is-clearfix
|
||||
[:div.is-pulled-right
|
||||
[form-builder/raw-field-v2 {:field :only-show-errors?}
|
||||
[com/checkbox {:label "Only show errors"}]]]]
|
||||
[:div
|
||||
[form-builder/raw-field-v2 {:field :line-items}
|
||||
[textarea->table {:headings [["Id" :id]
|
||||
["Client" :client-code]
|
||||
["Source" :source]
|
||||
["Vendor" :vendor-name]
|
||||
["Date" :date]
|
||||
["Account" :account-identifier]
|
||||
["Location" :location]
|
||||
["Debit" :debit]
|
||||
["Credit" :credit]
|
||||
["Note" :note]
|
||||
["Cleared against" :cleared-against]]
|
||||
: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}
|
||||
]]]])]))
|
||||
:row-filter
|
||||
(fn [{:keys [status-category]}]
|
||||
(if (:only-show-errors? data)
|
||||
(= :error status-category)
|
||||
true))}]]]])]]))
|
||||
{}))
|
||||
|
||||
(defn external-import-page []
|
||||
(re-frame/reg-event-fx
|
||||
::mounted
|
||||
(fn [_ _]
|
||||
{:dispatch [::forms/start-form ::form]}))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::unmounted
|
||||
(fn [_ _]
|
||||
{:dispatch [::forms/form-closing ::form]}))
|
||||
|
||||
(defn external-import-page-internal []
|
||||
[side-bar-layout
|
||||
{:side-bar [ledger-side-bar]
|
||||
:main [balance-sheet-content]}])
|
||||
|
||||
(defn external-import-page []
|
||||
(r/create-class
|
||||
{:display-name "external-import-page"
|
||||
:component-will-unmount #(re-frame/dispatch-sync [::unmounted])
|
||||
:component-did-mount #(re-frame/dispatch [::mounted])
|
||||
:reagent-render external-import-page-internal}))
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
:refer [appearing-side-bar side-bar-layout]]
|
||||
[auto-ap.views.components.modal :as modal]
|
||||
[auto-ap.views.components.switch-field :refer [switch-field]]
|
||||
[auto-ap.views.components.typeahead :refer [typeahead-v3]]
|
||||
[auto-ap.views.pages.data-page :as data-page]
|
||||
[auto-ap.views.pages.ledger.side-bar :refer [ledger-side-bar]]
|
||||
[auto-ap.views.pages.ledger.table :as ledger-table]
|
||||
@@ -19,7 +18,6 @@
|
||||
date-picker
|
||||
dispatch-event
|
||||
local-today
|
||||
multi-field
|
||||
query-params
|
||||
standard
|
||||
str->date
|
||||
|
||||
Reference in New Issue
Block a user