Skip to content

Commit 8cd9e4a

Browse files
committed
Improved the voting component - intent is more clear now
1 parent 3f9fef1 commit 8cd9e4a

File tree

2 files changed

+44
-40
lines changed

2 files changed

+44
-40
lines changed

resources/public/css/page.css

+4
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,7 @@
2626
margin-left: 20px;
2727
text-align: center;
2828
}
29+
30+
.vote-component {
31+
background-color: rgba(20, 184, 189, 0.15);
32+
}

src/cljs/cloodle/client.cljs

+40-40
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
(dom/a #js {:href (str "event/" code)} code))
8181

8282

83-
;; CLOODLE CODE COMPONENT
83+
;; Component that shows the Cloodle-link of the saved event
8484
(defcomponent cloodle-code [code owner]
8585

8686
(render-state [this state]
@@ -311,6 +311,7 @@
311311
(let [payload {:event-id (:_id app-state) :participant new-participant}]
312312
payload))
313313

314+
;; Component for submitting a new vote to an event
314315
(defcomponent vote-component [{:keys [app-state new-participant options]} owner]
315316

316317
(init-state [_]
@@ -319,55 +320,53 @@
319320
(will-mount [_]
320321
(let [save (om/get-state owner :save-vote-chan)]
321322

322-
323-
;; SAVE VOTE
323+
;; Saving the vote
324324
(go (loop []
325325
(let [new-participant (<! save)
326326
payload (vote->save-payload new-participant @app-state)]
327327

328-
328+
;; TODO: Assuming response contains the new participant data, show it in the UI
329329
(go
330330
(let [response (<! (http/post "api/event/vote" {:json-params payload}))
331331
status (:status response)]))
332332

333333
(recur))))))
334334

335335

336-
(render-state [this state]
337-
338-
(dom/div #js {:style #js {:border "solid black 1px"}}
339-
340-
(dom/div #js {:className "row form-group"}
341-
342-
(dom/label #js {:htmlFor "participant-name"
343-
:className "col-sm-2 control-label"}
344-
"Name")
345-
346-
(dom/div #js {:className "col-sm-6"}
347-
(dom/input #js {:id "name"
348-
:className "form-control"
349-
:type "text"
350-
:value (:name new-participant)
351-
:ref "participant-name"
352-
:onChange (fn [e]
353-
(om/transact! new-participant :name (fn [_] (.. e -target -value))))
354-
})))
355-
356-
357-
(apply dom/div nil
358-
(om/build-all option-slider
359-
(map
360-
(fn [option-cursor] {:option option-cursor
361-
:selections (:selections new-participant)})
362-
options)) )
363-
364-
365-
366-
(dom/button #js {:type "button"
367-
:className "btn btn-success"
368-
:onClick (fn [e] (put! (:save-vote-chan state) @new-participant))}
369-
"Save vote"))))
370-
336+
(render-state [this state]
337+
338+
(ddom/div {:className "vote-component"}
339+
(ddom/h2 "Vote on the options")
340+
(ddom/p "Use the sliders to express your preferences.")
341+
(ddom/div {:className "row form-group"}
342+
343+
(ddom/label {:htmlFor "participant-name"
344+
:className "col-sm-2 control-label"}
345+
"Who are you?")
346+
347+
(ddom/div {:className "col-sm-4"}
348+
(ddom/input {:id "name"
349+
:className "form-control"
350+
:type "text"
351+
:value (:name new-participant)
352+
:ref "participant-name"
353+
:onChange (fn [e]
354+
(om/transact!
355+
new-participant
356+
:name (fn [_] (.. e -target -value))))})))
357+
358+
359+
(ddom/div
360+
(om/build-all option-slider
361+
(map
362+
(fn [option-cursor] {:option option-cursor
363+
:selections (:selections new-participant)})
364+
options)))
365+
366+
(ddom/button {:type "button"
367+
:className "btn btn-success"
368+
:onClick (fn [e] (put! (:save-vote-chan state) @new-participant))}
369+
"Save vote"))))
371370

372371

373372
(defcomponent participant-component [cursors owner]
@@ -410,7 +409,8 @@
410409

411410

412411
(defn saved? [app-state]
413-
(print (str "Checking if saved: " (:cloodle-code app-state)))
412+
"Tells whether the event has been saved or is still in the process of being created.
413+
Based on the presence of :cloodle-code key in the app-state map"
414414
(not (string/blank? (:cloodle-code app-state))))
415415

416416
(defcomponent main-page [app-state owner]

0 commit comments

Comments
 (0)