Merge branch 'student_form' into 'develop'

Student form

See merge request !13
parents aca496db cede9d6c
......@@ -26,7 +26,7 @@
"tslint": "^3.15.1",
"tslint-loader": "^2.1.5",
"typescript": "^2.0.10",
"redux-logger" : "^2.7.4",
"redux-logger": "^2.7.4",
"webpack": "^1.14.0",
"webpack-dashboard": "^0.2.0",
"webpack-dev-server": "^1.16.2"
......@@ -41,7 +41,8 @@
"@angular/platform-browser-dynamic": "^2.0.0",
"@angular/router": "^3.2.0",
"@types/node": "^6.0.60",
"babel-polyfill" : "^6.20.0",
"babel-polyfill": "^6.20.0",
"bootstrap": "^4.0.0-alpha.6",
"core-js": "^2.4.1",
"css-loader": "^0.25.0",
"d3": "^3.5.16",
......
......@@ -10,10 +10,10 @@ export class RegionSchoolsActions {
private _ngRedux: NgRedux<IAppState>,
private _hds: HelperDataService) {}
getRegionSchools = () => {
getRegionSchools = (courseActive, reload) => {
const { regions } = this._ngRedux.getState();
if (regions.size === 0) {
return this._hds.getRegionsWithSchools().then(regions => {
if (reload === true || (reload === false && regions.size === 0)) {
return this._hds.getRegionsWithSchools(courseActive).then(regions => {
return this._ngRedux.dispatch({
type: REGIONSCHOOLS_RECEIVED,
payload: {
......@@ -24,6 +24,22 @@ export class RegionSchoolsActions {
}
};
/*
getRegionSchools_Reload = (courseActive) => {
const { regions } = this._ngRedux.getState();
//if (regions.size === 0) {
return this._hds.getRegionsWithSchools(courseActive).then(regions => {
return this._ngRedux.dispatch({
type: REGIONSCHOOLS_RECEIVED,
payload: {
regions
}
});
});
//}
};
*/
saveRegionSchoolsSelected = (regionSchoolsSelected) => {
return this._ngRedux.dispatch({
type: REGIONSCHOOLS_SELECTED_SAVE,
......
......@@ -10,9 +10,10 @@ export class SectorCoursesActions {
private _ngRedux: NgRedux<IAppState>,
private _hds: HelperDataService) {}
getSectorCourses = () => {
getSectorCourses = (reload) => {
const { sectors } = this._ngRedux.getState();
if (sectors.size === 0) {
//if (sectors.size === 0) {
if (reload === true || (reload === false && sectors.size === 0)) {
return this._hds.getSectorsWithCourses().then(sectors => {
return this._ngRedux.dispatch({
type: SECTORCOURSES_RECEIVED,
......@@ -24,11 +25,28 @@ export class SectorCoursesActions {
}
};
saveSectorCoursesSelected = (sectorCoursesSelected) => {
/*
getSectorCourses_Reload = () => {
const { sectors } = this._ngRedux.getState();
//if (sectors.size === 0) {
return this._hds.getSectorsWithCourses().then(sectors => {
return this._ngRedux.dispatch({
type: SECTORCOURSES_RECEIVED,
payload: {
sectors
}
});
});
//}
};
*/
saveSectorCoursesSelected = (sectorCoursesSelected,sectorSelected) => {
return this._ngRedux.dispatch({
type: SECTORCOURSES_SELECTED_SAVE,
payload: {
sectorCoursesSelected
sectorCoursesSelected,
sectorSelected
}
});
};
......
......@@ -2,8 +2,7 @@ import { STUDENTDATAFIELDS_SAVE, STUDENTDATAFIELDS_RECEIVED } from '../constants
import { Injectable } from '@angular/core';
import { NgRedux } from 'ng2-redux';
import { IAppState } from '../store';
//import { HelperDataService } from '../services/helper-data-service';
import { UserDataService } from '../services/user-data-service';
//import { UserDataService } from '../services/user-data-service';
@Injectable()
......
export class AppSettings {
public static get API_ENDPOINT(): string {
return 'http://localhost/angproject/eepal-front/drupal';
// return 'http://localhost/drupal-8.2.5';
// return 'http://eepal.dev/drupal';
// return 'http://eduslim2.minedu.gov.gr/drupal';
return 'http://localhost/dist';
// return 'http://localhost/drupal-8.2.5';
// return 'http://eepal.dev/drupal';
// return 'http://eduslim2.minedu.gov.gr/drupal';
}
}
......@@ -27,7 +27,7 @@ import { APP_ROUTER_PROVIDERS, APP_DECLARATIONS } from './app.routes';
/* Here we import services */
import {HelperDataService} from './services/helper-data-service';
import {UserDataService} from './services/user-data-service';
//import {UserDataService} from './services/user-data-service';
import { ACTION_PROVIDERS } from './actions';
import Home from './components/home';
......@@ -69,9 +69,9 @@ class MyLocalization extends NgLocalization {
{ provide: NgLocalization, useClass: MyLocalization },
DevToolsExtension,
ACTION_PROVIDERS,
// Service1, again services here
//Service1, again services here
HelperDataService,
UserDataService,
//UserDataService,
]
})
class AppModule {}
......
<div class="row equal">
<div class="col-md-8">
<form novalidate [formGroup]="studentDataGroup">
<form novalidate (ngSubmit)="onSubmit(studentDataGroup)" [formGroup]="studentDataGroup">
<div *ngFor="let studentDataField$ of studentDataFields$ | async; "> </div>
<div class="form-group">
<label for="studentAmka">ΑΜΚΑ μαθητή</label><input class="form-control" type="text" formControlName="studentAmka">
</div>
<div class="alert alert-danger" *ngIf="studentDataGroup.get('studentAmka').touched && studentDataGroup.get('studentAmka').hasError('required')">
Το πεδίο δεν μπορεί να αφεθεί κενό!
</div>
<div class="alert alert-danger" *ngIf="studentDataGroup.get('studentAmka').dirty && studentDataGroup.get('studentAmka').hasError('pattern')">
Επιτρέπονται μόνο ψηφία σε αυτό το πεδίο!
</div>
<div class="form-group">
<label for="studentFirstname">Όνομα μαθητή</label><input class="form-control" type="text" formControlName="studentFirstname">
......@@ -13,7 +19,7 @@
<div class="alert alert-danger" *ngIf="studentDataGroup.get('studentFirstname').touched && studentDataGroup.get('studentFirstname').hasError('required')">
Το πεδίο δεν μπορεί να αφεθεί κενό!
</div>
<div class="alert alert-danger" *ngIf="studentDataGroup.get('studentFirstname').touched && studentDataGroup.get('studentFirstname').hasError('pattern')">
<div class="alert alert-danger" *ngIf="studentDataGroup.get('studentFirstname').dirty && studentDataGroup.get('studentFirstname').hasError('pattern')">
Δεν επιτρέπονται ψηφία ή άλλοι μη έγκυροι χαρακτήρες σε αυτό το πεδίο!
</div>
......@@ -23,7 +29,7 @@
<div class="alert alert-danger" *ngIf="studentDataGroup.get('studentSurname').touched && studentDataGroup.get('studentSurname').hasError('required')">
Το πεδίο δεν μπορεί να αφεθεί κενό!
</div>
<div class="alert alert-danger" *ngIf="studentDataGroup.get('studentSurname').touched && studentDataGroup.get('studentSurname').hasError('pattern')">
<div class="alert alert-danger" *ngIf="studentDataGroup.get('studentSurname').dirty && studentDataGroup.get('studentSurname').hasError('pattern')">
Δεν επιτρέπονται ψηφία ή άλλοι μη έγκυροι χαρακτήρες σε αυτό το πεδίο!
</div>
......@@ -33,7 +39,7 @@
<div class="alert alert-danger" *ngIf="studentDataGroup.get('guardianFirstname').touched && studentDataGroup.get('guardianFirstname').hasError('required')">
Το πεδίο δεν μπορεί να αφεθεί κενό!
</div>
<div class="alert alert-danger" *ngIf="studentDataGroup.get('guardianFirstname').touched && studentDataGroup.get('guardianFirstname').hasError('pattern')">
<div class="alert alert-danger" *ngIf="studentDataGroup.get('guardianFirstname').dirty && studentDataGroup.get('guardianFirstname').hasError('pattern')">
Δεν επιτρέπονται ψηφία ή άλλοι μη έγκυροι χαρακτήρες σε αυτό το πεδίο!
</div>
......@@ -44,7 +50,7 @@
<div class="alert alert-danger" *ngIf="studentDataGroup.get('guardianSurname').touched && studentDataGroup.get('guardianSurname').hasError('required')">
Το πεδίο δεν μπορεί να αφεθεί κενό!
</div>
<div class="alert alert-danger" *ngIf="studentDataGroup.get('guardianSurname').touched && studentDataGroup.get('guardianSurname').hasError('pattern')">
<div class="alert alert-danger" *ngIf="studentDataGroup.get('guardianSurname').dirty && studentDataGroup.get('guardianSurname').hasError('pattern')">
Δεν επιτρέπονται ψηφία ή άλλοι μη έγκυροι χαρακτήρες σε αυτό το πεδίο!
</div>
......@@ -54,16 +60,34 @@
<div class="form-group">
<label for="regionAddress">Διεύθυνση κατοικίας</label><input class="form-control" type="text" formControlName="regionAddress">
</div>
<div class="alert alert-danger" *ngIf="studentDataGroup.get('regionAddress').touched && studentDataGroup.get('regionAddress').hasError('required')">
Το πεδίο δεν μπορεί να αφεθεί κενό!
</div>
<div class="alert alert-danger" *ngIf="studentDataGroup.get('regionAddress').dirty && studentDataGroup.get('regionAddress').hasError('pattern')">
Δεν επιτρέπονται μη έγκυροι χαρακτήρες σε αυτό το πεδίο!
</div>
</td>
<td>
<div class="form-group">
<label for="regionTK">TK </label><input class="form-control" type="text" formControlName="regionTK">
</div>
<div class="alert alert-danger" *ngIf="studentDataGroup.get('regionTK').touched && studentDataGroup.get('regionTK').hasError('required')">
Το πεδίο δεν μπορεί να αφεθεί κενό!
</div>
<div class="alert alert-danger" *ngIf="studentDataGroup.get('regionTK').dirty && studentDataGroup.get('regionTK').hasError('pattern')">
Δεν επιτρέπονται γράμματα αλφαβήτου ή μη έγκυροι χαρακτήρες σε αυτό το πεδίο!
</div>
</td>
<td>
<div class="form-group">
<label for="regionArea">Πόλη/Περιοχή</label><input class="form-control" type="text" formControlName="regionArea">
</div>
<div class="alert alert-danger" *ngIf="studentDataGroup.get('regionArea').touched && studentDataGroup.get('regionArea').hasError('required')">
Το πεδίο δεν μπορεί να αφεθεί κενό!
</div>
<div class="alert alert-danger" *ngIf="studentDataGroup.get('regionArea').dirty && studentDataGroup.get('regionArea').hasError('pattern')">
Δεν επιτρέπονται μη έγκυροι χαρακτήρες σε αυτό το πεδίο!
</div>
</td>
</tr>
</table>
......@@ -76,7 +100,7 @@
<option value="Απολυτήριο Λυκείου">Απολυτήριο Λυκείου</option>
</select>
</div>
<div class="alert alert-danger" *ngIf="studentDataGroup.get('certificateType').touched && studentDataGroup.get('certificateType').hasError('required')">
<div class="alert alert-danger" *ngIf="studentDataGroup.get('certificateType').dirty && studentDataGroup.get('certificateType').hasError('required')">
Η επιλογή από αυτή τη λίστα είναι απαραίτητη!
</div>
......@@ -87,7 +111,7 @@
<option value="Γονέας/Κηδεμόνας">Γονέας/Κηδεμόνας</option>
<option value="Μαθητής">Μαθητής</option>
</select>
<div class="alert alert-danger" *ngIf="studentDataGroup.get('relationToStudent').touched && studentDataGroup.get('relationToStudent').hasError('required')">
<div class="alert alert-danger" *ngIf="studentDataGroup.get('relationToStudent').dirty && studentDataGroup.get('relationToStudent').hasError('required')">
Η επιλογή από αυτή τη λίστα είναι απαραίτητη!
</div>
</div>
......@@ -99,7 +123,7 @@
</button>
</div>
<div class="col-md-2">
<button type="button" class="btn-primary btn-lg pull-center" (click)="submitSelected()">
<button type="button" class="btn-primary btn-lg pull-center" (click)="submitSelected()" [disabled]="studentDataGroup.invalid">
Αποστολή<span class="glyphicon glyphicon-menu-right"></span>
</button>
</div>
......
......@@ -8,7 +8,7 @@ import { NgRedux, select } from 'ng2-redux';
import { IStudentDataFields } from '../../store/studentdatafields/studentdatafields.types';
import { ICourseFields } from '../../store/coursefields/coursefields.types';
import { IAppState } from '../../store/store';
import { VALID_NAMES_PATTERN } from '../../constants';
import { VALID_NAMES_PATTERN, VALID_ADDRESS_PATTERN, VALID_ADDRESSTK_PATTERN, VALID_AMKA_PATTERN } from '../../constants';
import {
FormBuilder,
......@@ -34,6 +34,7 @@ import {
private _ngRedux: NgRedux<IAppState>,
private router: Router) {
this.studentDataGroup = this.fb.group({
/*
studentAmka: ['12346', Validators.required],
studentFirstname: ['ΝΙΚΟΣ', [Validators.pattern(VALID_NAMES_PATTERN),Validators.required]],
studentSurname: ['ΚΑΤΣΑΟΥΝΟΣ', [Validators.pattern(VALID_NAMES_PATTERN),Validators.required]],
......@@ -44,6 +45,17 @@ import {
regionArea: ['ΠΑΤΡΑ', [Validators.pattern(VALID_NAMES_PATTERN),Validators.required]],
certificateType: ['Απολυτήριο Λυκείου', Validators.required],
relationToStudent: ['Μαθητής', Validators.required],
*/
studentAmka: ['12346', [Validators.pattern(VALID_AMKA_PATTERN),Validators.required]],
studentFirstname: ['ΝΙΚΟΣ', [Validators.pattern(VALID_NAMES_PATTERN),Validators.required]],
studentSurname: ['ΚΑΤΣΑΟΥΝΟΣ', [Validators.pattern(VALID_NAMES_PATTERN),Validators.required]],
guardianFirstname: ['ΑΝΑΣΤΑΣΙΟΣ', [Validators.pattern(VALID_NAMES_PATTERN),Validators.required]],
guardianSurname: ['ΚΑΤΣΑΟΥΝΟΣ', [Validators.pattern(VALID_NAMES_PATTERN),Validators.required]],
regionAddress: ['ΓΙΑΝΝΙΤΣΩΝ 5', [Validators.pattern(VALID_ADDRESS_PATTERN),Validators.required]],
regionTK: ['26334', [Validators.pattern(VALID_ADDRESSTK_PATTERN),Validators.required]],
regionArea: ['ΠΑΤΡΑ', [Validators.pattern(VALID_NAMES_PATTERN),Validators.required]],
certificateType: ['Απολυτήριο Λυκείου', Validators.required],
relationToStudent: ['Μαθητής', Validators.required],
});
};
......@@ -57,13 +69,6 @@ import {
}
return state.studentDataFields;
});
this.courseFields$ = this._ngRedux.select(state => {
state.courseFields.reduce(({}, courseField) =>{
return courseField;
}, {});
return state.courseFields;
});
}
saveSelected() {
......
......@@ -36,11 +36,22 @@ import {AppSettings} from '../../app.settings';
<div class="row">
<div class="btn-group inline pull-center">
<button type="button" class="btn-primary btn-md pull-center" (click)="defineCourse()">
<button type="button" class="btn-primary btn-md pull-center" (click)="defineCourse()" >
Η ειδικότητά μου<span class="glyphicon glyphicon-menu-right"></span>
</button>
</div>
</div>
<!--
<div class="row">
<div class="btn-group inline pull-right">
<button class="btn-primary btn-md pull-right my-btn" type="button" (click)="defineCourse()" [hidden] = "numSelectedCourses === 0" >
Επαναφορά<span class="glyphicon glyphicon-menu-right"></span>
</button>
</div>
</div>
-->
<ul class="list-group" style="margin-bottom: 20px;">
<div *ngFor="let sector$ of sectors$ | async;">
<div *ngFor="let course$ of sector$.courses;" >
......@@ -53,7 +64,7 @@ import {AppSettings} from '../../app.settings';
<div class="row">
<div class="btn-group inline pull-center">
<button type="button" class="btn-primary btn-md pull-center" (click)="defineSchools()">
<button type="button" id = "butsch" class="btn-primary btn-md pull-center" (click)="defineSchools()" [disabled] = "numSelectedSchools === 0 ">
Τα σχολεία μου<span class="glyphicon glyphicon-menu-right"></span>
</button>
</div>
......@@ -96,6 +107,9 @@ import {AppSettings} from '../../app.settings';
private regions$: Observable<IRegions>;
private sectorFields$: Observable<ISectorFields>;
private studentDataFields$: Observable<IStudentDataFields>;
private courseActive = "-1";
private numSelectedSchools = <number>0;
//private numSelectedCourses = <number>0;
constructor(private _rsa: SectorCoursesActions,
private _rsb: RegionSchoolsActions,
......@@ -107,29 +121,36 @@ import {AppSettings} from '../../app.settings';
};
ngOnInit() {
this._rsa.getSectorCourses();
this.courseActive = this.getCourseActive();
this.sectors$ = this._ngRedux.select(state => {
//let numsel = 0;
state.sectors.reduce((prevSector, sector) =>{
sector.courses.reduce((prevCourse, course) =>{
//if (course.selected === true) {
// numsel++;
//}
return course;
}, {});
return sector;
}, {});
//this.numSelectedCourses = numsel;
return state.sectors;
});
this._rsb.getRegionSchools();
this.regions$ = this._ngRedux.select(state => {
state.regions.reduce((prevRegion, region) =>{
region.epals.reduce((prevSchool, school) =>{
return school;
}, {});
return region;
}, {});
return state.regions;
});
let numsel = 0;
state.regions.reduce((prevRegion, region) =>{
region.epals.reduce((prevEpal, epal) =>{
if (epal.selected === true)
numsel++;
return epal;
}, {});
return region;
}, {});
this.numSelectedSchools = numsel;
return state.regions;
});
this._rsc.getSectorFields();
this.sectorFields$ = this._ngRedux.select(state => {
state.sectorFields.reduce(({}, sectorField) =>{
return sectorField;
......@@ -149,9 +170,7 @@ import {AppSettings} from '../../app.settings';
defineSector() {
this.router.navigate(['/sector-fields-select']);
}
defineCourse() {
this.router.navigate(['/sectorcourses-fields-select']);
}
defineSchools() {
this.router.navigate(['/region-schools-select']);
}
......@@ -159,4 +178,51 @@ import {AppSettings} from '../../app.settings';
this.router.navigate(['/student-application-form-main']);
}
getCourseActive() {
const { sectors } = this._ngRedux.getState();
let l,m;
for ( l=0; l<sectors.size; l++)
if (sectors["_tail"]["array"][l]["sector_selected"] === true)
for ( m=0; m < sectors["_tail"]["array"][l]["courses"].length; m++)
if (sectors["_tail"]["array"][l]["courses"][m]["selected"] === true)
return sectors["_tail"]["array"][l]["courses"][m]["course_id"];
}
/*
defineCourse() {
this._rsb.getRegionSchools("-1", true);
this.regions$ = this._ngRedux.select(state => {
let numsel = 0;
state.regions.reduce((prevRegion, region) =>{
region.epals.reduce((prevSchool, school) =>{
if (school.selected === true)
numsel++;
return school;
}, {});
return region;
}, {});
this.numSelectedSchools = numsel;
return state.regions;
});
this._rsa.getSectorCourses(true);
this.sectors$ = this._ngRedux.select(state => {
state.sectors.reduce((prevSector, sector) =>{
sector.courses.reduce((prevCourse, course) =>{
return course;
}, {});
return sector;
}, {});
return state.sectors;
});
this.router.navigate(['/sectorcourses-fields-select']);
}
*/
defineCourse() {
this.router.navigate(['/sectorcourses-fields-select']);
}
}
......@@ -5,8 +5,13 @@ import { Injectable } from "@angular/core";
import { RegionSchoolsActions } from '../../actions/regionschools.actions';
import { NgRedux, select } from 'ng2-redux';
import { IRegions } from '../../store/regionschools/regionschools.types';
import { SectorCoursesActions } from '../../actions/sectorcourses.actions';
import { ISectors } from '../../store/sectorcourses/sectorcourses.types';
import { IAppState } from '../../store/store';
import {
FormBuilder,
FormGroup,
......@@ -32,7 +37,10 @@ import {AppSettings} from '../../app.settings';
<li class="list-group-item" >
<div class="row">
<div class="col-md-2">
<input type="checkbox" formControlName="{{ epal$.globalIndex }}">
<input #cb type="checkbox" formControlName="{{ epal$.globalIndex }}"
(change)="saveSelected()"
[hidden] = "numSelected === 3 && cb.checked === false"
>
</div>
<div class="col-md-10">
{{epal$.epal_name}}
......@@ -45,7 +53,7 @@ import {AppSettings} from '../../app.settings';
</div>
<div class="row">
<div class="col-md-2 col-md-offset-5">
<button type="button" class="btn-primary btn-lg pull-center" (click)="saveSelected()">
<button type="button" class="btn-primary btn-lg pull-center" (click)="navigateToApplication()" [disabled] = "numSelected === 0" >
Συνέχεια<span class="glyphicon glyphicon-menu-right"></span>
</button>
</div>
......@@ -53,20 +61,26 @@ import {AppSettings} from '../../app.settings';
</form>
</div>
<div class="col-md-4">
<application-preview-select></application-preview-select>
</div>
</div>
`
})
@Injectable() export default class RegionSchoolsSelect implements OnInit {
private regions$: Observable<IRegions>;
private sectors$: Observable<ISectors>;
private formGroup: FormGroup;
private rss = new FormArray([]);
private regionActive = <number>-1;
private numSelected = <number>0;
private courseActive = "-1";
constructor(private fb: FormBuilder,
private _rsa: RegionSchoolsActions,
private _rsb: SectorCoursesActions,
private _ngRedux: NgRedux<IAppState>,
private router: Router
) {
......@@ -77,23 +91,32 @@ import {AppSettings} from '../../app.settings';
ngOnInit() {
this._rsa.getRegionSchools();
this.courseActive = this.getCourseActive();
this._rsa.getRegionSchools(this.courseActive, false);
this.regions$ = this._ngRedux.select(state => {
let numsel = 0;
state.regions.reduce((prevRegion, region) =>{
region.epals.reduce((prevEpal, epal) =>{
this.rss.push( new FormControl(epal.selected, []));
if (epal.selected === true) {
numsel++;
console.log(epal.epal_name);
}
return epal;
}, {});
return region;
}, {});
this.numSelected = numsel;
return state.regions;
});
}
setActiveRegion(ind) {
this.regionActive = ind;
if (ind === this.regionActive)
ind = -1;
this.regionActive = ind;
}
toggleBackgroundColor(ind) {
......@@ -102,6 +125,32 @@ import {AppSettings} from '../../app.settings';
saveSelected() {
this._rsa.saveRegionSchoolsSelected(this.formGroup.value.formArray);
this.router.navigate(['/student-application-form-main']);
//this.router.navigate(['/student-application-form-main']);
}
navigateToApplication() {
this.router.navigate(['/student-application-form-main']);
}
//not used
updateCheckedOptions(globalIndex, cb){
/*
if (cb.checked)
this.numselected--;
else
this.numselected++;
*/
this.saveSelected();
}
getCourseActive() {
const { sectors } = this._ngRedux.getState();
let l,m;
for ( l=0; l<sectors.size; l++)
if (sectors["_tail"]["array"][l]["sector_selected"] === true)
for ( m=0; m < sectors["_tail"]["array"][l]["courses"].length; m++)
if (sectors["_tail"]["array"][l]["courses"][m]["selected"] === true)
return sectors["_tail"]["array"][l]["courses"][m]["course_id"];
}
}
......@@ -3,8 +3,10 @@ import { Router } from '@angular/router';
import { Observable } from 'rxjs/Rx';
import { Injectable } from "@angular/core";
import { SectorCoursesActions } from '../../actions/sectorcourses.actions';
import { NgRedux, select } from 'ng2-redux';
import { ISectors } from '../../store/sectorcourses/sectorcourses.types';
import { RegionSchoolsActions } from '../../actions/regionschools.actions';
import { IRegions } from '../../store/regionschools/regionschools.types';
import { NgRedux, select } from 'ng2-redux';
import { IAppState } from '../../store/store';
import {
......@@ -27,14 +29,14 @@ import {AppSettings} from '../../app.settings';
<li class="list-group-item" (click)="setActiveSector(i)" [style.background-color]="toggleBackgroundColor(i)">
<h5>{{sector$.sector_name}}</h5>
</li>
<div *ngFor="let course$ of sector$.courses; let j=index;" [hidden]="i !== sectorActive">
<li class="list-group-item" >
<div class="row">
<div class="col-md-2">
<input #cb type="checkbox" formControlName="{{ course$.globalIndex }}"
(change)="updateCheckedOptions(course$.globalIndex, cb)"
[checked] = " course$.globalIndex === idx ">
[checked] = " course$.globalIndex === idx "
>
</div>
<div class="col-md-10">
{{course$.course_name}}
......@@ -48,7 +50,7 @@ import {AppSettings} from '../../app.settings';
<div class="row">
<div class="col-md-2 col-md-offset-5">
<button type="button" class="btn-primary btn-lg pull-center" (click)="saveSelected()" [disabled]="idx === -1" >
<button type="button" class="btn-primary btn-lg pull-center" (click)="navigateToSchools()" [disabled]="idx === -1" >
Συνέχεια<span class="glyphicon glyphicon-menu-right"></span>
</button>
</div>
......@@ -64,13 +66,16 @@ import {AppSettings} from '../../app.settings';
})
@Injectable() export default class SectorCoursesSelect implements OnInit {
private sectors$: Observable<ISectors>;
private regions$: Observable<IRegions>;
private formGroup: FormGroup;
private rss = new FormArray([]);
private sectorActive = <number>-1;
private idx = <number>-1;
private sectorsList: Array<boolean> = new Array();
constructor(private fb: FormBuilder,
private _rsa: SectorCoursesActions,
private _rsr: RegionSchoolsActions,
private _ngRedux: NgRedux<IAppState>,
private router: Router
) {
......@@ -80,24 +85,39 @@ import {AppSettings} from '../../app.settings';
};
ngOnInit() {
this._rsa.getSectorCourses();
//re-initialize schools-redux-state
this.getAllSchools();
this._rsa.getSectorCourses(true);
let ids = 0;
this.sectors$ = this._ngRedux.select(state => {
state.sectors.reduce((prevSector, sector) =>{
this.sectorsList[ids] = sector.sector_selected;