X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fshared%2Fforms%2Fpeertube-checkbox.component.ts;h=a4b72aa37ad0c3c50bb521db0e8076f49c5e7b8f;hb=8e8eb2614b4e6be90ea5cf2f7347f1eb40f28932;hp=c626c4c5df94c5441d89ff6eeae0856629afad29;hpb=0f7fedc39857ebc0eb29182c1588a92b9adfb75a;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/shared/forms/peertube-checkbox.component.ts b/client/src/app/shared/forms/peertube-checkbox.component.ts index c626c4c5d..a4b72aa37 100644 --- a/client/src/app/shared/forms/peertube-checkbox.component.ts +++ b/client/src/app/shared/forms/peertube-checkbox.component.ts @@ -1,4 +1,4 @@ -import { Component, forwardRef, Input } from '@angular/core' +import { ChangeDetectorRef, Component, forwardRef, Input, OnChanges, SimpleChanges } from '@angular/core' import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' @Component({ @@ -17,14 +17,24 @@ export class PeertubeCheckboxComponent implements ControlValueAccessor { @Input() checked = false @Input() inputName: string @Input() labelText: string + @Input() labelHtml: string @Input() helpHtml: string + @Input() helpPlacement = 'top' + @Input() disabled = false - isDisabled = false + // FIXME: https://github.com/angular/angular/issues/10816#issuecomment-307567836 + @Input() onPushWorkaround = false + + constructor (private cdr: ChangeDetectorRef) { } propagateChange = (_: any) => { /* empty */ } writeValue (checked: boolean) { this.checked = checked + + if (this.onPushWorkaround) { + this.cdr.markForCheck() + } } registerOnChange (fn: (_: any) => void) { @@ -40,6 +50,6 @@ export class PeertubeCheckboxComponent implements ControlValueAccessor { } setDisabledState (isDisabled: boolean) { - this.isDisabled = isDisabled + this.disabled = isDisabled } }