mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-02-26 01:09:34 -06:00
Feature: email, webhook workflow actions (#8108)
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import { Component, forwardRef } from '@angular/core'
|
||||
import { AbstractInputComponent } from '../abstract-input'
|
||||
import { NG_VALUE_ACCESSOR } from '@angular/forms'
|
||||
|
||||
@Component({
|
||||
providers: [
|
||||
{
|
||||
provide: NG_VALUE_ACCESSOR,
|
||||
useExisting: forwardRef(() => EntriesComponent),
|
||||
multi: true,
|
||||
},
|
||||
],
|
||||
selector: 'pngx-input-entries',
|
||||
templateUrl: './entries.component.html',
|
||||
styleUrl: './entries.component.scss',
|
||||
})
|
||||
export class EntriesComponent extends AbstractInputComponent<object> {
|
||||
entries = []
|
||||
|
||||
constructor() {
|
||||
super()
|
||||
}
|
||||
|
||||
inputChange(): void {
|
||||
// Remove empty keys
|
||||
this.onChange(
|
||||
Object.fromEntries(this.entries.filter(([key]) => key?.length))
|
||||
)
|
||||
}
|
||||
|
||||
writeValue(newValue: any): void {
|
||||
if (!newValue) {
|
||||
newValue = {}
|
||||
}
|
||||
this.entries = Object.entries(newValue)
|
||||
this.value = newValue
|
||||
}
|
||||
|
||||
addEntry(): void {
|
||||
this.entries.push(['', ''])
|
||||
this.inputChange()
|
||||
}
|
||||
|
||||
removeEntry(index: number): void {
|
||||
this.entries.splice(index, 1)
|
||||
this.inputChange()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user