NgRedux.select rewrite(WIP)

parent f4987505
...@@ -68,35 +68,37 @@ export default class HeaderComponent implements OnInit, OnDestroy { ...@@ -68,35 +68,37 @@ export default class HeaderComponent implements OnInit, OnDestroy {
ngOnInit() { ngOnInit() {
(<any>$("#headerNotice")).appendTo("body"); (<any>$("#headerNotice")).appendTo("body");
this.loginInfoSub = this._ngRedux.select(state => { this.loginInfoSub = this._ngRedux.select('loginInfo')
if (state.loginInfo.size > 0) { .map(loginInfo => <ILoginInfo>loginInfo)
state.loginInfo.reduce(({}, loginInfoToken) => { .subscribe(loginInfo => {
this.authToken = loginInfoToken.auth_token; if (loginInfo.size > 0) {
this.authRole = loginInfoToken.auth_role; loginInfo.reduce(({}, loginInfoToken) => {
this.cuName = loginInfoToken.cu_name; this.authToken = loginInfoToken.auth_token;
return loginInfoToken; this.authRole = loginInfoToken.auth_role;
}, {}); this.cuName = loginInfoToken.cu_name;
return loginInfoToken;
if (this.hasvalue == false) }, {});
{
this.showLoader.next(true); if (this.hasvalue == false)
this.TotalStudentsSub = this._hds.findTotalStudents().subscribe(x => { {
this.TotalStudents$.next(x); this.showLoader.next(true);
this.showLoader.next(false); this.TotalStudentsSub = this._hds.findTotalStudents().subscribe(x => {
this.hasvalue = true; this.TotalStudents$.next(x);
},
error => {
this.TotalStudents$.next([{}]);
console.log("Error Getting courses perSchool");
this.showLoader.next(false); this.showLoader.next(false);
}); this.hasvalue = true;
},
error => {
this.TotalStudents$.next([{}]);
console.log("Error Getting courses perSchool");
this.showLoader.next(false);
});
} }
} }
return state.loginInfo; this.loginInfo$.next(loginInfo);
}).subscribe(this.loginInfo$); });
......
import {Router, ActivatedRoute, Params} from '@angular/router'; import {Router, ActivatedRoute, Params} from '@angular/router';
import {OnInit, Component} from '@angular/core'; import {OnInit, OnDestroy, Component} from '@angular/core';
import { LoginInfoActions } from '../actions/logininfo.actions'; import { LoginInfoActions } from '../actions/logininfo.actions';
import { ILoginInfo } from '../store/logininfo/logininfo.types'; import { ILoginInfo } from '../store/logininfo/logininfo.types';
import { NgRedux, select } from '@angular-redux/store'; import { NgRedux, select } from '@angular-redux/store';
import { Observable } from 'rxjs/Rx'; import { BehaviorSubject, Subscription } from 'rxjs/Rx';
import { IAppState } from '../store/store'; import { IAppState } from '../store/store';
import { HelperDataService } from '../services/helper-data-service'; import { HelperDataService } from '../services/helper-data-service';
import { CookieService } from 'ngx-cookie'; import { CookieService } from 'ngx-cookie';
import { STUDENT_ROLE } from '../constants'; import { STUDENT_ROLE } from '../constants';
import { LOGININFO_INITIAL_STATE } from "../store/logininfo/logininfo.initial-state";
import { import {
FormBuilder, FormBuilder,
FormGroup, FormGroup,
...@@ -27,16 +28,16 @@ import { API_ENDPOINT, API_ENDPOINT_PARAMS } from '../app.settings'; ...@@ -27,16 +28,16 @@ import { API_ENDPOINT, API_ENDPOINT_PARAMS } from '../app.settings';
<p> <p>
<strong>Ανακοίνωση:</strong> Παρακαλείσθε να μην καταχωρείτε δήλωση προτίμησης επιλέγοντας τα παρακάτω:</p> <strong>Ανακοίνωση:</strong> Παρακαλείσθε να μην καταχωρείτε δήλωση προτίμησης επιλέγοντας τα παρακάτω:</p>
<ul> <ul>
<li> 9ο ΕΠΑ.Λ. Πειραιά, Β τάξη, Τομέας Ναυτιλιακών Επαγγελμάτων, Γ τάξη-Ειδικότητες Πλοίαρχος Εμπορικού Ναυτικού, Μηχανικός Εμπορικού Ναυτικού <li> 9ο ΕΠΑ.Λ. Πειραιά, Β τάξη, Τομέας Ναυτιλιακών Επαγγελμάτων, Γ τάξη-Ειδικότητες Πλοίαρχος Εμπορικού Ναυτικού, Μηχανικός Εμπορικού Ναυτικού
</li> </li>
<li> 1ο ΕΠΑ.Λ. Δάφνης, Γ τάξη, Ειδικότητα Βοηθός Νοσηλευτή <li> 1ο ΕΠΑ.Λ. Δάφνης, Γ τάξη, Ειδικότητα Βοηθός Νοσηλευτή
</li> </li>
<li> 1ο Ημερήσιο ΕΠΑ.Λ. Σιβιτανιδείου, Γ τάξη, Ειδικότητα Βοηθός Νοσηλευτή <li> 1ο Ημερήσιο ΕΠΑ.Λ. Σιβιτανιδείου, Γ τάξη, Ειδικότητα Βοηθός Νοσηλευτή
</li> </li>
</ul> </ul>
<p>Τα τμήματα έχουν πληρότητα από την 1η περίοδο κατανομής. <p>Τα τμήματα έχουν πληρότητα από την 1η περίοδο κατανομής.
</p> </p>
</div> </div>
...@@ -56,15 +57,16 @@ import { API_ENDPOINT, API_ENDPOINT_PARAMS } from '../app.settings'; ...@@ -56,15 +57,16 @@ import { API_ENDPOINT, API_ENDPOINT_PARAMS } from '../app.settings';
` `
}) })
export default class Home implements OnInit { export default class Home implements OnInit, OnDestroy {
public formGroup: FormGroup; public formGroup: FormGroup;
private authToken: string; private authToken: string;
private authRole: string; private authRole: string;
private name: any; private name: any;
private xcsrftoken: any; private xcsrftoken: any;
private loginInfo$: Observable<ILoginInfo>; private loginInfo$: BehaviorSubject<ILoginInfo>;
private apiEndPoint = API_ENDPOINT; private apiEndPoint = API_ENDPOINT;
private apiEndPointParams = API_ENDPOINT_PARAMS; private apiEndPointParams = API_ENDPOINT_PARAMS;
private loginInfoSub: Subscription;
constructor(private fb: FormBuilder, constructor(private fb: FormBuilder,
private _ata: LoginInfoActions, private _ata: LoginInfoActions,
...@@ -79,13 +81,15 @@ export default class Home implements OnInit { ...@@ -79,13 +81,15 @@ export default class Home implements OnInit {
this.name = ''; this.name = '';
this.formGroup = this.fb.group({ this.formGroup = this.fb.group({
}); });
this.loginInfo$ = new BehaviorSubject(LOGININFO_INITIAL_STATE);
}; };
ngOnInit() { ngOnInit() {
this.loginInfo$ = this._ngRedux.select(state => { this.loginInfoSub = this._ngRedux.select('loginInfo').subscribe(loginInfo => {
if (state.loginInfo.size > 0) { let linfo=<ILoginInfo>loginInfo;
state.loginInfo.reduce(({}, loginInfoToken) => { if (linfo.size > 0) {
linfo.reduce(({}, loginInfoToken) => {
this.authToken = loginInfoToken.auth_token; this.authToken = loginInfoToken.auth_token;
this.authRole = loginInfoToken.auth_role; this.authRole = loginInfoToken.auth_role;
if (this.authToken && this.authToken.length > 0 && this.authRole && this.authRole === STUDENT_ROLE) { if (this.authToken && this.authToken.length > 0 && this.authRole && this.authRole === STUDENT_ROLE) {
...@@ -99,8 +103,8 @@ export default class Home implements OnInit { ...@@ -99,8 +103,8 @@ export default class Home implements OnInit {
}, {}); }, {});
} }
return state.loginInfo; this.loginInfo$.next(linfo);
}); }, error => {console.log("error selecting loginInfo");});
// subscribe to router event // subscribe to router event
this.activatedRoute.queryParams.subscribe((params: Params) => { this.activatedRoute.queryParams.subscribe((params: Params) => {
...@@ -115,6 +119,10 @@ export default class Home implements OnInit { ...@@ -115,6 +119,10 @@ export default class Home implements OnInit {
}); });
} }
ngOnDestroy () {
if (this.loginInfoSub) this.loginInfoSub.unsubscribe();
}
getCookie(key: string){ getCookie(key: string){
return this._cookieService.get(key); return this._cookieService.get(key);
} }
......
import { Router, Params} from '@angular/router'; import { Router, Params} from '@angular/router';
import { OnInit, Component} from '@angular/core'; import { OnInit, OnDestroy, Component} from '@angular/core';
import { LoginInfoActions } from '../actions/logininfo.actions'; import { LoginInfoActions } from '../actions/logininfo.actions';
import { ILoginInfo } from '../store/logininfo/logininfo.types'; import { ILoginInfo } from '../store/logininfo/logininfo.types';
import { NgRedux, select } from '@angular-redux/store'; import { NgRedux, select } from '@angular-redux/store';
import { Observable } from 'rxjs/Rx'; import { BehaviorSubject, Subscription } from 'rxjs/Rx';
import { IAppState } from '../store/store'; import { IAppState } from '../store/store';
import { HelperDataService } from '../services/helper-data-service'; import { HelperDataService } from '../services/helper-data-service';
import {Http, Response, RequestOptions} from '@angular/http'; import {Http, Response, RequestOptions} from '@angular/http';
import { LOGININFO_INITIAL_STATE } from "../store/logininfo/logininfo.initial-state";
import { import {
FormBuilder, FormBuilder,
FormGroup, FormGroup,
...@@ -57,14 +58,15 @@ import { API_ENDPOINT } from '../app.settings'; ...@@ -57,14 +58,15 @@ import { API_ENDPOINT } from '../app.settings';
` `
}) })
export default class MinistryHome implements OnInit { export default class MinistryHome implements OnInit, OnDestroy {
public userDataGroup: FormGroup; public userDataGroup: FormGroup;
private authRole: string; private authRole: string;
private mineduUsername: string; private mineduUsername: string;
//private mineduPassword: string; //private mineduPassword: string;
//private cuName: string; //private cuName: string;
private validLogin: number; private validLogin: number;
private loginInfo$: Observable<ILoginInfo>; private loginInfo$: BehaviorSubject<ILoginInfo>;
private loginInfoSub: Subscription;
private apiEndPoint = API_ENDPOINT; private apiEndPoint = API_ENDPOINT;
constructor(private fb: FormBuilder, constructor(private fb: FormBuilder,
...@@ -89,22 +91,29 @@ export default class MinistryHome implements OnInit { ...@@ -89,22 +91,29 @@ export default class MinistryHome implements OnInit {
cu_name: [''], cu_name: [''],
auth_role: [''], auth_role: [''],
}); });
this.loginInfo$ = new BehaviorSubject(LOGININFO_INITIAL_STATE);
}; };
ngOnInit() { ngOnInit() {
this.loginInfo$ = this._ngRedux.select(state => { this.loginInfoSub = this._ngRedux.select('loginInfo')
if (state.loginInfo.size > 0) { .subscribe(loginInfo => {
state.loginInfo.reduce(({}, loginInfoToken) => { let linfo = <ILoginInfo>loginInfo;
this.mineduUsername = loginInfoToken.minedu_username; if (linfo.size > 0) {
//this.mineduPassword = loginInfoToken.minedu_userpassword; linfo.reduce(({}, loginInfoToken) => {
if (this.mineduUsername && this.mineduUsername.length > 0) this.mineduUsername = loginInfoToken.minedu_username;
this.router.navigate(['/ministry/minister-settings']); //this.mineduPassword = loginInfoToken.minedu_userpassword;
return loginInfoToken; if (this.mineduUsername && this.mineduUsername.length > 0)
}, {}); this.router.navigate(['/ministry/minister-settings']);
} return loginInfoToken;
return state.loginInfo; }, {});
}); }
this.loginInfo$.next(linfo);
}, error => {console.log("error selecting loginInfo");});
}
ngOnDestroy() {
if (this.loginInfoSub) this.loginInfoSub.unsubscribe();
} }
submitCredentials() { submitCredentials() {
......
...@@ -87,26 +87,28 @@ export default class SchoolHome implements OnInit, OnDestroy { ...@@ -87,26 +87,28 @@ export default class SchoolHome implements OnInit, OnDestroy {
}; };
ngOnInit() { ngOnInit() {
this.loginInfoSub = this._ngRedux.select(state => { this.loginInfoSub = this._ngRedux.select('loginInfo')
if (state.loginInfo.size > 0) { .subscribe(loginInfo => {
state.loginInfo.reduce(({ }, loginInfoToken) => { let linfo=<ILoginInfo>loginInfo;
this.authToken = loginInfoToken.auth_token; if (linfo.size > 0) {
this.authRole = loginInfoToken.auth_role; linfo.reduce(({ }, loginInfoToken) => {
if (this.authToken && this.authToken.length > 0) { this.authToken = loginInfoToken.auth_token;
if (this.authRole === "director") { this.authRole = loginInfoToken.auth_role;
this.router.navigate(["/school/director-buttons"]); if (this.authToken && this.authToken.length > 0) {
if (this.authRole === "director") {
this.router.navigate(["/school/director-buttons"]);
}
else if (this.authRole === "pde")
this.router.navigate(["/school/perfecture-view"]);
else if (this.authRole === "dide")
this.router.navigate(["/school/eduadmin-view"]);
} }
else if (this.authRole === "pde") return loginInfoToken;
this.router.navigate(["/school/perfecture-view"]); }, {});
else if (this.authRole === "dide") }
this.router.navigate(["/school/eduadmin-view"]);
}
return loginInfoToken;
}, {});
}
return state.loginInfo; this.loginInfo$.next(linfo);
}).subscribe(this.loginInfo$); });
// subscribe to router event // subscribe to router event
this.activatedRoute.queryParams.subscribe((params: Params) => { this.activatedRoute.queryParams.subscribe((params: Params) => {
......
...@@ -38,7 +38,6 @@ import { StudentDataFieldsActions } from '../../actions/studentdatafields.action ...@@ -38,7 +38,6 @@ import { StudentDataFieldsActions } from '../../actions/studentdatafields.action
private authToken: string; private authToken: string;
private authRole: string; private authRole: string;
private cuName: string; private cuName: string;
private loginInfo$: BehaviorSubject<ILoginInfo>;
public cuser: any; public cuser: any;
private showLoader$: BehaviorSubject<boolean>; private showLoader$: BehaviorSubject<boolean>;
private loginInfoSub: Subscription; private loginInfoSub: Subscription;
...@@ -59,25 +58,24 @@ import { StudentDataFieldsActions } from '../../actions/studentdatafields.action ...@@ -59,25 +58,24 @@ import { StudentDataFieldsActions } from '../../actions/studentdatafields.action
}; };
ngOnInit() { ngOnInit() {
this.loginInfoSub = this._ngRedux.select(state => { this.loginInfoSub = this._ngRedux.select('loginInfo')
if (state.loginInfo.size > 0) { .subscribe(loginInfo => {
state.loginInfo.reduce(({}, loginInfoToken) => { let linfo = <ILoginInfo>loginInfo;
this.authToken = loginInfoToken.auth_token; if (linfo.size > 0) {
this.authRole = loginInfoToken.auth_role; linfo.reduce(({}, loginInfoToken) => {
this.cuName = loginInfoToken.cu_name; this.authToken = loginInfoToken.auth_token;
return loginInfoToken; this.authRole = loginInfoToken.auth_role;
}, {}) this.cuName = loginInfoToken.cu_name;
} return loginInfoToken;
}, {});
return state.loginInfo; }
}).subscribe(this.loginInfo$); }, error => {console.log("error selecting epalclasses")});
} };
ngOnDestroy() { ngOnDestroy() {
if (this.loginInfoSub) if (this.loginInfoSub)
this.loginInfoSub.unsubscribe(); this.loginInfoSub.unsubscribe();
};
}
signOut() { signOut() {
this.showLoader$.next(true); this.showLoader$.next(true);
......
...@@ -32,17 +32,17 @@ import { ...@@ -32,17 +32,17 @@ import {
@Injectable() export default class StudentApplicationMain implements OnInit { @Injectable() export default class StudentApplicationMain implements OnInit {
private loginInfo$: BehaviorSubject<ILoginInfo>;
private studentDataFields$: BehaviorSubject<IStudentDataFields>; private studentDataFields$: BehaviorSubject<IStudentDataFields>;
private criteria$: BehaviorSubject<ICriter>; private criteria$: BehaviorSubject<ICriter>;
private studentDataFieldsSub: Subscription; private studentDataFieldsSub: Subscription;
private loginInfoSub: Subscription;
private criteriaSub: Subscription; private criteriaSub: Subscription;
public studentDataGroup: FormGroup; public studentDataGroup: FormGroup;
public studentCriteriaGroup: FormGroup; public studentCriteriaGroup: FormGroup;
private loginInfo$: BehaviorSubject<ILoginInfo>;
private modalTitle: BehaviorSubject<string>; private modalTitle: BehaviorSubject<string>;
private modalText: BehaviorSubject<string>; private modalText: BehaviorSubject<string>;
private modalHeader: BehaviorSubject<string>; private modalHeader: BehaviorSubject<string>;
...@@ -84,11 +84,11 @@ import { ...@@ -84,11 +84,11 @@ import {
private router: Router, private router: Router,
private http: Http) { private http: Http) {
this.populateSchoolyears(); this.populateSchoolyears();
this.loginInfo$ = new BehaviorSubject(LOGININFO_INITIAL_STATE);
this.modalTitle = new BehaviorSubject(""); this.modalTitle = new BehaviorSubject("");
this.modalText = new BehaviorSubject(""); this.modalText = new BehaviorSubject("");
this.modalHeader = new BehaviorSubject(""); this.modalHeader = new BehaviorSubject("");
this.loginInfo$ = new BehaviorSubject(LOGININFO_INITIAL_STATE);
this.studentDataFields$ = new BehaviorSubject(STUDENT_DATA_FIELDS_INITIAL_STATE); this.studentDataFields$ = new BehaviorSubject(STUDENT_DATA_FIELDS_INITIAL_STATE);
this.criteria$ = new BehaviorSubject(CRITERIA_INITIAL_STATE); this.criteria$ = new BehaviorSubject(CRITERIA_INITIAL_STATE);
this.studentDataGroup = this.fb.group({ this.studentDataGroup = this.fb.group({
...@@ -111,45 +111,41 @@ import { ...@@ -111,45 +111,41 @@ import {
ngOnInit() { ngOnInit() {
(<any>$("#applicationFormNotice")).appendTo("body"); (<any>$("#applicationFormNotice")).appendTo("body");
this._ngRedux.select(state => { this.loginInfoSub = this._ngRedux.select('loginInfo')
if (state.loginInfo.size > 0) { .subscribe(loginInfo => {
state.loginInfo.reduce(({}, loginInfoToken) => { this.loginInfo$.next(<ILoginInfo>loginInfo);
return loginInfoToken; }, error => {console.log("error selecting loginInfo");});
}, {});
} this.studentDataFieldsSub = this._ngRedux.select('studentDataFields')
return state.loginInfo; .subscribe(studentDataFields => {
}).subscribe(this.loginInfo$); let sdfds = <IStudentDataFields>studentDataFields;
if (sdfds.size > 0) {
this.studentDataFieldsSub = this._ngRedux.select(state => { sdfds.reduce(({}, studentDataField) => {
if (state.studentDataFields.size > 0) {
state.studentDataFields.reduce(({}, studentDataField) => { this.studentDataGroup.controls["name"].setValue(studentDataField.name);
this.studentDataGroup.controls["studentsurname"].setValue(studentDataField.studentsurname);
this.studentDataGroup.controls["name"].setValue(studentDataField.name); this.studentDataGroup.controls["fatherfirstname"].setValue(studentDataField.fatherfirstname);
this.studentDataGroup.controls["studentsurname"].setValue(studentDataField.studentsurname); this.studentDataGroup.controls["motherfirstname"].setValue(studentDataField.motherfirstname);
this.studentDataGroup.controls["fatherfirstname"].setValue(studentDataField.fatherfirstname); this.studentDataGroup.controls["regionaddress"].setValue(studentDataField.regionaddress);
this.studentDataGroup.controls["motherfirstname"].setValue(studentDataField.motherfirstname); this.studentDataGroup.controls["regiontk"].setValue(studentDataField.regiontk);
this.studentDataGroup.controls["regionaddress"].setValue(studentDataField.regionaddress); this.studentDataGroup.controls["regionarea"].setValue(studentDataField.regionarea);
this.studentDataGroup.controls["regiontk"].setValue(studentDataField.regiontk); this.studentDataGroup.controls["lastschool_schoolname"].setValue(studentDataField.lastschool_schoolname);
this.studentDataGroup.controls["regionarea"].setValue(studentDataField.regionarea); this.studentDataGroup.controls["lastschool_schoolyear"].setValue(studentDataField.lastschool_schoolyear);
this.studentDataGroup.controls["lastschool_schoolname"].setValue(studentDataField.lastschool_schoolname); this.studentDataGroup.controls["lastschool_class"].setValue(studentDataField.lastschool_class);
this.studentDataGroup.controls["lastschool_schoolyear"].setValue(studentDataField.lastschool_schoolyear); this.studentDataGroup.controls["relationtostudent"].setValue(studentDataField.relationtostudent);
this.studentDataGroup.controls["lastschool_class"].setValue(studentDataField.lastschool_class); this.studentDataGroup.controls["telnum"].setValue(studentDataField.telnum);
this.studentDataGroup.controls["relationtostudent"].setValue(studentDataField.relationtostudent); this.studentDataGroup.controls["studentbirthdate"].setValue(this.populateDate(studentDataField.studentbirthdate));
this.studentDataGroup.controls["telnum"].setValue(studentDataField.telnum); return studentDataField;
this.studentDataGroup.controls["studentbirthdate"].setValue(this.populateDate(studentDataField.studentbirthdate)); }, {});
return studentDataField; }
}, {}); this.studentDataFields$.next(sdfds);
} }, error => {console.log("error selecting studentDataFields");});
return state.studentDataFields;
}).subscribe(this.studentDataFields$);
}; };
ngOnDestroy() { ngOnDestroy() {
(<any>$("#applicationFormNotice")).remove(); (<any>$("#applicationFormNotice")).remove();
if (this.studentDataFieldsSub) this.studentDataFieldsSub.unsubscribe(); if (this.studentDataFieldsSub) this.studentDataFieldsSub.unsubscribe();
if (this.studentDataFields$) this.studentDataFields$.unsubscribe();
if (this.loginInfo$) this.loginInfo$.unsubscribe();
} }
navigateBack() { navigateBack() {
......
...@@ -66,7 +66,7 @@ import { SECTOR_FIELDS_INITIAL_STATE } from '../../store/sectorfields/sectorfiel ...@@ -66,7 +66,7 @@ import { SECTOR_FIELDS_INITIAL_STATE } from '../../store/sectorfields/sectorfiel
</ul> </ul>
</div> </div>
<ul *ngIf="(regions$ | async)" class="list-group left-side-view" style="margin-bottom: 20px;"> <ul *ngIf="(selectedSchools$ | 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" >
...@@ -107,67 +107,68 @@ import { SECTOR_FIELDS_INITIAL_STATE } from '../../store/sectorfields/sectorfiel ...@@ -107,67 +107,68 @@ import { SECTOR_FIELDS_INITIAL_STATE } from '../../store/sectorfields/sectorfiel
ngOnInit() { ngOnInit() {
this.currentUrl = this.router.url; this.currentUrl = this.router.url;
this.sectorsSub = this._ngRedux.select(state => { this.sectorsSub = this._ngRedux.select('sectors')
state.sectors.reduce((prevSector, sector) => { .subscribe(sectors => {
sector.courses.reduce((prevCourse, course) => { let scs = <ISectors>sectors;
if (course.selected === true) { scs.reduce((prevSector, sector) => {
this.courseActive = course.course_id; sector.courses.reduce((prevCourse, course) => {
} if (course.selected === true) {
this.courseActive = course.course_id;
return course; }
return course;
}, {});
return sector;
}, {}); }, {});
return sector; this.sectors$.next(scs);
}, {}); });
//this.numSelectedCourses = numsel;
return state.sectors; this.regionsSub = this._ngRedux.select('regions')
}).subscribe(this.sectors$); .subscribe(regions => {
let rgns = <IRegionRecords>regions;
this.regionsSub = this._ngRedux.select(state => { let numsel = 0, numsel2 = 0;
let numsel = 0, numsel2 = 0; let selectedSchools = Array<IRegionSchoolRecord>();
let selectedSchools = Array<IRegionSchoolRecord>(); if (rgns.size === 0)
if (state.regions.size === 0) return;
return; rgns.reduce((prevRegion, region) => {
state.regions.reduce((prevRegion, region) => { region.get("epals").reduce((prevEpal, epal) => {
region.get("epals").reduce((prevEpal, epal) => { if (epal.get("selected") === true) {
if (epal.get("selected") === true) { numsel++;
numsel++; selectedSchools.push(epal);
selectedSchools.push(epal); }
} if (epal.get("order_id") !== 0) {
if (epal.get("order_id") !== 0) { numsel2++;
numsel2++; }
} return epal;
return epal; }, {});
return region;
}, {}); }, {});
return region; this.numSelectedSchools = numsel;
}, {}); this.numSelectedOrder = numsel2;
this.numSelectedSchools = numsel; this.selectedSchools$.next(selectedSchools.sort(this.compareSchools));
this.numSelectedOrder = numsel2; });
this.selectedSchools$.next(selectedSchools.sort(this.compareSchools));
// this.selectedSchools$.next(selectedSchools); this.sectorFieldsSub = this._ngRedux.select('sectorFields')
return state.regions; .subscribe(sectorFields => {
}).subscribe(this.regions$); this.sectorFields$.next(<ISectorFields>sectorFields);
}, error => {console.log("error selecting sectorFields");});
this.sectorFieldsSub = this._ngRedux.select(state => {
state.sectorFields.reduce(({}, sectorField) => { this.epalclassesSub = this._ngRedux.select('epalclasses')
return sectorField; .subscribe(epalclasses => {
}, {}); let ecs = <IEpalClasses>epalclasses;
return state.sectorFields; ecs.reduce(({}, epalclass) => {
}).subscribe(this.sectorFields$); if (epalclass.name === "Α' Λυκείου")
this.classSelected = 1;
this.epalclassesSub = this._ngRedux.select(state => { else if (epalclass.name === "Β' Λυκείου")
state.epalclasses.reduce(({}, epalclass) => { this.classSelected = 2;
if (epalclass.name === "Α' Λυκείου") else if (epalclass.name === "Γ' Λυκείου")
this.classSelected = 1; this.classSelected = 3;
else if (epalclass.name === "Β' Λυκείου") else if (epalclass.name === "Δ' Λυκείου")
this.classSelected = 2; this.classSelected = 4;
else if (epalclass.name === "Γ' Λυκείου") return epalclass;
this.classSelected = 3; }, {});
else if (epalclass.name === "Δ' Λυκείου") this.epalclasses$.next(ecs);
this.classSelected = 4; }, error => {console.log("error selecting epalclasses");});
return epalclass;
}, {});