updated parent.form. Removed fields from application.form.main. Birthdate...

updated parent.form. Removed fields from application.form.main. Birthdate checking. Other fixes, updates
parent 577c0784
......@@ -188,9 +188,11 @@ class CASLogin extends ControllerBase
phpCAS::trace($umdobject);
phpCAS::trace($physicaldeliveryofficename);
$gsnunitcodedn = $filterAttribute('edupersonorgunitdn:gsnunitcode:extended');
// phpCAS::trace($physicaldeliveryofficename);
// $gsnunitcodedn = $filterAttribute('edupersonorgunitdn:gsnunitcode:extended');
$gsnunitcode = substr($gsnunitcodedn, strpos($gsnunitcodedn, ";") + 1);
// $gsnunitcode = $filterAttribute('edupersonorgunitdn:gsnunitcode');
phpCAS::trace("$gsnunitcode=");
phpCAS::trace($gsnunitcode);
/* check if myschool account */
......
......@@ -46,6 +46,14 @@ epal.submitedapplications:
_controller: '\Drupal\epal\Controller\SubmitedApplications::getSubmittedApplications'
requirements:
_user_is_logged_in: 'TRUE'
epal.application_delete:
path: '/epal/application/delete'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\SubmitedApplications::deleteApplication'
requirements:
_user_is_logged_in: 'TRUE'
epal.studentapplication:
path: '/epal/student/{studentId}'
options:
......
......@@ -266,6 +266,7 @@ class ApplicationSubmit extends ControllerBase
*/
private function validateStudent($student)
{
$error_code = 0;
if (!$student["agreement"]) {
return 1001;
}
......
This diff is collapsed.
......@@ -44,29 +44,84 @@ class SubmitedApplications extends ControllerBase
);
}
public function deleteApplication(Request $request) {
public function deleteApplication(Request $request)
{
if (!$request->isMethod('POST')) {
return $this->respondWithStatus([
"error_code" => 2001
], Response::HTTP_METHOD_NOT_ALLOWED);
}
$content = $request->getContent();
$applicationId = 0;
if (!empty($content)) {
$postArr = json_decode($content, TRUE);
$applicationId = $postArr['applicationId'];
}
else {
return $this->respondWithStatus([
"error_code" => 5002
], Response::HTTP_BAD_REQUEST);
}
$authToken = $request->headers->get('PHP_AUTH_USER');
$epalUsers = $this->entityTypeManager->getStorage('epal_users')->loadByProperties(array('authtoken' => $authToken));
$epalUser = reset($epalUsers);
if ($epalUser) {
$userid = $epalUser->id();
$transaction = $this->connection->startTransaction();
try {
$epalUsers = $this->entityTypeManager->getStorage('epal_users')->loadByProperties(array('authtoken' => $authToken));
$epalUser = reset($epalUsers);
if ($epalUser) {
$userid = $epalUser->id();
$epalStudents = $this->entityTypeManager->getStorage('epal_student')->loadByProperties(array('epaluser_id' => $userid, 'id' => $applicationId));
$epalStudent = reset($epalStudents);
$epalStudents = $this->entityTypeManager->getStorage('epal_student')->loadByProperties(array('epaluser_id' => $userid));
$epalStudent = reset($epalStudents);
if ($epalStudent) {
if ($epalStudent) {
$epalStudentClasses = $this->entityTypeManager->getStorage('epal_student_class')->loadByProperties(array('student_id' => $applicationId));
$epalStudentClass = reset($epalStudentClasses);
if ($epalStudentClass) {
return $this->respondWithStatus([
"error_code" => 3002
], Response::HTTP_FORBIDDEN);
}
$delQuery = $this->connection->delete('epal_student_epal_chosen');
$delQuery->condition('student_id', $applicationId);
$delQuery->execute();
$delQuery = $this->connection->delete('epal_student_sector_field');
$delQuery->condition('student_id', $applicationId);
$delQuery->execute();
$delQuery = $this->connection->delete('epal_student_course_field');
$delQuery->condition('student_id', $applicationId);
$delQuery->execute();
$delQuery = $this->connection->delete('epal_student_class');
$delQuery->condition('student_id', $applicationId);
$delQuery->execute();
$epalStudent->delete();
return $this->respondWithStatus([
'error_code' => 0,
], Response::HTTP_OK);
} else {
return $this->respondWithStatus([
'message' => t('EPAL student not found'),
], Response::HTTP_FORBIDDEN);
}
} else {
return $this->respondWithStatus([
'message' => t('EPAL user not found'),
], Response::HTTP_FORBIDDEN);
}
} else {
return $this->respondWithStatus([
'message' => t('User not found'),
'message' => t('EPAL user not found'),
], Response::HTTP_FORBIDDEN);
}
} catch (\Exception $e) {
$this->logger->warning($e->getMessage());
$transaction->rollback();
return $this->respondWithStatus([
'error_code' => 5001,
], Response::HTTP_INTERNAL_SERVER_ERROR);
}
}
public function getSubmittedApplications(Request $request)
......@@ -79,13 +134,21 @@ class SubmitedApplications extends ControllerBase
$epalStudents = $this->entityTypeManager->getStorage('epal_student')->loadByProperties(array('epaluser_id' => $userid));
$i = 0;
$list = array();
if ($epalStudents) {
$crypt = new Crypt();
$list = array();
foreach ($epalStudents as $object) {
$indexid = intval($object->id()) - 1;
foreach ($epalStudents as $object) {
$canDelete = 0;
$epalStudentClasses = $this->entityTypeManager->getStorage('epal_student_class')->loadByProperties(array('student_id' => $object->id()));
$epalStudentClass = reset($epalStudentClasses);
if ($epalStudentClass) {
$canDelete = 0;
}
else {
$canDelete = 1;
}
try {
$name_decoded = $crypt->decrypt($object->name->value);
$studentsurname_decoded = $crypt->decrypt($object->studentsurname->value);
......@@ -99,11 +162,12 @@ class SubmitedApplications extends ControllerBase
}
$list[] = array(
'id' => $indexid,
'id' => $object->id(),
//'name' => $object -> name ->value,
'name' => $name_decoded,
//'studentsurname' => $object -> studentsurname ->value);
'studentsurname' => $studentsurname_decoded, );
'studentsurname' => $studentsurname_decoded,
'candelete' => $canDelete, );
++$i;
}
......@@ -112,9 +176,8 @@ class SubmitedApplications extends ControllerBase
return $this->respondWithStatus(
$list, Response::HTTP_OK);
} else {
return $this->respondWithStatus([
'message' => t('EPAL user not found'),
], Response::HTTP_FORBIDDEN);
return $this->respondWithStatus(
$list, Response::HTTP_OK);
}
} else {
return $this->respondWithStatus([
......
......@@ -200,9 +200,12 @@ class CBController extends ControllerBase
'drupaluser_id' => $user->id(),
'taxis_userid' => $taxis_userData['tin'],
'taxis_taxid' => $taxis_userData['tin'],
'name' => $taxis_userData['firstName'],
/* 'name' => $taxis_userData['firstName'],
'surname' => $taxis_userData['surname'],
'fathername' => $taxis_userData['fathersName'],
'fathername' => $taxis_userData['fathersName'], */
'name' => $unique_id,
'surname' => $unique_id,
'fathername' => $unique_id,
'mothername' => $unique_id,
'accesstoken' => $accessToken['oauth_token'],
'accesstoken_secret' => $accessToken['oauth_token_secret'],
......
This diff is collapsed.
This diff is collapsed.
......@@ -3,12 +3,12 @@
<footer class="footer">
<div class="container">
<div class="row">
<div class="col-xs-12 col-md-3"><span class="ft-text">Copyright (c) ΥΠ.Π.Ε.Θ. 2017</span></div>
<div class="col-xs-12 col-md-4"><span class="ft-text">Copyright (c) ΥΠ.Π.Ε.Θ. 2017</span></div>
<div class="cols-xs-12 col-md-6 text-center">
<span class="ft-text"><a href="#">ΟΡΟΙ ΧΡΗΣΗΣ – ΕΜΠΙΣΤΕΥΤΙΚΟΤΗΤΑ</a></span>
<span class="ft-text"><a href="#">ΠΡΟΣΩΠΙΚΑ ΔΕΔΟΜΕΝΑ</a></span>
<!-- <span class="ft-text"><a href="#">ΟΡΟΙ ΧΡΗΣΗΣ – ΕΜΠΙΣΤΕΥΤΙΚΟΤΗΤΑ</a></span>
<span class="ft-text"><a href="#">ΠΡΟΣΩΠΙΚΑ ΔΕΔΟΜΕΝΑ</a></span> -->
</div>
<div class="col-xs-12 col-md-3"><span class="ft-text">Version 1</span></div>
<div class="col-xs-12 col-md-2"><span class="ft-text" style="text-align: right;">Version 1.0</span></div>
</div>
</div>
</footer>
......@@ -139,34 +139,6 @@
Συμπληρώστε την ημερομηνία γέννησης του μαθητή!
</div>
<div class="form-group">
<label for="certificatetype">Τύπος απολυτηρίου(<span style="color: #ff0000;">*</span>)</label><br/>
<select class="form-control" formControlName="certificatetype">
<option value="">Παρακαλώ επιλέξτε...</option>
<option value="Απολυτήριο Γυμνασίου">Απολυτήριο Γυμνασίου</option>
<option value="Απολυτήριο Λυκείου">Απολυτήριο Λυκείου</option>
</select>
</div>
<div class="alert alert-danger" *ngIf="studentDataGroup.get('certificatetype').dirty && studentDataGroup.get('certificatetype').hasError('status')">
Η επιλογή από αυτή τη λίστα είναι απαραίτητη!
</div>
<div class="form-group">
<label for="graduation_year">Έτος κτήσης απολυτηρίου(<span style="color: #ff0000;">*</span>)</label>
<br/>
<select class="form-control" formControlName="graduation_year">
<option value="">Παρακαλώ επιλέξτε...</option>
<option *ngFor="let graduationyear of graduationyears" value="{{graduationyear}}">
{{ graduationyear }}
</option>
</select>
</div>
<div class="alert alert-danger" *ngIf="studentDataGroup.get('graduation_year').dirty && studentDataGroup.get('graduation_year').hasError('status')">
Η επιλογή από αυτή τη λίστα είναι απαραίτητη!
</div>
<div class="form-group">
<label for="lastschool_schoolname">Σχολείο τελευταίας φοίτησης(<span style="color: #ff0000;">*</span>)</label><br/>
<input ngui-auto-complete formControlName="lastschool_schoolname" [source]="observableSource.bind(this)" [list-formatter]="lastSchoolListFormatter" [value-formatter]="lastSchoolValueFormatter" [min-chars]="5" no-match-found-text="Δεν βρέθηκαν σχολεία"
......@@ -243,4 +215,4 @@
</form>
<!-- <pre>{{studentDataGroup.value | json}}</pre> -->
<!-- <pre>{{studentDataGroup.value | json}}</pre> -->
......@@ -47,7 +47,6 @@ import {
private modalText: BehaviorSubject<string>;
private modalHeader: BehaviorSubject<string>;
private schoolyears: string[];
private graduationyears: string[];
private rss = new FormArray([]);
......@@ -85,7 +84,6 @@ import {
private router: Router,
private http: Http) {
this.populateSchoolyears();
this.populateGraduationyears();
this.loginInfo$ = new BehaviorSubject(LOGININFO_INITIAL_STATE);
this.modalTitle = new BehaviorSubject("");
this.modalText = new BehaviorSubject("");
......@@ -94,31 +92,20 @@ import {
this.studentDataFields$ = new BehaviorSubject(STUDENT_DATA_FIELDS_INITIAL_STATE);
this.criteria$ = new BehaviorSubject(CRITERIA_INITIAL_STATE);
this.studentDataGroup = this.fb.group({
// epaluser_id: [,[]],
name: ['', [Validators.pattern(VALID_NAMES_PATTERN),Validators.required]],
studentsurname: ['', [Validators.pattern(VALID_NAMES_PATTERN),Validators.required]],
studentbirthdate: ['', [Validators.required]],
//studentbirthdate: ['', [Validators.pattern(VALID_DATE_PATTERN),Validators.required]],
fatherfirstname: ['', [Validators.pattern(VALID_NAMES_PATTERN),Validators.required]],
motherfirstname: ['', [Validators.pattern(VALID_NAMES_PATTERN),Validators.required]],
regionaddress: ['', [Validators.pattern(VALID_ADDRESS_PATTERN),Validators.required]],
regiontk: ['', [Validators.pattern(VALID_ADDRESSTK_PATTERN),Validators.required]],
regionarea: ['', [Validators.pattern(VALID_NAMES_PATTERN),Validators.required]],
certificatetype: ['', this.checkChoice],
relationtostudent: ['', this.checkChoice],
telnum: ['', [Validators.pattern(VALID_TELEPHONE_PATTERN),Validators.required]],
graduation_year: ['', this.checkChoice],
lastschool_schoolname: ['', [Validators.required]],
lastschool_schoolyear: ['', this.checkChoice],
lastschool_class: ['', this.checkChoice],
});
/* this.studentCriteriaGroup = this.fb.group({
formArray: this.rss,
}); */
};
ngOnInit() {
......@@ -145,8 +132,6 @@ import {
this.studentDataGroup.controls['regionaddress'].setValue(studentDataField.regionaddress);
this.studentDataGroup.controls['regiontk'].setValue(studentDataField.regiontk);
this.studentDataGroup.controls['regionarea'].setValue(studentDataField.regionarea);
this.studentDataGroup.controls['certificatetype'].setValue(studentDataField.certificatetype);
this.studentDataGroup.controls['graduation_year'].setValue(studentDataField.graduation_year);
this.studentDataGroup.controls['lastschool_schoolname'].setValue(studentDataField.lastschool_schoolname);
this.studentDataGroup.controls['lastschool_schoolyear'].setValue(studentDataField.lastschool_schoolyear);
this.studentDataGroup.controls['lastschool_class'].setValue(studentDataField.lastschool_class);
......@@ -159,47 +144,28 @@ import {
return state.studentDataFields;
}).subscribe(this.studentDataFields$);
/* this._sdfb.getCriteria(true);
this.criteriaSub = this._ngRedux.select(state => {
if (state.criter.size > 0) {
state.criter.reduce(({}, criteria) => {
//this.studentCriteriaGroup.setValue(criteria);
//if (criteria.selected === true && (criteria.name === "Εισόδημα" )) {
// this.selectionIncomeId = Number(criteria.id);
//}
this.rss.push( new FormControl(criteria.selected, []));
return criteria;
}, {});
}
return state.criter;
}).subscribe(this.criteria$); */
};
ngOnDestroy() {
(<any>$('#applicationFormNotice')).remove();
if (this.studentDataFieldsSub) this.studentDataFieldsSub.unsubscribe();
// if (this.criteriaSub) this.criteriaSub.unsubscribe();
if (this.studentDataFields$) this.studentDataFields$.unsubscribe();
// if (this.criteria$) this.criteria$.unsubscribe();
if (this.loginInfo$) this.loginInfo$.unsubscribe();
}
navigateBack() {
this._sdfa.saveStudentDataFields([this.studentDataGroup.value]);
// this._sdfb.saveCriteria([this.studentCriteriaGroup.value.formArray]);
this.router.navigate(['/schools-order-select']);
}
submitSelected() {
// if (this.studentDataGroup.invalid || this.studentCriteriaGroup.invalid) {
if (this.studentDataGroup.invalid || this.invalidFormData()) {
let invalidFlag = 0;
if (this.studentDataGroup.invalid || (invalidFlag = this.invalidFormData()) > 0) {
this.modalHeader.next("modal-header-danger");
this.modalTitle.next("Η δήλωση προτίμησης δεν είναι πλήρης");
if (this.invalidFormData())
if (invalidFlag === 1 || invalidFlag === 2)
this.modalText.next("Πρέπει να συμπληρώσετε όλα τα πεδία που συνοδεύονται από (*). Η ημερομηνία γέννησης του μαθητή δεν είναι επιτρεπόμενη για μαθητή ΕΠΑΛ.");
else if (invalidFlag === 3)
this.modalText.next("Πρέπει να συμπληρώσετε όλα τα πεδία που συνοδεύονται από (*). Το σχολείο τελευταίας φοίτησης πρέπει να αναζητηθεί και να επιλεχθεί από τα αποτελέσματα της αναζήτησης.");
else
this.modalText.next("Πρέπει να συμπληρώσετε όλα τα πεδία που συνοδεύονται από (*)");
......@@ -207,17 +173,21 @@ import {
this.showModal();
} else {
this._sdfa.saveStudentDataFields([this.studentDataGroup.value]);
// this._sdfb.saveCriteria([this.studentCriteriaGroup.value.formArray]);
this.router.navigate(['/application-submit']);
}
}
private invalidFormData() : boolean {
private invalidFormData() : number {
let d = this.studentDataGroup.controls['studentbirthdate'].value;
if (!d || !d.date || !d.date.year)
return 1;
else if ((new Date().getFullYear()) - d.date.year < 15)
return 2;
if (!this.studentDataGroup.controls['lastschool_schoolname'].value.registry_no)
return true;
return 3;
return false;
return 0;
}
checkcriteria(cb, mutual_disabled) {
......@@ -259,14 +229,6 @@ import {
}
};
private populateGraduationyears(): void {
let endYear = new Date().getFullYear();
this.graduationyears = new Array();
for (let i=endYear; i>FIRST_SCHOOL_YEAR; i--) {
this.graduationyears.push(i + "");
}
};
setDate() {
let date = new Date();
return { date: {
......@@ -297,7 +259,6 @@ import {
};
lastSchoolValueChanged(e: any): void {
// console.log(this.studentDataGroup.controls['lastschool_schoolname'].value);
};
}
......@@ -88,8 +88,6 @@ import { HelperDataService } from '../../services/helper-data-service';
<div><label for="motherfirstname">Όνομα Μητέρας</label> <p class="form-control" style="border:1px solid #eceeef;"> {{studentDataField$.motherfirstname}} </p></div>
<div><label for="birthdate">Ημερομηνία Γέννησης</label> <p class="form-control" style="border:1px solid #eceeef;"> {{studentDataField$.studentbirthdate}} </p></div>
<div><label for="certificatetype">Τύπος απολυτηρίου</label> <p class="form-control" style="border:1px solid #eceeef;"> {{studentDataField$.certificatetype}} </p></div>
<div><label for="graduation_year">Έτος κτήσης απολυτηρίου</label> <p class="form-control" style="border:1px solid #eceeef;"> {{studentDataField$.graduation_year}} </p></div>
<div><label for="lastschool_schoolname">Σχολείο τελευταίας φοίτησης</label> <p class="form-control" style="border:1px solid #eceeef;"> {{studentDataField$.lastschool_schoolname.name}} </p></div>
<div><label for="lastschool_schoolyear">Σχολικό έτος τελευταίας φοίτησης</label> <p class="form-control" style="border:1px solid #eceeef;"> {{studentDataField$.lastschool_schoolyear}} </p></div>
......@@ -284,14 +282,14 @@ import { HelperDataService } from '../../services/helper-data-service';
aitisiObj[0].regionaddress = std.regionaddress;
aitisiObj[0].regionarea = std.regionarea;
aitisiObj[0].regiontk = std.regiontk;
aitisiObj[0].certificatetype = std.certificatetype;
aitisiObj[0].certificatetype = '';
// aitisiObj[0].graduation_year = std.graduation_year;
// aitisiObj[0].lastschool_registrynumber = std.lastschool_registrynumber;
// aitisiObj[0].lastschool_schoolyear = std.lastschool_schoolyear;
// aitisiObj[0].lastschool_class = std.lastschool_class;
// aitisiObj[0].currentepal = std.currentepal;
aitisiObj[0].graduation_year = std.graduation_year;
aitisiObj[0].graduation_year = 0;
aitisiObj[0].lastschool_registrynumber = std.lastschool_schoolname.registry_no;
aitisiObj[0].lastschool_schoolname = std.lastschool_schoolname.name;
aitisiObj[0].lastschool_schoolyear = std.lastschool_schoolyear;
......
......@@ -3,8 +3,8 @@
<div id="emailSentNotice" (onHidden)="onHidden()" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header modal-header-success">
<h3 class="modal-title pull-left"><i class="fa fa-check-square-o"></i>&nbsp;&nbsp;{{ modalTitle | async }}</h3>
<div class="modal-header modal-header-danger">
<h3 class="modal-title pull-left"><i class="fa fa-ban"></i>&nbsp;&nbsp;{{ modalTitle | async }}</h3>
<button type="button" class="close pull-right" aria-label="Close" (click)="hideModal()">
<span aria-hidden="true"><i class="fa fa-times"></i></span>
</button>
......@@ -19,10 +19,11 @@
</div>
</div>
<div style="min-height: 500px; margin-bottom: 30px;">
<p style="margin-top: 20px; line-height: 2em;"> <b> Στοιχεία γονέα-κηδεμόνα. Όλα τα πεδία που συνοδεύονται από (*) είναι απαραίτητο να συμπληρωθούν</b></p>
<form [formGroup]="formGroup">
<div class="form-group">
<label for="userEmail">Email Επικοινωνίας</label><input #userEmail class="form-control" type="text" formControlName="userEmail">
<label for="userEmail">Email Επικοινωνίας(<span style="color: #ff0000;">*</span>)</label><input #userEmail class="form-control" type="text" formControlName="userEmail">
</div>
<div class="alert alert-danger" *ngIf="formGroup.get('userEmail').hasError('required')">
Το πεδίο δεν μπορεί να αφεθεί κενό!
......@@ -31,50 +32,8 @@
Πληκτρολογήστε ένα σωστό συντακτικά email!
</div>
<div class="row" *ngIf="(userEmailEnabled | async) && formGroup.get('userEmail').valid" style="margin-top: 20px; margin-bottom: 20px;">
<div class="col-md-12">
<button type="button" class="btn-primary btn-sm pull-right" (click)="sendVerificationCode()">
Λήψη Κωδικού Επαλήθευσης
</button>
</div>
</div>
<div class="row" style="margin-bottom: 20px;">
<div class="col-md-12">
<div *ngIf="(userEmailEnabled | async) && (epalUserData$ | async).userEmail !== ''">
<button type="button" class="btn-primary btn-sm pull-right" (click)="resetUserEmail();">
Ακύρωση Αλλαγής Email
</button>
</div>
<div *ngIf="!(userEmailEnabled | async)" style="margin-left: 10px;" >
<button type="button" class="btn-primary btn-sm pull-right" (click)="enableUserEmail();">
Αλλαγή Email
</button>
</div>
</div>
</div>
<div class="form-group" *ngIf="(verificationCodeSent | async) && !(verificationCodeVerified | async)">
<div class="alert alert-success">
<strong>Ελέγξτε το email σας!</strong> Αντιγράψτε τον κωδικό που σας στείλαμε εδώ και επιλέξτε "Αποστολή Κωδικού Επαλήθευσης"
</div>
<label for="verificationCode">Κωδικός επαλήθευσης</label><input class="form-control" type="text" formControlName="verificationCode">
</div>
<div class="row" *ngIf="(verificationCodeSent | async) && !(verificationCodeVerified | async)">
<div class="col-md-12">
<button type="button" class="btn-primary btn-sm pull-right" (click)="verifyVerificationCode()">
Αποστολή Κωδικού Επαλήθευσης
</button>
</div>
</div>
<div class="alert alert-success" *ngIf="(verificationCodeSent | async) && (verificationCodeVerified | async)">
<strong>Επιτυχία!</strong> Το email σας επαληθεύθηκε και είναι αυτό με το οποίο θα επικοινωνούμε μαζί σας στο εξής
</div>
<div class="form-group" *ngIf="!(userEmailEnabled | async) && (verificationCodeVerified | async)">
<label for="userName">Όνομα</label><input class="form-control" type="text" formControlName="userName">
<div class="form-group">
<label for="userName">Όνομα(<span style="color: #ff0000;">*</span>)</label><input class="form-control" type="text" formControlName="userName">
<div class="alert alert-danger" *ngIf="formGroup.get('userName').touched && formGroup.get('userName').hasError('required') ">
Το πεδίο δεν μπορεί να αφεθεί κενό!
</div>
......@@ -83,9 +42,8 @@
</div>
</div>
<div class="form-group" *ngIf="!(userEmailEnabled | async) && (verificationCodeVerified | async)">
<label for="userSurname">Επώνυμο</label><input class="form-control" type="text" formControlName="userSurname">
<div class="form-group">
<label for="userSurname">Επώνυμο(<span style="color: #ff0000;">*</span>)</label><input class="form-control" type="text" formControlName="userSurname">
<div class="alert alert-danger" *ngIf="formGroup.get('userSurname').touched && formGroup.get('userSurname').hasError('required') ">
Το πεδίο δεν μπορεί να αφεθεί κενό!
</div>
......@@ -94,9 +52,8 @@
</div>
</div>
<div class="form-group" *ngIf="!(userEmailEnabled | async) && (verificationCodeVerified | async)">
<label for="userFathername">Πατρώνυμο</label><input class="form-control" type="text" formControlName="userFathername">
<div class="form-group">
<label for="userFathername">Πατρώνυμο(<span style="color: #ff0000;">*</span>)</label><input class="form-control" type="text" formControlName="userFathername">
<div class="alert alert-danger" *ngIf="formGroup.get('userFathername').touched && formGroup.get('userFathername').hasError('required') ">
Το πεδίο δεν μπορεί να αφεθεί κενό!
</div>
......@@ -105,8 +62,8 @@
</div>
</div>
<div class="form-group" *ngIf="!(userEmailEnabled | async) && (verificationCodeVerified | async)">
<label for="userMothername">Μητρώνυμο</label><input class="form-control" type="text" formControlName="userMothername">
<div class="form-group">
<label for="userMothername">Μητρώνυμο(<span style="color: #ff0000;">*</span>)</label><input class="form-control" type="text" formControlName="userMothername">
<div class="alert alert-danger" *ngIf="formGroup.get('userMothername').touched && formGroup.get('userMothername').hasError('required') ">
Το πεδίο δεν μπορεί να αφεθεί κενό!
</div>
......@@ -116,9 +73,9 @@
</div>
<div class="row" *ngIf="!(userEmailEnabled | async) && (verificationCodeVerified | async)">
<div class="row">
<div class="col-md-12">
<button type="button" class="btn-primary btn-lg pull-right isclickable" style="width: 9em;" (click)="saveProfileAndContinue()" [disabled]="((userEmailEnabled | async) && !(verificationCodeVerified | async))" >
<button type="button" class="btn-primary btn-lg pull-right isclickable" style="width: 9em;" (click)="saveProfileAndContinue()" >
<span style="font-size: 0.9em; font-weight: bold;">Συνέχεια&nbsp;&nbsp;&nbsp;</span><i class="fa fa-forward"></i>
</button>
</div>
......
......@@ -25,14 +25,9 @@ import {AppSettings} from '../../app.settings';
private respond: any;
private epalUserData$: BehaviorSubject<any>;
private epalUserDataSub: Subscription;
private userEmailSub: Subscription;
private verificationCodeSent: BehaviorSubject<boolean>;
private showLoader: BehaviorSubject<boolean>;
private modalTitle: BehaviorSubject<string>;
private modalText: BehaviorSubject<string>;
private verificationCodeVerified: BehaviorSubject<boolean>;
private userEmailEnabled: BehaviorSubject<boolean>;
@ViewChild('userEmail') userEmail: ElementRef;
public isModalShown: BehaviorSubject<boolean>;
constructor(private fb: FormBuilder,
......@@ -40,17 +35,13 @@ import {AppSettings} from '../../app.settings';
private hds: HelperDataService,
private _prfa: LoginInfoActions,
private rd: Renderer) {
this.verificationCodeSent = new BehaviorSubject(false);
this.verificationCodeVerified = new BehaviorSubject(false);
this.userEmailEnabled = new BehaviorSubject(false);
this.isModalShown = new BehaviorSubject(false);
this.formGroup = this.fb.group({
userName: ['', [Validators.pattern(VALID_NAMES_PATTERN),Validators.required]],
userSurname: ['', [Validators.pattern(VALID_NAMES_PATTERN),Validators.required]],
userFathername: ['', [Validators.pattern(VALID_NAMES_PATTERN),Validators.required]],
userMothername: ['', [Validators.pattern(VALID_NAMES_PATTERN),Validators.required]],
userEmail: [{value: '', disabled: true}, [Validators.pattern(VALID_EMAIL_PATTERN),Validators.required]],
verificationCode: ['', []]
userEmail: ['', [Validators.pattern(VALID_EMAIL_PATTERN),Validators.required]],
});
this.epalUserData$ = new BehaviorSubject(<any>{userEmail: '', userName: '', userSurname: '', userFathername: '', userMothername: ''});
this.showLoader = new BehaviorSubject(false);
......@@ -59,7 +50,6 @@ import {AppSettings} from '../../app.settings';
}
public showModal():void {
console.log("about to show modal");
(<any>$('#emailSentNotice')).modal('show');
}
......@@ -83,100 +73,32 @@ import {AppSettings} from '../../app.settings';
this.formGroup.get('userFathername').setValue(x.userFathername);
this.formGroup.get('userMothername').setValue(x.userMothername);
if (typeof(x.verificationCodeVerified) !== 'undefined' && x.verificationCodeVerified === "1") {
this.verificationCodeVerified.next(true);
} else {
this.verificationCodeVerified.next(false);
}
if (typeof(x.userEmail) !== 'undefined' && x.userEmail.length > 0)
this.userEmailEnabled.next(false);
else {
this.enableUserEmail();
this.userEmailEnabled.next(true);
}
});
this.userEmailSub = this.formGroup.get('userEmail').valueChanges.subscribe(
x => {
if (this.formGroup.get('userEmail').value === '') {
this.enableUserEmail();
}
}
);
}
ngOnDestroy() {
(<any>$('#emailSentNotice')).remove();
if (this.epalUserDataSub) this.epalUserDataSub.unsubscribe();
if (this.userEmailSub) this.epalUserDataSub.unsubscribe();
this.epalUserData$.unsubscribe();
}
sendVerificationCode() {
this.showLoader.next(true);
this.hds.sendVerificationCode(this.formGroup.value.userEmail)
.then(res => {
this.verificationCodeSent.next(true);
this.verificationCodeVerified.next(false);
this.disableUserEmail();
this.showLoader.next(false);
this.modalTitle.next("Αποστολή Κωδικού Επαλήθευσης");
this.modalText.next("Έγινε αποστολή κωδικού επαλήθευσης στη διεύθυνση που δηλώσατε. Ελέγξτε το email σας! Αντιγράψτε τον κωδικό που σας στείλαμε στο πεδίο 'Κωδικός Επαλήθευσης' και επιλέξτε 'Αποστολή Κωδικού Επαλήθευσης'");
this.showModal();
})
.catch(err => {
console.log(err);
this.showLoader.next(false);
});
}
verifyVerificationCode() {
this.showLoader.next(true);
this.hds.verifyVerificationCode(this.formGroup.value.verificationCode)
.then(res => {
this.verificationCodeVerified.next((<any>res).verificationCodeVerified);
this.formGroup.value.userEmail=(<any>res).userEmail;
this.showLoader.next(false);
this.modalTitle.next("Επιτυχής επαλήθευση");
this.modalText.next("Έγινε επαλήθευση του email σας. Μπορείτε να συνεχίσετε συμπληρώνοντας σωστά και τα υπόλοιπα στοιχεία σας και επιλέγοντας 'Συνέχεια'.");
this.showModal();
})