From 421d935d256db5b77a652d8da0c9a38cb57147ba Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 27 Aug 2019 17:09:43 +0200 Subject: Add about information in registration page --- .../shared/forms/peertube-checkbox.component.ts | 24 ++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'client/src/app/shared/forms/peertube-checkbox.component.ts') diff --git a/client/src/app/shared/forms/peertube-checkbox.component.ts b/client/src/app/shared/forms/peertube-checkbox.component.ts index a4b72aa37..3b8f39ed0 100644 --- a/client/src/app/shared/forms/peertube-checkbox.component.ts +++ b/client/src/app/shared/forms/peertube-checkbox.component.ts @@ -1,5 +1,6 @@ -import { ChangeDetectorRef, Component, forwardRef, Input, OnChanges, SimpleChanges } from '@angular/core' +import { AfterContentInit, ChangeDetectorRef, Component, ContentChildren, forwardRef, Input, QueryList, TemplateRef } from '@angular/core' import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' +import { PeerTubeTemplateDirective } from '@app/shared/angular/peertube-template.directive' @Component({ selector: 'my-peertube-checkbox', @@ -13,20 +14,35 @@ import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' } ] }) -export class PeertubeCheckboxComponent implements ControlValueAccessor { +export class PeertubeCheckboxComponent implements ControlValueAccessor, AfterContentInit { @Input() checked = false @Input() inputName: string @Input() labelText: string - @Input() labelHtml: string - @Input() helpHtml: string @Input() helpPlacement = 'top' @Input() disabled = false + @ContentChildren(PeerTubeTemplateDirective) templates: QueryList> + // FIXME: https://github.com/angular/angular/issues/10816#issuecomment-307567836 @Input() onPushWorkaround = false + labelTemplate: TemplateRef + helpTemplate: TemplateRef + constructor (private cdr: ChangeDetectorRef) { } + ngAfterContentInit () { + { + const t = this.templates.find(t => t.name === 'label') + if (t) this.labelTemplate = t.template + } + + { + const t = this.templates.find(t => t.name === 'help') + if (t) this.helpTemplate = t.template + } + } + propagateChange = (_: any) => { /* empty */ } writeValue (checked: boolean) { -- cgit v1.2.3