mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-12-14 10:36:58 +01:00
Merge pull request #2818 from paperless-ngx/fix-2809
Fix: permissions display should not show users with inherited permissions & unable to change owner
This commit is contained in:
commit
62e756a11e
10 changed files with 77 additions and 26 deletions
|
|
@ -28,11 +28,6 @@ export class PermissionsUserComponent extends AbstractInputComponent<
|
|||
userService
|
||||
.listAll()
|
||||
.pipe(first())
|
||||
.subscribe(
|
||||
(result) =>
|
||||
(this.users = result.results.filter(
|
||||
(u) => u.id !== settings.currentUser.id
|
||||
))
|
||||
)
|
||||
.subscribe((result) => (this.users = result.results))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -446,6 +446,10 @@ export class DocumentDetailComponent
|
|||
.subscribe({
|
||||
next: (doc) => {
|
||||
Object.assign(this.document, doc)
|
||||
doc['permissions_form'] = {
|
||||
owner: doc.owner,
|
||||
set_permissions: doc.permissions,
|
||||
}
|
||||
this.title = doc.title
|
||||
this.documentForm.patchValue(doc)
|
||||
this.openDocumentService.setDirty(doc, false)
|
||||
|
|
@ -470,12 +474,17 @@ export class DocumentDetailComponent
|
|||
},
|
||||
error: (error) => {
|
||||
this.networkActive = false
|
||||
this.error = error.error
|
||||
this.toastService.showError(
|
||||
$localize`Error saving document` +
|
||||
': ' +
|
||||
(error.message ?? error.toString())
|
||||
)
|
||||
if (!this.userCanEdit) {
|
||||
this.toastService.showInfo($localize`Document saved successfully.`)
|
||||
this.close()
|
||||
} else {
|
||||
this.error = error.error
|
||||
this.toastService.showError(
|
||||
$localize`Error saving document` +
|
||||
': ' +
|
||||
(error.message ?? error.toString())
|
||||
)
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
|
@ -676,8 +685,8 @@ export class DocumentDetailComponent
|
|||
get userIsOwner(): boolean {
|
||||
let doc: PaperlessDocument = Object.assign({}, this.document)
|
||||
// dont disable while editing
|
||||
if (this.document && this.store?.value.owner) {
|
||||
doc.owner = this.store?.value.owner
|
||||
if (this.document && this.store?.value.permissions_form?.owner) {
|
||||
doc.owner = this.store?.value.permissions_form?.owner
|
||||
}
|
||||
return !this.document || this.permissionsService.currentUserOwnsObject(doc)
|
||||
}
|
||||
|
|
@ -685,8 +694,8 @@ export class DocumentDetailComponent
|
|||
get userCanEdit(): boolean {
|
||||
let doc: PaperlessDocument = Object.assign({}, this.document)
|
||||
// dont disable while editing
|
||||
if (this.document && this.store?.value.owner) {
|
||||
doc.owner = this.store?.value.owner
|
||||
if (this.document && this.store?.value.permissions_form?.owner) {
|
||||
doc.owner = this.store?.value.permissions_form?.owner
|
||||
}
|
||||
return (
|
||||
!this.document ||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue