website/web/templates/account/my_user_notes.html
2024-08-22 22:53:37 -07:00

174 lines
7.7 KiB
HTML

{{define "title"}}
My User Notes
{{end}}
{{define "content"}}
<div class="container">
<section class="hero is-link is-bold">
<div class="hero-body">
<div class="container">
<div class="level">
<div class="level-left">
<h1 class="title">
<span class="icon mr-4"><i class="fa fa-pen-square"></i></span>
<span>{{template "title" .}}</span>
</h1>
</div>
</div>
</div>
</div>
</section>
{{$Root := .}}
<div class="block p-4">
<div class="block">
You have saved <strong>{{.Pager.Total}}</strong> note{{Pluralize64 .Pager.Total}} about other members on {{PrettyTitle}} (page {{.Pager.Page}} of {{.Pager.Pages}}).
</div>
<!-- Filters -->
<div class="block">
<form action="{{.Request.URL.Path}}" method="GET">
<div class="card nonshy-collapsible-mobile">
<header class="card-header has-background-link-light">
<p class="card-header-title">
Search &amp; Sort
</p>
<button class="card-header-icon" type="button">
<span class="icon">
<i class="fa fa-angle-up"></i>
</span>
</button>
</header>
<div class="card-content">
<div class="columns is-multiline mb-0">
<div class="column">
<div class="field">
<label class="label" for="search">Search by username or content:</label>
<input type="text" class="input" name="search" id="search" placeholder="Search" value="{{.Search}}">
</div>
</div>
<!-- Admin Notes filter -->
{{if .CurrentUser.HasAdminScope "admin.user.notes"}}
<div class="column">
<div class="field">
<label class="label has-text-danger" for="admin_notes"><i class="fa fa-peace mr-1"></i> Admin Notes:</label>
<label class="checkbox">
<input type="checkbox" id="admin_notes"
name="admin_notes"
value="true"
{{if .AdminNotes}}checked{{end}}>
Show all notes by admin users
</label>
</div>
</div>
{{end}}
<div class="column">
<div class="field">
<label class="label" for="sort">Sort by:</label>
<div class="select is-fullwidth">
<select id="sort" name="sort">
<option value="updated_at desc"{{if eq .Sort "updated_at desc"}} selected{{end}}>Recently updated</option>
<option value="updated_at asc"{{if eq .Sort "updated_at asc"}} selected{{end}}>Oldest first</option>
<option value="username asc"{{if eq .Sort "username asc"}} selected{{end}}>Username (a-z)</option>
<option value="username desc"{{if eq .Sort "username desc"}} selected{{end}}>Username (z-a)</option>
</select>
</div>
</div>
</div>
<div class="column is-narrow has-text-centered">
<label class="label">&nbsp;</label><!-- Spacing :( -->
<a href="{{.Request.URL.Path}}" class="button">Reset</a>
<button type="submit" class="button is-success">
Apply Filters
</button>
</div>
</div>
</div>
</div>
</form>
</div>
{{SimplePager .Pager}}
{{range .Notes}}
<div class="card has-background-link-light mb-4">
{{$User := $Root.UserMap.Get .AboutUserID}}
<div class="card-content" style="position: relative">
<div class="columns">
<div class="column is-2 has-text-centered">
<div>
<a href="/u/{{$User.Username}}">
{{template "avatar-96x96" $User}}
</a>
</div>
<a href="/u/{{$User.Username}}">{{$User.Username}}</a>
{{if $User.IsAdmin}}
<div class="is-size-7 mt-1">
<span class="tag is-danger is-light">
<span class="icon"><i class="fa fa-peace"></i></span>
<span>Admin</span>
</span>
</div>
{{end}}
</div>
<div class="column">
<strong>About:</strong>
<a href="/u/{{$User.Username}}">{{$User.Username}}</a>
{{if $User.IsAdmin}}
<span class="tag ml-2 is-danger is-light">
<i class="fa fa-peace mr-1"></i> Admin
</span>
{{end}}
<!-- Admin Notes view? Say which admin wrote this note. -->
{{if $Root.AdminNotes}}
<span class="ml-4">
<strong>Written by:</strong>
{{$AdminUser := $Root.AdminUserMap.Get .UserID}}
<a href="/u/{{$AdminUser.Username}}">{{$AdminUser.Username}}</a>
</span>
{{end}}
<div class="my-2" style="white-space: pre-wrap; word-break: break-word; overflow: auto">{{.Message}}</div>
<div class="mt-3">
<form method="POST" action="{{$Root.Request.URL.Path}}">
{{InputCSRF}}
<input type="hidden" name="intent" value="delete">
<input type="hidden" name="id" value="{{.ID}}">
<em class="has-text-grey mr-3">
Last updated <span title="{{.UpdatedAt}}">{{SincePrettyCoarse .UpdatedAt}} ago.</span>
</em>
<!-- Delete button -->
{{if eq $Root.CurrentUser.ID .UserID}}
<button type="submit" class="button is-small is-outlined is-danger"
onclick="return confirm('Do you want to delete this note?')">
<i class="fa fa-trash mr-1"></i>
Delete
</button>
{{end}}
</form>
</div>
</div>
</div>
</div>
</div>
{{end}}
{{SimplePager .Pager}}
</div>
</div>
{{end}}