mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-12-04 00:31:12 -06:00
Use titles not IDs
This commit is contained in:
@@ -12,9 +12,9 @@
|
|||||||
</p>
|
</p>
|
||||||
@if (documentPreview.length > 0) {
|
@if (documentPreview.length > 0) {
|
||||||
<ul class="list-unstyled small mb-0">
|
<ul class="list-unstyled small mb-0">
|
||||||
@for (docId of documentPreview; track docId) {
|
@for (doc of documentPreview; track doc.id) {
|
||||||
<li>
|
<li>
|
||||||
<code>{{ docId }}</code>
|
<strong>{{ doc.title | documentTitle }}</strong>
|
||||||
</li>
|
</li>
|
||||||
}
|
}
|
||||||
@if (selectionCount > documentPreview.length) {
|
@if (selectionCount > documentPreview.length) {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { CommonModule } from '@angular/common'
|
|||||||
import { Component, Input, inject } from '@angular/core'
|
import { Component, Input, inject } from '@angular/core'
|
||||||
import { FormBuilder, FormGroup, ReactiveFormsModule } from '@angular/forms'
|
import { FormBuilder, FormGroup, ReactiveFormsModule } from '@angular/forms'
|
||||||
import { NgxBootstrapIconsModule } from 'ngx-bootstrap-icons'
|
import { NgxBootstrapIconsModule } from 'ngx-bootstrap-icons'
|
||||||
|
import { Document } from 'src/app/data/document'
|
||||||
import {
|
import {
|
||||||
SHARE_BUNDLE_FILE_VERSION_LABELS,
|
SHARE_BUNDLE_FILE_VERSION_LABELS,
|
||||||
SHARE_BUNDLE_STATUS_LABELS,
|
SHARE_BUNDLE_STATUS_LABELS,
|
||||||
@@ -14,6 +15,7 @@ import {
|
|||||||
FileVersion,
|
FileVersion,
|
||||||
SHARE_LINK_EXPIRATION_OPTIONS,
|
SHARE_LINK_EXPIRATION_OPTIONS,
|
||||||
} from 'src/app/data/share-link'
|
} from 'src/app/data/share-link'
|
||||||
|
import { DocumentTitlePipe } from 'src/app/pipes/document-title.pipe'
|
||||||
import { FileSizePipe } from 'src/app/pipes/file-size.pipe'
|
import { FileSizePipe } from 'src/app/pipes/file-size.pipe'
|
||||||
import { ToastService } from 'src/app/services/toast.service'
|
import { ToastService } from 'src/app/services/toast.service'
|
||||||
import { environment } from 'src/environments/environment'
|
import { environment } from 'src/environments/environment'
|
||||||
@@ -27,17 +29,19 @@ import { ConfirmDialogComponent } from '../confirm-dialog/confirm-dialog.compone
|
|||||||
ReactiveFormsModule,
|
ReactiveFormsModule,
|
||||||
NgxBootstrapIconsModule,
|
NgxBootstrapIconsModule,
|
||||||
FileSizePipe,
|
FileSizePipe,
|
||||||
|
DocumentTitlePipe,
|
||||||
],
|
],
|
||||||
|
providers: [],
|
||||||
})
|
})
|
||||||
export class ShareBundleDialogComponent extends ConfirmDialogComponent {
|
export class ShareBundleDialogComponent extends ConfirmDialogComponent {
|
||||||
private formBuilder = inject(FormBuilder)
|
private formBuilder = inject(FormBuilder)
|
||||||
private clipboard = inject(Clipboard)
|
private clipboard = inject(Clipboard)
|
||||||
private toastService = inject(ToastService)
|
private toastService = inject(ToastService)
|
||||||
|
|
||||||
private _documentIds: number[] = []
|
private _documents: Document[] = []
|
||||||
|
|
||||||
selectionCount = 0
|
selectionCount = 0
|
||||||
documentPreview: number[] = []
|
documentPreview: Document[] = []
|
||||||
form: FormGroup = this.formBuilder.group({
|
form: FormGroup = this.formBuilder.group({
|
||||||
shareArchiveVersion: [true],
|
shareArchiveVersion: [true],
|
||||||
expirationDays: [7],
|
expirationDays: [7],
|
||||||
@@ -59,20 +63,16 @@ export class ShareBundleDialogComponent extends ConfirmDialogComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
set documentIds(ids: number[]) {
|
set documents(docs: Document[]) {
|
||||||
this._documentIds = ids ?? []
|
this._documents = docs.concat()
|
||||||
this.selectionCount = this._documentIds.length
|
this.selectionCount = this._documents.length
|
||||||
this.documentPreview = this._documentIds.slice(0, 10)
|
this.documentPreview = this._documents.slice(0, 10)
|
||||||
}
|
|
||||||
|
|
||||||
get documentIds(): number[] {
|
|
||||||
return this._documentIds
|
|
||||||
}
|
}
|
||||||
|
|
||||||
submit() {
|
submit() {
|
||||||
if (this.createdBundle) return
|
if (this.createdBundle) return
|
||||||
this.payload = {
|
this.payload = {
|
||||||
document_ids: this.documentIds,
|
document_ids: this._documents.map((doc) => doc.id),
|
||||||
file_version: this.form.value.shareArchiveVersion
|
file_version: this.form.value.shareArchiveVersion
|
||||||
? FileVersion.Archive
|
? FileVersion.Archive
|
||||||
: FileVersion.Original,
|
: FileVersion.Original,
|
||||||
|
|||||||
@@ -84,10 +84,6 @@ export class ShareBundleManageDialogComponent
|
|||||||
super.ngOnDestroy()
|
super.ngOnDestroy()
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchBundles(): void {
|
|
||||||
this.triggerRefresh(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
getShareUrl(bundle: ShareBundleSummary): string {
|
getShareUrl(bundle: ShareBundleSummary): string {
|
||||||
const apiURL = new URL(environment.apiBaseUrl)
|
const apiURL = new URL(environment.apiBaseUrl)
|
||||||
return `${apiURL.origin}${apiURL.pathname.replace(/\/api\/$/, '/share/')}${
|
return `${apiURL.origin}${apiURL.pathname.replace(/\/api\/$/, '/share/')}${
|
||||||
|
|||||||
@@ -918,15 +918,15 @@ export class BulkEditorComponent
|
|||||||
size: 'lg',
|
size: 'lg',
|
||||||
})
|
})
|
||||||
const dialog = modal.componentInstance as ShareBundleDialogComponent
|
const dialog = modal.componentInstance as ShareBundleDialogComponent
|
||||||
dialog.documentIds = Array.from(this.list.selected)
|
const selectedDocuments = this.list.documents.filter((d) =>
|
||||||
|
this.list.selected.has(d.id)
|
||||||
|
)
|
||||||
|
dialog.documents = selectedDocuments
|
||||||
dialog.confirmClicked
|
dialog.confirmClicked
|
||||||
.pipe(takeUntil(this.unsubscribeNotifier))
|
.pipe(takeUntil(this.unsubscribeNotifier))
|
||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
const payload = dialog.payload
|
const payload = dialog.payload
|
||||||
if (!payload || !payload.document_ids.length) {
|
if (!payload) {
|
||||||
this.toastService.showInfo(
|
|
||||||
$localize`No documents selected for sharing.`
|
|
||||||
)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
dialog.loading = true
|
dialog.loading = true
|
||||||
|
|||||||
Reference in New Issue
Block a user