mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-17 10:13:56 -05:00
Fix multi-select with private items
This commit is contained in:
parent
f5d6a9f428
commit
b80c2126a3
@ -30,14 +30,34 @@ export class SelectComponent extends AbstractInputComponent<number> {
|
|||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
set items(items) {
|
set items(items) {
|
||||||
if (this.value && items.find((i) => i.id === this.value) === undefined) {
|
this._items = items
|
||||||
items.push({
|
if (items && this.value) this.checkForPrivateItems(this.value)
|
||||||
id: this.value,
|
}
|
||||||
|
|
||||||
|
writeValue(newValue: any): void {
|
||||||
|
if (newValue && this._items) {
|
||||||
|
this.checkForPrivateItems(newValue)
|
||||||
|
this.items = [...this._items] // we need to explicitly re-set items
|
||||||
|
}
|
||||||
|
super.writeValue(newValue)
|
||||||
|
}
|
||||||
|
|
||||||
|
checkForPrivateItems(value: any) {
|
||||||
|
if (Array.isArray(value) && value.length > 0) {
|
||||||
|
value.forEach((id) => this.checkForPrivateItem(id))
|
||||||
|
} else {
|
||||||
|
this.checkForPrivateItem(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
checkForPrivateItem(id) {
|
||||||
|
if (this._items.find((i) => i.id === id) === undefined) {
|
||||||
|
this._items.push({
|
||||||
|
id: id,
|
||||||
name: $localize`Private`,
|
name: $localize`Private`,
|
||||||
private: true,
|
private: true,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
this._items = items
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get items(): any[] {
|
get items(): any[] {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user