Merge pull request #3265 from crazyserver/MOBILE-3833

Mobile 3833
main
Dani Palou 2022-04-21 16:49:32 +02:00 committed by GitHub
commit c644eeb1e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 177 additions and 191 deletions

View File

@ -75,7 +75,7 @@ export class AddonUserProfileFieldDatetimeComponent extends CoreUserProfileField
this.max = field.param2; this.max = field.param2;
} }
this.max = this.max || CoreTimeUtils.getDatetimeDefaultMin(); this.min = this.min || CoreTimeUtils.getDatetimeDefaultMin();
this.max = this.max || CoreTimeUtils.getDatetimeDefaultMax(); this.max = this.max || CoreTimeUtils.getDatetimeDefaultMax();
} }

View File

@ -17,12 +17,8 @@
</ion-toolbar> </ion-toolbar>
</ion-header> </ion-header>
<ion-content> <ion-content>
<ion-refresher slot="fixed" [disabled]="!settingsLoaded || isMinor" (ionRefresh)="refreshSettings($event.target)"> <core-loading [hideUntil]="settingsLoaded" *ngIf="!isMinor">
<ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content> <div class="list-item-limited-width">
</ion-refresher>
<div class="list-item-limited-width">
<core-loading [hideUntil]="settingsLoaded" *ngIf="!isMinor">
<!-- Site has an unsupported required field. --> <!-- Site has an unsupported required field. -->
<ion-list *ngIf="!allRequiredSupported"> <ion-list *ngIf="!allRequiredSupported">
@ -36,195 +32,197 @@
</ion-button> </ion-button>
</ion-list> </ion-list>
<!-- Age verification. --> <ng-container *ngIf="allRequiredSupported && settingsLoaded && settings">
<form *ngIf="allRequiredSupported && settingsLoaded && settings && ageDigitalConsentVerification" <!-- Age verification. -->
[formGroup]="ageVerificationForm" (ngSubmit)="verifyAge($event)" #ageForm> <form *ngIf="ageDigitalConsentVerification" [formGroup]="ageVerificationForm" (ngSubmit)="verifyAge($event)" #ageForm>
<ion-item-divider class="ion-text-wrap"> <ion-item-divider class="ion-text-wrap">
<ion-label> <ion-label>
<h3>{{ 'core.agelocationverification' | translate }}</h3> <h3>{{ 'core.agelocationverification' | translate }}</h3>
</ion-label> </ion-label>
</ion-item-divider> </ion-item-divider>
<ion-item class="ion-text-wrap"> <ion-item class="ion-text-wrap">
<ion-label position="stacked"> <ion-label position="stacked">
<span core-mark-required="true">{{ 'core.whatisyourage' | translate }}</span> <span core-mark-required="true">{{ 'core.whatisyourage' | translate }}</span>
</ion-label> </ion-label>
<ion-input type="number" name="age" placeholder="0" formControlName="age" autocapitalize="none" autocorrect="off"> <ion-input type="number" name="age" placeholder="0" formControlName="age" autocapitalize="none" autocorrect="off">
</ion-input>
</ion-item>
<ion-item class="ion-text-wrap">
<ion-label position="stacked">
<span core-mark-required="true">{{ 'core.wheredoyoulive' | translate }}</span>
</ion-label>
<ion-select name="country" formControlName="country" [placeholder]="'core.login.selectacountry' | translate">
<ion-select-option value="">{{ 'core.login.selectacountry' | translate }}</ion-select-option>
<ion-select-option *ngFor="let country of countries" [value]="country.code">{{country.name}}</ion-select-option>
</ion-select>
</ion-item>
<!-- Submit button. -->
<ion-button expand="block" class="ion-margin" type="submit" [disabled]="!ageVerificationForm.valid">
{{ 'core.proceed' | translate }}
</ion-button>
<ion-item class="ion-text-wrap">
<ion-label>
<h3 class="item-heading">{{ 'core.whyisthisrequired' | translate }}</h3>
<p>{{ 'core.explanationdigitalminor' | translate }}</p>
</ion-label>
</ion-item>
</form>
<!-- Signup form. -->
<form *ngIf="allRequiredSupported && settingsLoaded && settings && !ageDigitalConsentVerification" [formGroup]="signupForm"
(ngSubmit)="create($event)" #signupFormEl>
<ion-item class="ion-text-wrap ion-text-center">
<ion-label>
<!-- If no sitename show big siteurl. -->
<p *ngIf="!siteName" class="ion-padding item-heading">{{siteUrl}}</p>
<!-- If sitename, show big sitename and small siteurl. -->
<p *ngIf="siteName" class="ion-padding item-heading">
<core-format-text [text]="siteName" [filter]="false"></core-format-text>
</p>
<p *ngIf="siteName">{{siteUrl}}</p>
</ion-label>
</ion-item>
<!-- Username and password. -->
<ion-item-divider class="ion-text-wrap">
<ion-label>
<h3>{{ 'core.login.createuserandpass' | translate }}</h3>
</ion-label>
</ion-item-divider>
<ion-item class="ion-text-wrap">
<ion-label position="stacked">
<span core-mark-required="true">{{ 'core.login.username' | translate }}</span>
</ion-label>
<ion-input type="text" name="username" placeholder="{{ 'core.login.username' | translate }}" formControlName="username"
autocapitalize="none" autocorrect="off">
</ion-input>
<core-input-errors [control]="signupForm.controls.username" [errorMessages]="usernameErrors"></core-input-errors>
</ion-item>
<ion-item class="ion-text-wrap">
<ion-label position="stacked">
<span core-mark-required="true">{{ 'core.login.password' | translate }}</span>
</ion-label>
<core-show-password name="password">
<ion-input name="password" type="password" placeholder="{{ 'core.login.password' | translate }}"
formControlName="password" [clearOnEdit]="false" autocomplete="new-password" required="true">
</ion-input> </ion-input>
</core-show-password> </ion-item>
<p *ngIf="settings.passwordpolicy" class="core-input-footnote">
{{settings.passwordpolicy}}
</p>
<core-input-errors [control]="signupForm.controls.password" [errorMessages]="passwordErrors"></core-input-errors>
</ion-item>
<!-- More details. --> <ion-item class="ion-text-wrap">
<ion-item-divider class="ion-text-wrap"> <ion-label position="stacked">
<ion-label> <span core-mark-required="true">{{ 'core.wheredoyoulive' | translate }}</span>
<h3>{{ 'core.login.supplyinfo' | translate }}</h3>
</ion-label>
</ion-item-divider>
<ion-item class="ion-text-wrap">
<ion-label position="stacked">
<span core-mark-required="true">{{ 'core.user.email' | translate }}</span>
</ion-label>
<ion-input type="email" name="email" placeholder="{{ 'core.user.email' | translate }}" formControlName="email"
autocapitalize="none" autocorrect="off">
</ion-input>
<core-input-errors [control]="signupForm.controls.email" [errorMessages]="emailErrors"></core-input-errors>
</ion-item>
<ion-item class="ion-text-wrap">
<ion-label position="stacked">
<span core-mark-required="true">{{ 'core.user.emailagain' | translate }}</span>
</ion-label>
<ion-input type="email" name="email2" placeholder="{{ 'core.user.emailagain' | translate }}" autocapitalize="none"
formControlName="email2" autocorrect="off" [pattern]="escapeMail(signupForm.controls.email.value)">
</ion-input>
<core-input-errors [control]="signupForm.controls.email2" [errorMessages]="email2Errors"></core-input-errors>
</ion-item>
<ion-item *ngFor="let nameField of settings.namefields" class="ion-text-wrap">
<ion-label position="stacked">
<span core-mark-required="true">{{ 'core.user.' + nameField | translate }}</span>
</ion-label>
<ion-input type="text" name="nameField" placeholder="{{ 'core.user.' + nameField | translate }}"
formControlName="{{nameField}}" autocorrect="off">
</ion-input>
<core-input-errors [control]="signupForm.controls[nameField]" [errorMessages]="namefieldsErrors![nameField]">
</core-input-errors>
</ion-item>
<ion-item class="ion-text-wrap">
<ion-label position="stacked">{{ 'core.user.city' | translate }}</ion-label>
<ion-input type="text" name="city" placeholder="{{ 'core.user.city' | translate }}" formControlName="city"
autocorrect="off">
</ion-input>
</ion-item>
<ion-item class="ion-text-wrap">
<ion-label position="stacked" id="core-login-signup-country">{{ 'core.user.country' | translate }}</ion-label>
<ion-select name="country" formControlName="country" aria-labelledby="core-login-signup-country"
[placeholder]="'core.login.selectacountry' | translate">
<ion-select-option value="">{{ 'core.login.selectacountry' | translate }}</ion-select-option>
<ion-select-option *ngFor="let country of countries" [value]="country.code">{{country.name}}</ion-select-option>
</ion-select>
</ion-item>
<!-- Other categories. -->
<ng-container *ngFor="let category of categories">
<ion-item-divider class="ion-text-wrap">
<ion-label>
<p class="item-heading">{{ category.name }}</p>
</ion-label> </ion-label>
</ion-item-divider> <ion-select name="country" formControlName="country" [placeholder]="'core.login.selectacountry' | translate">
<core-user-profile-field *ngFor="let field of category.fields" [field]="field" [edit]="true" [signup]="true" <ion-select-option value="">{{ 'core.login.selectacountry' | translate }}</ion-select-option>
registerAuth="email" [form]="signupForm"></core-user-profile-field> <ion-select-option *ngFor="let country of countries" [value]="country.code">{{country.name}}</ion-select-option>
</ng-container> </ion-select>
</ion-item>
<!-- ReCAPTCHA --> <!-- Submit button. -->
<ng-container *ngIf="settings.recaptchapublickey"> <ion-button expand="block" class="ion-margin" type="submit" [disabled]="!ageVerificationForm.valid">
<ion-item-divider class="ion-text-wrap"> {{ 'core.proceed' | translate }}
</ion-button>
<ion-item class="ion-text-wrap">
<ion-label> <ion-label>
<h3><span [core-mark-required]="true">{{ 'core.login.security_question' | translate }}</span></h3> <h3 class="item-heading">{{ 'core.whyisthisrequired' | translate }}</h3>
<p>{{ 'core.explanationdigitalminor' | translate }}</p>
</ion-label> </ion-label>
</ion-item-divider> </ion-item>
<core-recaptcha [publicKey]="settings.recaptchapublickey" [model]="captcha" [siteUrl]="siteUrl"></core-recaptcha> </form>
</ng-container>
<!-- Site policy (if any). --> <!-- Signup form. -->
<ng-container *ngIf="settings.sitepolicy"> <form *ngIf="!ageDigitalConsentVerification" [formGroup]="signupForm" (ngSubmit)="create($event)" #signupFormEl>
<ion-item class="ion-text-wrap ion-text-center">
<ion-label>
<!-- If no sitename show big siteurl. -->
<p *ngIf="!siteName" class="ion-padding item-heading">{{siteUrl}}</p>
<!-- If sitename, show big sitename and small siteurl. -->
<p *ngIf="siteName" class="ion-padding item-heading">
<core-format-text [text]="siteName" [filter]="false"></core-format-text>
</p>
<p *ngIf="siteName">{{siteUrl}}</p>
</ion-label>
</ion-item>
<!-- Username and password. -->
<ion-item-divider class="ion-text-wrap"> <ion-item-divider class="ion-text-wrap">
<ion-label> <ion-label>
<h3>{{ 'core.login.policyagreement' | translate }}</h3> <h3>{{ 'core.login.createuserandpass' | translate }}</h3>
</ion-label> </ion-label>
</ion-item-divider> </ion-item-divider>
<ion-item class="ion-text-wrap"> <ion-item class="ion-text-wrap">
<ion-label> <ion-label position="stacked">
<a [href]="settings.sitepolicy" core-link capture="false"> <span core-mark-required="true">{{ 'core.login.username' | translate }}</span>
{{ 'core.login.policyagreementclick' | translate }}
</a>
</ion-label> </ion-label>
<ion-input type="text" name="username" placeholder="{{ 'core.login.username' | translate }}"
formControlName="username" autocapitalize="none" autocorrect="off">
</ion-input>
<core-input-errors [control]="signupForm.controls.username" [errorMessages]="usernameErrors"></core-input-errors>
</ion-item> </ion-item>
<ion-item class="ion-text-wrap"> <ion-item class="ion-text-wrap">
<ion-label> <ion-label position="stacked">
<span [core-mark-required]="true">{{ 'core.login.policyacceptmandatory' | translate }}</span> <span core-mark-required="true">{{ 'core.login.password' | translate }}</span>
<core-input-errors [control]="signupForm.controls.policyagreed" [errorMessages]="policyErrors">
</core-input-errors>
</ion-label> </ion-label>
<ion-checkbox slot="end" name="policyagreed" formControlName="policyagreed"></ion-checkbox> <core-show-password name="password">
<ion-input name="password" type="password" placeholder="{{ 'core.login.password' | translate }}"
formControlName="password" [clearOnEdit]="false" autocomplete="new-password" required="true">
</ion-input>
</core-show-password>
<p *ngIf="settings.passwordpolicy" class="core-input-footnote">
{{settings.passwordpolicy}}
</p>
<core-input-errors [control]="signupForm.controls.password" [errorMessages]="passwordErrors"></core-input-errors>
</ion-item> </ion-item>
</ng-container>
<!-- Submit button. --> <!-- More details. -->
<ion-button expand="block" class="ion-margin" type="submit">{{ 'core.login.createaccount' | translate }}</ion-button> <ion-item-divider class="ion-text-wrap">
<!-- Remove this once Ionic fixes this bug: https://github.com/ionic-team/ionic-framework/issues/19368 --> <ion-label>
<input type="submit" class="core-submit-hidden-enter" /> <h3>{{ 'core.login.supplyinfo' | translate }}</h3>
</form> </ion-label>
</core-loading> </ion-item-divider>
<ion-item class="ion-text-wrap">
<ion-label position="stacked">
<span core-mark-required="true">{{ 'core.user.email' | translate }}</span>
</ion-label>
<ion-input type="email" name="email" placeholder="{{ 'core.user.email' | translate }}" formControlName="email"
autocapitalize="none" autocorrect="off">
</ion-input>
<core-input-errors [control]="signupForm.controls.email" [errorMessages]="emailErrors"></core-input-errors>
</ion-item>
<ion-item class="ion-text-wrap">
<ion-label position="stacked">
<span core-mark-required="true">{{ 'core.user.emailagain' | translate }}</span>
</ion-label>
<ion-input type="email" name="email2" placeholder="{{ 'core.user.emailagain' | translate }}" autocapitalize="none"
formControlName="email2" autocorrect="off" [pattern]="escapeMail(signupForm.controls.email.value)">
</ion-input>
<core-input-errors [control]="signupForm.controls.email2" [errorMessages]="email2Errors"></core-input-errors>
</ion-item>
<ion-item *ngFor="let nameField of settings.namefields" class="ion-text-wrap">
<ion-label position="stacked">
<span core-mark-required="true">{{ 'core.user.' + nameField | translate }}</span>
</ion-label>
<ion-input type="text" name="nameField" placeholder="{{ 'core.user.' + nameField | translate }}"
formControlName="{{nameField}}" autocorrect="off">
</ion-input>
<core-input-errors [control]="signupForm.controls[nameField]" [errorMessages]="namefieldsErrors![nameField]">
</core-input-errors>
</ion-item>
<ion-item class="ion-text-wrap">
<ion-label position="stacked">{{ 'core.user.city' | translate }}</ion-label>
<ion-input type="text" name="city" placeholder="{{ 'core.user.city' | translate }}" formControlName="city"
autocorrect="off">
</ion-input>
</ion-item>
<ion-item class="ion-text-wrap">
<ion-label position="stacked" id="core-login-signup-country">{{ 'core.user.country' | translate }}</ion-label>
<ion-select name="country" formControlName="country" aria-labelledby="core-login-signup-country"
[placeholder]="'core.login.selectacountry' | translate">
<ion-select-option value="">{{ 'core.login.selectacountry' | translate }}</ion-select-option>
<ion-select-option *ngFor="let country of countries" [value]="country.code">{{country.name}}</ion-select-option>
</ion-select>
</ion-item>
<!-- Other categories. -->
<ng-container *ngFor="let category of categories">
<ion-item-divider class="ion-text-wrap">
<ion-label>
<p class="item-heading">{{ category.name }}</p>
</ion-label>
</ion-item-divider>
<core-user-profile-field *ngFor="let field of category.fields" [field]="field" [edit]="true" [signup]="true"
registerAuth="email" [form]="signupForm"></core-user-profile-field>
</ng-container>
<!-- ReCAPTCHA -->
<ng-container *ngIf="settings.recaptchapublickey">
<ion-item-divider class="ion-text-wrap">
<ion-label>
<h3><span [core-mark-required]="true">{{ 'core.login.security_question' | translate }}</span></h3>
</ion-label>
</ion-item-divider>
<core-recaptcha [publicKey]="settings.recaptchapublickey" [model]="captcha" [siteUrl]="siteUrl"></core-recaptcha>
</ng-container>
<!-- Site policy (if any). -->
<ng-container *ngIf="settings.sitepolicy">
<ion-item-divider class="ion-text-wrap">
<ion-label>
<h3>{{ 'core.login.policyagreement' | translate }}</h3>
</ion-label>
</ion-item-divider>
<ion-item class="ion-text-wrap">
<ion-label>
<a [href]="settings.sitepolicy" core-link capture="false">
{{ 'core.login.policyagreementclick' | translate }}
</a>
</ion-label>
</ion-item>
<ion-item class="ion-text-wrap">
<ion-label>
<span [core-mark-required]="true">{{ 'core.login.policyacceptmandatory' | translate }}</span>
<core-input-errors [control]="signupForm.controls.policyagreed" [errorMessages]="policyErrors">
</core-input-errors>
</ion-label>
<ion-checkbox slot="end" name="policyagreed" formControlName="policyagreed"></ion-checkbox>
</ion-item>
</ng-container>
<!-- Submit button. -->
<ion-button expand="block" class="ion-margin" type="submit">{{ 'core.login.createaccount' | translate }}</ion-button>
<!-- Remove this once Ionic fixes this bug: https://github.com/ionic-team/ionic-framework/issues/19368 -->
<input type="submit" class="core-submit-hidden-enter" />
</form>
</ng-container>
</div>
</core-loading>
<div class="list-item-limited-width">
<ion-list *ngIf="allRequiredSupported && isMinor"> <ion-list *ngIf="allRequiredSupported && isMinor">
<ion-item-divider class="ion-text-wrap"> <ion-item-divider class="ion-text-wrap">
<ion-label> <ion-label>

View File

@ -14,7 +14,6 @@
import { Component, ViewChild, ElementRef, OnInit, ChangeDetectorRef } from '@angular/core'; import { Component, ViewChild, ElementRef, OnInit, ChangeDetectorRef } from '@angular/core';
import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms'; import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms';
import { IonRefresher } from '@ionic/angular';
import { CoreSites } from '@services/sites'; import { CoreSites } from '@services/sites';
import { CoreDomUtils } from '@services/utils/dom'; import { CoreDomUtils } from '@services/utils/dom';
@ -55,7 +54,7 @@ export class CoreLoginEmailSignupPage implements OnInit {
siteUrl!: string; siteUrl!: string;
siteConfig?: CoreSitePublicConfigResponse; siteConfig?: CoreSitePublicConfigResponse;
siteName?: string; siteName?: string;
authInstructions?: string; authInstructions = '';
settings?: AuthEmailSignupSettings; settings?: AuthEmailSignupSettings;
countries?: CoreCountry[]; countries?: CoreCountry[];
categories?: AuthEmailSignupProfileFieldsCategory[]; categories?: AuthEmailSignupProfileFieldsCategory[];
@ -256,17 +255,6 @@ export class CoreLoginEmailSignupPage implements OnInit {
} }
} }
/**
* Pull to refresh.
*
* @param event Event.
*/
refreshSettings(event?: IonRefresher): void {
this.fetchData().finally(() => {
event?.complete();
});
}
/** /**
* Create account. * Create account.
* *
@ -377,7 +365,7 @@ export class CoreLoginEmailSignupPage implements OnInit {
* Show authentication instructions. * Show authentication instructions.
*/ */
showAuthInstructions(): void { showAuthInstructions(): void {
CoreTextUtils.viewText(Translate.instant('core.login.instructions'), this.authInstructions!); CoreTextUtils.viewText(Translate.instant('core.login.instructions'), this.authInstructions);
} }
/** /**
@ -419,7 +407,7 @@ export class CoreLoginEmailSignupPage implements OnInit {
if (!result.status) { if (!result.status) {
if (this.countryControl.value) { if (this.countryControl.value) {
this.signUpCountryControl!.setValue(this.countryControl.value); this.signUpCountryControl?.setValue(this.countryControl.value);
} }
// Not a minor, go ahead. // Not a minor, go ahead.
@ -428,7 +416,7 @@ export class CoreLoginEmailSignupPage implements OnInit {
// Is a minor. // Is a minor.
this.isMinor = true; this.isMinor = true;
} }
} catch (error) { } catch {
// Something wrong, redirect to the site. // Something wrong, redirect to the site.
CoreDomUtils.showErrorModal('There was an error verifying your age, please try again using the browser.'); CoreDomUtils.showErrorModal('There was an error verifying your age, please try again using the browser.');
} finally { } finally {