Fixed routing reload bug. Other template fixes

parent 2cab38d0
......@@ -9,36 +9,7 @@ import { UserDataService } from '../services/user-data-service';
@Injectable()
export class StudentDataFieldsActions {
constructor(
private _ngRedux: NgRedux<IAppState>,
private _hds: UserDataService) {}
getStudentDataFields = () => {
const { studentDataFields } = this._ngRedux.getState();
//console.log(studentdataFields);
if (studentDataFields.size === 0) {
return this._hds.getStudentDataFields().then(studentdataFields => {
return this._ngRedux.dispatch({
type: STUDENTDATAFIELDS_RECEIVED,
payload: {
studentdataFields
}
});
});
}
};
/*
getStudentDataFields = () => {
return this._hds.getStudentDataFields().then(studentdataFields => {
return this._ngRedux.dispatch({
type: STUDENTDATAFIELDS_RECEIVED,
payload: {
studentdataFields
}
});
});
};
*/
private _ngRedux: NgRedux<IAppState>) {}
saveStudentDataFields = (studentDataFields) => {
......
<form novalidate [formGroup]="studentDataGroup">
<div *ngFor="let studentDataField$ of studentDataFields$ | async; "> </div>
<label>ΑΜΚΑ μαθητή</label><input type="text" formControlName="studentAmka">
<div class="form-group">
<label for="studentAmka">ΑΜΚΑ μαθητή</label><input class="form-control" type="text" formControlName="studentAmka">
</div>
<label>Όνομα μαθητή</label><input type="text" formControlName="studentFirstname">
<div class="form-group">
<label for="studentFirstname">Όνομα μαθητή</label><input class="form-control" type="text" formControlName="studentFirstname">
</div>
<div class="alert alert-danger" *ngIf="studentDataGroup.get('studentFirstname').touched && studentDataGroup.get('studentFirstname').hasError('required')">
Το πεδίο δεν μπορεί να αφεθεί κενό!
</div>
......@@ -11,7 +15,9 @@
Δεν επιτρέπονται ψηφία ή άλλοι μη έγκυροι χαρακτήρες σε αυτό το πεδίο!
</div>
<label>Επώνυμο μαθητή</label><input type="text" formControlName="studentSurname">
<div class="form-group">
<label for="studentSurname">Επώνυμο μαθητή</label><input class="form-control" type="text" formControlName="studentSurname">
</div>
<div class="alert alert-danger" *ngIf="studentDataGroup.get('studentSurname').touched && studentDataGroup.get('studentSurname').hasError('required')">
Το πεδίο δεν μπορεί να αφεθεί κενό!
</div>
......@@ -19,7 +25,9 @@
Δεν επιτρέπονται ψηφία ή άλλοι μη έγκυροι χαρακτήρες σε αυτό το πεδίο!
</div>
<label>Όνομα κηδεμόνα</label><input type="text" formControlName="guardianFirstname">
<div class="form-group">
<label for="guardianFirstname">Όνομα κηδεμόνα</label><input class="form-control" type="text" formControlName="guardianFirstname">
</div>
<div class="alert alert-danger" *ngIf="studentDataGroup.get('guardianFirstname').touched && studentDataGroup.get('guardianFirstname').hasError('required')">
Το πεδίο δεν μπορεί να αφεθεί κενό!
</div>
......@@ -27,7 +35,10 @@
Δεν επιτρέπονται ψηφία ή άλλοι μη έγκυροι χαρακτήρες σε αυτό το πεδίο!
</div>
<label>Επώνυμο κηδεμόνα</label><input type="text" formControlName="guardianSurname">
<div class="form-group">
<label for="guardianSurname">Επώνυμο κηδεμόνα</label>
<input class="form-control" type="text" formControlName="guardianSurname">
</div>
<div class="alert alert-danger" *ngIf="studentDataGroup.get('guardianSurname').touched && studentDataGroup.get('guardianSurname').hasError('required')">
Το πεδίο δεν μπορεί να αφεθεί κενό!
</div>
......@@ -39,56 +50,58 @@
<tr>
<td>
<div class="form-group">
<label>Διεύθυνση κατοικίας</label><input type="text" formControlName="regionAddress">
<label for="regionAddress">Διεύθυνση κατοικίας</label><input class="form-control" type="text" formControlName="regionAddress">
</div>
</td>
<td>
<div class="form-group">
<label>TK </label><input type="text" formControlName="regionTK">
<label for="regionTK">TK </label><input class="form-control" type="text" formControlName="regionTK">
</div>
</td>
<td>
<div class="form-group">
<label>Πόλη/Περιοχή</label><input type="text" formControlName="regionArea">
<label for="regionArea">Πόλη/Περιοχή</label><input class="form-control" type="text" formControlName="regionArea">
</div>
</td>
</tr>
</table>
<label for="certificateType">Τύπος απολυτηρίου</label><br/>
<select formControlName="certificateType">
<option value="">Παρακαλώ επιλέξτε..</option>
<option value="Απολυτήριο Γυμνασίου">Απολυτήριο Γυμνασίου</option>
<option value="Απολυτήριο Λυκείου">Απολυτήριο Λυκείου</option>
</select>
<br/>
<div class="form-group">
<label for="certificateType">Τύπος απολυτηρίου</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').touched && studentDataGroup.get('certificateType').hasError('required')">
Η επιλογή από αυτή τη λίστα είναι απαραίτητη!
</div>
<label for="relationToStudent">Η αίτηση γίνεται από:</label><br/>
<select formControlName="relationToStudent">
<option value="">Παρακαλώ επιλέξτε..</option>
<option value="Γονέας/Κηδεμόνας">Γονέας/Κηδεμόνας</option>
<option value="Μαθητής">Μαθητής</option>
</select>
<div class="alert alert-danger" *ngIf="studentDataGroup.get('relationToStudent').touched && studentDataGroup.get('relationToStudent').hasError('required')">
Η επιλογή από αυτή τη λίστα είναι απαραίτητη!
<div class="form-group">
<label for="relationToStudent">Η αίτηση γίνεται από:</label><br/>
<select class="form-control" formControlName="relationToStudent">
<option value="">Παρακαλώ επιλέξτε..</option>
<option value="Γονέας/Κηδεμόνας">Γονέας/Κηδεμόνας</option>
<option value="Μαθητής">Μαθητής</option>
</select>
<div class="alert alert-danger" *ngIf="studentDataGroup.get('relationToStudent').touched && studentDataGroup.get('relationToStudent').hasError('required')">
Η επιλογή από αυτή τη λίστα είναι απαραίτητη!
</div>
</div>
<h4 style="margin-top: 20px; line-height: 2em; background: #dddddd;">Επιλεγμένες Ειδικότητες</h4>
<h5 style="margin-top: 20px; line-height: 2em; background: #dddddd;">Επιλεγμένες Ειδικότητες</h5>
<ul class="list-group" style="margin-bottom: 20px;">
<div *ngFor="let courseField$ of courseFields$ | async">
<li class="list-group-item" *ngIf="courseField$.selected === true">
{{courseField$.name}}
</li>
<div *ngFor="let courseField$ of courseFields$ | async">
<li class="list-group-item" *ngIf="courseField$.selected === true">
{{courseField$.name}}
</li>
</div>
</ul>
<div class="row">
<div class="col-md-2 col-md-offset-4">
<button type="button" class="btn-primary btn-lg pull-center" (click)="saveSelected()" [routerLink]="['/course-fields-select']">
<button type="button" class="btn-primary btn-lg pull-center" (click)="saveSelected()">
<span class="glyphicon glyphicon-menu-left"></span>Πίσω
</button>
</div>
......
import {Component, OnInit} from '@angular/core';
import { Component, OnInit } from '@angular/core';
import { Observable } from 'rxjs/Rx';
import {Injectable, ChangeDetectionStrategy} from "@angular/core";
import {StudentDataFieldsActions} from '../../actions/studentdatafields.actions';
import { Injectable } from "@angular/core";
import { StudentDataFieldsActions } from '../../actions/studentdatafields.actions';
import { Router } from '@angular/router';
import { DevToolsExtension, NgRedux, select } from 'ng2-redux';
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';
......@@ -28,8 +29,10 @@ import {
public studentDataGroup: FormGroup;
constructor(private fb: FormBuilder, private _sdfa: StudentDataFieldsActions, private _ngRedux: NgRedux<IAppState>) {
constructor(private fb: FormBuilder,
private _sdfa: StudentDataFieldsActions,
private _ngRedux: NgRedux<IAppState>,
private router: Router) {
this.studentDataGroup = this.fb.group({
studentAmka: ['12345', Validators.required],
studentFirstname: ['', [Validators.pattern(VALID_NAMES_PATTERN),Validators.required]],
......@@ -42,7 +45,6 @@ import {
certificateType: ['', Validators.required],
relationToStudent: ['', Validators.required],
});
};
ngOnInit() {
......@@ -57,10 +59,7 @@ import {
});
this.courseFields$ = this._ngRedux.select(state => {
//console.log("test2");
state.courseFields.reduce(({}, courseField) =>{
// this.cfs.push(new FormControl(courseField.selected, []));
//console.log(courseField.selected);
return courseField;
}, {});
return state.courseFields;
......@@ -69,5 +68,6 @@ import {
saveSelected() {
this._sdfa.saveStudentDataFields([this.studentDataGroup.value]);
this.router.navigate(['/course-fields-select']);
}
}
import { Component, OnInit } from '@angular/core';
import { Http, Response, RequestOptions, Headers } from '@angular/http';
import { Router } from '@angular/router';
import { Observable } from 'rxjs/Rx';
import { Injectable } from "@angular/core";
import { CourseFieldsActions } from '../../actions/coursefields.actions';
import { DevToolsExtension, NgRedux, select } from 'ng2-redux';
import { ICourseFields, ICourseField } from '../../store/coursefields/coursefields.types';
import { NgRedux, select } from 'ng2-redux';
import { ICourseFields } from '../../store/coursefields/coursefields.types';
import { IAppState } from '../../store/store';
import {
......@@ -33,7 +33,7 @@ import {AppSettings} from '../../app.settings';
</div>
<div class="row">
<div class="col-md-2 col-md-offset-5">
<button class="btn-primary btn-lg pull-center" (click)="saveSelected()" [routerLink]="['/student-application-form-main']">
<button type="button" class="btn-primary btn-lg pull-center" (click)="saveSelected()">
Συνέχεια<span class="glyphicon glyphicon-menu-right"></span>
</button>
</div>
......@@ -48,7 +48,10 @@ import {AppSettings} from '../../app.settings';
public formGroup: FormGroup;
public cfs = new FormArray([]);
constructor(private http: Http, private fb: FormBuilder, private _cfa: CourseFieldsActions, private _ngRedux: NgRedux<IAppState>) {
constructor(private fb: FormBuilder,
private _cfa: CourseFieldsActions,
private _ngRedux: NgRedux<IAppState>,
private router: Router) {
this.formGroup = this.fb.group({
formArray: this.cfs
});
......@@ -59,10 +62,8 @@ import {AppSettings} from '../../app.settings';
this._cfa.getCourseFields();
this.courseFields$ = this._ngRedux.select(state => {
//console.log("test2");
state.courseFields.reduce(({}, courseField) =>{
this.cfs.push(new FormControl(courseField.selected, []));
//console.log(courseField.selected);
return courseField;
}, {});
return state.courseFields;
......@@ -72,7 +73,6 @@ import {AppSettings} from '../../app.settings';
saveSelected() {
this._cfa.saveCourseFieldsSelected(this.formGroup.value.formArray);
this.router.navigate(['/student-application-form-main']);
}
}
......@@ -7,32 +7,15 @@ import {
STUDENTDATAFIELDS_SAVE
} from '../../constants';
export function studentDataFieldsReducer(state: IStudentDataFields = INITIAL_STATE, action): IStudentDataFields {
switch (action.type) {
case STUDENTDATAFIELDS_RECEIVED:
let newStudentDataFields = Array<IStudentDataField>();
let i=0;
action.payload.studentdataFields.forEach(studentdataField => {
newStudentDataFields.push(<IStudentDataField>{studentFirstname: studentdataField.studentFirstname, studentSurname: studentdataField.studentSurname,
guardianFirstname: studentdataField.guardianFirstname, guardianSurname: studentdataField.guardianSurname,
studentAmka: studentdataField.studentAmka,
regionAddress: studentdataField.regionAddress, regionTK: studentdataField.regionTK, regionArea: studentdataField.regionArea,
certificateType: studentdataField.certificateType, relationToStudent: studentdataField.relationToStudent});
i++;
});
return Seq(newStudentDataFields).map(n => n).toList();
case STUDENTDATAFIELDS_SAVE:
let studentDataFields = Array<IStudentDataField>();
let ind=0;
//let testvar = "nikos";
action.payload.studentDataFields.forEach(studentDataField => {
studentDataFields.push(<IStudentDataField>studentDataField);
ind++;
//console.log(action.payload.studentdataFieldsFirstname);
});
return Seq(studentDataFields).map(n => n).toList();
......
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