add share to c/dt/t/sp, refactor share input, ifOwner directive

This commit is contained in:
Michael Shamoon
2022-12-07 14:55:40 -08:00
parent 5dc14449f9
commit 43b9909a09
18 changed files with 192 additions and 18 deletions

View File

@@ -0,0 +1,15 @@
<div class="mb-3 paperless-input-select">
<label class="form-label" [for]="inputId">{{title}}</label>
<div>
<ng-select name="inputId" [(ngModel)]="value"
[disabled]="disabled"
clearable="true"
[items]="users"
multiple="true"
bindLabel="username"
bindValue="id"
(change)="onChange(value)">
</ng-select>
</div>
<small *ngIf="hint" class="form-text text-muted">{{hint}}</small>
</div>

View File

@@ -0,0 +1,47 @@
import { Component, forwardRef, Input, OnInit } from '@angular/core'
import { NG_VALUE_ACCESSOR } from '@angular/forms'
import { first } from 'rxjs/operators'
import { PaperlessUser } from 'src/app/data/paperless-user'
import { UserService } from 'src/app/services/rest/user.service'
import { AbstractInputComponent } from '../abstract-input'
@Component({
providers: [
{
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => ShareUserComponent),
multi: true,
},
],
selector: 'app-share-user',
templateUrl: './share-user.component.html',
styleUrls: ['./share-user.component.scss'],
})
export class ShareUserComponent
extends AbstractInputComponent<PaperlessUser>
implements OnInit
{
users: PaperlessUser[]
@Input()
type: string
constructor(userService: UserService) {
super()
userService
.listAll()
.pipe(first())
.subscribe((result) => (this.users = result.results))
}
ngOnInit(): void {
if (this.type == 'view') {
this.title = $localize`Users can view`
} else if (this.type == 'change') {
this.title = $localize`Users can edit`
this.hint = $localize`Edit permissions also grant viewing permissions`
}
super.ngOnInit()
}
}