37 lines
2.3 KiB
Plaintext
37 lines
2.3 KiB
Plaintext
<%#
|
|
Admin user create/edit form body (todo §5), captured into the shell content slot. Config:
|
|
form { action, csrfToken, submitLabel, cancelHref, fields: field.ejs config[] }
|
|
edit? { nextLabel, stateAction, recoveryAction, deleteAction } (edit mode only)
|
|
recovery? { code?, link? } shown after a recovery link is generated
|
|
error? string shown when a write was rejected
|
|
%><%
|
|
const form = locals.form;
|
|
const edit = locals.edit;
|
|
const recovery = locals.recovery;
|
|
-%>
|
|
<div class="form-page">
|
|
<% if (locals.error) { -%>
|
|
<%- include("alert", { text: locals.error, tone: "neg" }) %>
|
|
<% } -%>
|
|
<% if (recovery) { -%>
|
|
<div class="alert alert-pos" role="status"><svg class="ico ico-sm" aria-hidden="true"><use href="#i-check-circle"/></svg><div class="alert-body"><strong>Recovery link generated</strong><% if (recovery.link) { %><span class="recovery-link"><a href="<%= recovery.link %>"><%= recovery.link %></a></span><% } %><% if (recovery.code) { %><span>Code: <code><%= recovery.code %></code></span><% } %></div></div>
|
|
<% } -%>
|
|
<form class="form-card" method="post" action="<%= form.action %>">
|
|
<input type="hidden" name="_csrf" value="<%= form.csrfToken %>">
|
|
<% form.fields.forEach((field) => { -%>
|
|
<%- include("field", field) %>
|
|
<% }) -%>
|
|
<div class="form-actions">
|
|
<a class="btn" href="<%= form.cancelHref %>">Cancel</a>
|
|
<button class="btn btn-primary" type="submit"><%= form.submitLabel %></button>
|
|
</div>
|
|
</form>
|
|
<% if (edit) { -%>
|
|
<section class="form-card admin-actions" aria-label="Account actions">
|
|
<form method="post" action="<%= edit.recoveryAction %>"><input type="hidden" name="_csrf" value="<%= form.csrfToken %>"><button class="btn" type="submit"><svg class="ico ico-sm" aria-hidden="true"><use href="#i-mail"/></svg>Send recovery link</button></form>
|
|
<form method="post" action="<%= edit.stateAction %>"><input type="hidden" name="_csrf" value="<%= form.csrfToken %>"><button class="btn" type="submit"><%= edit.nextLabel %></button></form>
|
|
<form method="post" action="<%= edit.deleteAction %>"><input type="hidden" name="_csrf" value="<%= form.csrfToken %>"><button class="btn btn-danger" type="submit"><svg class="ico ico-sm" aria-hidden="true"><use href="#i-trash"/></svg>Delete user</button></form>
|
|
</section>
|
|
<% } -%>
|
|
</div>
|