updated application.form.main component with criteria definition

parent 22040a4b
import { CRITERIA_SAVE} from '../constants';
import { Injectable } from '@angular/core';
import { NgRedux } from 'ng2-redux';
import { IAppState } from '../store';
@Injectable()
export class CriteriaActions {
constructor(
private _ngRedux: NgRedux<IAppState>) {}
saveCriteria = (criter) => {
return this._ngRedux.dispatch({
type: CRITERIA_SAVE,
payload: {
criter
}
});
};
}
......@@ -6,7 +6,10 @@ import { StudentDataFieldsActions } from './studentdatafields.actions';
import { EpalClassesActions } from './epalclass.actions';
import { AmkaFillsActions} from './amkafill.actions';
import { LoginInfoActions} from './logininfo.actions';
const ACTION_PROVIDERS = [ CourseFieldsActions, SectorFieldsActions, RegionSchoolsActions, SectorCoursesActions, StudentDataFieldsActions, EpalClassesActions, AmkaFillsActions, LoginInfoActions ];
import { CriteriaActions} from './criteria.actions';
const ACTION_PROVIDERS = [ CourseFieldsActions, SectorFieldsActions, RegionSchoolsActions, SectorCoursesActions, StudentDataFieldsActions,
EpalClassesActions, AmkaFillsActions, LoginInfoActions, CriteriaActions ];
export {
CourseFieldsActions,
......@@ -17,5 +20,6 @@ export {
EpalClassesActions,
AmkaFillsActions,
LoginInfoActions,
CriteriaActions,
ACTION_PROVIDERS,
};
export class AppSettings {
public static get API_ENDPOINT(): string {
return 'http://localhost/angular/eepal-front/drupal';
return 'http://localhost/drupal-8.2.5';
// return 'http://localhost/angular/eepal-front/drupal';
// return 'http://localhost/drupal';
// return 'http://eepal.dev/drupal';
// return 'http://eduslim2.minedu.gov.gr/drupal';
......
<div class="row equal">
<div class="col-md-8">
<div class="col-md-12">
<form novalidate (ngSubmit)="onSubmit(studentDataGroup)" [formGroup]="studentDataGroup">
<form [formGroup]="applicantDataGroup">
<table>
<tr><td>
<div class="form-group">
<label for="guardianfirstname">Όνομα κηδεμόνα</label><input class="form-control" type="text" formControlName="guardianfirstname" disabled = "true">
</div>
</td>
<td>
<div class="form-group">
<label for="guardiansurname">Επώνυμο κηδεμόνα</label><input class="form-control" type="text" formControlName="guardiansurname" disabled = "true">
</div>
</td></tr>
</table>
</form>
<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="name">Όνομα μαθητή</label><input class="form-control" type="text" formControlName="name">
......@@ -129,14 +134,79 @@
Επιτρέπονται μόνο ψηφία σε αυτό το πεδίο!
</div>
<form novalidate (ngSubmit)="onSubmit(studentCriteriaGroup)" [formGroup]="studentCriteriaGroup">
<div *ngFor="let criter$ of criteria$ | async; let i=index"> </div>
<fieldset class="group">
<legend>Εισοδηματικά κριτήρια</legend>
<div class="form-group">
<label for="income">Το κατά κεφαλήν εισόδημα στο προηγούμενο φορολογικό έτος είναι:</label><br/>
<select class="form-control" (change)="checkstatus()" formControlName="income">
<option value="noincomecriterio">Παρακαλώ επιλέξτε..</option>
<option value="<= 3000 Ευρώ">μικρότερο ή ίσο των 3000 Ευρώ</option>
<option value="<= 6000 Ευρώ">μικρότερο ή ίσο των 6000 Ευρώ</option>
<option value="<= 9000 Ευρώ">μικρότερο ή ίσο των 9000 Ευρώ</option>
<option value="> 9000 Ευρώ">μεγαλύτερο των 9000 Ευρώ</option>
</select>
<div class="alert alert-danger" *ngIf="studentCriteriaGroup.get('income').dirty && studentCriteriaGroup.get('income').hasError('status')">
Η επιλογή από αυτή τη λίστα είναι απαραίτητη!
</div>
</div>
<legend>Κοινωνικά κριτήρια</legend>
<p style="margin-top: 15px; line-height: 1.5em;">Επιλέξτε όσα από τα παρακάτω κριτήρια πληρούνται για εσάς.
Οι επιλογές σας επέχουν θέση υπέυθυνης δήλωσης.
Θα πρέπει να προσκομίσετε τα αντίστοιχα δικαιολογητικά στο σχολείο εγγραφής σας, όταν σας ζητηθεί.
</p>
<div class="row">
<div class="col-md-1"> <input #cborphanmono type="checkbox" (change)="checkorphan('mono', cborphanmono)" formControlName="orphanmono" ></div>
<div class="col-md-11 pull-left">Ορφανός από τον ένα γονέα</div>
</div>
<div class="row">
<div class="col-md-1"> <input #cborphantwice type="checkbox" (change)="checkorphan('twice', cborphantwice)" formControlName="orphantwice" ></div>
<div class="col-md-11 pull-left">Ορφανός και από τους δύο γονείς</div>
</div>
<div class="row">
<div class="col-md-1"> <input #cbthreechildren type="checkbox" (change)="checkchildren('three', cbthreechildren)" formControlName="threechildren"></div>
<div class="col-md-11 pull-left">Μέλος Τρίτεκνης Οικογένειας</div>
</div>
<div class="row">
<div class="col-md-1"> <input #cbmanychildren type="checkbox" (change)="checkchildren('many', cbmanychildren)" formControlName="manychildren"></div>
<div class="col-md-11 pull-left">Μέλος Πολύτεκνης Οικογένειας</div>
</div>
<div class="row">
<div class="col-md-1"> <input type="checkbox" (change)="checkstatus()" formControlName="twins"></div>
<div class="col-md-11 pull-left">Πολύδυμα Τέκνα</div>
</div>
<div class="row">
<div class="col-md-1"> <input type="checkbox" (change)="checkstatus()" formControlName="disability"></div>
<div class="col-md-11 pull-left">Γονείς, τέκνα, αδέλφια ή σύζυγος με αναπηρία 67% και άνω </div>
</div>
<div class="row">
<div class="col-md-1"> <input type="checkbox" (change)="checkstatus()" formControlName="studies"></div>
<div class="col-md-11 pull-left">Αδελφός,-ή που σπουδάζει σε άλλη πόλη</div>
</div>
</fieldset>
</form>
<div class="row">
<div class="col-md-2 col-md-offset-4">
<button type="button" class="btn-primary btn-lg pull-center" (click)="saveSelected()">
<span class="glyphicon glyphicon-menu-left"></span>Πίσω
</button>
</div>
<div class="col-md-2">
<button type="button" class="btn-primary btn-lg pull-center" (click)="submitSelected()" [disabled]="studentDataGroup.invalid">
<div class="col-md-8">
<button type="button" class="btn-primary btn-lg pull-right" (click)="submitSelected()" [disabled]="studentDataGroup.invalid || studentCriteriaGroup.invalid ">
Συνέχεια<span class="glyphicon glyphicon-menu-right"></span>
</button>
</div>
......@@ -144,7 +214,3 @@
</form>
</div>
<div class="col-md-4">
<application-preview-select></application-preview-select>
</div>
import { Component, OnInit } from '@angular/core';
import { Observable } from 'rxjs/Rx';
import { Injectable } from "@angular/core";
import { StudentDataFieldsActions } from '../../actions/studentdatafields.actions';
import { Router } from '@angular/router';
import { NgRedux, select } from 'ng2-redux';
import { StudentDataFieldsActions } from '../../actions/studentdatafields.actions';
import { IStudentDataFields } from '../../store/studentdatafields/studentdatafields.types';
//import { ICourseFields } from '../../store/coursefields/coursefields.types';
import { CriteriaActions } from '../../actions/criteria.actions';
import { ICriter } from '../../store/criteria/criteria.types';
import { IAppState } from '../../store/store';
import { VALID_NAMES_PATTERN, VALID_ADDRESS_PATTERN, VALID_ADDRESSTK_PATTERN, VALID_DIGITS_PATTERN } from '../../constants';
......@@ -24,20 +25,23 @@ import {
@Injectable() export default class StudentApplicationMain implements OnInit {
private studentDataFields$: Observable<IStudentDataFields>;
//private courseFields$: Observable<ICourseFields>;
private criteria$: Observable<ICriter>;
public studentDataGroup: FormGroup;
public applicantDataGroup: FormGroup;
public studentCriteriaGroup: FormGroup;
//public orphanmode = <number>0;
//public childrenmode = <number>0;
constructor(private fb: FormBuilder,
private _sdfa: StudentDataFieldsActions,
private _sdfb: CriteriaActions,
private _ngRedux: NgRedux<IAppState>,
private router: Router) {
this.studentDataGroup = this.fb.group({
epaluser_id: [1,[]],
name: ['ΝΙΚΟΣ', [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]],
......@@ -45,10 +49,27 @@ import {
relationtostudent: ['Μαθητής', Validators.required],
telnum: ['2610789789', [Validators.pattern(VALID_DIGITS_PATTERN),Validators.required]],
});
this.applicantDataGroup = this.fb.group({
guardianfirstname: ['ΑΝΑΣΤΑΣΙΟΣ', [Validators.pattern(VALID_NAMES_PATTERN),Validators.required]],
guardiansurname: ['ΚΑΤΣΑΟΥΝΟΣ', [Validators.pattern(VALID_NAMES_PATTERN),Validators.required]],
});
this.studentCriteriaGroup = this.fb.group({
orphanmono: false,
orphantwice: false,
threechildren: false,
manychildren: false,
twins: false,
disability: false,
studies: false,
income: ['noincomecriterio', checkChoice],
});
};
ngOnInit() {
this.studentDataFields$ = this._ngRedux.select(state => {
if (state.studentDataFields.size > 0) {
state.studentDataFields.reduce(({}, studentDataField) => {
......@@ -58,17 +79,66 @@ import {
}
return state.studentDataFields;
});
}
this.criteria$ = this._ngRedux.select(state => {
if (state.criter.size > 0) {
state.criter.reduce(({}, criteria) => {
this.studentCriteriaGroup.setValue(criteria);
return criteria;
}, {});
}
return state.criter;
});
saveSelected() {
this._sdfa.saveStudentDataFields([this.studentDataGroup.value]);
this.router.navigate(['/region-schools-select']);
}
submitSelected() {
this._sdfa.saveStudentDataFields([this.studentDataGroup.value]);
this.router.navigate(['/application-submit']);
}
checkorphan(orphanModeName,cb) {
if (orphanModeName === "mono" && cb.checked === true)
this.studentCriteriaGroup.controls['orphantwice'].setValue(false);
else if (orphanModeName === "twice" && cb.checked === true)
this.studentCriteriaGroup.controls['orphanmono'].setValue(false);
this._sdfb.saveCriteria([this.studentCriteriaGroup.value]);
//console.log("after check");
//console.log(this.studentCriteriaGroup.value);
}
checkchildren(childrenModeName, cb) {
if (childrenModeName === "three" && cb.checked === true)
this.studentCriteriaGroup.controls['manychildren'].setValue(false);
else if (childrenModeName === "many" && cb.checked === true)
this.studentCriteriaGroup.controls['threechildren'].setValue(false);
this._sdfb.saveCriteria([this.studentCriteriaGroup.value]);
//console.log("after check");
//console.log(this.studentCriteriaGroup.value);
}
checkstatus() {
//this.studentCriteriaGroup.controls[name].setValue(cb.checked);
//console.log("after check");
//console.log(this.studentCriteriaGroup.value);
this._sdfb.saveCriteria([this.studentCriteriaGroup.value]);
}
}
function checkChoice(c: FormControl) {
console.log("here!!!!");
console.log(c.value);
if (c.value === "noincomecriterio")
return {status: true}
else
// Null means valid, believe it or not
return null;
}
......@@ -19,6 +19,8 @@ export const AMKAFILL_SAVE = 'AMKAFILL_SAVE';
export const LOGININFO_SAVE = 'LOGININFO_SAVE';
export const CRITERIA_SAVE = 'CRITERIA_SAVE';
//export const VALID_NAMES_PATTERN = '[Α-ΩΆΈΉΊΎΌΏα-ωάέήίύόώ ]*$';
export const VALID_NAMES_PATTERN = '[A-Za-zΑ-ΩΆΈΉΊΎΌΏα-ωάέήίύόώ ]*$';
export const VALID_ADDRESS_PATTERN = '[0-9A-Za-zΑ-ΩΆΈΉΊΎΌΏα-ωάέήίύόώ ]*$';
......
......@@ -147,3 +147,8 @@
.form-group input[type="checkbox"]:checked + .btn-group > label span:last-child {
display: none;
}
fieldset{
border-width: 1px;
border-style: inset;
}
import { List } from 'immutable';
import { ICriteria } from './criteria.types';
// export const INITIAL_STATE = List<ICourseField>([new CourseFieldRecord({})]);
export const INITIAL_STATE = List<ICriteria>();
import { ICriteria, ICriter } from './criteria.types';
import { INITIAL_STATE } from './criteria.initial-state';
import { Seq } from 'immutable';
import {
CRITERIA_SAVE
} from '../../constants';
export function criteriaReducer(state: ICriter = INITIAL_STATE, action): ICriter {
switch (action.type) {
case CRITERIA_SAVE:
let criter = Array<ICriteria>();
let ind=0;
action.payload.criter.forEach(criteria => {
criter.push(<ICriteria>criteria);
ind++;
});
return Seq(criter).map(n => n).toList();
default: return state;
}
};
import { ICriteria, ICriter } from './criteria.types';
export function deimmutifyCriteria(state: ICriter): ICriteria[] {
let fetchedCriteria = new Array();
state.forEach(criteria => {
fetchedCriteria.push(<ICriteria>{orphanmono: criteria.orphanmono, orphantwice: criteria.orphantwice, threechildren: criteria.threechildren,
manychildren: criteria.manychildren, twins: criteria.twins, disability: criteria.disability, studies: criteria.studies, income: criteria.income,
});
});
return fetchedCriteria;
};
import { List } from 'immutable';
export interface ICriteria {
orphanmono: boolean;
orphantwice: boolean;
threechildren: boolean;
manychildren: boolean;
twins: boolean;
disability: boolean;
studies: boolean;
income: string;
}
export type ICriter = List<ICriteria>;
import { ICriter, ICriteria } from './criteria.types';
import { criteriaReducer } from './criteria.reducer';
import { deimmutifyCriteria } from './criteria.transformers';
export {
ICriter,
ICriteria,
criteriaReducer,
deimmutifyCriteria,
};
......@@ -8,6 +8,7 @@ import { ISectors, ISector, ISectorCourse } from './sectorcourses/sectorcourses.
import { IStudentDataField, IStudentDataFields } from './studentdatafields/studentdatafields.types';
import { IEpalClass, IEpalClasses } from './epalclasses/epalclasses.types';
import { ILoginInfoToken, ILoginInfo } from './logininfo/logininfo.types';
import { ICriter, ICriteria } from './criteria/criteria.types';
export {
IAppState,
......@@ -27,7 +28,8 @@ export {
IEpalClass,
IEpalClasses,
ILoginInfo,
ICriter,
ICriteria
};
export const middleware = [
......
......@@ -7,6 +7,7 @@ import * as studentDataFields from './studentdatafields';
import * as epalclasses from './epalclasses';
import * as amkafills from './amkafill';
import * as loginInfo from './logininfo';
import * as criter from './criteria';
/*
* This is where we 'assemble' the full store out of its modules.
......@@ -21,6 +22,7 @@ export interface IAppState {
epalclasses?: epalclasses.IEpalClasses;
amkafills?: amkafills.IAmkaFills;
loginInfo?: loginInfo.ILoginInfo;
criter?: criter.ICriter;
};
export const rootReducer = combineReducers<IAppState>({
......@@ -32,6 +34,7 @@ export const rootReducer = combineReducers<IAppState>({
epalclasses: epalclasses.epalclassesReducer,
amkafills: amkafills.amkafillReducer,
loginInfo: loginInfo.loginInfoReducer,
criter: criter.criteriaReducer,
});
export function deimmutify(state: IAppState): Object {
......@@ -44,5 +47,6 @@ export function deimmutify(state: IAppState): Object {
epalclasses: epalclasses.deimmutifyEpalClasses(state.epalclasses),
amkafills: amkafills.deimmutifyAmkaFills(state.amkafills),
loginInfo: loginInfo.deimmutifyLoginInfo(state.loginInfo),
criter: criter.deimmutifyCriteria(state.criter),
};
}
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