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) => {
|
document.querySelectorAll("form").forEach((form) => {
|
||||||
form.onsubmit = (e) => {
|
form.addEventListener("submit", (e) => {
|
||||||
if (e.target.attributes.disabled) {
|
if (e.target.attributes.disabled) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
const confirmMessage = e.target.dataset.confirm;
|
||||||
|
if (confirmMessage != null && !confirm(confirmMessage)) {
|
||||||
|
e.stopImmediatePropagation();
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -89,8 +89,15 @@
|
||||||
[:div.page-header
|
[:div.page-header
|
||||||
[:h1 (format-date (::event/date event)
|
[:h1 (format-date (::event/date event)
|
||||||
FormatStyle/FULL)]
|
FormatStyle/FULL)]
|
||||||
[:a {:href (str "/signup-forms/" (::event/id event) )}
|
[:div.spacer]
|
||||||
"Go to Signup Form"]]
|
[: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
|
[:div.stats
|
||||||
[:p (pluralize (:num-rsvps event) "RSVP")]
|
[:p (pluralize (:num-rsvps event) "RSVP")]
|
||||||
[:p (num-attendees event)]]
|
[:p (num-attendees event)]]
|
||||||
|
@ -220,6 +227,14 @@
|
||||||
:attendees attendees})))
|
:attendees attendees})))
|
||||||
(not-found "Event Not Found")))
|
(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" []
|
(GET "/attendees/import" []
|
||||||
(if-let [event (db/get db :event id)]
|
(if-let [event (db/get db :event id)]
|
||||||
(page-response
|
(page-response
|
||||||
|
|
|
@ -85,10 +85,10 @@
|
||||||
|
|
||||||
[:li.active
|
[:li.active
|
||||||
{:font-weight "bold"
|
{:font-weight "bold"
|
||||||
:border-bottom [["1px" "solid" black]]}]
|
:border-bottom [["1px" "solid" black]]}]]
|
||||||
|
|
||||||
[:.spacer
|
[:.spacer
|
||||||
{:flex 1}]])
|
{:flex 1}])
|
||||||
|
|
||||||
(def link-conditional-styles
|
(def link-conditional-styles
|
||||||
(list
|
(list
|
||||||
|
@ -165,18 +165,29 @@
|
||||||
:border [[(px 1) "solid" (color/lighten blue 30)]]
|
:border [[(px 1) "solid" (color/lighten blue 30)]]
|
||||||
:cursor :pointer
|
:cursor :pointer
|
||||||
:display :inline-block}
|
:display :inline-block}
|
||||||
|
|
||||||
[(& hover)
|
[(& hover)
|
||||||
{:border-color blue
|
{:border-color blue
|
||||||
:text-decoration :none
|
:text-decoration :none
|
||||||
:box-shadow [[0 "1px" "5px" "rgba(0,0,0,0.075)"]]}
|
:box-shadow [[0 "1px" "5px" "rgba(0,0,0,0.075)"]]}
|
||||||
[(& :a)
|
[(:a &)
|
||||||
{:text-decoration :none}]]
|
{:text-decoration :none}]]
|
||||||
|
|
||||||
[(& active)
|
[(& active)
|
||||||
{:background-color blue
|
{:background-color blue
|
||||||
:color :white
|
:color :white
|
||||||
:box-shadow :none}
|
:box-shadow :none}
|
||||||
[(& :a)
|
[(& :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
|
[:label
|
||||||
{:font-weight 600
|
{:font-weight 600
|
||||||
|
@ -377,8 +388,13 @@
|
||||||
:padding-bottom "0.7rem"
|
:padding-bottom "0.7rem"
|
||||||
:margin-bottom "1rem"
|
:margin-bottom "1rem"
|
||||||
:border-bottom [["1px" "solid" silver]]
|
:border-bottom [["1px" "solid" silver]]
|
||||||
:align-items :center
|
:align-items :center}
|
||||||
:justify-content :space-between}]
|
|
||||||
|
[:*+*
|
||||||
|
{:margin-left "0.5rem"}]
|
||||||
|
|
||||||
|
[:form
|
||||||
|
{:margin-block-end 0}]]
|
||||||
|
|
||||||
[(attr= "role" "button")
|
[(attr= "role" "button")
|
||||||
{:cursor :pointer}]
|
{:cursor :pointer}]
|
||||||
|
|
Loading…
Add table
Reference in a new issue