so many small tweaks due to the fact that the grid was slow.

This commit is contained in:
Bryce Covert
2020-08-12 09:18:59 -07:00
parent 5bc0e957ef
commit 255a73dc30
10 changed files with 192 additions and 161 deletions

View File

@@ -49,13 +49,14 @@
[:div.field.has-addons
[:p.control
[:a.button.is-static "Force vendor"]]
[typeahead-entity {:matches @(re-frame/subscribe [::subs/vendors])
:match->text :name
:name "vendor"
:type "typeahead"
:on-change (fn [v]
(reset! vendor v))
:value @vendor}]
[:div.control {:style {:width "400px"}}
[typeahead-entity {:matches @(re-frame/subscribe [::subs/vendors])
:match->text :name
:name "vendor"
:type "typeahead"
:on-change (fn [v]
(reset! vendor v))
:value @vendor}]]
]
[:div.tile.notification

View File

@@ -203,9 +203,10 @@
{:db (cond-> db
(#{:create :add-and-print} command) (forms/start-form ::form {:client @(re-frame/subscribe [::subs/client])
:status :unpaid
:date (date->str (c/now) standard)})
(#{:create :add-and-print} command) (-> (forms/stop-form ::form )
(forms/start-form ::form {:client @(re-frame/subscribe [::subs/client])
:status :unpaid
:date (date->str (c/now) standard)}))
(= :edit command) (forms/stop-form ::form))
:dispatch-n (cond-> [(conj invoice-created invoice)]
(= :add-and-print command) (conj (conj invoice-printed (:pdf-url (:add-and-print-invoice result)))))})))
@@ -228,111 +229,112 @@
min-total (if (= (:total (:original data)) (:outstanding-balance (:original data)))
nil
(- (:total (:original data)) (:outstanding-balance (:original data))))]
^{:key id}
(form-inline (assoc params :title "New Invoice")
[:<>
(when-not @(re-frame/subscribe [::subs/client])
(field "Client"
[typeahead-entity {:matches @(re-frame/subscribe [::subs/clients])
(with-meta
(form-inline (assoc params :title "New Invoice")
[:<>
(when-not @(re-frame/subscribe [::subs/client])
(field "Client"
[typeahead-entity {:matches @(re-frame/subscribe [::subs/clients])
:match->text :name
:type "typeahead"
:auto-focus (if @(re-frame/subscribe [::subs/client]) false true)
:field [:client]
:disabled exists?
:spec ::invoice/client}]))
(field "Vendor"
[typeahead-entity {:matches @(re-frame/subscribe [::subs/vendors])
:match->text :name
:type "typeahead"
:auto-focus (if @(re-frame/subscribe [::subs/client]) false true)
:field [:client]
:disabled exists?
:spec ::invoice/client}]))
:auto-focus (if @(re-frame/subscribe [::subs/client]) true false)
:field [:vendor]}])
(field "Vendor"
[typeahead-entity {:matches @(re-frame/subscribe [::subs/vendors])
:match->text :name
:type "typeahead"
:disabled exists?
:auto-focus (if @(re-frame/subscribe [::subs/client]) true false)
:field [:vendor]}])
(field "Date"
[date-picker {:class-name "input"
:class "input"
:format-week-number (fn [] "")
:previous-month-button-label ""
:placeholder "mm/dd/yyyy"
:next-month-button-label ""
:next-month-label ""
:type "date"
:field [:date]
:spec ::invoice/date}])
(field "Date"
[date-picker {:class-name "input"
:class "input"
:format-week-number (fn [] "")
:previous-month-button-label ""
:placeholder "mm/dd/yyyy"
:next-month-button-label ""
:next-month-label ""
:type "date"
:field [:date]
:spec ::invoice/date}])
(field "Due (optional)"
[date-picker {:class-name "input"
:class "input"
:format-week-number (fn [] "")
:previous-month-button-label ""
:placeholder "mm/dd/yyyy"
:next-month-button-label ""
:next-month-label ""
:type "date"
:field [:due]
:spec ::invoice/due}])
(field "Due (optional)"
[date-picker {:class-name "input"
:class "input"
:format-week-number (fn [] "")
:previous-month-button-label ""
:placeholder "mm/dd/yyyy"
:next-month-button-label ""
:next-month-label ""
:type "date"
:field [:due]
:spec ::invoice/due}])
[:div.field
[:label.checkbox
(raw-field
[:input {:type "checkbox"
:field [:automatically-paid-when-due]
:spec ::invoice/automatically-paid-when-due}])
" Mark as paid on due date"]]
[:div.field
[:label.checkbox
(raw-field
[:input {:type "checkbox"
:field [:automatically-paid-when-due]
:spec ::invoice/automatically-paid-when-due}])
" Mark as paid on due date"]]
(field "Invoice #"
[:input.input {:type "text"
:field [:invoice-number]
:spec ::invoice/invoice-number}])
(field "Invoice #"
[:input.input {:type "text"
:field [:invoice-number]
:spec ::invoice/invoice-number}])
(field "Total"
[money-field {:type "money"
:field [:total]
:disabled (if can-change-amount? "" "disabled")
:min min-total
:spec ::invoice/total
:step "0.01"}])
(field "Total"
[money-field {:type "money"
:field [:total]
:disabled (if can-change-amount? "" "disabled")
:min min-total
:spec ::invoice/total
:step "0.01"}])
(field nil
[expense-accounts-field {:type "expense-accounts"
:descriptor "expense account"
:locations (:locations (:client data))
:max (:total data)
:client (or (:client data) @(re-frame/subscribe [::subs/client]))
:field [:expense-accounts]}])
(field nil
[expense-accounts-field {:type "expense-accounts"
:descriptor "expense account"
:locations (:locations (:client data))
:max (:total data)
:client (or (:client data) @(re-frame/subscribe [::subs/client]))
:field [:expense-accounts]}])
(error-notification)
(error-notification)
[:div.columns
(when-not exists?
[:div.columns
(when-not exists?
[:div.column
[drop-down {:header [:button.button.is-info.is-outlined.is-medium.is-fullwidth {:aria-haspopup true
:type "button"
:on-click (dispatch-event [::events/toggle-menu ::add-and-print-invoice ])
:disabled (if @(re-frame/subscribe [::can-submit])
""
"disabled")
:class (if false
"is-loading"
"")}
"Save & Pay "
[:span " "]
[:span.icon.is-small [:i.fa.fa-angle-down {:aria-hidden "true"}]]]
:class "is-fullwidth"
:id ::add-and-print-invoice}
[:div
(list
(for [{:keys [id number name type]} (->> (:bank-accounts (:client data)) (filter :visible) (sort-by :sort-order))]
(if (= :cash type)
^{:key id} [:a.dropdown-item {:on-click (dispatch-event [::add-and-print params id :cash])} "With cash"]
(list
^{:key (str id "-check")} [:a.dropdown-item {:on-click (dispatch-event [::add-and-print params id :check])} "Print checks from " name]
^{:key (str id "-debit")} [:a.dropdown-item {:on-click (dispatch-event [::add-and-print params id :debit])} "Debit from " name]))))]]])
[:div.column
[drop-down {:header [:button.button.is-info.is-outlined.is-medium.is-fullwidth {:aria-haspopup true
:type "button"
:on-click (dispatch-event [::events/toggle-menu ::add-and-print-invoice ])
:disabled (if @(re-frame/subscribe [::can-submit])
""
"disabled")
:class (if false
"is-loading"
"")}
"Save & Pay "
[:span " "]
[:span.icon.is-small [:i.fa.fa-angle-down {:aria-hidden "true"}]]]
:class "is-fullwidth"
:id ::add-and-print-invoice}
[:div
(list
(for [{:keys [id number name type]} (->> (:bank-accounts (:client data)) (filter :visible) (sort-by :sort-order))]
(if (= :cash type)
^{:key id} [:a.dropdown-item {:on-click (dispatch-event [::add-and-print params id :cash])} "With cash"]
(list
^{:key (str id "-check")} [:a.dropdown-item {:on-click (dispatch-event [::add-and-print params id :check])} "Print checks from " name]
^{:key (str id "-debit")} [:a.dropdown-item {:on-click (dispatch-event [::add-and-print params id :debit])} "Debit from " name]))))]]])
[:div.column
(submit-button "Save")]]]))])
(submit-button "Save")]]])
{:key id}))])

