mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-11-20 12:36:53 +00:00
Merge branch 'dev' into feature/ocr-templates
This commit is contained in:
143 files changed
+8747
-7219
No files matched your search
@@ -452,21 +452,22 @@
|
||||
</div>
|
||||
|
||||
<ng-template #saveButtons>
|
||||
@let saveDisabled = !userCanEdit || networkActive() || (isDirty$ | async) !== true;
|
||||
<div class="btn-group">
|
||||
<ng-container *pngxIfPermissions="{ action: PermissionAction.Change, type: PermissionType.Document }">
|
||||
<button type="submit" class="order-3 btn btn-sm btn-primary" title="Save" i18n-title [disabled]="!userCanEdit || networkActive() || (isDirty$ | async) !== true">
|
||||
<button type="submit" class="order-3 btn btn-sm" [class.btn-primary]="!saveDisabled" [class.btn-outline-primary]="saveDisabled" title="Save" i18n-title [disabled]="saveDisabled">
|
||||
<pngx-bs-icon class="d-md-none" width="1.2em" height="1.2em" name="floppy"></pngx-bs-icon><span class="d-none d-md-inline" i18n>Save</span>
|
||||
</button>
|
||||
@if (hasNext()) {
|
||||
<button type="button" class="order-1 btn btn-sm btn-outline-primary d-none d-md-inline-block" (click)="saveEditNext()" i18n [disabled]="!userCanEdit || networkActive() || (isDirty$ | async) !== true">Save & next</button>
|
||||
<button type="button" class="order-1 btn btn-sm btn-outline-primary d-none d-md-inline-block" (click)="saveEditNext()" i18n [disabled]="saveDisabled">Save & next</button>
|
||||
} @else {
|
||||
<button type="button" class="order-2 btn btn-sm btn-outline-primary d-none d-md-inline-block" (click)="save(true)" i18n [disabled]="!userCanEdit || networkActive() || (isDirty$ | async) !== true">Save & close</button>
|
||||
<button type="button" class="order-2 btn btn-sm btn-outline-primary d-none d-md-inline-block" (click)="save(true)" i18n [disabled]="saveDisabled">Save & close</button>
|
||||
}
|
||||
<button type="button" class="order-0 btn btn-sm btn-outline-secondary" (click)="discard()" title="Discard" i18n-title [disabled]="!userCanEdit || networkActive() || (isDirty$ | async) !== true">
|
||||
<button type="button" class="order-0 btn btn-sm btn-outline-secondary" (click)="discard()" title="Discard" i18n-title [disabled]="saveDisabled">
|
||||
<pngx-bs-icon class="d-md-none" width="1.2em" height="1.2em" name="arrow-counterclockwise"></pngx-bs-icon><span class="d-none d-md-inline" i18n>Discard</span>
|
||||
</button>
|
||||
<div class="btn-group order-4 d-md-none" ngbDropdown placement="bottom-end top-end" role="group">
|
||||
<button type="button" class="btn btn-sm btn-outline-primary dropdown-toggle dropdown-toggle-split" ngbDropdownToggle aria-label="More save options" i18n-aria-label [disabled]="!userCanEdit || networkActive() || (isDirty$ | async) !== true"></button>
|
||||
<button type="button" class="btn btn-sm btn-outline-primary dropdown-toggle dropdown-toggle-split" ngbDropdownToggle aria-label="More save options" i18n-aria-label [disabled]="saveDisabled"></button>
|
||||
<div class="dropdown-menu shadow" ngbDropdownMenu>
|
||||
@if (hasNext()) {
|
||||
<button type="button" ngbDropdownItem (click)="saveEditNext()" i18n>Save & next</button>
|
||||
|
||||
@@ -54,7 +54,16 @@ textarea.rtl {
|
||||
border-color: var(--bs-border-color);
|
||||
}
|
||||
|
||||
// save buttons are visually reordered with order-*, fix btn-group border overlap here
|
||||
.btn-group > .order-1,
|
||||
.btn-group > .order-2,
|
||||
.btn-group > .order-3,
|
||||
.btn-group > .order-4 {
|
||||
margin-left: calc(-1 * var(--bs-border-width));
|
||||
}
|
||||
|
||||
.btn-group .btn.order-0 {
|
||||
margin-left: 0;
|
||||
border-top-right-radius: 0;
|
||||
border-bottom-right-radius: 0;
|
||||
border-top-left-radius: var(--bs-border-radius-sm);
|
||||
|
||||
@@ -940,6 +940,20 @@ describe('DocumentDetailComponent', () => {
|
||||
expect(navigateSpy).toHaveBeenCalledWith(['view', 77])
|
||||
})
|
||||
|
||||
it('should close back to the dashboard even if a saved view is active', () => {
|
||||
initNormally()
|
||||
jest
|
||||
.spyOn(componentRouterService, 'getComponentURLBefore')
|
||||
.mockReturnValue('dashboard')
|
||||
jest
|
||||
.spyOn(documentListViewService, 'activeSavedViewId', 'get')
|
||||
.mockReturnValue(77)
|
||||
const navigateSpy = jest.spyOn(router, 'navigate')
|
||||
component.close()
|
||||
expect(navigateSpy).toHaveBeenCalledWith(['dashboard'])
|
||||
expect(navigateSpy).not.toHaveBeenCalledWith(['view', 77])
|
||||
})
|
||||
|
||||
it('should not close if e.g. user-cancelled', () => {
|
||||
initNormally()
|
||||
jest.spyOn(openDocumentsService, 'closeDocument').mockReturnValue(of(false))
|
||||
|
||||
@@ -1463,7 +1463,12 @@ export class DocumentDetailComponent
|
||||
.subscribe((closed) => {
|
||||
if (!closed) return
|
||||
if (closedCallback) closedCallback()
|
||||
if (this.documentListViewService.activeSavedViewId) {
|
||||
if (
|
||||
this.componentRouterService.getComponentURLBefore() === 'dashboard'
|
||||
) {
|
||||
// e.g. opened from a dashboard widget
|
||||
this.router.navigate(['dashboard'])
|
||||
} else if (this.documentListViewService.activeSavedViewId) {
|
||||
this.router.navigate([
|
||||
'view',
|
||||
this.documentListViewService.activeSavedViewId,
|
||||
|
||||
Reference in new issue
Block a user