]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/shared/forms/peertube-checkbox.component.ts
Add ability to list all local videos on client
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / forms / peertube-checkbox.component.ts
CommitLineData
0f7fedc3
C
1import { Component, forwardRef, Input } from '@angular/core'
2import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'
3
4@Component({
5 selector: 'my-peertube-checkbox',
6 styleUrls: [ './peertube-checkbox.component.scss' ],
7 templateUrl: './peertube-checkbox.component.html',
8 providers: [
9 {
10 provide: NG_VALUE_ACCESSOR,
11 useExisting: forwardRef(() => PeertubeCheckboxComponent),
12 multi: true
13 }
14 ]
15})
16export class PeertubeCheckboxComponent implements ControlValueAccessor {
17 @Input() checked = false
18 @Input() inputName: string
19 @Input() labelText: string
b4a929ac 20 @Input() labelHtml: string
0f7fedc3
C
21 @Input() helpHtml: string
22
23 isDisabled = false
24
25 propagateChange = (_: any) => { /* empty */ }
26
27 writeValue (checked: boolean) {
28 this.checked = checked
29 }
30
31 registerOnChange (fn: (_: any) => void) {
32 this.propagateChange = fn
33 }
34
35 registerOnTouched () {
36 // Unused
37 }
38
39 onModelChange () {
40 this.propagateChange(this.checked)
41 }
42
43 setDisabledState (isDisabled: boolean) {
44 this.isDisabled = isDisabled
45 }
46}