From b74cc9a59011fba14b5f05fc62d8df4fbc3ad9c8 Mon Sep 17 00:00:00 2001
From: shamoon <4887959+shamoon@users.noreply.github.com>
Date: Sat, 1 Aug 2026 19:39:26 -0700
Subject: [PATCH] Frondend bulk edit stuff
---
.../bulk-editor/bulk-editor.component.html | 3 ++
.../bulk-editor/bulk-editor.component.spec.ts | 47 +++++++++++++++++++
.../bulk-editor/bulk-editor.component.ts | 28 +++++++++++
3 files changed, 78 insertions(+)
diff --git a/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.html b/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.html
index 2ea56d4c4..a5e5d2cc0 100644
--- a/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.html
+++ b/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.html
@@ -95,6 +95,9 @@
+
diff --git a/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.spec.ts b/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.spec.ts
index 40d21f39b..019bdaec7 100644
--- a/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.spec.ts
+++ b/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.spec.ts
@@ -1248,6 +1248,53 @@ describe('BulkEditorComponent', () => {
expect(documentListViewService.selected.size).toEqual(0)
})
+ it('should support merging documents as versions', () => {
+ let modal: NgbModalRef
+ modalService.activeInstances.subscribe((m) => (modal = m[0]))
+ jest.spyOn(permissionsService, 'currentUserCan').mockReturnValue(true)
+ jest
+ .spyOn(documentListViewService, 'documents', 'get')
+ .mockReturnValue([{ id: 3 }, { id: 4 }])
+ jest.spyOn(documentService, 'getFew').mockReturnValue(
+ of({
+ all: [3, 4],
+ count: 2,
+ results: [
+ { id: 3, title: 'Document 3' },
+ { id: 4, title: 'Document 4' },
+ ],
+ })
+ )
+ jest
+ .spyOn(documentListViewService, 'selected', 'get')
+ .mockReturnValue(new Set([3, 4]))
+ jest
+ .spyOn(permissionsService, 'currentUserHasObjectPermissions')
+ .mockReturnValue(true)
+ jest
+ .spyOn(permissionsService, 'currentUserOwnsObject')
+ .mockReturnValue(true)
+ const mergeAsVersionsSpy = jest
+ .spyOn(documentService, 'mergeDocumentsAsVersions')
+ .mockReturnValue(of(true))
+ fixture.detectChanges()
+
+ component.mergeSelectedAsVersions()
+ expect(modal).not.toBeUndefined()
+ expect(modal.componentInstance.mergeAsVersions).toBe(true)
+ modal.componentInstance.rootDocumentID.set(4)
+ modal.componentInstance.confirm()
+
+ expect(mergeAsVersionsSpy).toHaveBeenCalledWith([3, 4], 4)
+ httpTestingController.match(
+ `${environment.apiBaseUrl}documents/?page=1&page_size=50&ordering=-created&truncate_content=true&include_selection_data=true`
+ )
+ httpTestingController.match(
+ `${environment.apiBaseUrl}documents/?page=1&page_size=100000&fields=id`
+ )
+ expect(documentListViewService.selected.size).toEqual(0)
+ })
+
it('should support bulk download with archive, originals or both and file formatting', () => {
jest.spyOn(permissionsService, 'currentUserCan').mockReturnValue(true)
jest
diff --git a/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.ts b/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.ts
index 67b2e04ae..9507c2524 100644
--- a/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.ts
+++ b/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.ts
@@ -1002,6 +1002,34 @@ export class BulkEditorComponent
})
}
+ mergeSelectedAsVersions() {
+ let modal = this.modalService.open(MergeConfirmDialogComponent, {
+ backdrop: 'static',
+ })
+ const mergeDialog = modal.componentInstance as MergeConfirmDialogComponent
+ const documentIDs = Array.from(this.list.selected)
+ mergeDialog.title = $localize`Merge as versions`
+ mergeDialog.message = $localize`The selected documents will become versions of the root document.`
+ mergeDialog.btnCaption = $localize`Proceed`
+ mergeDialog.mergeAsVersions = true
+ mergeDialog.documentIDs.set(documentIDs)
+ mergeDialog.rootDocumentID.set(documentIDs[0])
+ mergeDialog.confirmClicked
+ .pipe(takeUntil(this.unsubscribeNotifier))
+ .subscribe(() => {
+ mergeDialog.buttonsEnabled = false
+ this.executeDocumentAction(
+ modal,
+ this.documentService.mergeDocumentsAsVersions(
+ mergeDialog.documentIDs(),
+ mergeDialog.rootDocumentID()
+ ),
+ { deleteOriginals: true }
+ )
+ this.toastService.showInfo($localize`Documents merged as versions.`)
+ })
+ }
+
public setCustomFieldValues(changedCustomFields: ChangedItems) {
const modal = this.modalService.open(CustomFieldsBulkEditDialogComponent, {
backdrop: 'static',