lishwist/server/templates/foreign_wishlist.gotmpl

99 lines
3.9 KiB
Go Template

{{define "navbar"}}
<nav>
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="/">Home</a>
</li>
</ul>
</nav>
<div class="flex-grow-1"></div>
<ul class="navbar-nav">
<li class="nav-item">
<div class="dropdown">
<button class="nav-link dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
Logged in as '{{.CurrentUserName}}'
</button>
<ul class="dropdown-menu">
<li>
<form class="d-contents" method="post" action="/logout">
<button class="dropdown-item" type="submit">Logout</button>
</form>
</li>
</ul>
</div>
</li>
</ul>
{{end}}
{{define "body"}}
<div class="overflow-y-scroll flex-grow-1">
<div class="container py-5">
<section class="card">
<div class="card-body">
<h2>{{.Username}}'s list</h2>
{{with .Gifts}}
<form method="post" autocomplete="off"
onchange="acceptNames(this, 'claimSubmit', 'claimed', 'unclaimed'); acceptNames(this, 'completeSubmit', 'claimed'); acceptAttribute(this, 'deleteSubmit', 'data-deletable')">
<ul class="list-group mb-3">
{{range .}}
{{$isMine := eq .ClaimantId $.CurrentUserId}}
{{$createdByMe := eq .CreatorId $.CurrentUserId}}
{{$outsideIdea := ne .RecipientId .CreatorId}}
<li class="list-group-item{{if .Sent}} list-group-item-light{{end}}">
<input id="foreignlist_select_{{.Id}}" class="form-check-input" type="checkbox"
aria-describedby="wish_detail_{{.Id}}" {{if $isMine}} name="claimed" value="{{.Id}}" {{else if
.ClaimantId}} disabled {{else}} name="unclaimed" value="{{.Id}}" {{end}} {{if .Sent}} disabled {{end}}
{{if $createdByMe}}data-deletable{{end}}>
<label class="form-check-label stretched-link" for="foreignlist_select_{{.Id}}">
{{if .Sent}}
<s>{{.Name}}</s>
{{else}}
{{.Name}}
{{end}}
</label>
{{if or .ClaimantId $outsideIdea}}
<div class="d-inline" id="wish_detail_{{.Id}}">
{{if .ClaimantId}}
<span style="color: {{if $isMine}}blue{{else}}red{{end}};">{{if .Sent}}Completed{{else}}Claimed{{end}}
by
{{if $isMine}}<em>you</em>{{else}}{{.ClaimantName}}{{end}}</span>
{{end}}
{{if $outsideIdea}}
<span style="color: green;">Added by {{if
$createdByMe}}<em>you</em>{{else}}{{.CreatorName}}{{end}}</span>
{{end}}
</div>
{{end}}
</li>
{{end}}
</ul>
<button id="claimSubmit" class="btn btn-warning" type="submit" name="intent" value="claim"
disabled>Claim/Unclaim</button>
<button id="completeSubmit" class="btn btn-success" type="submit" name="intent" value="complete"
disabled>Complete</button>
<button id="deleteSubmit" class="btn btn-danger" type="submit" name="intent" value="delete"
disabled>Delete</button>
</form>
{{else}}
<p>They don't have any gift ideas. Ask them to think of something, or add an idea yourself! 👇 (everyone
except them will be able to see it and claim it)</p>
{{end}}
<form method="post">
<div class="input-group mt-3">
<input class="form-control" name="gift_name" required aria-describedby="gift_name_help" placeholder="Write a gift idea here" autofocus>
<button class="btn btn-primary" type="submit" name="intent" value="add">Add gift idea</button>
</div>
<div id="gift_name_help" class="form-text">This will be invisible to {{.Username}}, but everyone else will be
able to see it and
possibly claim it.</div>
</form>
</div>
</section>
</div>
</div>
{{end}}