View File

@@ -74,7 +74,7 @@
[grid/cell {} (date->str date) ]
[grid/cell {:class "has-text-right"} (nf amount )]
[grid/cell {} status]
[grid/cell {:style {:overflow "visible"}}
[grid/button-cell {}
[:div.buttons
(when (seq invoices)
[drop-down {:id [::invoices id]

View File

@@ -93,7 +93,7 @@
[grid/cell {} (date->str date) ]
[grid/cell {:class "has-text-right"} (nf amount )]
[grid/cell {} status]
[grid/cell {:style {:overflow "visible"}}
[grid/button-cell {}
[:div.buttons
[drop-down {:id [::expense-accounts id ]
:header [buttons/sl-icon {:aria-haspopup true

View File

@@ -97,6 +97,7 @@
::params-change
[with-user]
(fn [{:keys [user]} [_ params]]
(println "REQUERY")
{:graphql {:token user
:owns-state {:single ::page}
:query-obj (table/query params )
@@ -363,10 +364,21 @@
(re-frame/reg-event-fx
::invoice-updated
[(re-frame/path [::invoice-page :invoices])]
(fn [{:keys [db]} [_ [_ invoice]]]
{:db (merge-by db :id invoice)}))
(fn [{:keys [db]} [_ [_ invoice]]]
(let [by-id (by :id db )]
{:db (if (by-id (:id invoice))
(merge-by db :id invoice)
(into [invoice] db))})))
(re-frame/reg-event-fx
::invoice-edited
[(re-frame/path [::invoice-page :invoices])]
(fn [{:keys [db]} [_ invoice]]
(let [invoice (assoc invoice :class "live-added")]
(let [by-id (by :id db )]
{:db (if (by-id (:id invoice))
(merge-by db :id invoice)
(into [invoice] db))}))))
(re-frame/reg-event-fx
::expense-accounts-updated
@@ -630,5 +642,5 @@
[print-checks-modal]
[handwrite-checks-modal]
[change-expense-accounts-modal {:updated-event [::expense-accounts-updated]}]]
:right-side-bar [appearing-side-bar {:visible? invoice-bar-active?} [form/form {:invoice-created [::invoice-updated]
:right-side-bar [appearing-side-bar {:visible? invoice-bar-active?} [form/form {:invoice-created [::invoice-edited]
:invoice-printed [::checks-printed]}]]}]))}))