UI improvements.

This commit is contained in:
BC
2018-06-21 23:57:44 -07:00
parent e4e2525ce9
commit 1ac76d4ad1
5 changed files with 26 additions and 19 deletions

View File

@@ -140,9 +140,7 @@
:date date})))) :date date}))))
inserted-row-count (invoices/upsert-multi! insert-rows) inserted-row-count (invoices/upsert-multi! insert-rows)
already-imported-count (- (count insert-rows) inserted-row-count) already-imported-count (- (count insert-rows) inserted-row-count)]
]
(expense-accounts/assign-defaults!) (expense-accounts/assign-defaults!)

View File

@@ -25,21 +25,27 @@
(let [{:keys [visible? saving?]} @(re-frame/subscribe [::subs/modal-state id])] (let [{:keys [visible? saving?]} @(re-frame/subscribe [::subs/modal-state id])]
(when visible? (when visible?
(-> [modal {:title title (-> [modal {:title title
:foot [:button.button.is-primary {:on-click (fn [] :foot [:input.button.is-primary {
(re-frame/dispatch [::events/modal-status id {:saving? true}]) :type "submit"
(re-frame/dispatch save-event)) :form id
:disabled (cond saving? :disabled (cond saving?
"disabled" "disabled"
(not can-submit?) (not can-submit?)
"disabled" "disabled"
:else :else
"") "")
:class (when saving? :class (when saving?
"is-loading")} "is-loading")
[:span action-text]] :value action-text}
]
:id id :id id
:hide-event [::events/modal-status id {:visible? false}]}] :hide-event [::events/modal-status id {:visible? false}]}
(into (r/children (r/current-component)) ) (into [:form {:id id
:on-submit (fn [e]
(.preventDefault e)
(re-frame/dispatch [::events/modal-status id {:saving? true}])
(re-frame/dispatch save-event))}]
(r/children (r/current-component)) )]
(into [(when saving? [:div.is-overlay {:style {"backgroundColor" "rgba(150,150,150, 0.5)"}}])]))))) (into [(when saving? [:div.is-overlay {:style {"backgroundColor" "rgba(150,150,150, 0.5)"}}])])))))

View File

@@ -3,7 +3,7 @@
[clojure.string :as str])) [clojure.string :as str]))
(defn typeahead [{:keys [matches on-change field text-field value class not-found-description (defn typeahead [{:keys [matches on-change field text-field value class not-found-description
not-found-value]}] not-found-value auto-focus]}]
(let [text (r/atom (or (second (first (filter #(= (first %) value) matches))) "")) (let [text (r/atom (or (second (first (filter #(= (first %) value) matches))) ""))
highlighted (r/atom 0) highlighted (r/atom 0)
selected (r/atom (first (first (filter #(= (first %) value) matches)))) selected (r/atom (first (first (filter #(= (first %) value) matches))))
@@ -34,6 +34,7 @@
:class class :class class
:field field :field field
:value @text :value @text
:auto-focus auto-focus
:on-blur (fn [e] :on-blur (fn [e]
(cond @selected (cond @selected
nil nil

View File

@@ -7,11 +7,12 @@
(let [form-data (re-frame/subscribe [::subs/new-invoice-form])] (let [form-data (re-frame/subscribe [::subs/new-invoice-form])]
[:div [:div
[:form [:form
[:h1.title "New Invoice"] [:h1.title "New InvoiceR"]
[:div.field [:div.field
[:label.label "Vendor"] [:label.label "Vendor"]
[:div.control [:div.control
[:input.input {:type "text" [:input.input {:type "text"
:auto-focus true
:placeholder "CINTAS" :placeholder "CINTAS"
:value (:vendor @form-data) :value (:vendor @form-data)
:on-change (fn [e] :on-change (fn [e]

View File

@@ -426,6 +426,7 @@
[bind-field [bind-field
[typeahead {:matches (map (fn [x] [(:id x) (:name x)]) @(re-frame/subscribe [::subs/vendors])) [typeahead {:matches (map (fn [x] [(:id x) (:name x)]) @(re-frame/subscribe [::subs/vendors]))
:type "typeahead" :type "typeahead"
:auto-focus true
:field [:vendor-id] :field [:vendor-id]
:text-field [:vendor-name] :text-field [:vendor-name]
:not-found-description #(str "Create vendor '" % "'") :not-found-description #(str "Create vendor '" % "'")