mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-28 18:24:38 -05:00
add share to c/dt/t/sp, refactor share input, ifOwner directive
This commit is contained in:
@@ -5,10 +5,20 @@
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
<app-input-text i18n-title title="Name" formControlName="name" [error]="error?.name"></app-input-text>
|
||||
<app-input-select i18n-title title="Matching algorithm" [items]="getMatchingAlgorithms()" formControlName="matching_algorithm"></app-input-select>
|
||||
<app-input-text *ngIf="patternRequired" i18n-title title="Matching pattern" formControlName="match" [error]="error?.match"></app-input-text>
|
||||
<app-input-check *ngIf="patternRequired" i18n-title title="Case insensitive" formControlName="is_insensitive" novalidate></app-input-check>
|
||||
|
||||
<div *ifOwner="object.owner">
|
||||
<h5 i18n>Permissions</h5>
|
||||
<div formGroupName="set_permissions">
|
||||
<app-share-user type="view" formControlName="view"></app-share-user>
|
||||
<app-share-user type="change" formControlName="change"></app-share-user>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-outline-secondary" (click)="cancel()" i18n [disabled]="networkActive">Cancel</button>
|
||||
|
@@ -30,6 +30,10 @@ export class CorrespondentEditDialogComponent extends EditDialogComponent<Paperl
|
||||
matching_algorithm: new FormControl(DEFAULT_MATCHING_ALGORITHM),
|
||||
match: new FormControl(''),
|
||||
is_insensitive: new FormControl(true),
|
||||
set_permissions: new FormGroup({
|
||||
view: new FormControl(null),
|
||||
change: new FormControl(null),
|
||||
}),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@@ -11,6 +11,14 @@
|
||||
<app-input-text *ngIf="patternRequired" i18n-title title="Matching pattern" formControlName="match" [error]="error?.match"></app-input-text>
|
||||
<app-input-check *ngIf="patternRequired" i18n-title title="Case insensitive" formControlName="is_insensitive"></app-input-check>
|
||||
|
||||
<div *ifOwner="object.owner">
|
||||
<h5 i18n>Permissions</h5>
|
||||
<div formGroupName="set_permissions">
|
||||
<app-share-user type="view" formControlName="view"></app-share-user>
|
||||
<app-share-user type="change" formControlName="change"></app-share-user>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-outline-secondary" (click)="cancel()" i18n [disabled]="networkActive">Cancel</button>
|
||||
|
@@ -30,6 +30,10 @@ export class DocumentTypeEditDialogComponent extends EditDialogComponent<Paperle
|
||||
matching_algorithm: new FormControl(DEFAULT_MATCHING_ALGORITHM),
|
||||
match: new FormControl(''),
|
||||
is_insensitive: new FormControl(true),
|
||||
set_permissions: new FormGroup({
|
||||
view: new FormControl(null),
|
||||
change: new FormControl(null),
|
||||
}),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@@ -4,11 +4,13 @@ import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
|
||||
import { Observable } from 'rxjs'
|
||||
import { MATCHING_ALGORITHMS, MATCH_AUTO } from 'src/app/data/matching-model'
|
||||
import { ObjectWithId } from 'src/app/data/object-with-id'
|
||||
import { ObjectWithPermissions } from 'src/app/data/object-with-permissions'
|
||||
import { AbstractPaperlessService } from 'src/app/services/rest/abstract-paperless-service'
|
||||
|
||||
@Directive()
|
||||
export abstract class EditDialogComponent<T extends ObjectWithId>
|
||||
implements OnInit
|
||||
export abstract class EditDialogComponent<
|
||||
T extends ObjectWithPermissions | ObjectWithId
|
||||
> implements OnInit
|
||||
{
|
||||
constructor(
|
||||
private service: AbstractPaperlessService<T>,
|
||||
@@ -36,6 +38,16 @@ export abstract class EditDialogComponent<T extends ObjectWithId>
|
||||
|
||||
ngOnInit(): void {
|
||||
if (this.object != null) {
|
||||
if (this.object['permissions']) {
|
||||
this.object['set_permissions'] = {
|
||||
view: (this.object as ObjectWithPermissions).permissions
|
||||
.filter((p) => (p[1] as string).includes('view'))
|
||||
.map((p) => p[0]),
|
||||
change: (this.object as ObjectWithPermissions).permissions
|
||||
.filter((p) => (p[1] as string).includes('change'))
|
||||
.map((p) => p[0]),
|
||||
}
|
||||
}
|
||||
this.objectForm.patchValue(this.object)
|
||||
}
|
||||
|
||||
|
@@ -16,6 +16,14 @@
|
||||
<app-input-text *ngIf="patternRequired" i18n-title title="Matching pattern" formControlName="match" [error]="error?.match"></app-input-text>
|
||||
<app-input-check *ngIf="patternRequired" i18n-title title="Case insensitive" formControlName="is_insensitive"></app-input-check>
|
||||
|
||||
<div *ifOwner="object.owner">
|
||||
<h5 i18n>Permissions</h5>
|
||||
<div formGroupName="set_permissions">
|
||||
<app-share-user type="view" formControlName="view"></app-share-user>
|
||||
<app-share-user type="change" formControlName="change"></app-share-user>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-outline-secondary" (click)="cancel()" i18n [disabled]="networkActive">Cancel</button>
|
||||
|
@@ -41,6 +41,10 @@ export class StoragePathEditDialogComponent extends EditDialogComponent<Paperles
|
||||
matching_algorithm: new FormControl(DEFAULT_MATCHING_ALGORITHM),
|
||||
match: new FormControl(''),
|
||||
is_insensitive: new FormControl(true),
|
||||
set_permissions: new FormGroup({
|
||||
view: new FormControl(null),
|
||||
change: new FormControl(null),
|
||||
}),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@@ -13,6 +13,15 @@
|
||||
<app-input-select i18n-title title="Matching algorithm" [items]="getMatchingAlgorithms()" formControlName="matching_algorithm"></app-input-select>
|
||||
<app-input-text *ngIf="patternRequired" i18n-title title="Matching pattern" formControlName="match" [error]="error?.match"></app-input-text>
|
||||
<app-input-check *ngIf="patternRequired" i18n-title title="Case insensitive" formControlName="is_insensitive"></app-input-check>
|
||||
|
||||
<div *ifOwner="object.owner">
|
||||
<h5 i18n>Permissions</h5>
|
||||
<div formGroupName="set_permissions">
|
||||
<app-share-user type="view" formControlName="view"></app-share-user>
|
||||
<app-share-user type="change" formControlName="change"></app-share-user>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-outline-secondary" (click)="cancel()" i18n [disabled]="networkActive">Cancel</button>
|
||||
|
@@ -33,6 +33,10 @@ export class TagEditDialogComponent extends EditDialogComponent<PaperlessTag> {
|
||||
matching_algorithm: new FormControl(DEFAULT_MATCHING_ALGORITHM),
|
||||
match: new FormControl(''),
|
||||
is_insensitive: new FormControl(true),
|
||||
set_permissions: new FormGroup({
|
||||
view: new FormControl(null),
|
||||
change: new FormControl(null),
|
||||
}),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user