feat(grfn/bbbg): Add delete event button
Change-Id: I763e7a6b367ea5b474ab3aa13c7ff21e99db34af Reviewed-on: https://cl.tvl.fyi/c/depot/+/5023 Reviewed-by: grfn <grfn@gws.fyi> Autosubmit: grfn <grfn@gws.fyi> Tested-by: BuildkiteCI
This commit is contained in:
parent
86496ca4cd
commit
c364b1273b
3 changed files with 50 additions and 13 deletions
|
@ -58,10 +58,16 @@ window.onload = () => {
|
|||
}
|
||||
|
||||
document.querySelectorAll("form").forEach((form) => {
|
||||
form.onsubmit = (e) => {
|
||||
form.addEventListener("submit", (e) => {
|
||||
if (e.target.attributes.disabled) {
|
||||
e.preventDefault();
|
||||
}
|
||||
};
|
||||
|
||||
const confirmMessage = e.target.dataset.confirm;
|
||||
if (confirmMessage != null && !confirm(confirmMessage)) {
|
||||
e.stopImmediatePropagation();
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
@ -89,8 +89,15 @@
|
|||
[:div.page-header
|
||||
[:h1 (format-date (::event/date event)
|
||||
FormatStyle/FULL)]
|
||||
[:a {:href (str "/signup-forms/" (::event/id event) )}
|
||||
"Go to Signup Form"]]
|
||||
[:div.spacer]
|
||||
[:a.button {:href (str "/signup-forms/" (::event/id event) )}
|
||||
"Go to Signup Form"]
|
||||
[:form#delete-event
|
||||
{:method :post
|
||||
:action (str "/events/" (::event/id event) "/delete")
|
||||
:data-confirm "Are you sure you want to delete this event?"}
|
||||
[:input.error {:type "submit"
|
||||
:value "Delete Event"}]]]
|
||||
[:div.stats
|
||||
[:p (pluralize (:num-rsvps event) "RSVP")]
|
||||
[:p (num-attendees event)]]
|
||||
|
@ -220,6 +227,14 @@
|
|||
:attendees attendees})))
|
||||
(not-found "Event Not Found")))
|
||||
|
||||
(POST "/delete" []
|
||||
(db/delete! db :event_attendee [:= :event-id id])
|
||||
(db/delete! db :event [:= :id id])
|
||||
(-> (redirect "/events")
|
||||
(flash/add-flash
|
||||
#:flash {:type :success
|
||||
:message "Successfully deleted event"})))
|
||||
|
||||
(GET "/attendees/import" []
|
||||
(if-let [event (db/get db :event id)]
|
||||
(page-response
|
||||
|
|
|
@ -85,10 +85,10 @@
|
|||
|
||||
[:li.active
|
||||
{:font-weight "bold"
|
||||
:border-bottom [["1px" "solid" black]]}]
|
||||
:border-bottom [["1px" "solid" black]]}]]
|
||||
|
||||
[:.spacer
|
||||
{:flex 1}]])
|
||||
{:flex 1}])
|
||||
|
||||
(def link-conditional-styles
|
||||
(list
|
||||
|
@ -165,18 +165,29 @@
|
|||
:border [[(px 1) "solid" (color/lighten blue 30)]]
|
||||
:cursor :pointer
|
||||
:display :inline-block}
|
||||
|
||||
[(& hover)
|
||||
{:border-color blue
|
||||
:text-decoration :none
|
||||
:box-shadow [[0 "1px" "5px" "rgba(0,0,0,0.075)"]]}
|
||||
[(& :a)
|
||||
[(:a &)
|
||||
{:text-decoration :none}]]
|
||||
|
||||
[(& active)
|
||||
{:background-color blue
|
||||
:color :white
|
||||
:box-shadow :none}
|
||||
[(& :a)
|
||||
{:text-decoration :none}]]]
|
||||
{:text-decoration :none}]]
|
||||
|
||||
(for [[context color] contextual-colors]
|
||||
[(& (keyword (str "." (name context))))
|
||||
{:background-color (color/lighten color 30)
|
||||
:border-color (color/lighten color 30)
|
||||
:color black}
|
||||
|
||||
[(& hover)
|
||||
{:border-color color}]])]
|
||||
|
||||
[:label
|
||||
{:font-weight 600
|
||||
|
@ -377,8 +388,13 @@
|
|||
:padding-bottom "0.7rem"
|
||||
:margin-bottom "1rem"
|
||||
:border-bottom [["1px" "solid" silver]]
|
||||
:align-items :center
|
||||
:justify-content :space-between}]
|
||||
:align-items :center}
|
||||
|
||||
[:*+*
|
||||
{:margin-left "0.5rem"}]
|
||||
|
||||
[:form
|
||||
{:margin-block-end 0}]]
|
||||
|
||||
[(attr= "role" "button")
|
||||
{:cursor :pointer}]
|
||||
|
|
Loading…
Reference in a new issue