Respect permissions for customfielddropdown
This commit is contained in:
parent
fde4753cf7
commit
99d1de543c
@ -14,11 +14,12 @@
|
|||||||
[(ngModel)]="field"
|
[(ngModel)]="field"
|
||||||
[placeholder]="placeholderText"
|
[placeholder]="placeholderText"
|
||||||
[notFoundText]="notFoundText"
|
[notFoundText]="notFoundText"
|
||||||
|
[disableCreateNew]="!canCreateFields"
|
||||||
(createNew)="createField($event)"
|
(createNew)="createField($event)"
|
||||||
bindValue="id">
|
bindValue="id">
|
||||||
</pngx-input-select>
|
</pngx-input-select>
|
||||||
<div class="btn-toolbar" role="toolbar">
|
<div class="btn-toolbar" role="toolbar">
|
||||||
<button class="btn btn-sm btn-outline-secondary me-auto" type="button" (click)="createField()">
|
<button class="btn btn-sm btn-outline-secondary me-auto" type="button" (click)="createField()" [disabled]="!canCreateFields">
|
||||||
<svg fill="currentColor" class="buttonicon-sm me-1 mb-1">
|
<svg fill="currentColor" class="buttonicon-sm me-1 mb-1">
|
||||||
<use xlink:href="assets/bootstrap-icons.svg#asterisk"/>
|
<use xlink:href="assets/bootstrap-icons.svg#asterisk"/>
|
||||||
</svg><ng-container i18n>Create New Field</ng-container>
|
</svg><ng-container i18n>Create New Field</ng-container>
|
||||||
|
@ -12,6 +12,11 @@ import { PaperlessCustomFieldInstance } from 'src/app/data/paperless-custom-fiel
|
|||||||
import { CustomFieldsService } from 'src/app/services/rest/custom-fields.service'
|
import { CustomFieldsService } from 'src/app/services/rest/custom-fields.service'
|
||||||
import { ToastService } from 'src/app/services/toast.service'
|
import { ToastService } from 'src/app/services/toast.service'
|
||||||
import { CustomFieldEditDialogComponent } from '../edit-dialog/custom-field-edit-dialog/custom-field-edit-dialog.component'
|
import { CustomFieldEditDialogComponent } from '../edit-dialog/custom-field-edit-dialog/custom-field-edit-dialog.component'
|
||||||
|
import {
|
||||||
|
PermissionAction,
|
||||||
|
PermissionType,
|
||||||
|
PermissionsService,
|
||||||
|
} from 'src/app/services/permissions.service'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'pngx-custom-fields-dropdown',
|
selector: 'pngx-custom-fields-dropdown',
|
||||||
@ -48,10 +53,18 @@ export class CustomFieldsDropdownComponent implements OnDestroy {
|
|||||||
return $localize`No unused fields found`
|
return $localize`No unused fields found`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get canCreateFields(): boolean {
|
||||||
|
return this.permissionsService.currentUserCan(
|
||||||
|
PermissionAction.Add,
|
||||||
|
PermissionType.CustomField
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private customFieldsService: CustomFieldsService,
|
private customFieldsService: CustomFieldsService,
|
||||||
private modalService: NgbModal,
|
private modalService: NgbModal,
|
||||||
private toastService: ToastService
|
private toastService: ToastService,
|
||||||
|
private permissionsService: PermissionsService
|
||||||
) {
|
) {
|
||||||
this.getFields()
|
this.getFields()
|
||||||
}
|
}
|
||||||
|
@ -91,6 +91,9 @@ export class SelectComponent extends AbstractInputComponent<number> {
|
|||||||
@Input()
|
@Input()
|
||||||
notFoundText: string = $localize`No items found`
|
notFoundText: string = $localize`No items found`
|
||||||
|
|
||||||
|
@Input()
|
||||||
|
disableCreateNew: boolean = false
|
||||||
|
|
||||||
@Output()
|
@Output()
|
||||||
createNew = new EventEmitter<string>()
|
createNew = new EventEmitter<string>()
|
||||||
|
|
||||||
@ -102,7 +105,7 @@ export class SelectComponent extends AbstractInputComponent<number> {
|
|||||||
private _lastSearchTerm: string
|
private _lastSearchTerm: string
|
||||||
|
|
||||||
get allowCreateNew(): boolean {
|
get allowCreateNew(): boolean {
|
||||||
return this.createNew.observers.length > 0
|
return !this.disableCreateNew && this.createNew.observers.length > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
get isPrivate(): boolean {
|
get isPrivate(): boolean {
|
||||||
|
@ -49,6 +49,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<pngx-custom-fields-dropdown
|
<pngx-custom-fields-dropdown
|
||||||
|
*pngxIfPermissions="{ action: PermissionAction.View, type: PermissionType.CustomField }"
|
||||||
class="me-2"
|
class="me-2"
|
||||||
[documentId]="documentId"
|
[documentId]="documentId"
|
||||||
[disabled]="!userIsOwner"
|
[disabled]="!userIsOwner"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user