mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-28 18:24:38 -05:00
Add ability to set owner per object
This commit is contained in:
@@ -12,19 +12,7 @@
|
||||
<app-input-check *ngIf="patternRequired" i18n-title title="Case insensitive" formControlName="is_insensitive" novalidate></app-input-check>
|
||||
|
||||
<div *ifOwner="object">
|
||||
<h5 i18n>Permissions</h5>
|
||||
<div formGroupName="set_permissions">
|
||||
<h6 i18n>View</h6>
|
||||
<div formGroupName="view">
|
||||
<app-permissions-user type="view" formControlName="users"></app-permissions-user>
|
||||
<app-permissions-group type="view" formControlName="groups"></app-permissions-group>
|
||||
</div>
|
||||
<h6 i18n>Edit</h6>
|
||||
<div formGroupName="change">
|
||||
<app-permissions-user type="change" formControlName="users"></app-permissions-user>
|
||||
<app-permissions-group type="change" formControlName="groups"></app-permissions-group>
|
||||
</div>
|
||||
</div>
|
||||
<app-permissions-form [users]="users" formControlName="permissions_form"></app-permissions-form>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
@@ -5,6 +5,7 @@ import { EditDialogComponent } from 'src/app/components/common/edit-dialog/edit-
|
||||
import { DEFAULT_MATCHING_ALGORITHM } from 'src/app/data/matching-model'
|
||||
import { PaperlessCorrespondent } from 'src/app/data/paperless-correspondent'
|
||||
import { CorrespondentService } from 'src/app/services/rest/correspondent.service'
|
||||
import { UserService } from 'src/app/services/rest/user.service'
|
||||
|
||||
@Component({
|
||||
selector: 'app-correspondent-edit-dialog',
|
||||
@@ -12,8 +13,12 @@ import { CorrespondentService } from 'src/app/services/rest/correspondent.servic
|
||||
styleUrls: ['./correspondent-edit-dialog.component.scss'],
|
||||
})
|
||||
export class CorrespondentEditDialogComponent extends EditDialogComponent<PaperlessCorrespondent> {
|
||||
constructor(service: CorrespondentService, activeModal: NgbActiveModal) {
|
||||
super(service, activeModal)
|
||||
constructor(
|
||||
service: CorrespondentService,
|
||||
activeModal: NgbActiveModal,
|
||||
userService: UserService
|
||||
) {
|
||||
super(service, activeModal, userService)
|
||||
}
|
||||
|
||||
getCreateTitle() {
|
||||
@@ -30,16 +35,7 @@ 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 FormGroup({
|
||||
users: new FormControl(null),
|
||||
groups: new FormControl(null),
|
||||
}),
|
||||
change: new FormGroup({
|
||||
users: new FormControl(null),
|
||||
groups: new FormControl(null),
|
||||
}),
|
||||
}),
|
||||
permissions_form: new FormControl(null),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@@ -6,25 +6,15 @@
|
||||
</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"></app-input-check>
|
||||
<div class="col">
|
||||
<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"></app-input-check>
|
||||
</div>
|
||||
|
||||
<div *ifOwner="object">
|
||||
<h5 i18n>Permissions</h5>
|
||||
<div formGroupName="set_permissions">
|
||||
<h6 i18n>View</h6>
|
||||
<div formGroupName="view">
|
||||
<app-permissions-user type="view" formControlName="users"></app-permissions-user>
|
||||
<app-permissions-group type="view" formControlName="groups"></app-permissions-group>
|
||||
</div>
|
||||
<h6 i18n>Edit</h6>
|
||||
<div formGroupName="change">
|
||||
<app-permissions-user type="change" formControlName="users"></app-permissions-user>
|
||||
<app-permissions-group type="change" formControlName="groups"></app-permissions-group>
|
||||
</div>
|
||||
</div>
|
||||
<app-permissions-form [users]="users" formControlName="permissions_form"></app-permissions-form>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
@@ -5,6 +5,7 @@ import { EditDialogComponent } from 'src/app/components/common/edit-dialog/edit-
|
||||
import { DEFAULT_MATCHING_ALGORITHM } from 'src/app/data/matching-model'
|
||||
import { PaperlessDocumentType } from 'src/app/data/paperless-document-type'
|
||||
import { DocumentTypeService } from 'src/app/services/rest/document-type.service'
|
||||
import { UserService } from 'src/app/services/rest/user.service'
|
||||
|
||||
@Component({
|
||||
selector: 'app-document-type-edit-dialog',
|
||||
@@ -12,8 +13,12 @@ import { DocumentTypeService } from 'src/app/services/rest/document-type.service
|
||||
styleUrls: ['./document-type-edit-dialog.component.scss'],
|
||||
})
|
||||
export class DocumentTypeEditDialogComponent extends EditDialogComponent<PaperlessDocumentType> {
|
||||
constructor(service: DocumentTypeService, activeModal: NgbActiveModal) {
|
||||
super(service, activeModal)
|
||||
constructor(
|
||||
service: DocumentTypeService,
|
||||
activeModal: NgbActiveModal,
|
||||
userService: UserService
|
||||
) {
|
||||
super(service, activeModal, userService)
|
||||
}
|
||||
|
||||
getCreateTitle() {
|
||||
@@ -30,16 +35,7 @@ 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 FormGroup({
|
||||
users: new FormControl(null),
|
||||
groups: new FormControl(null),
|
||||
}),
|
||||
change: new FormGroup({
|
||||
users: new FormControl(null),
|
||||
groups: new FormControl(null),
|
||||
}),
|
||||
}),
|
||||
permissions_form: new FormControl(null),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@@ -5,7 +5,10 @@ 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 { PaperlessUser } from 'src/app/data/paperless-user'
|
||||
import { AbstractPaperlessService } from 'src/app/services/rest/abstract-paperless-service'
|
||||
import { UserService } from 'src/app/services/rest/user.service'
|
||||
import { PermissionsFormObject } from '../input/permissions-form/permissions-form.component'
|
||||
|
||||
@Directive()
|
||||
export abstract class EditDialogComponent<
|
||||
@@ -14,9 +17,12 @@ export abstract class EditDialogComponent<
|
||||
{
|
||||
constructor(
|
||||
private service: AbstractPaperlessService<T>,
|
||||
private activeModal: NgbActiveModal
|
||||
private activeModal: NgbActiveModal,
|
||||
private userService: UserService
|
||||
) {}
|
||||
|
||||
users: PaperlessUser[]
|
||||
|
||||
@Input()
|
||||
dialogMode: string = 'create'
|
||||
|
||||
@@ -41,6 +47,12 @@ export abstract class EditDialogComponent<
|
||||
if (this.object['permissions']) {
|
||||
this.object['set_permissions'] = this.object['permissions']
|
||||
}
|
||||
console.log(this.object)
|
||||
|
||||
this.object['permissions_form'] = {
|
||||
owner: (this.object as ObjectWithPermissions).owner,
|
||||
set_permissions: (this.object as ObjectWithPermissions).permissions,
|
||||
}
|
||||
this.objectForm.patchValue(this.object)
|
||||
}
|
||||
|
||||
@@ -48,6 +60,8 @@ export abstract class EditDialogComponent<
|
||||
setTimeout(() => {
|
||||
this.closeEnabled = true
|
||||
})
|
||||
|
||||
this.userService.listAll().subscribe((r) => (this.users = r.results))
|
||||
}
|
||||
|
||||
getCreateTitle() {
|
||||
@@ -82,10 +96,16 @@ export abstract class EditDialogComponent<
|
||||
}
|
||||
|
||||
save() {
|
||||
var newObject = Object.assign(
|
||||
Object.assign({}, this.object),
|
||||
this.objectForm.value
|
||||
)
|
||||
const formValues = Object.assign({}, this.objectForm.value)
|
||||
const permissionsObject: PermissionsFormObject =
|
||||
this.objectForm.get('permissions_form').value
|
||||
if (permissionsObject) {
|
||||
formValues.owner = permissionsObject.owner
|
||||
formValues.set_permissions = permissionsObject.set_permissions
|
||||
delete formValues.permissions_form
|
||||
}
|
||||
|
||||
var newObject = Object.assign(Object.assign({}, this.object), formValues)
|
||||
var serverResponse: Observable<T>
|
||||
switch (this.dialogMode) {
|
||||
case 'create':
|
||||
|
@@ -4,6 +4,7 @@ import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
|
||||
import { EditDialogComponent } from 'src/app/components/common/edit-dialog/edit-dialog.component'
|
||||
import { PaperlessGroup } from 'src/app/data/paperless-group'
|
||||
import { GroupService } from 'src/app/services/rest/group.service'
|
||||
import { UserService } from 'src/app/services/rest/user.service'
|
||||
|
||||
@Component({
|
||||
selector: 'app-group-edit-dialog',
|
||||
@@ -11,8 +12,12 @@ import { GroupService } from 'src/app/services/rest/group.service'
|
||||
styleUrls: ['./group-edit-dialog.component.scss'],
|
||||
})
|
||||
export class GroupEditDialogComponent extends EditDialogComponent<PaperlessGroup> {
|
||||
constructor(service: GroupService, activeModal: NgbActiveModal) {
|
||||
super(service, activeModal)
|
||||
constructor(
|
||||
service: GroupService,
|
||||
activeModal: NgbActiveModal,
|
||||
userService: UserService
|
||||
) {
|
||||
super(service, activeModal, userService)
|
||||
}
|
||||
|
||||
getCreateTitle() {
|
||||
|
@@ -7,6 +7,7 @@ import {
|
||||
PaperlessMailAccount,
|
||||
} from 'src/app/data/paperless-mail-account'
|
||||
import { MailAccountService } from 'src/app/services/rest/mail-account.service'
|
||||
import { UserService } from 'src/app/services/rest/user.service'
|
||||
|
||||
const IMAP_SECURITY_OPTIONS = [
|
||||
{ id: IMAPSecurity.None, name: $localize`No encryption` },
|
||||
@@ -20,8 +21,12 @@ const IMAP_SECURITY_OPTIONS = [
|
||||
styleUrls: ['./mail-account-edit-dialog.component.scss'],
|
||||
})
|
||||
export class MailAccountEditDialogComponent extends EditDialogComponent<PaperlessMailAccount> {
|
||||
constructor(service: MailAccountService, activeModal: NgbActiveModal) {
|
||||
super(service, activeModal)
|
||||
constructor(
|
||||
service: MailAccountService,
|
||||
activeModal: NgbActiveModal,
|
||||
userService: UserService
|
||||
) {
|
||||
super(service, activeModal, userService)
|
||||
}
|
||||
|
||||
getCreateTitle() {
|
||||
|
@@ -17,6 +17,7 @@ import { CorrespondentService } from 'src/app/services/rest/correspondent.servic
|
||||
import { DocumentTypeService } from 'src/app/services/rest/document-type.service'
|
||||
import { MailAccountService } from 'src/app/services/rest/mail-account.service'
|
||||
import { MailRuleService } from 'src/app/services/rest/mail-rule.service'
|
||||
import { UserService } from 'src/app/services/rest/user.service'
|
||||
|
||||
const ATTACHMENT_TYPE_OPTIONS = [
|
||||
{
|
||||
@@ -97,9 +98,10 @@ export class MailRuleEditDialogComponent extends EditDialogComponent<PaperlessMa
|
||||
activeModal: NgbActiveModal,
|
||||
accountService: MailAccountService,
|
||||
correspondentService: CorrespondentService,
|
||||
documentTypeService: DocumentTypeService
|
||||
documentTypeService: DocumentTypeService,
|
||||
userService: UserService
|
||||
) {
|
||||
super(service, activeModal)
|
||||
super(service, activeModal, userService)
|
||||
|
||||
accountService
|
||||
.listAll()
|
||||
|
@@ -17,19 +17,7 @@
|
||||
<app-input-check *ngIf="patternRequired" i18n-title title="Case insensitive" formControlName="is_insensitive"></app-input-check>
|
||||
|
||||
<div *ifOwner="object">
|
||||
<h5 i18n>Permissions</h5>
|
||||
<div formGroupName="set_permissions">
|
||||
<h6 i18n>View</h6>
|
||||
<div formGroupName="view">
|
||||
<app-permissions-user type="view" formControlName="users"></app-permissions-user>
|
||||
<app-permissions-group type="view" formControlName="groups"></app-permissions-group>
|
||||
</div>
|
||||
<h6 i18n>Edit</h6>
|
||||
<div formGroupName="change">
|
||||
<app-permissions-user type="change" formControlName="users"></app-permissions-user>
|
||||
<app-permissions-group type="change" formControlName="groups"></app-permissions-group>
|
||||
</div>
|
||||
</div>
|
||||
<app-permissions-form [users]="users" formControlName="permissions_form"></app-permissions-form>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
@@ -5,6 +5,7 @@ import { EditDialogComponent } from 'src/app/components/common/edit-dialog/edit-
|
||||
import { DEFAULT_MATCHING_ALGORITHM } from 'src/app/data/matching-model'
|
||||
import { PaperlessStoragePath } from 'src/app/data/paperless-storage-path'
|
||||
import { StoragePathService } from 'src/app/services/rest/storage-path.service'
|
||||
import { UserService } from 'src/app/services/rest/user.service'
|
||||
|
||||
@Component({
|
||||
selector: 'app-storage-path-edit-dialog',
|
||||
@@ -12,8 +13,12 @@ import { StoragePathService } from 'src/app/services/rest/storage-path.service'
|
||||
styleUrls: ['./storage-path-edit-dialog.component.scss'],
|
||||
})
|
||||
export class StoragePathEditDialogComponent extends EditDialogComponent<PaperlessStoragePath> {
|
||||
constructor(service: StoragePathService, activeModal: NgbActiveModal) {
|
||||
super(service, activeModal)
|
||||
constructor(
|
||||
service: StoragePathService,
|
||||
activeModal: NgbActiveModal,
|
||||
userService: UserService
|
||||
) {
|
||||
super(service, activeModal, userService)
|
||||
}
|
||||
|
||||
get pathHint() {
|
||||
@@ -41,16 +46,7 @@ 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 FormGroup({
|
||||
users: new FormControl(null),
|
||||
groups: new FormControl(null),
|
||||
}),
|
||||
change: new FormGroup({
|
||||
users: new FormControl(null),
|
||||
groups: new FormControl(null),
|
||||
}),
|
||||
}),
|
||||
permissions_form: new FormControl(null),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@@ -15,19 +15,7 @@
|
||||
<app-input-check *ngIf="patternRequired" i18n-title title="Case insensitive" formControlName="is_insensitive"></app-input-check>
|
||||
|
||||
<div *ifOwner="object">
|
||||
<h5 i18n>Permissions</h5>
|
||||
<div formGroupName="set_permissions">
|
||||
<h6 i18n>View</h6>
|
||||
<div formGroupName="view">
|
||||
<app-permissions-user type="view" formControlName="users"></app-permissions-user>
|
||||
<app-permissions-group type="view" formControlName="groups"></app-permissions-group>
|
||||
</div>
|
||||
<h6 i18n>Edit</h6>
|
||||
<div formGroupName="change">
|
||||
<app-permissions-user type="change" formControlName="users"></app-permissions-user>
|
||||
<app-permissions-group type="change" formControlName="groups"></app-permissions-group>
|
||||
</div>
|
||||
</div>
|
||||
<app-permissions-form [users]="users" formControlName="permissions_form"></app-permissions-form>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
@@ -6,6 +6,7 @@ import { PaperlessTag } from 'src/app/data/paperless-tag'
|
||||
import { TagService } from 'src/app/services/rest/tag.service'
|
||||
import { randomColor } from 'src/app/utils/color'
|
||||
import { DEFAULT_MATCHING_ALGORITHM } from 'src/app/data/matching-model'
|
||||
import { UserService } from 'src/app/services/rest/user.service'
|
||||
|
||||
@Component({
|
||||
selector: 'app-tag-edit-dialog',
|
||||
@@ -13,8 +14,12 @@ import { DEFAULT_MATCHING_ALGORITHM } from 'src/app/data/matching-model'
|
||||
styleUrls: ['./tag-edit-dialog.component.scss'],
|
||||
})
|
||||
export class TagEditDialogComponent extends EditDialogComponent<PaperlessTag> {
|
||||
constructor(service: TagService, activeModal: NgbActiveModal) {
|
||||
super(service, activeModal)
|
||||
constructor(
|
||||
service: TagService,
|
||||
activeModal: NgbActiveModal,
|
||||
userService: UserService
|
||||
) {
|
||||
super(service, activeModal, userService)
|
||||
}
|
||||
|
||||
getCreateTitle() {
|
||||
@@ -33,16 +38,7 @@ 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 FormGroup({
|
||||
users: new FormControl(null),
|
||||
groups: new FormControl(null),
|
||||
}),
|
||||
change: new FormGroup({
|
||||
users: new FormControl(null),
|
||||
groups: new FormControl(null),
|
||||
}),
|
||||
}),
|
||||
permissions_form: new FormControl(null),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@@ -24,7 +24,7 @@ export class UserEditDialogComponent
|
||||
activeModal: NgbActiveModal,
|
||||
groupsService: GroupService
|
||||
) {
|
||||
super(service, activeModal)
|
||||
super(service, activeModal, service)
|
||||
|
||||
groupsService
|
||||
.listAll()
|
||||
|
Reference in New Issue
Block a user