vendor dialog.
This commit is contained in:
@@ -4,9 +4,8 @@
|
||||
[auto-ap.views.components.modal :refer [action-modal]]
|
||||
[auto-ap.views.components.address :refer [address-field]]
|
||||
[auto-ap.views.components.typeahead :refer [typeahead]]
|
||||
|
||||
[auto-ap.expense-accounts :refer [chooseable-expense-accounts]]
|
||||
[clj-fuzzy.metrics :refer [jaccard]]
|
||||
[clj-fuzzy.metrics :refer [jaccard jaro-winkler]]
|
||||
[clojure.spec.alpha :as s]
|
||||
[clojure.string :as str]
|
||||
[auto-ap.entities.vendors :as entity]
|
||||
@@ -16,17 +15,19 @@
|
||||
(mapv #(.toLowerCase (str/join "" %))
|
||||
(partition len 1 text)))
|
||||
|
||||
(defn partial-matches-vendor? [text vendors]
|
||||
(when (> (count text) 4)
|
||||
(let [text (.toLowerCase text)]
|
||||
(defn partial-matches-vendor? [vendor vendors]
|
||||
(when (> (count (:name vendor)) 5)
|
||||
(let [text (.toLowerCase (:name vendor))]
|
||||
(->> vendors
|
||||
(filter #(not= (:id %) (:id vendor)))
|
||||
(map :name)
|
||||
(mapcat
|
||||
(fn [v] (mapv
|
||||
(fn [n] [v (jaccard text n )])
|
||||
(fn [n] [v (jaro-winkler text n ) n text])
|
||||
(ngrams v (count text)))))
|
||||
#_(sort-by second)
|
||||
(filter #(< (second %) 0.3))
|
||||
(filter #(> (second %) 0.9))
|
||||
#_(map (fn [x] (doto x println)))
|
||||
(map first)
|
||||
first))))
|
||||
|
||||
@@ -41,7 +42,7 @@
|
||||
(when (:error vendor)
|
||||
[:span.icon.has-text-danger
|
||||
[:i.fa.fa-exclamation-triangle]])]
|
||||
:warning (when-let [vendor (partial-matches-vendor? (:name vendor) all-vendors)]
|
||||
:warning (when-let [vendor (partial-matches-vendor? vendor all-vendors)]
|
||||
(str "Are you sure you don't mean " vendor "?"))
|
||||
:action-text "Save"
|
||||
:save-event save-event
|
||||
@@ -128,7 +129,6 @@
|
||||
:subscription vendor}]]
|
||||
[:span.icon.is-small.is-left
|
||||
[:i.fa.fa-phone]]]]
|
||||
|
||||
[horizontal-field
|
||||
[:label.label "Secondary"]
|
||||
[:div.control.has-icons-left
|
||||
@@ -158,7 +158,6 @@
|
||||
:subscription vendor}]]
|
||||
[:span.icon.is-small.is-left
|
||||
[:i.fa.fa-phone]]]]
|
||||
|
||||
[horizontal-field
|
||||
[:label.label "Invoice Reminders"]
|
||||
[:div.control
|
||||
@@ -183,11 +182,4 @@
|
||||
:event change-event
|
||||
:subscription vendor}]]
|
||||
" Never"]]]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(when (:saving? vendor) [:div.is-overlay {:style {"backgroundColor" "rgba(150,150,150, 0.5)"}}])]))
|
||||
|
||||
Reference in New Issue
Block a user