Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve usability of revisions dialog
Browse files Browse the repository at this point in the history
allanlasser committed Jan 8, 2024
1 parent 32bbf9f commit 17bec64
Showing 3 changed files with 24 additions and 11 deletions.
9 changes: 7 additions & 2 deletions src/api/document.js
Original file line number Diff line number Diff line change
@@ -163,13 +163,18 @@ export async function changeAccess(ids, access) {

export async function changeRevisionControl(ids, revision_control) {
// Enable or disable revision control on specified documents
await session.patch(
apiUrl(`documents/`),
const { data } = await session.patch(
apiUrl(
queryBuilder(`documents/`, {
expand: [DEFAULT_EXPAND, "revisions"].join(","),
}),
),
ids.map((id) => ({
id,
revision_control,
})),
);
return data;
}

export async function reprocessDocument(ids, forceOcr, ocrEngine) {
6 changes: 3 additions & 3 deletions src/common/dialog/RevisionsDialog.svelte
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@
$: sortedRevisions =
revisions?.sort((a, b) => {
return b.version - a.version;
}) ?? [];
}) ?? null;
let user;
let loading = false;
@@ -57,7 +57,7 @@
<PremiumBadge />
</header>

{#if enabled}
{#if enabled && Array.isArray(revisions)}
<div class="overflow-scroll">
<table class="revisions">
{#each sortedRevisions as revision}
@@ -81,7 +81,7 @@
{/each}
</table>
</div>
{#if revisions && revisions.length > 0}<p class="count">
{#if revisions.length > 0}<p class="count">
{$_("dialogRevisionsDialog.total", {
values: { n: revisions.length },
})}
20 changes: 14 additions & 6 deletions src/manager/documents.js
Original file line number Diff line number Diff line change
@@ -439,12 +439,20 @@ export async function changeRevisionControlForDocuments(
revision_control,
) {
await wrapLoad(layout, async () => {
await changeRevisionControl(
documents.map((doc) => doc.id),
revision_control,
);
documents.forEach((doc) =>
updateInCollection(doc, (d) => (d.doc = { ...d.doc, revision_control })),
await Promise.all(
documents.forEach(async (doc) => {
const patchData = await changeRevisionControl(
[doc.id],
revision_control,
);
updateInCollection(doc, (d) => {
d.doc = {
...d.doc,
revision_control: patchData.revision_control,
revisions: patchData.revisions,
};
});
}),
);
});
hideRevisions();

0 comments on commit 17bec64

Please sign in to comment.