Skip to content

Commit

Permalink
Improve the detail page
Browse files Browse the repository at this point in the history
finish #1

- Show Spots to everyone
  ;; As a conference attendee, I want to see how many spots are still available
- Only show attendees to organizer
  ;; As an organizer, I want to see who the participants are
  • Loading branch information
humorless committed Jul 29, 2024
1 parent 5ad4d03 commit 9c9fe70
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 14 deletions.
21 changes: 19 additions & 2 deletions repl-sessions/db.clj
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,29 @@
(db/transact [[:db/retractEntity 17592186045468]]))
(user/conn)

(db/transact [{:user/email "[email protected]"
:user/handle "laurence.chen"
:user/name "Laurence"}])

(db/q
'[:find
[(pull ?e [*]) ...]
:where
[?e :user/email]]
(db/db))

(def session-eid 17592186045438)

(db/transact [{:db/id session-eid
:session/participants 17592186045458}])

(first (:session/participants (db/entity session-eid)))
;; Test transact participants

(def req {:identity {:user/email "ddd"}
:path-params {:id "17592186045455"}})
:path-params {:id "17592186045438"}})

(def session-eid 17592186045455)
(def session-eid 17592186045438)

@(db/transact [[:db/add session-eid :session/capacity 14]
[:db/add session-eid :session/signup 0]])
Expand Down
23 changes: 12 additions & 11 deletions src/co/gaiwan/compass/html/sessions.clj
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
:hx-select (str "." session-card)
:hx-swap "outerHTML"
:on-click "event.stopPropagation()"
:hx-indicator (str ".c" (:db/id session)) }
:hx-indicator (str ".c" (:db/id session))}
(if (session/participating? session user)
"Leave"
"Participate")]
Expand Down Expand Up @@ -130,8 +130,9 @@
#_[:p.host "Organized by " organized]]]))

(o/defstyled attendee :li
([{:user/keys [name email handle uuid]}]
handle))
([{:db/keys [id]}]
(let [{:user/keys [name]} (session/attendee id)]
name)))

(o/defstyled session-detail :div
[capacity-gauge :w-100px]
Expand Down Expand Up @@ -163,14 +164,13 @@
[:div "Location "]
[:div (:location/name location)]]
[:div.capacity
[:div "Location capacity:"]
[:div capacity]]
[:div.signup-count
[:div "Current Signup:"]
[:div signup-count]]
[:div.participants
[:div "Participants:"]
[:ol (map attendee participants)]]
[:div "Spots available:"]
[:div (- (or capacity 0) (or signup-count 0))]]
(when (session/organizing? organized user)
;; Only show the participants' list to organizer.
[:div.participants
[:div "Participants:"]
[:ol (map attendee participants)]])
(when (:session/ticket-required? session)
[:p "Required Ticket"])
[:div.actions
Expand All @@ -184,6 +184,7 @@
"Leave"]
[:button "Edit"]]
#_[:p.host "Organized by " organized]
#_[:p (pr-str user)]
#_[:p (pr-str session)]]]))

(o/defstyled session-list :section#sessions
Expand Down
12 changes: 11 additions & 1 deletion src/co/gaiwan/compass/model/session.clj
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
(ns co.gaiwan.compass.model.session)
(ns co.gaiwan.compass.model.session
(:require
[co.gaiwan.compass.db :as db]))

(defn participating? [session user]
(some (comp #{(:db/id user)} :db/id)
(:session/participants session)))

(defn organizing? [organized user]
(and
(some? organized)
(= (:db/id user) (:db/id organized))))

(defn attendee [id]
(db/entity id))

0 comments on commit 9c9fe70

Please sign in to comment.