Document details: inline category dropdown, formatted processed_at timestamp
This commit is contained in:
parent
4a0e9648ac
commit
9c9bd5e881
|
|
@ -12,12 +12,9 @@
|
||||||
</a>
|
</a>
|
||||||
<div>
|
<div>
|
||||||
<div class="flex items-center space-x-3 mb-1">
|
<div class="flex items-center space-x-3 mb-1">
|
||||||
<select id="inline-category" onchange="inlineUpdateCategory(this.value)"
|
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-brand-100 dark:bg-brand-900/30 text-brand-700 dark:text-brand-300">
|
||||||
class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-brand-100 dark:bg-brand-900/30 text-brand-700 dark:text-brand-300 border-0 cursor-pointer hover:bg-brand-200 dark:hover:bg-brand-900/50">
|
{{categoryIcon .Document.Category}} {{title .Document.Category}}
|
||||||
{{range .Categories}}
|
</span>
|
||||||
<option value="{{.}}" {{if eq . $.Document.Category}}selected{{end}}>{{categoryIcon .}} {{title .}}</option>
|
|
||||||
{{end}}
|
|
||||||
</select>
|
|
||||||
{{if .Document.Type}}
|
{{if .Document.Type}}
|
||||||
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-gray-100 dark:bg-gray-700 text-gray-600 dark:text-gray-300">
|
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-gray-100 dark:bg-gray-700 text-gray-600 dark:text-gray-300">
|
||||||
{{title .Document.Type}}
|
{{title .Document.Type}}
|
||||||
|
|
@ -62,6 +59,17 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="p-6">
|
<div class="p-6">
|
||||||
<dl class="grid grid-cols-2 gap-4">
|
<dl class="grid grid-cols-2 gap-4">
|
||||||
|
<div>
|
||||||
|
<dt class="text-sm text-gray-500 dark:text-gray-400">Category</dt>
|
||||||
|
<dd class="mt-1">
|
||||||
|
<select onchange="inlineUpdateCategory(this.value)"
|
||||||
|
class="font-medium text-gray-900 dark:text-white bg-gray-100 dark:bg-gray-700 rounded-lg px-2 py-1 border-0 cursor-pointer hover:bg-gray-200 dark:hover:bg-gray-600 text-sm">
|
||||||
|
{{range .Categories}}
|
||||||
|
<option value="{{.}}" {{if eq . $.Document.Category}}selected{{end}}>{{categoryIcon .}} {{title .}}</option>
|
||||||
|
{{end}}
|
||||||
|
</select>
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
{{if .Document.Date}}
|
{{if .Document.Date}}
|
||||||
<div>
|
<div>
|
||||||
<dt class="text-sm text-gray-500 dark:text-gray-400">Date</dt>
|
<dt class="text-sm text-gray-500 dark:text-gray-400">Date</dt>
|
||||||
|
|
@ -83,7 +91,7 @@
|
||||||
{{if .Document.ProcessedAt}}
|
{{if .Document.ProcessedAt}}
|
||||||
<div>
|
<div>
|
||||||
<dt class="text-sm text-gray-500 dark:text-gray-400">Processed</dt>
|
<dt class="text-sm text-gray-500 dark:text-gray-400">Processed</dt>
|
||||||
<dd class="mt-1 font-medium text-gray-900 dark:text-white">{{formatDate .Document.ProcessedAt}}</dd>
|
<dd class="mt-1 font-medium text-gray-900 dark:text-white">{{formatDateTime .Document.ProcessedAt}}</dd>
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{if .Document.OriginalFile}}
|
{{if .Document.OriginalFile}}
|
||||||
|
|
@ -380,14 +388,19 @@
|
||||||
document.getElementById('edit-modal').classList.toggle('hidden');
|
document.getElementById('edit-modal').classList.toggle('hidden');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const _docMeta = {
|
||||||
|
id: "{{.Document.ID}}",
|
||||||
|
title: "{{.Document.Title}}",
|
||||||
|
notes: "{{.Document.Notes}}"
|
||||||
|
};
|
||||||
async function inlineUpdateCategory(newCategory) {
|
async function inlineUpdateCategory(newCategory) {
|
||||||
const res = await fetch('/api/document/{{.Document.ID}}', {
|
const res = await fetch('/api/document/' + _docMeta.id, {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
headers: {'Content-Type': 'application/json'},
|
headers: {'Content-Type': 'application/json'},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
title: '{{.Document.Title}}',
|
title: _docMeta.title,
|
||||||
category: newCategory,
|
category: newCategory,
|
||||||
notes: `{{.Document.Notes}}`
|
notes: _docMeta.notes
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue