Signup form for tutors ready

parent 71a8171b
......@@ -121,6 +121,7 @@
"edit": "Edit",
"email": "Email address",
"email_confirm": "E-mail address confirmation",
"email_invalid": "Invalid email",
"email_match": "The emails must match",
"email_type": "E-mail address",
"enable_sound_for": "Enable sound for",
......
......@@ -121,6 +121,7 @@
"edit": "Editar",
"email": "Correo electrónico",
"email_confirm": "Repite tu email",
"email_invalid": "El email no es válido",
"email_match": "Los emails deben coincidir",
"email_type": "Introduce tu email",
"enable_sound_for": "Habilitar sonido para",
......
......@@ -113,40 +113,56 @@ function LoginCtrl(
role: '',
};
$scope.minlength = CONSTANTS.password_minlength;
$scope.minlength = CONSTANTS.password_minlength;
$scope.reset = function () {
/* Forms objects */
$scope.forms = {};
$scope.reset = function () {
$scope.formdata = formdata_empty;
};
};
$scope.reset();
$scope.reset();
// Signup form submit
$scope.signup = function () {
$scope.signup = function (formName) {
var form;
if (formName == 'tutorForm')
form = $scope.forms.tutorForm;
else if (formName == 'therapistForm')
form = $scope.forms.therapistForm;
else
form = $scope.forms.officeForm;
if (typeof $scope.formdata.email == 'undefined' || form.email.$invalid) {
ngToast.danger($translate.instant('email_invalid'));
return;
}
if ($scope.formdata.password.length < CONSTANTS.password_minlength) {
ngToast.danger({ content: $translate.instant('password_short', {minlength: CONSTANTS.password_minlength}) });
ngToast.danger($translate.instant('password_short', {minlength: CONSTANTS.password_minlength}));
return;
}
if (!$scope.formdata.disclaimer_accepted) {
ngToast.danger({ content: $translate.instant('disclaimer_requested') });
if ($scope.formdata.password !== $scope.formdata.password_confirm) {
ngToast.danger($translate.instant('password_match'));
return;
}
if (!$scope.formdata.role) {
ngToast.danger({ content: $translate.instant('case_requested') });
if (!$scope.formdata.disclaimer_accepted) {
ngToast.danger($translate.instant('disclaimer_requested'));
return;
}
if (!$scope.signInForm.$valid)
if (form.$invalid)
return;
$http
.post(config.backend + '/sup', $scope.formdata)
.success(function () {
ngToast.success({ content: $translate.instant('user_created', { name: $scope.formdata.name, surname: $scope.formdata.surname }) });
$scope.reset();
$scope.slide.rightTo('confirmation');
})
.error(function () {
ngToast.danger({ content: $translate.instant('user_exists', {email: $scope.formdata.email}) });
......
......@@ -86,9 +86,6 @@
</div>
</div>
<form name="signupForm" role="form" ng-submit="signup()">
<!--
SLIDE 2: Account selection
-->
......@@ -146,27 +143,32 @@
<!--
SLIDE 3: Tutor account form
-->
<form name="forms.tutorForm" role="form" ng-submit="signup('tutorForm')" novalidate ng-if="formdata.role == 'tutor'">
<div ng-class="slide.back ? 'switch-animation-back' : 'switch-animation'" ng-switch-when="tutor">
<legend translate>parents_tutor</legend>
<div class="row">
<div class="col-md-4 text-center">
<img src="img/parents.png" alt="{{'parents_tutor' | translate}}" title="{{'parents_tutor' | translate}}" />
</div>
<div class="form-group col-md-4" id="tutor_form">
<div class="form-group col-md-4">
<input type="hidden" ng-model="formdata.role" value="tutor"></input>
<div class="form-group">
<label translate>email</label>
<input type="email" class="form-control" placeholder="{{ 'email' | translate }}" required required ng-model="formdata.email"/>
<div class="form-group">
<input type="email" class="form-control" name="email" placeholder="{{ 'email' | translate }}" ng-model="formdata.email"/>
<span class="color_red text_sm pull-right" ng-show="forms.tutorForm.email.$dirty && forms.tutorForm.email.$invalid" translate>email_invalid</span>
</div>
</div>
<fieldset>
<label translate>password</label>
<span class="color_red text_sm pull-right" ng-show="formdata.password != formdata.password_confirm" translate>password_match</span>
<span class="color_red text_sm pull-right" ng-show="formdata.password.length < minlength" translate>password_short</span>
<div class="form-group">
<input type="password" class="form-control" id="signin_password1" placeholder="{{ 'password_type' | translate }}" required ng-model="formdata.password"/>
<input type="password" class="form-control" id="signin_password1" placeholder="{{ 'password_type' | translate }}" name="password" required ng-model="formdata.password"/>
</div>
<div class="form-group">
<input type="password" class="form-control" id="signin_password2" placeholder="{{ 'password_confirm' | translate }}" required ng-model="formdata.password_confirm"/>
<input type="password" class="form-control" id="signin_password2" placeholder="{{ 'password_confirm' | translate }}" name="password_confirm" required ng-model="formdata.password_confirm"/>
<span class="color_red text_sm pull-right" ng-show="formdata.password != formdata.password_confirm && forms.tutorForm.password.$dirty && forms.tutorForm.password_confirm.$dirty" translate>password_match</span>
<span class="color_red text_sm pull-right" ng-show="formdata.password.length < minlength && forms.tutorForm.password.$dirty && forms.tutorForm.password_confirm.$dirty"> {{ 'password_short' | translate:'{ minlength: minlength }' }}</span>
</div>
</fieldset>
<div class="form-group">
......@@ -186,15 +188,19 @@
<button class="btn btn-default" ng-click="slide.leftTo('accounts')">&lt;&lt; {{ 'back' | translate }} </button>
</div>
<div class="col-md-4">
<button type="submit" class="btn btn-primary" ng-disabled="signupForm.$invalid" ng-click="slide.rightTo('confirmation')">{{ 'create_account' | translate }} &gt;&gt; </button>
<button type="submit" class="btn btn-primary" ng-disabled="forms.tutorForm.$invalid || !formdata.disclaimer_accepted">{{ 'create_account' | translate }} &gt;&gt; </button>
</div>
</div>
</div>
</form>
<!--
SLIDE 4: Therapist account form
-->
<form name="forms.therapistForm" role="form" ng-submit="signup('therapistForm')" novalidate ng-if="formdata.role == 'therapist'">
<div ng-class="slide.back ? 'switch-animation-back' : 'switch-animation'" ng-switch-when="therapist">
<legend translate>therapist</legend>
<div class="row">
......@@ -204,12 +210,12 @@
<div class="form-group col-md-4" id="tutor_form">
<div class="form-group">
<label translate>email</label>
<input type="email" class="form-control" placeholder="{{ 'email' | translate }}" required ng-model="formdata.office.email"/>
<input type="email" class="form-control" placeholder="{{ 'email' | translate }}" ng-model="formdata.email"/>
</div>
<fieldset>
<label translate>password</label>
<span class="color_red text_sm pull-right" ng-show="formdata.password != formdata.password_confirm" translate>password_match</span>
<div class="form-group">
<span class="color_red text_sm pull-right" ng-show="formdata.password != formdata.password_confirm" translate>password_match</span>
<input type="password" class="form-control" id="signin_password1" placeholder="{{ 'password_type' | translate }}" required ng-model="formdata.password"/>
</div>
<div class="form-group">
......@@ -231,14 +237,19 @@
<button class="btn btn-default" ng-click="slide.leftTo('accounts')">&lt;&lt; {{ 'back' | translate }} </button>
</div>
<div class="col-md-4">
<button type="submit" class="btn btn-primary" ng-disabled="signupForm.$invalid" ng-click="slide.rightTo('confirmation')">{{ 'create_account' | translate }} &gt;&gt; </button>
<button type="submit" class="btn btn-primary" ng-disabled="forms.therapistForm.$invalid" ng-click="slide.rightTo('confirmation')">{{ 'create_account' | translate }} &gt;&gt; </button>
</div>
</div>
</div>
</form>
<!--
SLIDE 5: Office account form
-->
<form name="forms.officeForm" role="form" ng-submit="signup('officeForm')" novalidate ng-if="formdata.role == 'office'">
<div ng-class="slide.back ? 'switch-animation-back' : 'switch-animation'" ng-switch-when="office">
<legend translate>office_center</legend>
<div class="row">
......@@ -279,7 +290,7 @@
<button class="btn btn-default" ng-click="slide.leftTo('accounts')">&lt;&lt; {{ 'back' | translate }} </button>
</div>
<div class="col-md-4">
<button type="submit" class="btn btn-primary" ng-disabled="signupForm.$invalid" ng-click="slide.rightTo('confirmation')">{{ 'create_account' | translate }} &gt;&gt; </button>
<button type="submit" class="btn btn-primary" ng-disabled="forms.officeForm.$invalid" ng-click="slide.rightTo('confirmation')">{{ 'create_account' | translate }} &gt;&gt; </button>
</div>
</div>
</div>
......@@ -292,7 +303,7 @@
<div ng-class="slide.back ? 'switch-animation-back' : 'switch-animation'" ng-switch-when="confirmation">
<h2>{{ 'user_created' | translate }} </h2>
<p> {{ 'user_created_text' | translate }} </p>
<p> {{ 'user_created_text' | translate:'{ email: formdata.email }' }} </p>
<br>
<img src="img/child.png"/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment