MOBILE-2428 core: Fix and complete input errors
parent
7c08fb4b77
commit
d61a2e597c
|
@ -10,8 +10,10 @@
|
||||||
</ion-item>
|
</ion-item>
|
||||||
<!-- Edit. -->
|
<!-- Edit. -->
|
||||||
<ion-item *ngIf="edit && field && field.shortname" [formGroup]="form">
|
<ion-item *ngIf="edit && field && field.shortname" [formGroup]="form">
|
||||||
<ion-label [core-mark-required]="field.required">{{ field.name }}</ion-label>
|
<ion-label>
|
||||||
|
<span [core-mark-required]="field.required">{{ field.name }}</span>
|
||||||
|
<core-input-errors [control]="form.controls[field.modelName]"></core-input-errors>
|
||||||
|
</ion-label>
|
||||||
<ion-checkbox item-end [formControlName]="field.modelName">
|
<ion-checkbox item-end [formControlName]="field.modelName">
|
||||||
</ion-checkbox>
|
</ion-checkbox>
|
||||||
<core-input-errors [control]="form.controls[field.modelName]" [errorMessages]="errors"></core-input-errors>
|
|
||||||
</ion-item>
|
</ion-item>
|
|
@ -7,4 +7,5 @@
|
||||||
<ion-item *ngIf="edit && field && field.shortname" text-wrap [formGroup]="form">
|
<ion-item *ngIf="edit && field && field.shortname" text-wrap [formGroup]="form">
|
||||||
<ion-label stacked [core-mark-required]="field.required">{{ field.name }}</ion-label>
|
<ion-label stacked [core-mark-required]="field.required">{{ field.name }}</ion-label>
|
||||||
<ion-datetime [formControlName]="field.modelName" [placeholder]="'core.choosedots' | translate" [displayFormat]="field.format" [max]="field.max" [min]="field.min"></ion-datetime>
|
<ion-datetime [formControlName]="field.modelName" [placeholder]="'core.choosedots' | translate" [displayFormat]="field.format" [max]="field.max" [min]="field.min"></ion-datetime>
|
||||||
|
<core-input-errors item-content [control]="form.controls[field.modelName]"></core-input-errors>
|
||||||
</ion-item>
|
</ion-item>
|
|
@ -10,4 +10,5 @@
|
||||||
<ion-option value="">{{ 'core.choosedots' | translate }}</ion-option>
|
<ion-option value="">{{ 'core.choosedots' | translate }}</ion-option>
|
||||||
<ion-option *ngFor="let option of field.options" [value]="option">{{option}}</ion-option>
|
<ion-option *ngFor="let option of field.options" [value]="option">{{option}}</ion-option>
|
||||||
</ion-select>
|
</ion-select>
|
||||||
|
<core-input-errors item-content [control]="form.controls[field.modelName]"></core-input-errors>
|
||||||
</ion-item>
|
</ion-item>
|
||||||
|
|
|
@ -7,4 +7,5 @@
|
||||||
<ion-item *ngIf="edit && field && field.shortname" text-wrap [formGroup]="form">
|
<ion-item *ngIf="edit && field && field.shortname" text-wrap [formGroup]="form">
|
||||||
<ion-label stacked [core-mark-required]="field.required">{{ field.name }}</ion-label>
|
<ion-label stacked [core-mark-required]="field.required">{{ field.name }}</ion-label>
|
||||||
<ion-input [type]="field.inputType" [formControlName]="field.modelName" [placeholder]="field.name" maxlength="{{field.maxlength}}"></ion-input>
|
<ion-input [type]="field.inputType" [formControlName]="field.modelName" [placeholder]="field.name" maxlength="{{field.maxlength}}"></ion-input>
|
||||||
|
<core-input-errors item-content [control]="form.controls[field.modelName]"></core-input-errors>
|
||||||
</ion-item>
|
</ion-item>
|
||||||
|
|
|
@ -5,6 +5,9 @@
|
||||||
</ion-item>
|
</ion-item>
|
||||||
<!-- Edit. -->
|
<!-- Edit. -->
|
||||||
<ion-item *ngIf="edit && field && field.shortname" text-wrap [formGroup]="form">
|
<ion-item *ngIf="edit && field && field.shortname" text-wrap [formGroup]="form">
|
||||||
<ion-label stacked [core-mark-required]="field.required">{{ field.name }}</ion-label>
|
<ion-label stacked>
|
||||||
|
<span [core-mark-required]="field.required">{{ field.name }}</span>
|
||||||
|
<core-input-errors [control]="control"></core-input-errors>
|
||||||
|
</ion-label>
|
||||||
<core-rich-text-editor item-content [control]="control" [placeholder]="field.name"></core-rich-text-editor>
|
<core-rich-text-editor item-content [control]="control" [placeholder]="field.name"></core-rich-text-editor>
|
||||||
</ion-item>
|
</ion-item>
|
|
@ -1,7 +1,15 @@
|
||||||
<div class="core-input-error-container" role="alert" *ngIf="(formControl && formControl.dirty && !formControl.valid) || errorText">
|
<div class="core-input-error-container" role="alert" *ngIf="(formControl && formControl.dirty && !formControl.valid) || errorText">
|
||||||
<ng-container *ngIf="formControl && formControl.dirty && !formControl.valid">
|
<ng-container *ngIf="formControl && formControl.dirty && !formControl.valid">
|
||||||
<ng-container *ngFor="let error of errorKeys">
|
<ng-container *ngFor="let error of errorKeys">
|
||||||
<div *ngIf="formControl.hasError(error)" class="core-input-error">{{errorMessages[error]}}</div>
|
<div *ngIf="formControl.hasError(error)" class="core-input-error">
|
||||||
|
<span *ngIf="errorMessages[error]">{{errorMessages[error]}}</span>
|
||||||
|
<span *ngIf="!errorMessages[error] && error == 'max' && formControl.errors.max">
|
||||||
|
{{ 'core.login.invalidvaluemax' | translate:{$a: formControl.errors.max.max} }}
|
||||||
|
</span>
|
||||||
|
<span *ngIf="!errorMessages[error] && error == 'min' && formControl.errors.min">
|
||||||
|
{{ 'core.login.invalidvaluemin' | translate:{$a: formControl.errors.min.min} }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<div *ngIf="errorText" class="core-input-error">{{ errorText }}</div>
|
<div *ngIf="errorText" class="core-input-error">{{ errorText }}</div>
|
||||||
|
|
|
@ -75,7 +75,9 @@ export class CoreInputErrorsComponent implements OnInit, OnChanges {
|
||||||
this.errorMessages.time = this.errorMessages.time || this.translate.instant('core.login.invalidtime');
|
this.errorMessages.time = this.errorMessages.time || this.translate.instant('core.login.invalidtime');
|
||||||
this.errorMessages.url = this.errorMessages.url || this.translate.instant('core.login.invalidurl');
|
this.errorMessages.url = this.errorMessages.url || this.translate.instant('core.login.invalidurl');
|
||||||
|
|
||||||
// @todo: Check how to handle min/max errors once we have a test case to use. Also, review previous errors.
|
// Set empty values by default, the default error messages will be built in the template when needed.
|
||||||
|
this.errorMessages.max = this.errorMessages.max || '';
|
||||||
|
this.errorMessages.min = this.errorMessages.min || '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -181,6 +181,7 @@ export class CoreRichTextEditorComponent implements AfterContentInit, OnDestroy
|
||||||
} else {
|
} else {
|
||||||
// Don't emit event so our valueChanges doesn't get notified by this change.
|
// Don't emit event so our valueChanges doesn't get notified by this change.
|
||||||
this.control.setValue(this.editorElement.innerHTML, {emitEvent: false});
|
this.control.setValue(this.editorElement.innerHTML, {emitEvent: false});
|
||||||
|
this.control.markAsDirty();
|
||||||
this.textarea.value = this.editorElement.innerHTML;
|
this.textarea.value = this.editorElement.innerHTML;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -189,6 +190,7 @@ export class CoreRichTextEditorComponent implements AfterContentInit, OnDestroy
|
||||||
} else {
|
} else {
|
||||||
// Don't emit event so our valueChanges doesn't get notified by this change.
|
// Don't emit event so our valueChanges doesn't get notified by this change.
|
||||||
this.control.setValue(this.textarea.value, {emitEvent: false});
|
this.control.setValue(this.textarea.value, {emitEvent: false});
|
||||||
|
this.control.markAsDirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,6 +242,11 @@ export class CoreRichTextEditorComponent implements AfterContentInit, OnDestroy
|
||||||
* Treating videos and audios in here is complex, so if a user manually adds one he won't be able to play it in the editor.
|
* Treating videos and audios in here is complex, so if a user manually adds one he won't be able to play it in the editor.
|
||||||
*/
|
*/
|
||||||
protected treatExternalContent(): void {
|
protected treatExternalContent(): void {
|
||||||
|
if (!this.sitesProvider.isLoggedIn()) {
|
||||||
|
// Only treat external content if the user is logged in.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const elements = Array.from(this.editorElement.querySelectorAll('img')),
|
const elements = Array.from(this.editorElement.querySelectorAll('img')),
|
||||||
siteId = this.sitesProvider.getCurrentSiteId(),
|
siteId = this.sitesProvider.getCurrentSiteId(),
|
||||||
canDownloadFiles = this.sitesProvider.getCurrentSite().canDownloadFiles();
|
canDownloadFiles = this.sitesProvider.getCurrentSite().canDownloadFiles();
|
||||||
|
|
|
@ -128,9 +128,11 @@
|
||||||
<p><a [href]="settings.sitepolicy" core-link capture="false">{{ 'core.login.policyagreementclick' | translate }}</a></p>
|
<p><a [href]="settings.sitepolicy" core-link capture="false">{{ 'core.login.policyagreementclick' | translate }}</a></p>
|
||||||
</ion-item>
|
</ion-item>
|
||||||
<ion-item text-wrap>
|
<ion-item text-wrap>
|
||||||
<ion-label core-mark-required="true">{{ 'core.login.policyaccept' | translate }}</ion-label>
|
<ion-label>
|
||||||
<ion-checkbox item-end name="policyagreed" formControlName="policyagreed"></ion-checkbox>
|
<span [core-mark-required]="true">{{ 'core.login.policyaccept' | translate }}</span>
|
||||||
<core-input-errors [control]="signupForm.controls.policyagreed" [errorMessages]="policyErrors"></core-input-errors>
|
<core-input-errors [control]="signupForm.controls.policyagreed" [errorMessages]="policyErrors"></core-input-errors>
|
||||||
|
</ion-label>
|
||||||
|
<ion-checkbox item-end name="policyagreed" formControlName="policyagreed"></ion-checkbox>
|
||||||
</ion-item>
|
</ion-item>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue