From 1ac76d4ad1f6691b2e7480d460a6055f8f823af6 Mon Sep 17 00:00:00 2001 From: BC Date: Thu, 21 Jun 2018 23:57:44 -0700 Subject: [PATCH] UI improvements. --- src/clj/auto_ap/routes/invoices.clj | 4 +-- src/cljs/auto_ap/views/components/modal.cljs | 34 +++++++++++-------- .../auto_ap/views/components/typeahead.cljs | 3 +- src/cljs/auto_ap/views/pages/new_invoice.cljs | 3 +- .../auto_ap/views/pages/unpaid_invoices.cljs | 1 + 5 files changed, 26 insertions(+), 19 deletions(-) diff --git a/src/clj/auto_ap/routes/invoices.clj b/src/clj/auto_ap/routes/invoices.clj index eebcc05d..1e107c8f 100644 --- a/src/clj/auto_ap/routes/invoices.clj +++ b/src/clj/auto_ap/routes/invoices.clj @@ -140,9 +140,7 @@ :date date})))) 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!) diff --git a/src/cljs/auto_ap/views/components/modal.cljs b/src/cljs/auto_ap/views/components/modal.cljs index 73d5bdce..62ba6d18 100644 --- a/src/cljs/auto_ap/views/components/modal.cljs +++ b/src/cljs/auto_ap/views/components/modal.cljs @@ -25,21 +25,27 @@ (let [{:keys [visible? saving?]} @(re-frame/subscribe [::subs/modal-state id])] (when visible? (-> [modal {:title title - :foot [:button.button.is-primary {:on-click (fn [] - (re-frame/dispatch [::events/modal-status id {:saving? true}]) - (re-frame/dispatch save-event)) - :disabled (cond saving? - "disabled" + :foot [:input.button.is-primary { + :type "submit" + :form id + :disabled (cond saving? + "disabled" - (not can-submit?) - "disabled" + (not can-submit?) + "disabled" - :else - "") - :class (when saving? - "is-loading")} - [:span action-text]] + :else + "") + :class (when saving? + "is-loading") + :value action-text} + ] :id id - :hide-event [::events/modal-status id {:visible? false}]}] - (into (r/children (r/current-component)) ) + :hide-event [::events/modal-status id {:visible? false}]} + (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)"}}])]))))) diff --git a/src/cljs/auto_ap/views/components/typeahead.cljs b/src/cljs/auto_ap/views/components/typeahead.cljs index 84829762..1f9fdf6e 100644 --- a/src/cljs/auto_ap/views/components/typeahead.cljs +++ b/src/cljs/auto_ap/views/components/typeahead.cljs @@ -3,7 +3,7 @@ [clojure.string :as str])) (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))) "")) highlighted (r/atom 0) selected (r/atom (first (first (filter #(= (first %) value) matches)))) @@ -34,6 +34,7 @@ :class class :field field :value @text + :auto-focus auto-focus :on-blur (fn [e] (cond @selected nil diff --git a/src/cljs/auto_ap/views/pages/new_invoice.cljs b/src/cljs/auto_ap/views/pages/new_invoice.cljs index 13e539bd..d412144f 100644 --- a/src/cljs/auto_ap/views/pages/new_invoice.cljs +++ b/src/cljs/auto_ap/views/pages/new_invoice.cljs @@ -7,11 +7,12 @@ (let [form-data (re-frame/subscribe [::subs/new-invoice-form])] [:div [:form - [:h1.title "New Invoice"] + [:h1.title "New InvoiceR"] [:div.field [:label.label "Vendor"] [:div.control [:input.input {:type "text" + :auto-focus true :placeholder "CINTAS" :value (:vendor @form-data) :on-change (fn [e] diff --git a/src/cljs/auto_ap/views/pages/unpaid_invoices.cljs b/src/cljs/auto_ap/views/pages/unpaid_invoices.cljs index db1a0c2c..9cde6ac2 100644 --- a/src/cljs/auto_ap/views/pages/unpaid_invoices.cljs +++ b/src/cljs/auto_ap/views/pages/unpaid_invoices.cljs @@ -426,6 +426,7 @@ [bind-field [typeahead {:matches (map (fn [x] [(:id x) (:name x)]) @(re-frame/subscribe [::subs/vendors])) :type "typeahead" + :auto-focus true :field [:vendor-id] :text-field [:vendor-name] :not-found-description #(str "Create vendor '" % "'")