Document details: inline category dropdown, formatted processed_at timestamp
This commit is contained in:
parent
4a0e9648ac
commit
9c9bd5e881
|
|
@ -12,12 +12,9 @@
|
|||
</a>
|
||||
<div>
|
||||
<div class="flex items-center space-x-3 mb-1">
|
||||
<select id="inline-category" onchange="inlineUpdateCategory(this.value)"
|
||||
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">
|
||||
{{range .Categories}}
|
||||
<option value="{{.}}" {{if eq . $.Document.Category}}selected{{end}}>{{categoryIcon .}} {{title .}}</option>
|
||||
{{end}}
|
||||
</select>
|
||||
<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">
|
||||
{{categoryIcon .Document.Category}} {{title .Document.Category}}
|
||||
</span>
|
||||
{{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">
|
||||
{{title .Document.Type}}
|
||||
|
|
@ -62,6 +59,17 @@
|
|||
</div>
|
||||
<div class="p-6">
|
||||
<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}}
|
||||
<div>
|
||||
<dt class="text-sm text-gray-500 dark:text-gray-400">Date</dt>
|
||||
|
|
@ -83,7 +91,7 @@
|
|||
{{if .Document.ProcessedAt}}
|
||||
<div>
|
||||
<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>
|
||||
{{end}}
|
||||
{{if .Document.OriginalFile}}
|
||||
|
|
@ -380,14 +388,19 @@
|
|||
document.getElementById('edit-modal').classList.toggle('hidden');
|
||||
}
|
||||
|
||||
const _docMeta = {
|
||||
id: "{{.Document.ID}}",
|
||||
title: "{{.Document.Title}}",
|
||||
notes: "{{.Document.Notes}}"
|
||||
};
|
||||
async function inlineUpdateCategory(newCategory) {
|
||||
const res = await fetch('/api/document/{{.Document.ID}}', {
|
||||
const res = await fetch('/api/document/' + _docMeta.id, {
|
||||
method: 'PUT',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify({
|
||||
title: '{{.Document.Title}}',
|
||||
title: _docMeta.title,
|
||||
category: newCategory,
|
||||
notes: `{{.Document.Notes}}`
|
||||
notes: _docMeta.notes
|
||||
})
|
||||
});
|
||||
if (res.ok) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue