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