Merge branch 'master' into datomic
This commit is contained in:
@@ -18,9 +18,10 @@
|
||||
]
|
||||
(r/create-class
|
||||
{:reagent-render (fn [{:keys [matches on-change field text-field value class not-found-description]}]
|
||||
|
||||
(let [text @text
|
||||
valid-matches (take 5 (for [[[id t :as match] i] (map vector matches (range))
|
||||
:when (str/includes? (.toLowerCase t) (.toLowerCase text))]
|
||||
:when (str/includes? (or (some-> t .toLowerCase) "") (or (some-> text .toLowerCase) ""))]
|
||||
match))
|
||||
valid-matches (if (and not-found-description text)
|
||||
(concat valid-matches [[:not-found (not-found-description text) (not-found-value text)]])
|
||||
@@ -68,6 +69,7 @@
|
||||
false)
|
||||
true))
|
||||
:on-change (fn [e]
|
||||
(println valid-matches)
|
||||
(reset! highlighted (ffirst valid-matches))
|
||||
(select [nil (.. e -target -value)]))}
|
||||
])
|
||||
|
||||
@@ -3,8 +3,11 @@
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[reagent.core :as reagent]
|
||||
[auto-ap.subs :as subs]
|
||||
[auto-ap.events :as all-events]
|
||||
[auto-ap.events.admin.companies :as events]
|
||||
[auto-ap.entities.companies :as entity]
|
||||
|
||||
[auto-ap.views.components.typeahead :refer [typeahead]]
|
||||
[auto-ap.views.utils :refer [login-url dispatch-value-change bind-field horizontal-field dispatch-event]]
|
||||
[cljs.reader :as edn]
|
||||
[auto-ap.routes :as routes]
|
||||
@@ -16,6 +19,11 @@
|
||||
(fn [db]
|
||||
(::excel-import db)))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::expense-accounts
|
||||
(fn [db]
|
||||
(::expense-accounts db)))
|
||||
|
||||
(re-frame/reg-event-db
|
||||
::change
|
||||
(fn [db [_ field v]]
|
||||
@@ -71,13 +79,15 @@
|
||||
::create-vendors
|
||||
(fn [{:keys [db]}]
|
||||
(let [excel-import (::excel-import db)]
|
||||
(println (::expense-accounts db))
|
||||
{:https {:requests (map (fn [v]
|
||||
{:token (:user db)
|
||||
:method :post
|
||||
:body (pr-str {:name v})
|
||||
:body (pr-str {:name v :default-expense-account (-> db ::expense-accounts (get v) :default-expense-account) })
|
||||
:headers {"Content-Type" "application/edn"}
|
||||
:uri (str "/api/vendors/")})
|
||||
(get-in db [::excel-import :create-vendors]))
|
||||
(doto (get-in db [::excel-import :create-vendors])
|
||||
println))
|
||||
:on-success [::create-vendor-complete]
|
||||
:on-error [::create-vendor-error]}
|
||||
:db (-> db
|
||||
@@ -98,7 +108,11 @@
|
||||
(let [{{:keys [vendors-not-found already-imported imported]} :rows
|
||||
:keys [create-vendors]
|
||||
:or {create-vendors #{}}
|
||||
:as excel-import-data} @(re-frame/subscribe [::excel-import])]
|
||||
:as excel-import-data} @(re-frame/subscribe [::excel-import])
|
||||
data @(re-frame/subscribe [::expense-accounts])
|
||||
|
||||
chooseable-expense-accounts @(re-frame/subscribe [::subs/chooseable-expense-accounts])
|
||||
change-event [::all-events/change-form [::expense-accounts]]]
|
||||
[:div
|
||||
[:h1.title "Import Invoices from Integreat Excel"]
|
||||
(when (seq vendors-not-found)
|
||||
@@ -113,17 +127,26 @@
|
||||
^{:key i}
|
||||
[:div.column
|
||||
(for [v vendor-group]
|
||||
^{:key v} [:div.control
|
||||
[:label.checkbox
|
||||
[:input {:value v
|
||||
:checked (if (create-vendors v)
|
||||
"checked"
|
||||
"")
|
||||
^{:key v} [:div.field.is-grouped
|
||||
[:p.control
|
||||
[:label.checkbox
|
||||
[:input {:value v
|
||||
:checked (if (create-vendors v)
|
||||
"checked"
|
||||
"")
|
||||
|
||||
:type "checkbox"
|
||||
:on-change (fn []
|
||||
(re-frame/dispatch [::toggle-vendor v]))}]
|
||||
(str " " v)]])])]
|
||||
:type "checkbox"
|
||||
:on-change (fn []
|
||||
(re-frame/dispatch [::toggle-vendor v]))}]
|
||||
(str " " v)]]
|
||||
|
||||
[:p.control
|
||||
[bind-field
|
||||
[typeahead {:matches (map (fn [x] [(:id x) (:name x)]) chooseable-expense-accounts)
|
||||
:type "typeahead"
|
||||
:field [v :default-expense-account]
|
||||
:event change-event
|
||||
:subscription data}]]]])])]
|
||||
[:div
|
||||
[:button.button.is-pulled-right
|
||||
{:on-click (dispatch-event [::create-vendors])
|
||||
|
||||
@@ -554,7 +554,7 @@
|
||||
(for [{:keys [id number name]} (:bank-accounts current-company)]
|
||||
^{:key id} [:option {:value id} name])]]]]
|
||||
|
||||
[:table.table
|
||||
[:table.table.is-fullwidth
|
||||
[:thead
|
||||
[:tr
|
||||
[:th "Vendor"]
|
||||
|
||||
Reference in New Issue
Block a user