Commit f3f705c5 authored by Χάρης Παπαδόπουλος's avatar Χάρης Παπαδόπουλος
Browse files

Angularjs v4 migration. WIP: Fixing region.schools.select. Restructuring redux...

Angularjs v4 migration. WIP: Fixing region.schools.select. Restructuring redux store for deep immutability. DirectorView bug fix.
parent 887da2d0
...@@ -50,7 +50,7 @@ class DirectorView extends ControllerBase ...@@ -50,7 +50,7 @@ class DirectorView extends ControllerBase
"error_code" => 3001 "error_code" => 3001
], Response::HTTP_FORBIDDEN); ], Response::HTTP_FORBIDDEN);
} }
if ($epalConfig->lock_students->value) { if ($epalConfig->lock_school_students_view->value) {
return $this->respondWithStatus([ return $this->respondWithStatus([
"error_code" => 3002 "error_code" => 3002
], Response::HTTP_FORBIDDEN); ], Response::HTTP_FORBIDDEN);
...@@ -555,7 +555,7 @@ class DirectorView extends ControllerBase ...@@ -555,7 +555,7 @@ class DirectorView extends ControllerBase
$specialityid = $object->specialty_id->entity->id(); $specialityid = $object->specialty_id->entity->id();
$studentPerSchool = $this->entityTypeManager->getStorage('epal_student_class') $studentPerSchool = $this->entityTypeManager->getStorage('epal_student_class')
->loadByProperties(array('epal_id' => $schoolid, 'specialization_id' => $specialityid, 'currentclass' => 4)); ->loadByProperties(array('epal_id' => $schoolid, 'specialization_id' => $specialityid, 'currentclass' => 4));
$capacity_class_d = ($object -> capacity_class_specialty_d ->value) *25; $capacity_class_d = ($object -> capacity_class_specialty_d ->value) *25;
$list[] = array( $list[] = array(
'id' => $object->specialty_id->entity->id(), 'id' => $object->specialty_id->entity->id(),
'name' => 'Δ Λυκείου '.$object->specialty_id->entity->get('name')->value, 'name' => 'Δ Λυκείου '.$object->specialty_id->entity->get('name')->value,
......
...@@ -436,9 +436,9 @@ class SubmitedApplications extends ControllerBase ...@@ -436,9 +436,9 @@ class SubmitedApplications extends ControllerBase
'name' => $name_decoded, 'name' => $name_decoded,
'studentsurname' => $studentsurname_decoded, 'studentsurname' => $studentsurname_decoded,
'fatherfirstname' => $fatherfirstname_decoded, 'fatherfirstname' => $fatherfirstname_decoded,
'fathersurname' => $epalStudent->fathersurname, 'fathersurname' => '',
'motherfirstname' => $motherfirstname_decoded, 'motherfirstname' => $motherfirstname_decoded,
'mothersurname' => $epalStudent->mothersurname, 'mothersurname' => '',
'guardian_name' => $guardian_name_decoded, 'guardian_name' => $guardian_name_decoded,
'guardian_surname' => $guardian_surname_decoded, 'guardian_surname' => $guardian_surname_decoded,
'guardian_fathername' => $guardian_fathername_decoded, 'guardian_fathername' => $guardian_fathername_decoded,
...@@ -720,7 +720,7 @@ class SubmitedApplications extends ControllerBase ...@@ -720,7 +720,7 @@ class SubmitedApplications extends ControllerBase
} }
$transaction = $this->connection->startTransaction(); $transaction = $this->connection->startTransaction();
try { try {
//ανάκτηση τιμής από ρυθμίσεις διαχειριστή για lock_school_students_view //ανάκτηση τιμής από ρυθμίσεις διαχειριστή για lock_school_students_view
...@@ -749,7 +749,7 @@ class SubmitedApplications extends ControllerBase ...@@ -749,7 +749,7 @@ class SubmitedApplications extends ControllerBase
if ($epalStudent) { if ($epalStudent) {
$epalStudentClasses = $this->entityTypeManager->getStorage('epal_student_class')->loadByProperties(array('student_id' => $applicationId)); $epalStudentClasses = $this->entityTypeManager->getStorage('epal_student_class')->loadByProperties(array('student_id' => $applicationId));
$epalStudentClass = reset($epalStudentClasses); $epalStudentClass = reset($epalStudentClasses);
if ($epalStudentClass) { if ($epalStudentClass) {
if ($epalStudentClass->directorconfirm->value === "1") { if ($epalStudentClass->directorconfirm->value === "1") {
return $this->respondWithStatus([ return $this->respondWithStatus([
...@@ -801,4 +801,4 @@ class SubmitedApplications extends ControllerBase ...@@ -801,4 +801,4 @@ class SubmitedApplications extends ControllerBase
return $res; return $res;
} }
} }
\ No newline at end of file
...@@ -304,14 +304,14 @@ class CBController extends ControllerBase ...@@ -304,14 +304,14 @@ class CBController extends ControllerBase
public function getXMLElements($doc){ public function getXMLElements($doc){
$webUserDetails = $doc->getElementsByTagName( "WebUserDetails" ); $webUserDetails = $doc->getElementsByTagName( "WebUserDetails" );
if (!$webUserDetails || $webUserDetails->length === 0) if (!$webUserDetails || $webUserDetails->length === 0)
return false; // return false;
/* return array( // to be changed to empty array return array( // to be changed to empty array
'firstName' => '', 'firstName' => '',
'surname' => '', 'surname' => '',
'fathersName' => '', 'fathersName' => '',
'comments' => '', 'comments' => '',
'tin' => '12345' 'tin' => '12345'
); */ );
foreach( $webUserDetails as $element ) foreach( $webUserDetails as $element )
{ {
...@@ -331,14 +331,14 @@ class CBController extends ControllerBase ...@@ -331,14 +331,14 @@ class CBController extends ControllerBase
$tin = $tins->item(0)->nodeValue; $tin = $tins->item(0)->nodeValue;
if (!$tin || $tin === '') if (!$tin || $tin === '')
return false; // return false;
/* return array( // to be changed to empty array return array( // to be changed to empty array
'firstName' => '', 'firstName' => '',
'surname' => '', 'surname' => '',
'fathersName' => '', 'fathersName' => '',
'comments' => '', 'comments' => '',
'tin' => '12345' 'tin' => '12345'
); */ );
return array( return array(
'firstName' => $firstName, 'firstName' => $firstName,
'surname' => $surname, 'surname' => $surname,
......
...@@ -42,17 +42,20 @@ ...@@ -42,17 +42,20 @@
"webpack-dev-server": "^1.16.2" "webpack-dev-server": "^1.16.2"
}, },
"dependencies": { "dependencies": {
"@angular/common": "^2.0.0", "@angular/animations": "^4.0.0",
"@angular/compiler": "^2.0.0", "@angular/common": "^4.0.0",
"@angular/core": "^2.0.0", "@angular/compiler": "^4.0.0",
"@angular/forms": "^2.0.0", "@angular/compiler-cli": "^4.0.0",
"@angular/http": "^2.0.0", "@angular/core": "^4.0.0",
"@angular/platform-browser": "^2.0.0", "@angular/forms": "^4.0.0",
"@angular/platform-browser-dynamic": "^2.0.0", "@angular/http": "^4.0.0",
"@angular/router": "^3.2.0", "@angular/platform-browser": "^4.0.0",
"@angular/platform-browser-dynamic": "^4.0.0",
"@angular/platform-server": "^4.0.0",
"@angular/router": "^4.0.0",
"@ngui/auto-complete": "^0.13.3", "@ngui/auto-complete": "^0.13.3",
"@types/file-saver": "0.0.1", "@types/file-saver": "0.0.1",
"@types/jquery": "^2.0.41", "@types/jquery": "^2.0.48",
"@types/node": "^6.0.60", "@types/node": "^6.0.60",
"@types/node-sass": "^3.10.32", "@types/node-sass": "^3.10.32",
"babel-polyfill": "^6.20.0", "babel-polyfill": "^6.20.0",
...@@ -68,10 +71,10 @@ ...@@ -68,10 +71,10 @@
"fs-writefile-promise": "^2.0.0", "fs-writefile-promise": "^2.0.0",
"html-webpack-plugin": "^2.24.1", "html-webpack-plugin": "^2.24.1",
"immutable": "^3.8.1", "immutable": "^3.8.1",
"jquery": "^3.1.1", "jquery": "^3.2.1",
"mydatepicker": "^2.0.13", "mydatepicker": "^2.0.13",
"ng2-redux": "^5.1.0", "ng2-redux": "^5.1.0",
"ng2-smart-table": "^0.4.0-5", "ng2-smart-table": "^1.2.1",
"ngx-cookie": "^1.0.0", "ngx-cookie": "^1.0.0",
"ngx-uploader": "^2.2.5", "ngx-uploader": "^2.2.5",
"raw-loader": "^0.5.1", "raw-loader": "^0.5.1",
...@@ -82,6 +85,7 @@ ...@@ -82,6 +85,7 @@
"rxjs": "^5.0.0-rc.3", "rxjs": "^5.0.0-rc.3",
"style-loader": "^0.13.1", "style-loader": "^0.13.1",
"ts-loader": "^1.2.1", "ts-loader": "^1.2.1",
"typescript": "^2.4.1",
"url-loader": "^0.5.7", "url-loader": "^0.5.7",
"webpack": "^1.13.3", "webpack": "^1.13.3",
"zone.js": ">=0.6.26" "zone.js": ">=0.6.26"
......
...@@ -40,6 +40,7 @@ import RegionEduAuthGuard from './guards/regionedu.auth.guard'; ...@@ -40,6 +40,7 @@ import RegionEduAuthGuard from './guards/regionedu.auth.guard';
import EduAdminAuthGuard from './guards/eduadmin.auth.guard'; import EduAdminAuthGuard from './guards/eduadmin.auth.guard';
import MinistryAuthGuard from './guards/ministry.auth.guard'; import MinistryAuthGuard from './guards/ministry.auth.guard';
import * as $ from 'jquery';
import { ACTION_PROVIDERS } from './actions'; import { ACTION_PROVIDERS } from './actions';
import Home from './components/home'; import Home from './components/home';
import { Ng2SmartTableModule, LocalDataSource } from 'ng2-smart-table'; import { Ng2SmartTableModule, LocalDataSource } from 'ng2-smart-table';
...@@ -101,5 +102,5 @@ class MyLocalization extends NgLocalization { ...@@ -101,5 +102,5 @@ class MyLocalization extends NgLocalization {
}) })
class AppModule {} class AppModule {}
enableProdMode(); // enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule); platformBrowserDynamic().bootstrapModule(AppModule);
...@@ -82,7 +82,7 @@ export default class HeaderComponent implements OnInit, OnDestroy { ...@@ -82,7 +82,7 @@ export default class HeaderComponent implements OnInit, OnDestroy {
this.TotalStudentsSub = this._hds.findTotalStudents().subscribe(x => { this.TotalStudentsSub = this._hds.findTotalStudents().subscribe(x => {
this.TotalStudents$.next(x); this.TotalStudents$.next(x);
this.showLoader.next(false); this.showLoader.next(false);
this.hasvalue = true; this.hasvalue = true;
}, },
error => { error => {
this.TotalStudents$.next([{}]); this.TotalStudents$.next([{}]);
......
...@@ -66,12 +66,12 @@ import { SECTOR_FIELDS_INITIAL_STATE } from '../../store/sectorfields/sectorfiel ...@@ -66,12 +66,12 @@ import { SECTOR_FIELDS_INITIAL_STATE } from '../../store/sectorfields/sectorfiel
</ul> </ul>
</div> </div>
<ul *ngIf="(regions$ | async).size > 0" class="list-group left-side-view" style="margin-bottom: 20px;"> <ul *ngIf="(regions$ | async)" class="list-group left-side-view" style="margin-bottom: 20px;">
<div *ngFor="let epal$ of selectedSchools$ | async; let i=index; let isOdd=odd; let isEven=even" > <div *ngFor="let epal$ of selectedSchools$ | async; let i=index; let isOdd=odd; let isEven=even" >
<li class="list-group-item" [class.oddout]="isOdd" [class.evenout]="isEven"> <li class="list-group-item" [class.oddout]="isOdd" [class.evenout]="isEven">
<span class="roundedNumber">{{(i+1)}}</span>&nbsp;&nbsp;{{epal$.epal_name}} <span class="roundedNumber">{{(i+1)}}</span>&nbsp;&nbsp;{{epal$.get("epal_name")}}
</li> </li>
</div> </div>
</ul> </ul>
...@@ -124,13 +124,17 @@ import { SECTOR_FIELDS_INITIAL_STATE } from '../../store/sectorfields/sectorfiel ...@@ -124,13 +124,17 @@ import { SECTOR_FIELDS_INITIAL_STATE } from '../../store/sectorfields/sectorfiel
this.regionsSub = this._ngRedux.select(state => { this.regionsSub = this._ngRedux.select(state => {
let numsel = 0, numsel2 = 0; let numsel = 0, numsel2 = 0;
let selectedSchools = Array<IRegionSchool>(); let selectedSchools = Array<IRegionSchool>();
if (state.regions.size === 0)
return;
console.log(state.regions);
state.regions.reduce((prevRegion, region) => { state.regions.reduce((prevRegion, region) => {
region.epals.reduce((prevEpal, epal) => { console.log(region);
if (epal.selected === true) { region.get("epals").reduce((prevEpal, epal) => {
if (epal.get("selected") === true) {
numsel++; numsel++;
selectedSchools.push(epal); selectedSchools.push(epal);
} }
if (epal.order_id !== 0) { if (epal.get("order_id") !== 0) {
numsel2++; numsel2++;
} }
return epal; return epal;
......
...@@ -32,7 +32,7 @@ import {AppSettings} from '../../app.settings'; ...@@ -32,7 +32,7 @@ import {AppSettings} from '../../app.settings';
<breadcrumbs></breadcrumbs> <breadcrumbs></breadcrumbs>
</div> </div>
<div class = "loading" *ngIf="(regions$ | async).size === 0"> <div class = "loading" *ngIf="!(regions$ | async)">
</div> </div>
<!-- <div class="row equal"> <!-- <div class="row equal">
<div class="col-md-12"> --> <div class="col-md-12"> -->
...@@ -66,20 +66,20 @@ import {AppSettings} from '../../app.settings'; ...@@ -66,20 +66,20 @@ import {AppSettings} from '../../app.settings';
<ul class="list-group main-view"> <ul class="list-group main-view">
<div *ngFor="let region$ of regions$ | async; let i=index; let isOdd=odd; let isEven=even" > <div *ngFor="let region$ of regions$ | async; let i=index; let isOdd=odd; let isEven=even" >
<li class="list-group-item isclickable" (click)="setActiveRegion(i)" [class.oddout]="isOdd" [class.evenout]="isEven" [class.selectedout]="regionActive === i"> <li class="list-group-item isclickable" (click)="setActiveRegion(i)" [class.oddout]="isOdd" [class.evenout]="isEven" [class.selectedout]="regionActive === i">
<h5>{{region$.region_name}}</h5> <h5>{{region$.get("region_name")}}</h5>
</li> </li>
<div *ngFor="let epal$ of region$.epals; let j=index; let isOdd2=odd; let isEven2=even" [class.oddin]="isOdd2" [class.evenin]="isEven2" [hidden]="i !== regionActive"> <div *ngFor="let epal$ of region$.get('epals'); let j=index; let isOdd2=odd; let isEven2=even" [class.oddin]="isOdd2" [class.evenin]="isEven2" [hidden]="i !== regionActive">
<div class="row"> <div class="row">
<div class="col-md-2 col-md-offset-1"> <div class="col-md-2 col-md-offset-1">
<input #cb type="checkbox" formControlName="{{ epal$.globalIndex }}" <input #cb type="checkbox" formControlName="{{ epal$.get('globalIndex') }}"
(change)="saveSelected(cb.checked,i,j)" (change)="saveSelected(cb.checked,i,j)"
[hidden] = "(numSelected | async) === 3 && cb.checked === false" [hidden] = "(numSelected | async) === 3 && cb.checked === false"
> >
</div> </div>
<div class="col-md-8 col-md-offset-1 isclickable"> <div class="col-md-8 col-md-offset-1 isclickable">
{{epal$.epal_name | removeSpaces}} {{epal$.get("epal_name") | removeSpaces}}
</div> </div>
</div> </div>
...@@ -88,7 +88,7 @@ import {AppSettings} from '../../app.settings'; ...@@ -88,7 +88,7 @@ import {AppSettings} from '../../app.settings';
</div> </div>
</ul> </ul>
</div> </div>
<div class="row" style="margin-top: 20px; margin-bottom: 20px;" *ngIf="(regions$ | async).size > 0"> <div class="row" style="margin-top: 20px; margin-bottom: 20px;" *ngIf="(regions$ | async)">
<div class="col-md-6"> <div class="col-md-6">
<button type="button" class="btn-primary btn-lg pull-left isclickable" (click)="navigateBack()" > <button type="button" class="btn-primary btn-lg pull-left isclickable" (click)="navigateBack()" >
<i class="fa fa-backward"></i> <i class="fa fa-backward"></i>
...@@ -109,6 +109,7 @@ import {AppSettings} from '../../app.settings'; ...@@ -109,6 +109,7 @@ import {AppSettings} from '../../app.settings';
</div> </div>
</div> </div>
</form> </form>
<!-- <pre>{{formGroup.value | json}}</pre> -->
</div> </div>
` `
}) })
...@@ -233,20 +234,28 @@ import {AppSettings} from '../../app.settings'; ...@@ -233,20 +234,28 @@ import {AppSettings} from '../../app.settings';
let numreg = 0; //count reduced regions in order to set activeRegion when user comes back to his choices let numreg = 0; //count reduced regions in order to set activeRegion when user comes back to his choices
this.selectionLimitOptional.next(false); this.selectionLimitOptional.next(false);
console.log("numsel="+numsel);
console.log(state.regions);
console.log(state.regions.size);
console.log(this.regions$.getValue());
if (state.regions.size === 0)
return;
state.regions.reduce((prevRegion, region) =>{ state.regions.reduce((prevRegion, region) =>{
numreg++; numreg++;
region.epals.reduce((prevEpal, epal) =>{ region.get("epals").reduce((prevEpal, epal) =>{
this.rss.push( new FormControl(epal.selected, [])); this.rss.push( new FormControl(epal.get("selected"), []));
if (epal.selected === true) { if (epal.get("selected") === true) {
numsel++; numsel++;
if ( epal.epal_special_case === "1") { console.log("numsel2="+numsel);
if ( epal.get("epal_special_case") === "1") {
this.selectionLimitOptional.next(true); this.selectionLimitOptional.next(true);
} }
this.regionActiveId = Number(region.region_id); this.regionActiveId = Number(region.region_id);
this.regionActive = numreg - 1; this.regionActive = numreg - 1;
} }
if (Number(region.region_id) === this.regionActiveId) { if (Number(region.region_id) === this.regionActiveId) {
if (region.epals.length < this.regionSizeLimit) if (region.get("epals").length < this.regionSizeLimit)
this.selectionLimitOptional.next(true); this.selectionLimitOptional.next(true);
} }
return epal; return epal;
...@@ -254,9 +263,12 @@ import {AppSettings} from '../../app.settings'; ...@@ -254,9 +263,12 @@ import {AppSettings} from '../../app.settings';
return region; return region;
}, {}); }, {});
console.log("numsel3="+numsel);
this.numSelected.next(numsel); this.numSelected.next(numsel);
return state.regions; return state.regions;
}).subscribe(this.regions$); }).subscribe(this.regions$);
} }
setClassActive(className) { setClassActive(className) {
...@@ -327,12 +339,12 @@ import {AppSettings} from '../../app.settings'; ...@@ -327,12 +339,12 @@ import {AppSettings} from '../../app.settings';
// if ( (this.selectionLimitOptional.value === false /*&& this.classNight.value === false */ && this.numSelected.value < this.selectionLimit.value ) // if ( (this.selectionLimitOptional.value === false /*&& this.classNight.value === false */ && this.numSelected.value < this.selectionLimit.value )
// || (this.numSelected.value === 0) ) { // || (this.numSelected.value === 0) ) {
if ( this.numSelected.value === 0) { if ( this.numSelected.getValue() === 0) {
//this.modalHeader = "modal-header-success"; //this.modalHeader = "modal-header-success";
this.modalHeader.next("modal-header-danger"); this.modalHeader.next("modal-header-danger");
this.modalTitle.next("Επιλογή αριθμού σχολείων"); this.modalTitle.next("Επιλογή αριθμού σχολείων");
if (this.numSelected.value === 0) if (this.numSelected.getValue() === 0)
this.modalText.next("Δεν έχετε επιλέξει κανένα σχολείο!"); this.modalText.next("Δεν έχετε επιλέξει κανένα σχολείο!");
/* /*
else else
......
...@@ -272,8 +272,8 @@ import {Location} from '@angular/common'; ...@@ -272,8 +272,8 @@ import {Location} from '@angular/common';
} }
ngOnDestroy() { ngOnDestroy() {
(<any>$('#applicationDeleteConfirm')).remove(); (<any>jQuery('#applicationDeleteConfirm')).remove();
(<any>$('#applicationDeleteError')).remove(); (<any>jQuery('#applicationDeleteError')).remove();
if (this.SubmitedUsersSub) if (this.SubmitedUsersSub)
this.SubmitedUsersSub.unsubscribe(); this.SubmitedUsersSub.unsubscribe();
if (this.SubmitedDetailsSub) if (this.SubmitedDetailsSub)
...@@ -284,8 +284,8 @@ import {Location} from '@angular/common'; ...@@ -284,8 +284,8 @@ import {Location} from '@angular/common';
ngOnInit() { ngOnInit() {
(<any>$('#applicationDeleteConfirm')).appendTo("body"); (<any>jQuery('#applicationDeleteConfirm')).appendTo("body");
(<any>$('#applicationDeleteError')).appendTo("body"); (<any>jQuery('#applicationDeleteError')).appendTo("body");
this.showLoader$.next(true); this.showLoader$.next(true);
this.SubmitedUsersSub = this._hds.getSubmittedPreviw().subscribe( this.SubmitedUsersSub = this._hds.getSubmittedPreviw().subscribe(
...@@ -356,18 +356,18 @@ import {Location} from '@angular/common'; ...@@ -356,18 +356,18 @@ import {Location} from '@angular/common';
} }
public showConfirmModal(): void { public showConfirmModal(): void {
(<any>$('#applicationDeleteConfirm')).modal('show'); (<any>jQuery('#applicationDeleteConfirm')).modal('show');
} }
public showErrorModal(): void { public showErrorModal(): void {
(<any>$('#applicationDeleteError')).modal('show'); (<any>jQuery('#applicationDeleteError')).modal('show');
} }
public hideConfirmModal(): void { public hideConfirmModal(): void {
(<any>$('#applicationDeleteConfirm')).modal('hide'); (<any>jQuery('#applicationDeleteConfirm')).modal('hide');
} }
public hideErrorModal(): void { public hideErrorModal(): void {
(<any>$('#applicationDeleteError')).modal('hide'); (<any>jQuery('#applicationDeleteError')).modal('hide');
} }
public onHidden(): void { public onHidden(): void {
......
...@@ -3,6 +3,7 @@ import { Component, Inject, OnInit, OnDestroy } ...@@ -3,6 +3,7 @@ import { Component, Inject, OnInit, OnDestroy }
import { import {
Router, Router,
ActivatedRoute, ActivatedRoute,
NavigationStart
} }
from '@angular/router'; from '@angular/router';
import './globalstyles.css'; import './globalstyles.css';
...@@ -34,10 +35,18 @@ export default class Main { ...@@ -34,10 +35,18 @@ export default class Main {
private _ngRedux: NgRedux<IAppState>, private _ngRedux: NgRedux<IAppState>,
private _devTools: DevToolsExtension private _devTools: DevToolsExtension
) { ) {
router.events.subscribe((data) => { /* router.events
.filter((e: Event) => e instanceof NavigationStart)
.subscribe((e: NavigationStart) => {
console.log(e.url);
console.log(e.toString());
this.path = e.url.substr(1);
this.pathSchool = e.url.substr(1);
}); */
/* router.events.subscribe((data) => {
this.path = data.url.substr(1); this.path = data.url.substr(1);
this.pathSchool = data.url.substr(1); this.pathSchool = data.url.substr(1);
}); }); */
const tools = _devTools.enhancer({ const tools = _devTools.enhancer({
...@@ -46,9 +55,9 @@ export default class Main { ...@@ -46,9 +55,9 @@ export default class Main {
_ngRedux.configureStore( _ngRedux.configureStore(
rootReducer, rootReducer,
{}, {},
// middleware, middleware,
// tools ? [ ...enhancers, tools ] : enhancers); // tools ? [ ...enhancers, tools ] : enhancers);
// tools); tools);
); // );
} }
}