Add "agree to the terms" checkbox in registration form
This commit is contained in:
parent
b2c60abe6e
commit
b4a929accf
|
@ -12,7 +12,7 @@
|
||||||
<div [innerHTML]="descriptionHTML"></div>
|
<div [innerHTML]="descriptionHTML"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="terms">
|
<div class="terms" id="terms-section">
|
||||||
<div i18n class="section-title">Terms</div>
|
<div i18n class="section-title">Terms</div>
|
||||||
|
|
||||||
<div [innerHTML]="termsHTML"></div>
|
<div [innerHTML]="termsHTML"></div>
|
||||||
|
|
|
@ -23,7 +23,7 @@ export abstract class FormReactive {
|
||||||
this.formErrors = formErrors
|
this.formErrors = formErrors
|
||||||
this.validationMessages = validationMessages
|
this.validationMessages = validationMessages
|
||||||
|
|
||||||
this.form.valueChanges.subscribe(data => this.onValueChanged(false))
|
this.form.valueChanges.subscribe(() => this.onValueChanged(false))
|
||||||
}
|
}
|
||||||
|
|
||||||
protected onValueChanged (forceCheck = false) {
|
protected onValueChanged (forceCheck = false) {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import { FormBuilder, FormControl, FormGroup, ValidatorFn } from '@angular/forms'
|
import { FormBuilder, FormControl, FormGroup, ValidatorFn } from '@angular/forms'
|
||||||
import { Injectable } from '@angular/core'
|
import { Injectable } from '@angular/core'
|
||||||
import { FormReactiveErrors, FormReactiveValidationMessages } from '@app/shared/forms/form-reactive'
|
import { FormReactiveErrors, FormReactiveValidationMessages } from '@app/shared/forms/form-reactive'
|
||||||
import { I18n } from '@ngx-translate/i18n-polyfill'
|
|
||||||
|
|
||||||
export type BuildFormValidator = {
|
export type BuildFormValidator = {
|
||||||
VALIDATORS: ValidatorFn[],
|
VALIDATORS: ValidatorFn[],
|
||||||
|
@ -18,8 +17,7 @@ export type BuildFormDefaultValues = {
|
||||||
export class FormValidatorService {
|
export class FormValidatorService {
|
||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
private formBuilder: FormBuilder,
|
private formBuilder: FormBuilder
|
||||||
private i18n: I18n
|
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
buildForm (obj: BuildFormArgument, defaultValues: BuildFormDefaultValues = {}) {
|
buildForm (obj: BuildFormArgument, defaultValues: BuildFormDefaultValues = {}) {
|
||||||
|
|
|
@ -12,6 +12,7 @@ export class UserValidatorsService {
|
||||||
readonly USER_ROLE: BuildFormValidator
|
readonly USER_ROLE: BuildFormValidator
|
||||||
readonly USER_DISPLAY_NAME: BuildFormValidator
|
readonly USER_DISPLAY_NAME: BuildFormValidator
|
||||||
readonly USER_DESCRIPTION: BuildFormValidator
|
readonly USER_DESCRIPTION: BuildFormValidator
|
||||||
|
readonly USER_TERMS: BuildFormValidator
|
||||||
|
|
||||||
constructor (private i18n: I18n) {
|
constructor (private i18n: I18n) {
|
||||||
|
|
||||||
|
@ -89,5 +90,14 @@ export class UserValidatorsService {
|
||||||
'maxlength': this.i18n('Description cannot be more than 250 characters long.')
|
'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.')
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
<input type="checkbox" [(ngModel)]="checked" (ngModelChange)="onModelChange()" [id]="inputName" [disabled]="isDisabled" />
|
<input type="checkbox" [(ngModel)]="checked" (ngModelChange)="onModelChange()" [id]="inputName" [disabled]="isDisabled" />
|
||||||
<span role="checkbox" [attr.aria-checked]="checked"></span>
|
<span role="checkbox" [attr.aria-checked]="checked"></span>
|
||||||
<span *ngIf="labelText">{{ labelText }}</span>
|
<span *ngIf="labelText">{{ labelText }}</span>
|
||||||
|
<span *ngIf="labelHtml" [innerHTML]="labelHtml"></span>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<my-help *ngIf="helpHtml" tooltipPlacement="top" helpType="custom" i18n-customHtml [customHtml]="helpHtml"></my-help>
|
<my-help *ngIf="helpHtml" tooltipPlacement="top" helpType="custom" i18n-customHtml [customHtml]="helpHtml"></my-help>
|
||||||
|
|
|
@ -17,6 +17,7 @@ export class PeertubeCheckboxComponent implements ControlValueAccessor {
|
||||||
@Input() checked = false
|
@Input() checked = false
|
||||||
@Input() inputName: string
|
@Input() inputName: string
|
||||||
@Input() labelText: string
|
@Input() labelText: string
|
||||||
|
@Input() labelHtml: string
|
||||||
@Input() helpHtml: string
|
@Input() helpHtml: string
|
||||||
|
|
||||||
isDisabled = false
|
isDisabled = false
|
||||||
|
|
|
@ -54,6 +54,17 @@
|
||||||
</div>
|
</div>
|
||||||
</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">
|
<input type="submit" i18n-value value="Signup" [disabled]="!form.valid">
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,9 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.form-group-terms {
|
||||||
|
margin: 30px 0;
|
||||||
|
}
|
||||||
|
|
||||||
input:not([type=submit]) {
|
input:not([type=submit]) {
|
||||||
@include peertube-input-text(340px);
|
@include peertube-input-text(340px);
|
||||||
|
|
|
@ -38,7 +38,8 @@ export class SignupComponent extends FormReactive implements OnInit {
|
||||||
this.buildForm({
|
this.buildForm({
|
||||||
username: this.userValidatorsService.USER_USERNAME,
|
username: this.userValidatorsService.USER_USERNAME,
|
||||||
password: this.userValidatorsService.USER_PASSWORD,
|
password: this.userValidatorsService.USER_PASSWORD,
|
||||||
email: this.userValidatorsService.USER_EMAIL
|
email: this.userValidatorsService.USER_EMAIL,
|
||||||
|
terms: this.userValidatorsService.USER_TERMS
|
||||||
})
|
})
|
||||||
|
|
||||||
this.serverService.configLoaded
|
this.serverService.configLoaded
|
||||||
|
|
Loading…
Reference in New Issue
Block a user