File tree 1 file changed +14
-11
lines changed
1 file changed +14
-11
lines changed Original file line number Diff line number Diff line change 23
23
(defn get-editor [t]
24
24
(or (get @editors t) editor-view))
25
25
26
- (defn create-edit-element [{:keys [set-fn get-fn]} {:keys [path name type] :as options}]
26
+ (defn create-edit-element [{:keys [state set-fn get-fn]} {:keys [path name type] :as options}]
27
27
(let [editor (get-editor type)]
28
28
(if (= type :label )
29
29
; label only
39
39
:display " inline-block" }}
40
40
41
41
name] ; <label for= "pet-select" >Choose a pet:</label>
42
- [editor {:set-fn (partial set-fn path)
42
+ [editor {:set-fn (partial set-fn state path)
43
43
:options options}
44
- (get-fn path)]])))
44
+ (get-fn @state path)]])))
45
45
46
46
(defn options-ui2 [{:keys [class style
47
47
edit
48
48
state
49
49
set-fn
50
- get-fn]
51
- :or {set-fn (fn [path v]
52
- ; (println "setting " path " to: " v)
53
- (swap! state assoc path v))
54
- get-fn (fn [path]
55
- (get @state path))}}]
50
+ get-fn]}]
51
+ (let [set-fn (or set-fn
52
+ (fn [path v]
53
+ ; (println "setting " path " to: " v)
54
+ (swap! state assoc path v)))
55
+ get-fn (or get-fn
56
+ (fn [state-val path]
57
+ (get state-val path)))]
56
58
(into [:div {:style style
57
59
:class class}]
58
- (map #(create-edit-element {:set-fn set-fn
59
- :get-fn get-fn} %) edit)))
60
+ (map #(create-edit-element {:state state
61
+ :set-fn set-fn
62
+ :get-fn get-fn} %) edit))))
60
63
61
64
(defn options-ui [{:keys [class style]} ; styling
62
65
{:keys [current state options]
You can’t perform that action at this time.
0 commit comments