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