refactor(module): Remove AMD wrapper from SignUpPasswordView (#6287) r=@vladikoff
Extraction from #6273
This commit is contained in:
Родитель
1fd05d2110
Коммит
fe9c262404
|
@ -2,97 +2,93 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
define(function (require, exports, module) {
|
import AuthErrors from '../lib/auth-errors';
|
||||||
'use strict';
|
import BackMixin from './mixins/back-mixin';
|
||||||
|
import CheckboxMixin from './mixins/checkbox-mixin';
|
||||||
|
import Cocktail from 'cocktail';
|
||||||
|
import CoppaMixin from './mixins/coppa-mixin';
|
||||||
|
import EmailOptInMixin from './mixins/email-opt-in-mixin';
|
||||||
|
import FlowEventsMixin from './mixins/flow-events-mixin';
|
||||||
|
import FormPrefillMixin from './mixins/form-prefill-mixin';
|
||||||
|
import FormView from './form';
|
||||||
|
import PasswordMixin from './mixins/password-mixin';
|
||||||
|
import ServiceMixin from './mixins/service-mixin';
|
||||||
|
import SignUpMixin from './mixins/signup-mixin';
|
||||||
|
import Template from 'templates/sign_up_password.mustache';
|
||||||
|
|
||||||
const AuthErrors = require('../lib/auth-errors');
|
class SignUpPasswordView extends FormView {
|
||||||
const BackMixin = require('./mixins/back-mixin');
|
constructor (options) {
|
||||||
const CheckboxMixin = require('./mixins/checkbox-mixin');
|
super(options);
|
||||||
const Cocktail = require('cocktail');
|
|
||||||
const CoppaMixin = require('./mixins/coppa-mixin');
|
|
||||||
const EmailOptInMixin = require('./mixins/email-opt-in-mixin');
|
|
||||||
const FlowEventsMixin = require('./mixins/flow-events-mixin');
|
|
||||||
const FormPrefillMixin = require('./mixins/form-prefill-mixin');
|
|
||||||
const FormView = require('./form');
|
|
||||||
const PasswordMixin = require('./mixins/password-mixin');
|
|
||||||
const ServiceMixin = require('./mixins/service-mixin');
|
|
||||||
const SignUpMixin = require('./mixins/signup-mixin');
|
|
||||||
const Template = require('templates/sign_up_password.mustache');
|
|
||||||
|
|
||||||
class SignUpPasswordView extends FormView {
|
this.template = Template;
|
||||||
constructor (options) {
|
}
|
||||||
super(options);
|
|
||||||
|
|
||||||
this.template = Template;
|
getAccount () {
|
||||||
}
|
return this.model.get('account');
|
||||||
|
}
|
||||||
|
|
||||||
getAccount () {
|
beforeRender () {
|
||||||
return this.model.get('account');
|
if (! this.getAccount()) {
|
||||||
}
|
this.navigate('/');
|
||||||
|
|
||||||
beforeRender () {
|
|
||||||
if (! this.getAccount()) {
|
|
||||||
this.navigate('/');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
setInitialContext (context) {
|
|
||||||
context.set(this.getAccount().pick('email'));
|
|
||||||
}
|
|
||||||
|
|
||||||
isValidEnd () {
|
|
||||||
if (! this._doPasswordsMatch()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.isValidEnd();
|
|
||||||
}
|
|
||||||
|
|
||||||
showValidationErrorsEnd () {
|
|
||||||
if (! this._doPasswordsMatch()) {
|
|
||||||
this.displayError(AuthErrors.toError('PASSWORDS_DO_NOT_MATCH'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
submit () {
|
|
||||||
return Promise.resolve().then(() => {
|
|
||||||
if (! this.isUserOldEnough()) {
|
|
||||||
return this.tooYoung();
|
|
||||||
}
|
|
||||||
|
|
||||||
const account = this.getAccount();
|
|
||||||
account.set('needsOptedInToMarketingEmail', this.hasOptedInToMarketingEmail());
|
|
||||||
return this.signUp(account, this._getPassword());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
_getPassword () {
|
|
||||||
return this.getElementValue('#password');
|
|
||||||
}
|
|
||||||
|
|
||||||
_getVPassword () {
|
|
||||||
return this.getElementValue('#vpassword');
|
|
||||||
}
|
|
||||||
|
|
||||||
_doPasswordsMatch() {
|
|
||||||
return this._getPassword() === this._getVPassword();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Cocktail.mixin(
|
setInitialContext (context) {
|
||||||
SignUpPasswordView,
|
context.set(this.getAccount().pick('email'));
|
||||||
BackMixin,
|
}
|
||||||
CheckboxMixin,
|
|
||||||
CoppaMixin({
|
|
||||||
required: true
|
|
||||||
}),
|
|
||||||
EmailOptInMixin,
|
|
||||||
FlowEventsMixin,
|
|
||||||
FormPrefillMixin,
|
|
||||||
PasswordMixin,
|
|
||||||
ServiceMixin,
|
|
||||||
SignUpMixin
|
|
||||||
);
|
|
||||||
|
|
||||||
module.exports = SignUpPasswordView;
|
isValidEnd () {
|
||||||
});
|
if (! this._doPasswordsMatch()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.isValidEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
showValidationErrorsEnd () {
|
||||||
|
if (! this._doPasswordsMatch()) {
|
||||||
|
this.displayError(AuthErrors.toError('PASSWORDS_DO_NOT_MATCH'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
submit () {
|
||||||
|
return Promise.resolve().then(() => {
|
||||||
|
if (! this.isUserOldEnough()) {
|
||||||
|
return this.tooYoung();
|
||||||
|
}
|
||||||
|
|
||||||
|
const account = this.getAccount();
|
||||||
|
account.set('needsOptedInToMarketingEmail', this.hasOptedInToMarketingEmail());
|
||||||
|
return this.signUp(account, this._getPassword());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
_getPassword () {
|
||||||
|
return this.getElementValue('#password');
|
||||||
|
}
|
||||||
|
|
||||||
|
_getVPassword () {
|
||||||
|
return this.getElementValue('#vpassword');
|
||||||
|
}
|
||||||
|
|
||||||
|
_doPasswordsMatch() {
|
||||||
|
return this._getPassword() === this._getVPassword();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Cocktail.mixin(
|
||||||
|
SignUpPasswordView,
|
||||||
|
BackMixin,
|
||||||
|
CheckboxMixin,
|
||||||
|
CoppaMixin({
|
||||||
|
required: true
|
||||||
|
}),
|
||||||
|
EmailOptInMixin,
|
||||||
|
FlowEventsMixin,
|
||||||
|
FormPrefillMixin,
|
||||||
|
PasswordMixin,
|
||||||
|
ServiceMixin,
|
||||||
|
SignUpMixin
|
||||||
|
);
|
||||||
|
|
||||||
|
module.exports = SignUpPasswordView;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче