diff options
author | Chocobozzz <me@florianbigard.com> | 2020-11-19 11:12:01 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-11-19 15:25:41 +0100 |
commit | 4f926722ea6784ea389013378fd233f59077ec8a (patch) | |
tree | 36e92da1d8fc9394e1e36144f206e0427b7c02c3 /client/src/app/shared/shared-forms/input-switch.component.ts | |
parent | fce7fe04eed39e23e76717085e92118e963def81 (diff) | |
download | PeerTube-4f926722ea6784ea389013378fd233f59077ec8a.tar.gz PeerTube-4f926722ea6784ea389013378fd233f59077ec8a.tar.zst PeerTube-4f926722ea6784ea389013378fd233f59077ec8a.zip |
Upgrade client dependencies
Migrate removed primeng theme to custom CSS
Diffstat (limited to 'client/src/app/shared/shared-forms/input-switch.component.ts')
-rw-r--r-- | client/src/app/shared/shared-forms/input-switch.component.ts | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/client/src/app/shared/shared-forms/input-switch.component.ts b/client/src/app/shared/shared-forms/input-switch.component.ts new file mode 100644 index 000000000..abb96de62 --- /dev/null +++ b/client/src/app/shared/shared-forms/input-switch.component.ts | |||
@@ -0,0 +1,38 @@ | |||
1 | import { Component, forwardRef, Input } from '@angular/core' | ||
2 | import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' | ||
3 | |||
4 | @Component({ | ||
5 | selector: 'my-input-switch', | ||
6 | styleUrls: [ './input-switch.component.scss' ], | ||
7 | templateUrl: './input-switch.component.html', | ||
8 | providers: [ | ||
9 | { | ||
10 | provide: NG_VALUE_ACCESSOR, | ||
11 | useExisting: forwardRef(() => InputSwitchComponent), | ||
12 | multi: true | ||
13 | } | ||
14 | ] | ||
15 | }) | ||
16 | export class InputSwitchComponent implements ControlValueAccessor { | ||
17 | @Input() checked = false | ||
18 | @Input() inputName: string | ||
19 | |||
20 | propagateChange = (_: any) => { /* empty */ } | ||
21 | |||
22 | writeValue (checked: boolean) { | ||
23 | this.checked = checked | ||
24 | } | ||
25 | |||
26 | registerOnChange (fn: (_: any) => void) { | ||
27 | this.propagateChange = fn | ||
28 | } | ||
29 | |||
30 | registerOnTouched () { | ||
31 | // Unused | ||
32 | } | ||
33 | |||
34 | update () { | ||
35 | this.checked = !this.checked | ||
36 | this.propagateChange(this.checked) | ||
37 | } | ||
38 | } | ||