installed and started using ng2-bootstrap. Parent form fixes and enhancements

parent 12d749f6
......@@ -64,6 +64,7 @@ class CreateDemoData extends ControllerBase {
public function createData() {
$transaction = $this->connection->startTransaction();
try {
//insert demo records in entity: epal_student
$entity_manager = \Drupal::entityTypeManager();
......@@ -132,7 +133,7 @@ class CreateDemoData extends ControllerBase {
for ($j = 0; $j < $numEpalsChosen ; $j++) {
print_r("<br>Data: Student" . $created_student_id . "EPAL" . $epal_id . "CHOICE" . $j );
// print_r("<br>Data: Student" . $created_student_id . "EPAL" . $epal_id . "CHOICE" . $j );
$epalchosen = array(
'student_id' => $created_student_id,
'epal_id' => $epal_id[$j],
......@@ -186,6 +187,7 @@ class CreateDemoData extends ControllerBase {
$returnmsg = "Αποτυχία καταχώρησης demo data!";
$response = new JsonResponse([$returnmsg]);
$transaction->rollback();
return $response;
}
......
......@@ -23,32 +23,32 @@ class SubmitedApplications extends ControllerBase
return new static(
$container->get('entity_type.manager')
);
}
}
public function getSubmittedApplications(Request $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();
$epalStudents = $this->entityTypeManager->getStorage('epal_student')->loadByProperties(array('epaluser_id' => $userid));
$i = 0;
if ($epalStudents) {
$list = array();
foreach ($epalStudents as $object) {
$list[] = array(
'id' => $object -> id(),
'name' => $object -> name ->value,
'studentsurname' => $object -> studentsurname ->value);
$i++;
}
return $this->respondWithStatus(
$list
, Response::HTTP_OK);
......@@ -58,8 +58,8 @@ class SubmitedApplications extends ControllerBase
'message' => t("EPAL user not found"),
], Response::HTTP_FORBIDDEN);
}
} else {
......@@ -67,15 +67,15 @@ class SubmitedApplications extends ControllerBase
'message' => t("User not found"),
], Response::HTTP_FORBIDDEN);
}
}
public function getStudentApplications(Request $request, $studentId)
{
$authToken = $request->headers->get('PHP_AUTH_USER');
$epalUsers = $this->entityTypeManager->getStorage('epal_users')->loadByProperties(array('authtoken' => $authToken));
$epalUser = reset($epalUsers);
......@@ -100,7 +100,7 @@ class SubmitedApplications extends ControllerBase
$i++;
}
return $this->respondWithStatus(
$list
, Response::HTTP_OK);
......@@ -110,7 +110,7 @@ class SubmitedApplications extends ControllerBase
'message' => t("EPAL user not found"),
], Response::HTTP_FORBIDDEN);
}
} else {
......@@ -118,13 +118,13 @@ class SubmitedApplications extends ControllerBase
'message' => t("User not found"),
], Response::HTTP_FORBIDDEN);
}
}
public function getEpalChosen(Request $request, $studentId)
{
$authToken = $request->headers->get('PHP_AUTH_USER');
$epalUsers = $this->entityTypeManager->getStorage('epal_users')->loadByProperties(array('authtoken' => $authToken));
$epalUser = reset($epalUsers);
......@@ -144,7 +144,7 @@ public function getEpalChosen(Request $request, $studentId)
$i++;
}
return $this->respondWithStatus(
$list
, Response::HTTP_OK);
......@@ -154,7 +154,7 @@ public function getEpalChosen(Request $request, $studentId)
'message' => t("EPAL chosen not found!!!"),
], Response::HTTP_FORBIDDEN);
}
} else {
......@@ -162,7 +162,7 @@ public function getEpalChosen(Request $request, $studentId)
'message' => t("User not found"),
], Response::HTTP_FORBIDDEN);
}
}
......@@ -180,8 +180,3 @@ public function getEpalChosen(Request $request, $studentId)
}
export const API_ENDPOINT = 'http://localhost/drupal-8.2.6';
// export const API_ENDPOINT = 'http://eduslim2.minedu.gov.gr/drupal';
export const API_ENDPOINT = 'http://eepal.dev/drupal';
export class AppSettings {
public static get API_ENDPOINT(): string {
return 'http://localhost/drupal-8.2.6';
// return 'http://eduslim2.minedu.gov.gr/drupal';
return 'http://eepal.dev/drupal';
}
}
\ No newline at end of file
}
......@@ -36,6 +36,10 @@ import HeaderComponent from './components/header/header.component';
import NavbarComponent from './components/navbar/navbar.component';
import MainComponent from './components/main/main.component';
import FooterComponent from './components/footer/footer.component';
import { ModalModule } from 'ng2-bootstrap/modal';
import { AlertModule } from 'ng2-bootstrap/alert';
import {enableProdMode} from '@angular/core';
class MyLocalization extends NgLocalization {
getPluralCategory(value: any) {
......@@ -55,7 +59,8 @@ class MyLocalization extends NgLocalization {
HttpModule,
Ng2SmartTableModule,
NgReduxModule,
ModalModule.forRoot(),
AlertModule.forRoot()
],
declarations: [
Main, FooterComponent, HeaderComponent, NavbarComponent, MainComponent,
......@@ -75,4 +80,5 @@ class MyLocalization extends NgLocalization {
})
class AppModule {}
// enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule);
......@@ -88,4 +88,4 @@ export default class Home implements OnInit {
checkvalidation() {
}
}
\ No newline at end of file
}
<div class = "loading" *ngIf="(epalUserData$ | async) === {}"></div>
<div *ngIf="(isModalShown | async)" [config]="{ show: true }" (onHidden)="onHidden()" bsModal #autoShownModal="bs-modal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title pull-left">Auto shown modal</h4>
<button type="button" class="close pull-right" aria-label="Close" (click)="hideModal()">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<p>-------------------------</p>
<p>-------------------------</p>
<p>-------------------------</p>
</div>
</div>
</div>
</div>
<form [formGroup]="formGroup">
<div class="form-group">
......@@ -36,6 +53,9 @@
<div class="form-group" *ngIf="(verificationCodeSent | async) && !(verificationCodeVerified | async)">
<alert type="success">
<strong>Ελέγξτε το email σας!</strong> Αντιγράψτε τον κωδικό που σας στείλαμε εδώ και επιλέξτε "Αποστολή Κωδικού Επαλήθευσης"
</alert>
<label for="verificationCode">Κωδικός επαλήθευσης</label><input class="form-control" type="text" formControlName="verificationCode">
</div>
<div class="row" *ngIf="(verificationCodeSent | async) && !(verificationCodeVerified | async)">
......@@ -45,47 +65,53 @@
</button>
</div>
</div>
<alert type="success" *ngIf="(verificationCodeSent | async) && (verificationCodeVerified | async)">
<strong>Επιτυχία!</strong> Το email σας επαληθεύθηκε και είναι αυτό με το οποίο θα επικοινωνούμε μαζί σας στο εξής
</alert>
<div class="form-group" *ngIf="!(userEmailEnabled | async) && (verificationCodeVerified | async)">
<label for="userName">Όνομα</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>
<div class="alert alert-danger" *ngIf="formGroup.get('userName').hasError('pattern')">
Πληκτρολογήστε το όνομά σας!
</div>
</div>
<div class="alert alert-danger" *ngIf="formGroup.get('userName').touched && formGroup.get('userName').hasError('required') ">
Το πεδίο δεν μπορεί να αφεθεί κενό!
</div>
<div class="alert alert-danger" *ngIf="formGroup.get('userName').hasError('pattern')">
Πληκτρολογήστε το όνομά σας!
</div>
<div class="form-group" *ngIf="!(userEmailEnabled | async) && (verificationCodeVerified | async)">
<label for="userSurname">Επώνυμο</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>
<div class="alert alert-danger" *ngIf="formGroup.get('userSurname').hasError('pattern')">
Πληκτρολογήστε το επώνυμό σας!
</div>
</div>
<div class="alert alert-danger" *ngIf="formGroup.get('userSurname').touched && formGroup.get('userSurname').hasError('required') ">
Το πεδίο δεν μπορεί να αφεθεί κενό!
</div>
<div class="alert alert-danger" *ngIf="formGroup.get('userSurname').hasError('pattern')">
Πληκτρολογήστε το επώνυμό σας!
</div>
<div class="form-group" *ngIf="!(userEmailEnabled | async) && (verificationCodeVerified | async)">
<label for="userFathername">Πατρώνυμο</label><input class="form-control" type="text" formControlName="userFathername">
</div>
<div class="alert alert-danger" *ngIf="formGroup.get('userFathername').touched && formGroup.get('userFathername').hasError('required') ">
Το πεδίο δεν μπορεί να αφεθεί κενό!
</div>
<div class="alert alert-danger" *ngIf="formGroup.get('userFathername').hasError('pattern')">
Πληκτρολογήστε το όνομα του πατέρα σας!
<div class="alert alert-danger" *ngIf="formGroup.get('userFathername').touched && formGroup.get('userFathername').hasError('required') ">
Το πεδίο δεν μπορεί να αφεθεί κενό!
</div>
<div class="alert alert-danger" *ngIf="formGroup.get('userFathername').hasError('pattern')">
Πληκτρολογήστε το όνομα του πατέρα σας!
</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="alert alert-danger" *ngIf="formGroup.get('userMothername').touched && formGroup.get('userMothername').hasError('required') ">
Το πεδίο δεν μπορεί να αφεθεί κενό!
</div>
<div class="alert alert-danger" *ngIf="formGroup.get('userMothername').hasError('pattern')">
Πληκτρολογήστε το όνομα της μητέρας σας!
</div>
</div>
<div class="alert alert-danger" *ngIf="formGroup.get('userMothername').touched && formGroup.get('userMothername').hasError('required') ">
Το πεδίο δεν μπορεί να αφεθεί κενό!
</div>
<div class="alert alert-danger" *ngIf="formGroup.get('userMothername').hasError('pattern')">
Πληκτρολογήστε το όνομα της μητέρας σας!
</div>
<div class="row" *ngIf="!(userEmailEnabled | async) && (verificationCodeVerified | async)">
<div class="col-md-12">
......
......@@ -3,6 +3,7 @@ import { Router } from '@angular/router';
import { BehaviorSubject, Subscription } from 'rxjs/Rx';
import { VALID_EMAIL_PATTERN, VALID_NAMES_PATTERN } from '../../constants';
import { HelperDataService } from '../../services/helper-data-service';
import { ModalDirective } from 'ng2-bootstrap/modal';
import {
FormBuilder,
......@@ -29,6 +30,8 @@ import {AppSettings} from '../../app.settings';
private verificationCodeVerified: BehaviorSubject<boolean>;
private userEmailEnabled: BehaviorSubject<boolean>;
@ViewChild('userEmail') userEmail: ElementRef;
@ViewChild('autoShownModal') public autoShownModal: ModalDirective;
public isModalShown: BehaviorSubject<boolean>;
constructor(private fb: FormBuilder,
private router: Router,
......@@ -38,6 +41,7 @@ import {AppSettings} from '../../app.settings';
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]],
......@@ -48,6 +52,20 @@ import {AppSettings} from '../../app.settings';
});
this.epalUserData$ = new BehaviorSubject({});
}
public showModal():void {
console.log("about to show modal");
this.isModalShown.next(true);
}
public hideModal():void {
this.autoShownModal.hide();
}
public onHidden():void {
this.isModalShown.next(false);
}
ngOnInit() {
this.epalUserDataSub = this.hds.getEpalUserData().subscribe(
x => {
......@@ -93,7 +111,9 @@ import {AppSettings} from '../../app.settings';
.then(res => {
this.verificationCodeSent.next(true);
this.verificationCodeVerified.next(false);
this.disableUserEmail();})
this.disableUserEmail();
// this.showModal();
})
.catch(err => {console.log(err)});
}
......@@ -101,7 +121,9 @@ import {AppSettings} from '../../app.settings';
this.hds.verifyVerificationCode(this.formGroup.value.verificationCode)
.then(res => {
this.verificationCodeVerified.next((<any>res).verificationCodeVerified);
this.formGroup.value.userEmail=(<any>res).userEmail;})
this.formGroup.value.userEmail=(<any>res).userEmail;
// this.showModal();
})
.catch(err => {console.log(err)});
}
......
......@@ -82,5 +82,6 @@ export default class Main {
middleware,
// tools ? [ ...enhancers, tools ] : enhancers);
tools);
// );
}
}
......@@ -2,7 +2,7 @@
<html lang="en" data-framework="angular2">
<head>
<meta charset="utf-8">
<title>Angular 2 με Drupal backend RESTful server</title>
<title>Σύστημα υποβολής αιτήσεων εγγραφής σε ΕΠΑΛ</title>
</head>
<body>
<main></main>
......
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 to comment