Move document title ownership from document to version

Title is now owned by document_versions, following the same pattern as
classification and document_type. The documents.title column is made
nullable with a TODO to drop it. Backend loads title from a
latest_versions CTE for ordering purposes only. The frontend resolves
title from the latest version, and DocumentTitleForm now operates on
DocumentVersion using UpdateDocumentVersion mutation.

Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
Sacha Al Himdani
2026-04-07 18:45:46 +02:00
parent ba386d188b
commit b63f043849
20 changed files with 329 additions and 333 deletions

View File

@@ -43,11 +43,11 @@ import { LinkedDocumentDialog } from "./LinkedDocumentsDialog";
const linkedDocumentFragment = graphql`
fragment LinkedDocumentsCardFragment on Document {
id
title
versions(first: 1) {
edges {
node {
id
title
documentType
status
}
@@ -217,7 +217,7 @@ function DocumentRow(props: {
height={36}
className="border-4 border-highlight rounded box-content"
/>
{document.title}
{document.versions.edges[0].node.title}
</div>
</Td>
<Td>

View File

@@ -71,10 +71,10 @@ const documentsFragment = graphql`
edges {
node {
id
title
versions(first: 1, orderBy: { field: CREATED_AT, direction: DESC }) {
edges {
node {
title
documentType
}
}
@@ -135,7 +135,7 @@ function LinkedDocumentsDialogContent(props: Omit<Props, "children">) {
const filteredDocuments = useMemo(() => {
return documents.filter(document =>
document.title.toLowerCase().includes(search.toLowerCase()),
document.versions.edges[0].node.title.toLowerCase().includes(search.toLowerCase()),
);
}, [documents, search]);
@@ -192,7 +192,7 @@ function DocumentRow(props: RowProps) {
className="py-4 flex items-center gap-4 hover:bg-subtle cursor-pointer px-6 w-full h-[100px]"
onClick={() => onClick(props.document.id)}
>
{props.document.title}
{props.document.versions.edges[0].node.title}
<DocumentTypeBadge type={props.document.versions.edges[0].node.documentType} />
<Button
disabled={props.disabled}