This commit is contained in:
shamoon 2024-04-23 01:21:57 -07:00
parent 872fc206b4
commit e58c2d4bbf
3 changed files with 20 additions and 17 deletions

View File

@ -6,6 +6,9 @@ info="Manage trashed items."
<button class="btn btn-sm btn-outline-secondary" (click)="clearSelection()" [hidden]="selectedDocuments.size === 0">
<i-bs name="x"></i-bs>&nbsp;<ng-container i18n>Clear selection</ng-container>
</button>
<button type="button" class="btn btn-sm btn-outline-primary" (click)="restoreAll(selectedDocuments)" [disabled]="selectedDocuments.size === 0">
<i-bs name="arrow-counterclockwise"></i-bs>&nbsp;<ng-container i18n>Restore selected</ng-container>
</button>
<button type="button" class="btn btn-sm btn-outline-danger" (click)="emptyTrash(selectedDocuments)" [disabled]="selectedDocuments.size === 0">
<i-bs name="trash"></i-bs>&nbsp;<ng-container i18n>Delete selected</ng-container>
</button>
@ -24,7 +27,7 @@ info="Manage trashed items."
<tr>
<th scope="col">
<div class="form-check m-0 ms-2 me-n2">
<input type="checkbox" class="form-check-input" id="all-objects" [(ngModel)]="togggleAll" [disabled]="documentsInTrash.length === 0" (click)="toggleAll($event); $event.stopPropagation();">
<input type="checkbox" class="form-check-input" id="all-objects" [(ngModel)]="allToggled" [disabled]="documentsInTrash.length === 0" (click)="toggleAll($event); $event.stopPropagation();">
<label class="form-check-label" for="all-objects"></label>
</div>
</th>
@ -66,10 +69,10 @@ info="Manage trashed items."
</div>
<div class="btn-group d-none d-sm-block">
<button class="btn btn-sm btn-outline-secondary" (click)="restore(document); $event.stopPropagation();">
<i-bs width="1em" height="1em" name="restore"></i-bs>&nbsp;<ng-container i18n>Restore</ng-container>
<i-bs width="1em" height="1em" name="arrow-counterclockwise"></i-bs>&nbsp;<ng-container i18n>Restore</ng-container>
</button>
<button class="btn btn-sm btn-outline-danger" (click)="delete(document); $event.stopPropagation();">
<i-bs width="1em" height="1em" name="trash"></i-bs>&nbsp;<ng-container i18n>Delete</ng-container>
<i-bs width="1em" height="1em" name="trash"></i-bs>&nbsp;<ng-container i18n>Delete</ng-container>
</button>
</div>
</td>

View File

@ -14,7 +14,7 @@ import { Subject, takeUntil } from 'rxjs'
export class TrashComponent implements OnDestroy {
public documentsInTrash: Document[] = []
public selectedDocuments: Set<number> = new Set()
public togggleAll: boolean = false
public allToggled: boolean = false
public page: number = 1
public isLoading: boolean = false
unsubscribeNotifier: Subject<void> = new Subject()
@ -37,7 +37,7 @@ export class TrashComponent implements OnDestroy {
this.trashService.getTrash().subscribe((documentsInTrash) => {
this.documentsInTrash = documentsInTrash
this.isLoading = false
console.log('Trash:', documentsInTrash)
this.selectedDocuments.clear()
})
}
@ -79,6 +79,7 @@ export class TrashComponent implements OnDestroy {
.emptyTrash(documents ? Array.from(documents) : [])
.subscribe(() => {
this.toastService.showInfo($localize`Document(s) deleted`)
this.allToggled = false
this.reload()
})
})
@ -86,7 +87,7 @@ export class TrashComponent implements OnDestroy {
restore(document: Document) {
this.trashService.restoreDocuments([document.id]).subscribe(() => {
this.toastService.showInfo($localize`Object restored`)
this.toastService.showInfo($localize`Document restored`)
this.reload()
})
}
@ -95,7 +96,8 @@ export class TrashComponent implements OnDestroy {
this.trashService
.restoreDocuments(objects ? Array.from(this.selectedDocuments) : [])
.subscribe(() => {
this.toastService.showInfo($localize`Object(s) restored`)
this.toastService.showInfo($localize`Document(s) restored`)
this.allToggled = false
this.reload()
})
}
@ -115,7 +117,7 @@ export class TrashComponent implements OnDestroy {
}
clearSelection() {
this.togggleAll = false
this.allToggled = false
this.selectedDocuments.clear()
}
}

View File

@ -267,15 +267,13 @@
</a>
</li>
}
<!-- @if (permissionsService.isAdmin()) { -->
<li class="nav-item app-link">
<a class="nav-link" routerLink="trash" routerLinkActive="active" (click)="closeMenu()" ngbPopover="Trash"
i18n-ngbPopover [disablePopover]="!slimSidebarEnabled" placement="end" container="body"
triggers="mouseenter:mouseleave" popoverClass="popover-slim">
<i-bs class="me-1" name="trash"></i-bs><span>&nbsp;<ng-container i18n>Trash</ng-container></span>
</a>
</li>
<!-- } -->
<li class="nav-item app-link" *pngxIfPermissions="{ action: PermissionAction.Delete, type: PermissionType.Document }">
<a class="nav-link" routerLink="trash" routerLinkActive="active" (click)="closeMenu()" ngbPopover="Trash"
i18n-ngbPopover [disablePopover]="!slimSidebarEnabled" placement="end" container="body"
triggers="mouseenter:mouseleave" popoverClass="popover-slim">
<i-bs class="me-1" name="trash"></i-bs><span>&nbsp;<ng-container i18n>Trash</ng-container></span>
</a>
</li>
<li class="nav-item mt-2" tourAnchor="tour.outro">
<a class="px-3 py-2 text-muted small d-flex align-items-center flex-wrap text-decoration-none"
target="_blank" rel="noopener noreferrer" href="https://docs.paperless-ngx.com" ngbPopover="Documentation"