feat: empty list prompts

This commit is contained in:
Teajey 2024-05-13 20:57:25 +12:00
parent e90ca47c5d
commit 04647f3bcd
Signed by: Teajey
GPG Key ID: 970E790FE834A713
2 changed files with 94 additions and 77 deletions

View File

@ -7,39 +7,45 @@
</li> </li>
</ul> </ul>
</nav> </nav>
<h2>{{.Username}}'s list</h2> <section>
<form method="post" action="/{{.UserReference}}/update" autocomplete="off" <h2>{{.Username}}'s list</h2>
onchange="acceptNames(this, 'claimSubmit', 'claimed', 'unclaimed'); acceptNames(this, 'completeSubmit', 'claimed');"> {{with .Gifts}}
<button id="claimSubmit" type="submit" name="mode" value="claim" disabled>Claim/Unclaim</button> <form method="post" action="/{{$.UserReference}}/update" autocomplete="off"
<button id="completeSubmit" type="submit" name="mode" value="complete" disabled>Complete</button> onchange="acceptNames(this, 'claimSubmit', 'claimed', 'unclaimed'); acceptNames(this, 'completeSubmit', 'claimed');">
<ul> <button id="claimSubmit" type="submit" name="mode" value="claim" disabled>Claim/Unclaim</button>
{{range .Gifts}} <button id="completeSubmit" type="submit" name="mode" value="complete" disabled>Complete</button>
<li> <ul>
<label> {{range .}}
{{if .ClaimantId}} <li>
{{if eq .ClaimantId $.CurrentUserId}} <label>
<input type="checkbox" name="claimed" value="{{.Id}}" {{if .Sent}}disabled{{end}}> {{if .ClaimantId}}
{{else}} {{if eq .ClaimantId $.CurrentUserId}}
<input type="checkbox" disabled> <input type="checkbox" name="claimed" value="{{.Id}}" {{if .Sent}}disabled{{end}}>
{{end}} {{else}}
{{else}} <input type="checkbox" disabled>
<input type="checkbox" name="unclaimed" value="{{.Id}}" {{if .Sent}}disabled{{end}}> {{end}}
{{end}} {{else}}
{{if .Sent}} <input type="checkbox" name="unclaimed" value="{{.Id}}" {{if .Sent}}disabled{{end}}>
<s>{{.Name}}</s> {{end}}
{{else}} {{if .Sent}}
{{.Name}} <s>{{.Name}}</s>
{{end}} {{else}}
{{if .ClaimantId}} {{.Name}}
{{if eq .ClaimantId $.CurrentUserId}} {{end}}
<span style="color: blue;">{{if .Sent}}Completed{{else}}Claimed{{end}} by you</span> {{if .ClaimantId}}
{{else}} {{if eq .ClaimantId $.CurrentUserId}}
<span style="color: red;">{{if .Sent}}Completed{{else}}Claimed{{end}} by {{.ClaimantName}}</span> <span style="color: blue;">{{if .Sent}}Completed{{else}}Claimed{{end}} by you</span>
{{end}} {{else}}
{{end}} <span style="color: red;">{{if .Sent}}Completed{{else}}Claimed{{end}} by {{.ClaimantName}}</span>
</label> {{end}}
</li> {{end}}
{{end}} </label>
</ul> </li>
</form> {{end}}
</ul>
</form>
{{else}}
<p>They haven't wished for anything. Ask them to think of some stuff!</p>
{{end}}
</section>
{{end}} {{end}}

View File

@ -10,48 +10,59 @@
<pre>{{.Reference}}</pre> <pre>{{.Reference}}</pre>
</dd> </dd>
</dl> </dl>
<h2>Your wishlist</h2> <section>
<form method="post" action="/wishlist/delete" onchange="acceptNames(this, 'deleteSubmit', 'gift')" autocomplete="off"> <h2>Your wishlist</h2>
<button id="deleteSubmit" type="submit" name="mode" value="delete" disabled>Delete</button> {{with .Gifts}}
<ul> <form method="post" action="/wishlist/delete" onchange="acceptNames(this, 'deleteSubmit', 'gift')" autocomplete="off">
{{range .Gifts}} <button id="deleteSubmit" type="submit" name="mode" value="delete" disabled>Delete</button>
<li> <ul>
<label> {{range .}}
<input type="checkbox" name="gift" value="{{.Id}}"> <li>
{{.Name}} <label>
</label> <input type="checkbox" name="gift" value="{{.Id}}">
</li>
{{end}}
</ul>
</form>
<form method="post" action="/wishlist/add">
<input name="gift_name" required>
<button type="submit">Add gift idea</button>
</form>
<h2>Your todo list</h2>
<form method="post" action="/todo/update"
onchange="acceptNames(this, 'unclaimSubmit', 'gift'); acceptNames(this, 'completeSubmit', 'gift')" autocomplete="off">
<button id="unclaimSubmit" type="submit" name="mode" value="unclaim" disabled>Unclaim</button>
<button id="completeSubmit" type="submit" name="mode" value="complete" disabled>Complete</button>
<ul>
{{range .Todo}}
<li>
<label>
{{if .Sent}}
<input type="checkbox" disabled>
{{else}}
<input type="checkbox" name="gift" value="{{.Id}}">
{{end}}
<em>
{{if .Sent}}
<s>{{.Name}}</s>
{{else}}
{{.Name}} {{.Name}}
</label>
</li>
{{end}}
</ul>
</form>
{{else}}
<p>Your list is empty. Think of some things to add!</p>
{{end}}
<form method="post" action="/wishlist/add">
<input name="gift_name" required>
<button type="submit">Add gift idea</button>
</form>
</section>
{{with .Todo}}
<section>
<h2>Your todo list</h2>
<form method="post" action="/todo/update"
onchange="acceptNames(this, 'unclaimSubmit', 'gift'); acceptNames(this, 'completeSubmit', 'gift')"
autocomplete="off">
<button id="unclaimSubmit" type="submit" name="mode" value="unclaim" disabled>Unclaim</button>
<button id="completeSubmit" type="submit" name="mode" value="complete" disabled>Complete</button>
<ul>
{{range .}}
<li>
<label>
{{if .Sent}}
<input type="checkbox" disabled>
{{else}}
<input type="checkbox" name="gift" value="{{.Id}}">
{{end}} {{end}}
</em> for <a href="/{{.RecipientRef}}">{{.RecipientName}}</a> <em>
</label> {{if .Sent}}
</li> <s>{{.Name}}</s>
{{end}} {{else}}
</ul> {{.Name}}
</form> {{end}}
</em> for <a href="/{{.RecipientRef}}">{{.RecipientName}}</a>
</label>
</li>
{{end}}
</ul>
</form>
</section>
{{end}}
{{end}} {{end}}