diff --git a/context/context.go b/context/context.go index 36dc5b6..d428514 100644 --- a/context/context.go +++ b/context/context.go @@ -78,6 +78,16 @@ func (ctx *Context) UpdateForeignWishlist(w http.ResponseWriter, r *http.Request http.Error(w, "Failed to add gift idea to other user...", http.StatusInternalServerError) return } + case "delete": + claims := r.Form["unclaimed"] + unclaims := r.Form["claimed"] + gifts := append(claims, unclaims...) + err := user.RemoveGifts(gifts...) + if err != nil { + log.Printf("Failed to remove gift idea for other user: %s\n", err) + http.Error(w, "Failed to remove gift idea for other user...", http.StatusInternalServerError) + return + } default: http.Error(w, "Invalid intent", http.StatusBadRequest) } diff --git a/templates/base.gotmpl b/templates/base.gotmpl index 038a0a0..c46ff5b 100644 --- a/templates/base.gotmpl +++ b/templates/base.gotmpl @@ -28,6 +28,12 @@ const accepted = submissionNames.length > 0 && submissionNames.every((name) => acceptedNames.includes(name)); submitter.disabled = !accepted; } + function acceptAttribute(form, submitId, acceptedAttribute) { + const checkedInputs = Array.from(form.querySelectorAll("input")).filter((i) => i.checked); + const submitter = document.getElementById(submitId); + const accepted = checkedInputs.length > 0 && checkedInputs.every((i) => i.hasAttribute(acceptedAttribute)); + submitter.disabled = !accepted; + } diff --git a/templates/foreign_wishlist.gotmpl b/templates/foreign_wishlist.gotmpl index 7cc9ffa..e36f746 100644 --- a/templates/foreign_wishlist.gotmpl +++ b/templates/foreign_wishlist.gotmpl @@ -33,26 +33,19 @@

{{.Username}}'s list

{{with .Gifts}}
- - -