mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-11-03 03:16:10 -06:00 
			
		
		
		
	Merge pull request #630 from paperless-ngx/fix-disableable-download-buttons
Fix: download buttons should disable while waiting
This commit is contained in:
		@@ -57,13 +57,18 @@
 | 
			
		||||
  </div>
 | 
			
		||||
  <div class="col-auto ms-auto mb-2 mb-xl-0 d-flex">
 | 
			
		||||
    <div class="btn-group btn-group-sm me-2">
 | 
			
		||||
      <button type="button" class="btn btn-outline-primary btn-sm" (click)="downloadSelected()">
 | 
			
		||||
        <svg width="1em" height="1em" viewBox="0 0 16 16" fill="currentColor">
 | 
			
		||||
      <button type="button" [disabled]="awaitingDownload" class="btn btn-outline-primary btn-sm" (click)="downloadSelected()">
 | 
			
		||||
        <svg *ngIf="!awaitingDownload" width="1em" height="1em" viewBox="0 0 16 16" fill="currentColor">
 | 
			
		||||
          <use xlink:href="assets/bootstrap-icons.svg#download" />
 | 
			
		||||
        </svg> <ng-container i18n>Download</ng-container>
 | 
			
		||||
        </svg>
 | 
			
		||||
        <div *ngIf="awaitingDownload" class="spinner-border spinner-border-sm" role="status">
 | 
			
		||||
          <span class="visually-hidden">Preparing download...</span>
 | 
			
		||||
        </div>
 | 
			
		||||
         
 | 
			
		||||
        <ng-container i18n>Download</ng-container>
 | 
			
		||||
      </button>
 | 
			
		||||
      <div class="btn-group" ngbDropdown role="group" aria-label="Button group with nested dropdown">
 | 
			
		||||
        <button class="btn btn-outline-primary btn-sm dropdown-toggle-split" ngbDropdownToggle></button>
 | 
			
		||||
        <button [disabled]="awaitingDownload" class="btn btn-outline-primary btn-sm dropdown-toggle-split" ngbDropdownToggle></button>
 | 
			
		||||
        <div class="dropdown-menu shadow" ngbDropdownMenu>
 | 
			
		||||
          <button ngbDropdownItem i18n (click)="downloadSelected('originals')">Download originals</button>
 | 
			
		||||
        </div>
 | 
			
		||||
 
 | 
			
		||||
@@ -39,6 +39,7 @@ export class BulkEditorComponent {
 | 
			
		||||
  tagSelectionModel = new FilterableDropdownSelectionModel()
 | 
			
		||||
  correspondentSelectionModel = new FilterableDropdownSelectionModel()
 | 
			
		||||
  documentTypeSelectionModel = new FilterableDropdownSelectionModel()
 | 
			
		||||
  awaitingDownload: boolean
 | 
			
		||||
 | 
			
		||||
  constructor(
 | 
			
		||||
    private documentTypeService: DocumentTypeService,
 | 
			
		||||
@@ -317,10 +318,12 @@ export class BulkEditorComponent {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  downloadSelected(content = 'archive') {
 | 
			
		||||
    this.awaitingDownload = true
 | 
			
		||||
    this.documentService
 | 
			
		||||
      .bulkDownload(Array.from(this.list.selected), content)
 | 
			
		||||
      .subscribe((result: any) => {
 | 
			
		||||
        saveAs(result, 'documents.zip')
 | 
			
		||||
        this.awaitingDownload = false
 | 
			
		||||
      })
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user