V4.4 revision to facsimile print format

This commit is contained in:
Jim Lancaster
2026-08-15 23:25:12 -05:00
parent 7db4df1729
commit 5b97c759fe
11 changed files with 76 additions and 9 deletions
+1 -1
View File
@@ -51,4 +51,4 @@ async def read_document_source_media(
media_type = SOURCE_MIME_TYPES.get(path.suffix.lower())
if media_type is None:
raise HTTPException(status_code=415, detail="Unsupported Source media type")
return FileResponse(path, media_type=media_type, filename=source.upload_name)
return FileResponse(path, media_type=media_type)
+2
View File
@@ -95,6 +95,7 @@ class DocumentPrintJob:
class DocumentPrintProjection:
id: UUID
title: str
document_type: str | None
authors: tuple[str, ...]
document_date: date | None
document_date_raw: str | None
@@ -335,6 +336,7 @@ class DocumentService(ServiceBase):
return DocumentPrintProjection(
id=document.id,
title=document.name,
document_type=document.document_type_ref.label if document.document_type_ref is not None else None,
authors=tuple(authors),
document_date=document.document_date,
document_date_raw=document.document_date_raw,
@@ -528,6 +528,10 @@ def _render_bento_metadata_zone(document: Document) -> None:
with ui.column().classes("col-span-12 lg:col-span-4 gap-4"):
with archival_card(title="Archival Metadata"):
metadata_row("Author(s):", ", ".join(author_names) if author_names else "Not set")
metadata_row(
"Document Type:",
document.document_type_ref.label if document.document_type_ref is not None else "Not set",
)
metadata_row("Document Date:", compact_date(document.document_date, document.document_date_raw))
metadata_row("Location Created:", document.location_created or "Not set")
metadata_row("Archive Identifier:", document.archive_identifier or "Not set")
@@ -101,17 +101,20 @@ def _render_facsimile_source(*, document_id: UUID, source: DocumentPrintSource,
with ui.row().classes("print-facsimile-row w-full items-start gap-4"):
media_url = f"/api/v4/documents/{document_id}/sources/{source.id}/media"
if source.media_type == "application/pdf":
ui.html(
f'<iframe class="print-source-pdf" src="{media_url}" title="Source page {source.page_number}"></iframe>'
ui.element("iframe").props(f'src="{media_url}" title="Source page {source.page_number}"').classes(
"print-source-pdf"
)
else:
ui.image(media_url).classes("print-source-image")
ui.element("img").props(f'src="{media_url}" alt="Source page {source.page_number}"').classes(
"print-source-image"
)
ui.label(text).classes("print-transcription print-preserve-lines")
def _render_metadata_table(projection: DocumentPrintProjection) -> None:
rows = [
{"field": "Author", "value": ", ".join(projection.authors) or "Not set"},
{"field": "Document Type", "value": projection.document_type or "Not set"},
{
"field": "Date",
"value": compact_date(projection.document_date, projection.document_date_raw) or "Not set",
@@ -127,7 +130,7 @@ def _render_metadata_table(projection: DocumentPrintProjection) -> None:
rows=rows,
row_key="field",
pagination={"rowsPerPage": 0},
).props("flat hide-header").classes("print-metadata-table w-full")
).props("flat hide-header hide-bottom").classes("print-data-table print-metadata-table")
def _render_job_table(jobs: tuple[DocumentPrintJob, ...]) -> None:
@@ -155,7 +158,7 @@ def _render_job_table(jobs: tuple[DocumentPrintJob, ...]) -> None:
rows=rows,
row_key="field",
pagination={"rowsPerPage": 0},
).props("flat hide-bottom").classes("print-job-table w-full")
).props("flat hide-bottom").classes("print-data-table print-job-table")
def reflow_transcription(text: str) -> list[str]:
+36
View File
@@ -69,6 +69,42 @@ input:focus-visible,
border: 0;
}
.print-data-table {
--print-label-column-width: 11rem;
--print-value-column-width: 20rem;
align-self: flex-start;
width: fit-content;
max-width: 100%;
}
.print-data-table .q-table__container,
.print-data-table .q-table__middle,
.print-data-table .q-table {
width: auto;
max-width: 100%;
}
.print-data-table .q-table {
table-layout: fixed;
}
.print-data-table .q-table th:first-child,
.print-data-table .q-table td:first-child {
width: var(--print-label-column-width);
min-width: var(--print-label-column-width);
max-width: var(--print-label-column-width);
white-space: nowrap;
}
.print-data-table .q-table th:not(:first-child),
.print-data-table .q-table td:not(:first-child) {
width: var(--print-value-column-width);
min-width: var(--print-value-column-width);
max-width: var(--print-value-column-width);
white-space: normal;
overflow-wrap: anywhere;
}
.print-transcription {
flex: 1;
line-height: 1.5;