<div [innerHTML]="descriptionHTML"></div>
</div>
-<div class="terms">
+<div class="terms" id="terms-section">
<div i18n class="section-title">Terms</div>
<div [innerHTML]="termsHTML"></div>
this.formErrors = formErrors
this.validationMessages = validationMessages
- this.form.valueChanges.subscribe(data => this.onValueChanged(false))
+ this.form.valueChanges.subscribe(() => this.onValueChanged(false))
}
protected onValueChanged (forceCheck = false) {
import { FormBuilder, FormControl, FormGroup, ValidatorFn } from '@angular/forms'
import { Injectable } from '@angular/core'
import { FormReactiveErrors, FormReactiveValidationMessages } from '@app/shared/forms/form-reactive'
-import { I18n } from '@ngx-translate/i18n-polyfill'
export type BuildFormValidator = {
VALIDATORS: ValidatorFn[],
export class FormValidatorService {
constructor (
- private formBuilder: FormBuilder,
- private i18n: I18n
+ private formBuilder: FormBuilder
) {}
buildForm (obj: BuildFormArgument, defaultValues: BuildFormDefaultValues = {}) {
readonly USER_ROLE: BuildFormValidator
readonly USER_DISPLAY_NAME: BuildFormValidator
readonly USER_DESCRIPTION: BuildFormValidator
+ readonly USER_TERMS: BuildFormValidator
constructor (private i18n: I18n) {
'maxlength': this.i18n('Description cannot be more than 250 characters long.')
}
}
+
+ this.USER_TERMS = {
+ VALIDATORS: [
+ Validators.requiredTrue
+ ],
+ MESSAGES: {
+ 'required': this.i18n('You must to agree with the instance terms in order to registering on it.')
+ }
+ }
}
}
<input type="checkbox" [(ngModel)]="checked" (ngModelChange)="onModelChange()" [id]="inputName" [disabled]="isDisabled" />
<span role="checkbox" [attr.aria-checked]="checked"></span>
<span *ngIf="labelText">{{ labelText }}</span>
+ <span *ngIf="labelHtml" [innerHTML]="labelHtml"></span>
</label>
<my-help *ngIf="helpHtml" tooltipPlacement="top" helpType="custom" i18n-customHtml [customHtml]="helpHtml"></my-help>
@Input() checked = false
@Input() inputName: string
@Input() labelText: string
+ @Input() labelHtml: string
@Input() helpHtml: string
isDisabled = false
</div>
</div>
+ <div class="form-group form-group-terms">
+ <my-peertube-checkbox
+ inputName="terms" formControlName="terms"
+ i18n-labelHtml labelHtml="I have read and agree to the <a href='/about/instance#terms-section' target='_blank'rel='noopener noreferrer'>Terms</a> of this instance"
+ ></my-peertube-checkbox>
+
+ <div *ngIf="formErrors.terms" class="form-error">
+ {{ formErrors.terms }}
+ </div>
+ </div>
+
<input type="submit" i18n-value value="Signup" [disabled]="!form.valid">
</form>
}
}
+.form-group-terms {
+ margin: 30px 0;
+}
input:not([type=submit]) {
@include peertube-input-text(340px);
this.buildForm({
username: this.userValidatorsService.USER_USERNAME,
password: this.userValidatorsService.USER_PASSWORD,
- email: this.userValidatorsService.USER_EMAIL
+ email: this.userValidatorsService.USER_EMAIL,
+ terms: this.userValidatorsService.USER_TERMS
})
this.serverService.configLoaded