Commit 29505eab authored by Kostas G's avatar Kostas G

School Type imlementation

parent be87e3df
......@@ -11,6 +11,8 @@ import { ElectiveCourseFieldsActions } from "./electivecoursesfields.actions";
import { LangCourseFieldsActions } from "./langcoursesfields.actions";
import { GelClassesActions } from "./gelclasses.actions";
import { GelStudentDataFieldsActions } from "./gelstudentdatafields.actions";
import { SchoolTypeActions } from "./schooltype.actions";
const ACTION_PROVIDERS = [
SectorFieldsActions,
......@@ -26,6 +28,7 @@ const ACTION_PROVIDERS = [
LangCourseFieldsActions,
GelClassesActions,
GelStudentDataFieldsActions,
SchoolTypeActions,
];
export {
......@@ -42,6 +45,7 @@ export {
LangCourseFieldsActions,
GelClassesActions,
GelStudentDataFieldsActions,
SchoolTypeActions,
ACTION_PROVIDERS,
};
import { NgRedux } from "@angular-redux/store";
import { Injectable } from "@angular/core";
import { SCHOOLTYPE_SAVE } from "../constants";
import { SCHOOLTYPE_INIT, SCHOOLTYPE_RECEIVED, SCHOOLTYPE_RESET } from "../constants";
import { IAppState } from "../store";
import { HelperDataService } from "../services/helper-data-service";
@Injectable()
export class SchoolTypeActions {
constructor(
private _ngRedux: NgRedux<IAppState>,
private _hds: HelperDataService) { }
initSchoolType = () => {
return this._ngRedux.dispatch({
type: SCHOOLTYPE_INIT,
payload: {
}
});
};
saveSchoolTypeSelected = (schooltype_id, schooltype_name) => {
return this._ngRedux.dispatch({
type: SCHOOLTYPE_SAVE,
payload: {
schooltype_id,
schooltype_name
}
});
};
}
......@@ -9,6 +9,13 @@ import { RegionSchoolsActions } from "../../actions/regionschools.actions";
import { SectorCoursesActions } from "../../actions/sectorcourses.actions";
import { SectorFieldsActions } from "../../actions/sectorfields.actions";
import { StudentDataFieldsActions } from "../../actions/studentdatafields.actions";
import { SchoolTypeActions } from "../../actions/schooltype.actions";
import { GelClassesActions } from "../../actions/gelclasses.actions";
import { ElectiveCourseFieldsActions } from "../../actions/electivecoursesfields.actions";
import { OrientationGroupActions } from "../../actions/orientationgroup.action";
import { LangCourseFieldsActions } from "../../actions/langcoursesfields.actions";
import { GelStudentDataFieldsActions } from "../../actions/gelstudentdatafields.actions";
import { DIDE_ROLE, MINISTRY_ROLE, PDE_ROLE, SCHOOL_ROLE, STUDENT_ROLE } from "../../constants";
import { HelperDataService } from "../../services/helper-data-service";
import { LOGININFO_INITIAL_STATE } from "../../store/logininfo/logininfo.initial-state";
......@@ -44,6 +51,12 @@ export default class HeaderComponent implements OnInit, OnDestroy {
private _rsa: RegionSchoolsActions,
private _eca: EpalClassesActions,
private _sdfa: StudentDataFieldsActions,
private _sta: SchoolTypeActions,
private _gca: GelClassesActions,
private _ecfa: ElectiveCourseFieldsActions,
private _oga: OrientationGroupActions,
private _lcfa: LangCourseFieldsActions,
private _gsdfa: GelStudentDataFieldsActions,
private _ngRedux: NgRedux<IAppState>,
private router: Router
) {
......@@ -126,6 +139,12 @@ export default class HeaderComponent implements OnInit, OnDestroy {
this._rsa.initRegionSchools();
this._csa.initSectorCourses();
this._sdfa.initStudentDataFields();
this._sta.initSchoolType();
this._gca.initGelClasses();
this._ecfa.initElectiveCourseFields();
this._oga.initOrientationGroup();
this._lcfa.initLangCourseFields();
this._gsdfa.initGelStudentDataFields();
this.router.navigate([""]);
}
else if (this.authRole === MINISTRY_ROLE) {
......
......@@ -6,6 +6,8 @@ import { Router } from "@angular/router";
import { BehaviorSubject, Subscription } from "rxjs/Rx";
import { GelClassesActions } from "../../actions/gelclasses.actions";
import { ElectiveCourseFieldsActions } from "../../actions/electivecoursesfields.actions";
import { GELCLASSES_INITIAL_STATE } from "../../store/gelclasses/gelclasses.initial-state";
import { IGelClass, IGelClassRecord, IGelClassRecords } from "../../store/gelclasses/gelclasses.types";
import { IAppState } from "../../store/store";
......@@ -75,13 +77,12 @@ import { gelclassesReducer } from "../../store/gelclasses/gelclasses.reducer";
})
@Injectable() export default class ClassSelection implements OnInit, OnDestroy {
private gelclasses$: BehaviorSubject<IGelClassRecords>;
private gelclassesSub: Subscription;
private categoryChosen: String;
private enableclassfilter: boolean;
private classActive=0;
private classActive;
private formGroup: FormGroup;
private modalTitle: BehaviorSubject<string>;
private modalText: BehaviorSubject<string>;
......@@ -92,7 +93,8 @@ import { gelclassesReducer } from "../../store/gelclasses/gelclasses.reducer";
constructor(private fb: FormBuilder,
private _ngRedux: NgRedux<IAppState>,
private _cfa: GelClassesActions,
private _gca: GelClassesActions,
private _ecfa: ElectiveCourseFieldsActions,
private router: Router) {
this.formGroup = this.fb.group({
classId: [],
......@@ -104,12 +106,13 @@ import { gelclassesReducer } from "../../store/gelclasses/gelclasses.reducer";
this.isModalShown = new BehaviorSubject(false);
this.gelclasses$ = new BehaviorSubject(GELCLASSES_INITIAL_STATE);
this.enableclassfilter = false;
this.classActive=0;
};
ngOnInit() {
(<any>$("#gelClassNotice")).appendTo("body");
this._cfa.getClassesList(false);
this._gca.getClassesList(false);
this.gelclassesSub = this._ngRedux.select("gelclasses")
.map(gelclasses => <IGelClassRecords>gelclasses)
.subscribe(ecs => {
......@@ -120,11 +123,15 @@ import { gelclassesReducer } from "../../store/gelclasses/gelclasses.reducer";
this.formGroup.controls["category"].setValue(gelclass.get("category"));
this.enableclassfilter = true;
this.classActive=gelclass.get("id");
this.categoryChosen=gelclass.get("category");
}
return gelclass;
}, {});
} else {
//this.formGroup.controls["name"].setValue("...");
//this.formGroup.controls["classId"].setValue("...");
}
if (this.enableclassfilter === false){
this.formGroup.controls["category"].setValue("0");
}
this.gelclasses$.next(ecs);
}, error => { console.log("error selecting gelclasses"); });
......@@ -157,7 +164,7 @@ import { gelclassesReducer } from "../../store/gelclasses/gelclasses.reducer";
public categoryselected(typeId) {
this.categoryChosen = typeId.value;
this._cfa.resetGelClassesSelected();
this._gca.resetGelClassesSelected();
if (this.categoryChosen == "ΗΜΕΡΗΣΙΟ" || this.categoryChosen == "ΕΣΠΕΡΙΝΟ") {
this.enableclassfilter=true;
......@@ -177,17 +184,18 @@ import { gelclassesReducer } from "../../store/gelclasses/gelclasses.reducer";
this.showModal();
}
else {
this._cfa.saveGelClassesSelected(this.classActive-1, this.formGroup.value.classId-1);
if (this.formGroup.value.classId != "0")
//this.router.navigate(["/orientation-group-select"]);
if (this.formGroup.value.classId != "0"){
this.router.navigate(["/electivecourse-fields-select"]);
}
}
}
initializestore() {
this._cfa.saveGelClassesSelected(this.classActive-1, this.formGroup.value.classId-1);
this._gca.saveGelClassesSelected(this.classActive-1, this.formGroup.value.classId-1);
this.classActive=this.formGroup.value.classId;
this._ecfa.initElectiveCourseFields();
}
}
......@@ -211,7 +211,7 @@ import { IAppState } from "../../store/store";
navigateBack() {
this.updateStore();
this.router.navigate(["/intro-statement"]);
this.router.navigate(["/gel-class-select"]);
}
}
......@@ -197,7 +197,7 @@ import { IAppState } from "../../store/store";
this._lia.saveStatementAgree(this.formGroup.controls["disclaimerChecked"].value);
//this.router.navigate(["epal-class-select"]);
this.router.navigate(["gel-class-select"]);
this.router.navigate(["school-type-select"]);
}
}
}
import { NgRedux } from "@angular-redux/store";
import { Component, OnDestroy, OnInit } from "@angular/core";
import { Injectable } from "@angular/core";
import { FormBuilder, FormGroup } from "@angular/forms";
import { Router } from "@angular/router";
import { BehaviorSubject, Subscription } from "rxjs/Rx";
import { SchoolTypeActions } from "../../actions/schooltype.actions";
import { GelClassesActions } from "../../actions/gelclasses.actions";
import { SCHOOLTYPE_INITIAL_STATE } from "../../store/schooltype/schooltype.initial-state";
import { ISchoolType, ISchoolTypeRecord, ISchoolTypeRecords } from "../../store/schooltype/schooltype.types";
import { IAppState } from "../../store/store";
import { schooltypeReducer } from "../../store/schooltype/schooltype.reducer";
@Component({
selector: "school-type-select",
template: `
<div id="SchoolTypeNotice" (onHidden)="onHidden()" class="modal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static" data-keyboard="false">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header {{modalHeader | async}}">
<h3 class="modal-title pull-left"><i class="fa fa-check-square-o"></i>&nbsp;&nbsp;{{ modalTitle | async }}</h3>
<button type="button" class="close pull-right" aria-label="Close" (click)="hideModal()">
<span aria-hidden="true"><i class="fa fa-times"></i></span>
</button>
</div>
<div class="modal-body">
<p>{{ modalText | async }}</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" (click)="hideModal()">Κλείσιμο</button>
</div>
</div>
</div>
</div>
<h4> Επιλογή Τύπου Σχολείου </h4>
<form [formGroup]="formGroup">
<p style="margin-top: 5px; line-height: 2em;"> Παρακαλώ επιλέξτε τον τυπο σχολείου που θα φοιτήσει ο μαθητής
κατά το σχολικό έτος 2018-19 και έπειτα επιλέξτε <i>Συνέχεια</i>.</p>
<div class="form-group" style= "margin-top: 50px; margin-bottom: 100px;">
<label for="typeId">Τύπος Σχολείου:</label><br/>
<select class="form-control" formControlName="typeId" (change)="initializestore()">
<option value="0">Επιλέξτε Τύπο Σχολείου:</option>
<option value="1">ΓΕΛ - Γενικό Λύκειο</option>
<option value="2">ΕΠΑΛ - Επαγγελματικό Λύκειο</option>
</select>
</div>
<div class="row" style="margin-top: 20px; margin-bottom: 20px;">
<div class="col-md-6">
<button type="button" class="btn-primary btn-lg pull-left" (click)="navigateBack()">
<i class="fa fa-backward"></i>
</button>
</div>
<div class="col-md-6">
<button type="button" class="btn-primary btn-lg pull-right isclickable" style="width: 9em;" (click)="saveSelected()">
<span style="font-size: 0.9em; font-weight: bold;">Συνέχεια&nbsp;&nbsp;&nbsp;</span><i class="fa fa-forward"></i>
</button>
</div>
</div>
</form>
`
})
@Injectable() export default class SchoolTypeSelection implements OnInit, OnDestroy {
private schooltype$: BehaviorSubject<ISchoolTypeRecords>;
private schooltypeSub: Subscription;
private formGroup: FormGroup;
private modalTitle: BehaviorSubject<string>;
private modalText: BehaviorSubject<string>;
private modalHeader: BehaviorSubject<string>;
public isModalShown: BehaviorSubject<boolean>;
constructor(private fb: FormBuilder,
private _ngRedux: NgRedux<IAppState>,
private _cfa: SchoolTypeActions,
private _gca: GelClassesActions,
private router: Router) {
this.formGroup = this.fb.group({
typeId: []
});
this.modalTitle = new BehaviorSubject("");
this.modalText = new BehaviorSubject("");
this.modalHeader = new BehaviorSubject("");
this.isModalShown = new BehaviorSubject(false);
this.schooltype$ = new BehaviorSubject(SCHOOLTYPE_INITIAL_STATE);
};
ngOnInit() {
(<any>$("#SchoolTypeNotice")).appendTo("body");
this.schooltypeSub = this._ngRedux.select("schooltype")
.map(schooltype => <ISchoolTypeRecords>schooltype)
.subscribe(ecs => {
if (ecs.size > 0) {
ecs.reduce(({}, type) => {
this.formGroup.controls["typeId"].setValue(type.get("id"));
return type;
}, {});
} else {
this.formGroup.controls["typeId"].setValue("0");
}
this.schooltype$.next(ecs);
}, error => { console.log("error selecting schooltype"); });
}
ngOnDestroy() {
if (this.schooltypeSub)
this.schooltypeSub.unsubscribe();
(<any>$("#SchoolTypeNotice")).remove();
}
public showModal(): void {
(<any>$("#SchoolTypeNotice")).modal("show");
}
public hideModal(): void {
(<any>$("#SchoolTypeNotice")).modal("hide");
}
public onHidden(): void {
this.isModalShown.next(false);
}
navigateBack() {
this.router.navigate(["/school-type-select"]);
}
saveSelected() {
if (this.formGroup.controls["typeId"].value === "0") {
this.modalTitle.next("Δεν επιλέχθηκε τύπος Σχολείου");
this.modalText.next("Παρακαλούμε να επιλέξετε πρώτα τον τύπο Σχολείου φοίτησης του μαθητή για το νέο σχολικό έτος");
this.modalHeader.next("modal-header-danger");
this.showModal();
}
else {
if (this.formGroup.value.typeId === "1"){
this._cfa.saveSchoolTypeSelected(this.formGroup.value.typeId,"ΓΕΛ");
this.router.navigate(["/gel-class-select"]);
}
else if (this.formGroup.value.typeId === "2"){
this._cfa.saveSchoolTypeSelected(this.formGroup.value.typeId,"ΕΠΑΛ");
this.router.navigate(["/epal-class-select"]);
}
}
}
initializestore() {
this._gca.initGelClasses();
}
}
......@@ -20,6 +20,11 @@ export const GELCLASSES_RECEIVED = "GELCLASSES_RECEIVED";
export const GELCLASSES_SAVE = "GELCLASSES_SAVE";
export const GELCLASSES_RESET = "GELCLASSES_RESET";
export const SCHOOLTYPE_SAVE = "SCHOOLTYPE_SAVE";
export const SCHOOLTYPE_INIT = "SCHOOLTYPE_INIT";
export const SCHOOLTYPE_RECEIVED = "SCHOOLTYPE_RECEIVED";
export const SCHOOLTYPE_RESET = "SCHOOLTYPE_RESET";
export const GELSTUDENTDATAFIELDS_SAVE = "GELSTUDENTDATAFIELDS_SAVE";
export const GELSTUDENTDATAFIELDS_INIT = "GELSTUDENTDATAFIELDS_INIT";
......
......@@ -57,6 +57,8 @@ import LangCourseFieldsSelect from "../components/student-application-form/langc
import CoursesOrderSelect from "../components/student-application-form/courses.order.select";
import ClassSelection from "../components/student-application-form/class.selection";
import GelStudentApplicationMain from "../components/student-application-form/gelapplication.form.main";
import SchoolTypeSelection from "../components/student-application-form/schooltype.selection";
export const MainRoutes: Routes = [
......@@ -107,6 +109,8 @@ export const MainRoutes: Routes = [
{ path: "course-order-select", component: CoursesOrderSelect, canActivate: [StudentAuthGuard, StudentLockGuard]},
{ path: "gel-class-select", component: ClassSelection, canActivate: [StudentAuthGuard, StudentLockGuard]},
{ path: "gelstudent-application-form-main", component: GelStudentApplicationMain, canActivate: [StudentAuthGuard, StudentLockGuard] },
{ path: "school-type-select", component: SchoolTypeSelection, canActivate: [StudentAuthGuard, StudentLockGuard]},
];
......@@ -157,5 +161,6 @@ export const MainDeclarations = [
LangCourseFieldsSelect,
CoursesOrderSelect,
ClassSelection,
GelStudentApplicationMain
GelStudentApplicationMain,
SchoolTypeSelection
];
......@@ -14,6 +14,7 @@ import { IElectiveCourseFieldRecord, IElectiveCourseFieldRecords } from "./elect
import { ILangCourseFieldRecord, ILangCourseFieldRecords } from "./langcoursesfields/langcoursesfields.types";
import { IGelClass, IGelClassRecord, IGelClassRecords } from "./gelclasses/gelclasses.types";
import { IGelStudentDataFieldRecord, IGelStudentDataFieldRecords } from "./gelstudentdatafields/gelstudentdatafields.types";
import { ISchoolType, ISchoolTypeRecord, ISchoolTypeRecords } from "./schooltype/schooltype.types";
export {
IAppState,
......@@ -55,7 +56,10 @@ export {
IGelClassRecord,
IGelClassRecords,
IGelStudentDataFieldRecord,
IGelStudentDataFieldRecords
IGelStudentDataFieldRecords,
ISchoolType,
ISchoolTypeRecord,
ISchoolTypeRecords
};
const myLogger = createLogger({
......
import { ISchoolType, ISchoolTypeRecord, ISchoolTypeRecords } from "./schooltype.types";
import { schooltypeReducer } from "./schooltype.reducer";
import { deimmutifySchoolType } from "./schooltype.transformers";
export {
ISchoolType,
ISchoolTypeRecord,
ISchoolTypeRecords,
schooltypeReducer,
deimmutifySchoolType,
};
import { List } from "immutable";
import { ISchoolTypeRecord } from "./schooltype.types";
export const SCHOOLTYPE_INITIAL_STATE = List<ISchoolTypeRecord>();
import { List } from "immutable";
import { recordify } from "typed-immutable-record";
import { SCHOOLTYPE_INIT, SCHOOLTYPE_SAVE, SCHOOLTYPE_RECEIVED, SCHOOLTYPE_RESET } from "../../constants";
import { SCHOOLTYPE_INITIAL_STATE } from "./schooltype.initial-state";
import { ISchoolType, ISchoolTypeRecord, ISchoolTypeRecords } from "./schooltype.types";
export function schooltypeReducer(state: ISchoolTypeRecords = SCHOOLTYPE_INITIAL_STATE, action): ISchoolTypeRecords {
switch (action.type) {
case SCHOOLTYPE_SAVE:
let newSchoolType = Array<ISchoolTypeRecord>();
newSchoolType.push(recordify<ISchoolType, ISchoolTypeRecord>({ id: action.payload.schooltype_id, name: action.payload.schooltype_name}));
return List(newSchoolType);
case SCHOOLTYPE_INIT:
return SCHOOLTYPE_INITIAL_STATE;
default: return state;
}
};
import { ISchoolTypeRecords } from "./schooltype.types";
export function deimmutifySchoolType(state: ISchoolTypeRecords): ISchoolTypeRecords {
return state;
};
import { List } from "immutable";
import { TypedRecord } from "typed-immutable-record";
export interface ISchoolType {
id: number;
name: string;
}
export interface ISchoolTypeRecord extends TypedRecord<ISchoolTypeRecord>, ISchoolType { };
export type ISchoolTypeRecords = List<ISchoolTypeRecord>;
\ No newline at end of file
......@@ -13,6 +13,8 @@ import * as electivecourseFields from "./electivecoursesfields";
import * as langcourseFields from "./langcoursesfields";
import * as gelclasses from "./gelclasses";
import * as gelstudentDataFields from "./gelstudentdatafields";
import * as schooltype from "./schooltype";
export interface IAppState {
sectorFields?: sectorFields.ISectorFieldRecords;
......@@ -28,6 +30,7 @@ export interface IAppState {
langcourseFields?: langcourseFields.ILangCourseFieldRecords;
gelclasses?: gelclasses.IGelClassRecords;
gelstudentDataFields?: gelstudentDataFields.IGelStudentDataFieldRecords;
schooltype?: schooltype.ISchoolTypeRecords
};
export const rootReducer = combineReducers<IAppState>({
......@@ -44,6 +47,7 @@ export const rootReducer = combineReducers<IAppState>({
langcourseFields: langcourseFields.langcourseFieldsReducer,
gelclasses: gelclasses.gelclassesReducer,
gelstudentDataFields: gelstudentDataFields.gelstudentDataFieldsReducer,
schooltype: schooltype.schooltypeReducer,
});
export function deimmutify(state: IAppState): Object {
......@@ -61,5 +65,7 @@ export function deimmutify(state: IAppState): Object {
langcourseFields: langcourseFields.deimmutifyLangCourseFields(state.langcourseFields),
gelclasses: gelclasses.deimmutifyGelClasses(state.gelclasses),
gelstudentdataFields: gelstudentDataFields.deimmutifyGelStudentDataFields(state.gelstudentDataFields),
schooltype: schooltype.deimmutifySchoolType(state.schooltype),
};
}
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