blob: c1a6915e8613c901ef780a237411d1cb46c4604e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
import { Component, forwardRef, Input } from '@angular/core'
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'
@Component({
selector: 'my-peertube-checkbox',
styleUrls: [ './peertube-checkbox.component.scss' ],
templateUrl: './peertube-checkbox.component.html',
providers: [
{
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => PeertubeCheckboxComponent),
multi: true
}
]
})
export class PeertubeCheckboxComponent implements ControlValueAccessor {
@Input() checked = false
@Input() inputName: string
@Input() labelText: string
@Input() labelHtml: string
@Input() helpHtml: string
@Input() disabled = false
propagateChange = (_: any) => { /* empty */ }
writeValue (checked: boolean) {
this.checked = checked
}
registerOnChange (fn: (_: any) => void) {
this.propagateChange = fn
}
registerOnTouched () {
// Unused
}
onModelChange () {
this.propagateChange(this.checked)
}
setDisabledState (isDisabled: boolean) {
this.disabled = isDisabled
}
}
|