started working on validation on action form.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
(:require [reagent.core :as r]
|
||||
[clojure.string :as str]))
|
||||
|
||||
(defn typeahead [{:keys [matches on-change field value]}]
|
||||
(defn typeahead [{:keys [matches on-change field value class]}]
|
||||
(let [text (r/atom (or (second (first (filter #(= (first %) value) matches))) ""))
|
||||
highlighted (r/atom 0)
|
||||
selected (r/atom (first (first (filter #(= (first %) value) matches))))
|
||||
@@ -12,19 +12,20 @@
|
||||
(println [id t])
|
||||
(when on-change
|
||||
(on-change id)))]
|
||||
(fn [{:keys [matches on-change field value]}]
|
||||
(fn [{:keys [matches on-change field value class]}]
|
||||
(let [valid-matches (take 5 (for [[[id t :as match] i] (map vector matches (range))
|
||||
:when (str/includes? (.toLowerCase t) (.toLowerCase @text))]
|
||||
match))]
|
||||
[:div.typeahead
|
||||
(if @selected
|
||||
[:div.input
|
||||
[:div.input {:class class}
|
||||
[:div.control
|
||||
[:div.tags.has-addons
|
||||
[:span.tag @text]
|
||||
[:a.tag.is-delete {:on-click (fn [] (select [nil ""]))}]]]]
|
||||
|
||||
[:input.input {:type "text"
|
||||
:class class
|
||||
:field [:vendor]
|
||||
:value @text
|
||||
:on-blur (fn [e]
|
||||
|
||||
Reference in New Issue
Block a user