1 import { Component, forwardRef, Input } from '@angular/core'
2 import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'
5 selector: 'my-peertube-checkbox',
6 styleUrls: [ './peertube-checkbox.component.scss' ],
7 templateUrl: './peertube-checkbox.component.html',
10 provide: NG_VALUE_ACCESSOR,
11 useExisting: forwardRef(() => PeertubeCheckboxComponent),
16 export class PeertubeCheckboxComponent implements ControlValueAccessor {
17 @Input() checked = false
18 @Input() inputName: string
19 @Input() labelText: string
20 @Input() labelHtml: string
21 @Input() helpHtml: string
25 propagateChange = (_: any) => { /* empty */ }
27 writeValue (checked: boolean) {
28 this.checked = checked
31 registerOnChange (fn: (_: any) => void) {
32 this.propagateChange = fn
35 registerOnTouched () {
40 this.propagateChange(this.checked)
43 setDisabledState (isDisabled: boolean) {
44 this.isDisabled = isDisabled