Default frontend to current owner, allow setting no owner on create

This commit is contained in:
shamoon
2023-05-08 01:56:28 -07:00
parent 2c4e2e352a
commit 4443ba9d5e
11 changed files with 116 additions and 18 deletions

View File

@@ -6,6 +6,7 @@ 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'
import { SettingsService } from 'src/app/services/settings.service'
@Component({
selector: 'app-correspondent-edit-dialog',
@@ -16,9 +17,10 @@ export class CorrespondentEditDialogComponent extends EditDialogComponent<Paperl
constructor(
service: CorrespondentService,
activeModal: NgbActiveModal,
userService: UserService
userService: UserService,
settingsService: SettingsService
) {
super(service, activeModal, userService)
super(service, activeModal, userService, settingsService)
}
getCreateTitle() {

View File

@@ -6,6 +6,7 @@ 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'
import { SettingsService } from 'src/app/services/settings.service'
@Component({
selector: 'app-document-type-edit-dialog',
@@ -16,9 +17,10 @@ export class DocumentTypeEditDialogComponent extends EditDialogComponent<Paperle
constructor(
service: DocumentTypeService,
activeModal: NgbActiveModal,
userService: UserService
userService: UserService,
settingsService: SettingsService
) {
super(service, activeModal, userService)
super(service, activeModal, userService, settingsService)
}
getCreateTitle() {

View File

@@ -13,6 +13,7 @@ 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/permissions-form/permissions-form.component'
import { SettingsService } from 'src/app/services/settings.service'
@Directive()
export abstract class EditDialogComponent<
@@ -22,7 +23,8 @@ export abstract class EditDialogComponent<
constructor(
protected service: AbstractPaperlessService<T>,
private activeModal: NgbActiveModal,
private userService: UserService
private userService: UserService,
private settingsService: SettingsService
) {}
users: PaperlessUser[]
@@ -64,7 +66,14 @@ export abstract class EditDialogComponent<
this.closeEnabled = true
})
this.userService.listAll().subscribe((r) => (this.users = r.results))
this.userService.listAll().subscribe((r) => {
this.users = r.results
if (this.dialogMode === 'create') {
this.objectForm.get('permissions_form').setValue({
owner: this.settingsService.currentUser.id,
})
}
})
}
getCreateTitle() {

View File

@@ -5,6 +5,7 @@ import { EditDialogComponent } from 'src/app/components/common/edit-dialog/edit-
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'
import { SettingsService } from 'src/app/services/settings.service'
@Component({
selector: 'app-group-edit-dialog',
@@ -15,9 +16,10 @@ export class GroupEditDialogComponent extends EditDialogComponent<PaperlessGroup
constructor(
service: GroupService,
activeModal: NgbActiveModal,
userService: UserService
userService: UserService,
settingsService: SettingsService
) {
super(service, activeModal, userService)
super(service, activeModal, userService, settingsService)
}
getCreateTitle() {

View File

@@ -8,6 +8,7 @@ import {
} 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'
import { SettingsService } from 'src/app/services/settings.service'
const IMAP_SECURITY_OPTIONS = [
{ id: IMAPSecurity.None, name: $localize`No encryption` },
@@ -30,9 +31,10 @@ export class MailAccountEditDialogComponent extends EditDialogComponent<Paperles
constructor(
service: MailAccountService,
activeModal: NgbActiveModal,
userService: UserService
userService: UserService,
settingsService: SettingsService
) {
super(service, activeModal, userService)
super(service, activeModal, userService, settingsService)
}
getCreateTitle() {

View File

@@ -19,6 +19,7 @@ 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'
import { SettingsService } from 'src/app/services/settings.service'
const ATTACHMENT_TYPE_OPTIONS = [
{
@@ -115,9 +116,10 @@ export class MailRuleEditDialogComponent extends EditDialogComponent<PaperlessMa
accountService: MailAccountService,
correspondentService: CorrespondentService,
documentTypeService: DocumentTypeService,
userService: UserService
userService: UserService,
settingsService: SettingsService
) {
super(service, activeModal, userService)
super(service, activeModal, userService, settingsService)
accountService
.listAll()

View File

@@ -6,6 +6,7 @@ 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'
import { SettingsService } from 'src/app/services/settings.service'
@Component({
selector: 'app-storage-path-edit-dialog',
@@ -16,9 +17,10 @@ export class StoragePathEditDialogComponent extends EditDialogComponent<Paperles
constructor(
service: StoragePathService,
activeModal: NgbActiveModal,
userService: UserService
userService: UserService,
settingsService: SettingsService
) {
super(service, activeModal, userService)
super(service, activeModal, userService, settingsService)
}
get pathHint() {

View File

@@ -7,6 +7,7 @@ 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'
import { SettingsService } from 'src/app/services/settings.service'
@Component({
selector: 'app-tag-edit-dialog',
@@ -17,9 +18,10 @@ export class TagEditDialogComponent extends EditDialogComponent<PaperlessTag> {
constructor(
service: TagService,
activeModal: NgbActiveModal,
userService: UserService
userService: UserService,
settingsService: SettingsService
) {
super(service, activeModal, userService)
super(service, activeModal, userService, settingsService)
}
getCreateTitle() {

View File

@@ -7,6 +7,7 @@ import { PaperlessGroup } from 'src/app/data/paperless-group'
import { PaperlessUser } from 'src/app/data/paperless-user'
import { GroupService } from 'src/app/services/rest/group.service'
import { UserService } from 'src/app/services/rest/user.service'
import { SettingsService } from 'src/app/services/settings.service'
@Component({
selector: 'app-user-edit-dialog',
@@ -23,9 +24,10 @@ export class UserEditDialogComponent
constructor(
service: UserService,
activeModal: NgbActiveModal,
groupsService: GroupService
groupsService: GroupService,
settingsService: SettingsService
) {
super(service, activeModal, service)
super(service, activeModal, service, settingsService)
groupsService
.listAll()