Merge branch 'edge_v4' into 'develop_v4'

Restructured epalclasses

See merge request !242
parents 06f93885 73892c9c
import { SECTORCOURSES_RECEIVED, SECTORCOURSES_SECTOR_SELECTED_SAVE, SECTORCOURSES_SELECTED_SAVE, SECTORCOURSES_INIT } from "../constants";
import { SECTORCOURSES_RECEIVED, SECTORCOURSES_SELECTED_SAVE, SECTORCOURSES_INIT } from "../constants";
import { Injectable } from "@angular/core";
import { NgRedux } from "@angular-redux/store";
import { IAppState } from "../store";
......@@ -33,18 +33,6 @@ export class SectorCoursesActions {
});
};
selectSector = (prevChoice, newChoice) => {
return this._ngRedux.dispatch({
type: SECTORCOURSES_SECTOR_SELECTED_SAVE,
payload: {
prevChoice: prevChoice,
newChoice: newChoice
// sectorCoursesSelected,
// sectorSelected
}
});
}
saveSectorCoursesSelected = (oldSIndex, oldCIndex, checked, i, j) => {
return this._ngRedux.dispatch({
type: SECTORCOURSES_SELECTED_SAVE,
......@@ -54,8 +42,6 @@ export class SectorCoursesActions {
checked: checked,
sIndex: i,
cIndex: j
// sectorCoursesSelected,
// sectorSelected
}
});
};
......
......@@ -11,7 +11,7 @@ import { EpalClassesActions } from "../../actions/epalclass.actions";
import { ISectorFieldRecords } from "../../store/sectorfields/sectorfields.types";
import { ISectorRecords } from "../../store/sectorcourses/sectorcourses.types";
import { IRegionRecord, IRegionRecords, IRegionSchoolRecord } from "../../store/regionschools/regionschools.types";
import { IEpalClasses } from "../../store/epalclasses/epalclasses.types";
import { IEpalClassRecords } from "../../store/epalclasses/epalclasses.types";
import {AppSettings} from "../../app.settings";
import { REGION_SCHOOLS_INITIAL_STATE } from "../../store/regionschools/regionschools.initial-state";
import { EPALCLASSES_INITIAL_STATE } from "../../store/epalclasses/epalclasses.initial-state";
......@@ -27,16 +27,16 @@ import { SECTOR_FIELDS_INITIAL_STATE } from "../../store/sectorfields/sectorfiel
<li class="list-group-item active">
Τάξη φοίτησης στο νέο σχολικό έτος
</li>
<li class="list-group-item" *ngIf="epalclass$.name === '1'">
<li class="list-group-item" *ngIf="epalclass$.get('name') === '1'">
Α’ Λυκείου
</li>
<li class="list-group-item" *ngIf="epalclass$.name === '2'">
<li class="list-group-item" *ngIf="epalclass$.get('name') === '2'">
Β’ Λυκείου
</li>
<li class="list-group-item" *ngIf="epalclass$.name === '3'">
<li class="list-group-item" *ngIf="epalclass$.get('name') === '3'">
Γ’ Λυκείου
</li>
<li class="list-group-item" *ngIf="epalclass$.name === '4'">
<li class="list-group-item" *ngIf="epalclass$.get('name') === '4'">
Δ’ Λυκείου
</li>
......@@ -83,7 +83,7 @@ import { SECTOR_FIELDS_INITIAL_STATE } from "../../store/sectorfields/sectorfiel
private regions$: BehaviorSubject<IRegionRecords>;
private selectedSchools$: BehaviorSubject<Array<IRegionSchoolRecord>> = new BehaviorSubject(Array());
private sectorFields$: BehaviorSubject<ISectorFieldRecords>;
private epalclasses$: BehaviorSubject<IEpalClasses>;
private epalclasses$: BehaviorSubject<IEpalClassRecords>;
private epalclassesSub: Subscription;
private sectorsSub: Subscription;
private regionsSub: Subscription;
......@@ -153,15 +153,15 @@ import { SECTOR_FIELDS_INITIAL_STATE } from "../../store/sectorfields/sectorfiel
this.epalclassesSub = this._ngRedux.select("epalclasses")
.subscribe(epalclasses => {
let ecs = <IEpalClasses>epalclasses;
let ecs = <IEpalClassRecords>epalclasses;
ecs.reduce(({}, epalclass) => {
if (epalclass.name === "Α' Λυκείου")
if (epalclass.get("name") === "Α' Λυκείου")
this.classSelected = 1;
else if (epalclass.name === "Β' Λυκείου")
else if (epalclass.get("name") === "Β' Λυκείου")
this.classSelected = 2;
else if (epalclass.name === "Γ' Λυκείου")
else if (epalclass.get("name") === "Γ' Λυκείου")
this.classSelected = 3;
else if (epalclass.name === "Δ' Λυκείου")
else if (epalclass.get("name") === "Δ' Λυκείου")
this.classSelected = 4;
return epalclass;
}, {});
......@@ -181,19 +181,15 @@ import { SECTOR_FIELDS_INITIAL_STATE } from "../../store/sectorfields/sectorfiel
ngOnDestroy() {
if (this.regionsSub) {
this.regionsSub.unsubscribe();
// this.regions$.unsubscribe();
}
if (this.sectorsSub) {
this.sectorsSub.unsubscribe();
// this.sectors$.unsubscribe();
}
if (this.sectorFieldsSub) {
this.sectorFieldsSub.unsubscribe();
// this.sectorFields$.unsubscribe();
}
if (this.epalclassesSub) {
this.epalclassesSub.unsubscribe();
// this.epalclasses$.unsubscribe();
}
}
......
......@@ -9,7 +9,7 @@ import { IStudentDataFieldRecords } from "../../store/studentdatafields/studentd
import { IRegionRecord, IRegionRecords, IRegionSchoolRecord } from "../../store/regionschools/regionschools.types";
import { ISectorRecords } from "../../store/sectorcourses/sectorcourses.types";
import { ISectorFieldRecords } from "../../store/sectorfields/sectorfields.types";
import { IEpalClasses } from "../../store/epalclasses/epalclasses.types";
import { IEpalClassRecords } from "../../store/epalclasses/epalclasses.types";
import { STUDENT_DATA_FIELDS_INITIAL_STATE } from "../../store/studentdatafields/studentdatafields.initial-state";
import { REGION_SCHOOLS_INITIAL_STATE } from "../../store/regionschools/regionschools.initial-state";
import { EPALCLASSES_INITIAL_STATE } from "../../store/epalclasses/epalclasses.initial-state";
......@@ -124,7 +124,7 @@ import { HelperDataService } from "../../services/helper-data-service";
private classSelected;
private totalPoints = <number>0;
private studentDataFields$: BehaviorSubject<IStudentDataFieldRecords>;
private epalclasses$: BehaviorSubject<IEpalClasses>;
private epalclasses$: BehaviorSubject<IEpalClassRecords>;
private loginInfo$: BehaviorSubject<ILoginInfo>;
private studentDataFieldsSub: Subscription;
private regionsSub: Subscription;
......@@ -191,15 +191,14 @@ import { HelperDataService } from "../../services/helper-data-service";
this.loginInfo$.next(linfo);
}, error => { console.log("error selecting loginInfo"); });
this.epalclassesSub = this._ngRedux.select("epalclasses").subscribe(epalclasses => {
let ecs = <IEpalClasses>epalclasses;
this.epalclassesSub = this._ngRedux.select("epalclasses")
.map(epalClasses => <IEpalClassRecords>epalClasses)
.subscribe(ecs => {
console.log("SELECTOR4");
if (ecs.size > 0) {
ecs.reduce(({ }, epalclass) => {
this.classSelected = epalclass.name;
this.classSelected = epalclass.get("name");
return epalclass;
}, {});
}
this.epalclasses$.next(ecs);
}, error => { console.log("error selecting epalclasses"); });
......
......@@ -4,7 +4,7 @@ import { BehaviorSubject, Subscription } from "rxjs/Rx";
import { Injectable } from "@angular/core";
import { EpalClassesActions } from "../../actions/epalclass.actions";
import { NgRedux, select } from "@angular-redux/store";
import { IEpalClasses } from "../../store/epalclasses/epalclasses.types";
import { IEpalClassRecords } from "../../store/epalclasses/epalclasses.types";
import { SectorFieldsActions } from "../../actions/sectorfields.actions";
import { RegionSchoolsActions } from "../../actions/regionschools.actions";
import { SectorCoursesActions } from "../../actions/sectorcourses.actions";
......@@ -77,7 +77,7 @@ import {AppSettings} from "../../app.settings";
})
@Injectable() export default class EpalClassesSelect implements OnInit, OnDestroy {
private epalclasses$: BehaviorSubject<IEpalClasses>;
private epalclasses$: BehaviorSubject<IEpalClassRecords>;
private epalclassesSub: Subscription;
private formGroup: FormGroup;
......@@ -106,11 +106,11 @@ import {AppSettings} from "../../app.settings";
ngOnInit() {
(<any>$("#epalClassNotice")).appendTo("body");
this.epalclassesSub = this._ngRedux.select("epalclasses")
.subscribe(epalclasses => {
let ecs = <IEpalClasses>epalclasses;
.map(epalClasses => <IEpalClassRecords>epalClasses)
.subscribe(ecs => {
if (ecs.size > 0) {
ecs.reduce(({}, epalclass) => {
this.formGroup.setValue(epalclass);
this.formGroup.controls["name"].setValue(epalclass.get("name"));
return epalclass;
}, {});
} else {
......
......@@ -9,7 +9,7 @@ import { REGION_SCHOOLS_INITIAL_STATE } from "../../store/regionschools/regionsc
import { ISectorRecords } from "../../store/sectorcourses/sectorcourses.types";
import { IAppState } from "../../store/store";
import { RemoveSpaces } from "../../pipes/removespaces";
import { IEpalClasses } from "../../store/epalclasses/epalclasses.types";
import { IEpalClassRecords } from "../../store/epalclasses/epalclasses.types";
import { ISectorFieldRecords } from "../../store/sectorfields/sectorfields.types";
......@@ -190,16 +190,15 @@ import {AppSettings} from "../../app.settings";
selectEpalClasses() {
this.epalclassesSub = this._ngRedux.select("epalclasses")
.subscribe(epalclasses => {
console.log(epalclasses);
let ecs = <IEpalClasses>epalclasses;
.map(epalClasses => <IEpalClassRecords>epalClasses)
.subscribe(ecs => {
if (ecs.size > 0) {
ecs.reduce(({}, epalclass, i) => {
this.setClassActive(epalclass.name);
if (epalclass.name === "4") {
this.setClassActive(epalclass.get("name"));
if (epalclass.get("name") === "4") {
this.classNight.next(true);
}
this.getAppropriateSchools(epalclass.name);
this.getAppropriateSchools(epalclass.get("name"));
return epalclass;
}, {});
}
......
......@@ -98,7 +98,6 @@ import {AppSettings} from "../../app.settings";
private courseSelectedPrev = <number>-1;
private idx = <number>-1;
private idxPrev = <number>-1;
private sectorsList: Array<boolean> = new Array();
private modalTitle: BehaviorSubject<string>;
private modalText: BehaviorSubject<string>;
private modalHeader: BehaviorSubject<string>;
......@@ -134,24 +133,18 @@ import {AppSettings} from "../../app.settings";
pushControls = true;
scs.reduce((prevSector, sector) => {
this.sectorsList[ids] = sector.get("sector_selected");
// In case we want to preserve last checked option when we revisit the form
if (sector.get("sector_selected") === true)
this.sectorActive = ids;
sector.get("courses").reduce((prevCourse, course) => {
if (pushControls)
this.scsControls.push(new FormControl(course.get("selected"), []));
// this.retrieveCheck();
if (course.get("selected") === true) {
// In case we want to preserve last checked option when we revisit the form
this.sectorBelongingPrev = this.sectorBelonging;
this.sectorBelonging = ids;
this.courseSelectedPrev = this.courseSelected;
this.courseSelected = idc;
this.idxPrev = this.idx;
this.idx = course.get("globalIndex");
}
idc++;
return course;
......@@ -184,7 +177,6 @@ import {AppSettings} from "../../app.settings";
}
setActiveSector(ind) {
// this._sca.selectSector(this.sectorActive, ind);
this.sectorActive = ind;
}
......@@ -208,15 +200,14 @@ import {AppSettings} from "../../app.settings";
this.idxPrev = this.idx;
this.idx = globalIndex;
/* for (let i = 0; i < this.formGroup.value.formArray.length; i++)
this.formGroup.value.formArray[i] = false; */
if (this.idxPrev >= 0)
this.formGroup.value.formArray[this.idxPrev] = false;
if (this.idx >= 0)
this.formGroup.value.formArray[globalIndex] = cb.checked;
this._sca.saveSectorCoursesSelected(this.sectorBelongingPrev, this.courseSelectedPrev, cb.checked, i, j);
if (cb.checked === false) {
this.idxPrev = -1;
this.idx = -1;
......@@ -224,11 +215,6 @@ import {AppSettings} from "../../app.settings";
this._rsa.initRegionSchools();
/* for (let i = 0; i < this.sectorsList.length; i++)
this.sectorsList[i] = false;
this.sectorsList[this.sectorActive] = true; */
// this.saveSelected();
}
}
......@@ -16,7 +16,6 @@ export const REGIONSCHOOLS_INIT = "REGIONSCHOOLS_INIT";
export const SECTORCOURSES_RECEIVED = "SECTORCOURSES_RECEIVED";
export const SECTORCOURSES_SELECTED_SAVE = "SECTORCOURSES_SELECTED_SAVE";
export const SECTORCOURSES_SECTOR_SELECTED_SAVE = "SECTORCOURSES_SECTOR_SELECTED_SAVE";
export const SECTORCOURSES_INIT = "SECTORCOURSES_INIT";
export const STUDENTDATAFIELDS_SAVE = "STUDENTDATAFIELDS_SAVE";
......
import { List } from "immutable";
import { IEpalClass} from "./epalclasses.types";
import { IEpalClassRecord} from "./epalclasses.types";
export const EPALCLASSES_INITIAL_STATE = List<IEpalClass>();
export const EPALCLASSES_INITIAL_STATE = List<IEpalClassRecord>();
import { IEpalClasses, IEpalClass } from "./epalclasses.types";
import { IEpalClassRecords, IEpalClass, IEpalClassRecord } from "./epalclasses.types";
import { EPALCLASSES_INITIAL_STATE } from "./epalclasses.initial-state";
import { Seq } from "immutable";
import { List } from "immutable";
import {recordify} from "typed-immutable-record";
import { EPALCLASSES_SAVE, EPALCLASSES_INIT } from "../../constants";
export function epalclassesReducer(state: IEpalClasses = EPALCLASSES_INITIAL_STATE, action): IEpalClasses {
export function epalclassesReducer(state: IEpalClassRecords = EPALCLASSES_INITIAL_STATE, action): IEpalClassRecords {
switch (action.type) {
case EPALCLASSES_SAVE:
let selectedEpalClasses = Array<IEpalClass>();
selectedEpalClasses.push(<IEpalClass>{ name: action.payload.epalClasses.name });
return Seq(selectedEpalClasses).map(n => n).toList();
let newEpalClasses = Array<IEpalClassRecord>();
newEpalClasses.push(recordify<IEpalClass, IEpalClassRecord>({ name: action.payload.epalClasses.name }));
return List(newEpalClasses);
case EPALCLASSES_INIT:
return EPALCLASSES_INITIAL_STATE;
default: return state;
......
import { IEpalClasses, IEpalClass } from "./epalclasses.types";
import { IEpalClassRecords } from "./epalclasses.types";
export function deimmutifyEpalClasses(state: IEpalClasses): IEpalClass[] {
let fetchedEpalClasses = new Array();
state.forEach(epalclass => {
fetchedEpalClasses.push(<IEpalClass>{ name: epalclass.name });
});
return fetchedEpalClasses;
export function deimmutifyEpalClasses(state: IEpalClassRecords): IEpalClassRecords {
return state;
};
import { List } from "immutable";
import {TypedRecord} from "typed-immutable-record";
export interface IEpalClass {
// id: number;
name: string;
}
export type IEpalClasses = List<IEpalClass>;
export interface IEpalClassRecord extends TypedRecord<IEpalClassRecord>, IEpalClass { };
export type IEpalClassRecords = List<IEpalClassRecord>;
import { IEpalClass, IEpalClasses } from "./epalclasses.types";
import { IEpalClass, IEpalClassRecords, IEpalClassRecord } from "./epalclasses.types";
import { epalclassesReducer } from "./epalclasses.reducer";
import { deimmutifyEpalClasses } from "./epalclasses.transformers";
export {
IEpalClass,
IEpalClasses,
IEpalClassRecords,
IEpalClassRecord,
epalclassesReducer,
deimmutifyEpalClasses,
};
......@@ -5,7 +5,7 @@ import { ISectorFieldRecord, ISectorFieldRecords } from "./sectorfields/sectorfi
import { IRRegion, IRRegionSchool, IRegionRecord, IRegionRecords, IRegionSchoolRecord, IRegionSchoolRecords } from "./regionschools/regionschools.types";
import { ISectorRecords, ISectorRecord, ISector, ISectorCourseRecords, ISectorCourseRecord, ISectorCourse } from "./sectorcourses/sectorcourses.types";
import { IStudentDataFieldRecord, IStudentDataFieldRecords } from "./studentdatafields/studentdatafields.types";
import { IEpalClass, IEpalClasses } from "./epalclasses/epalclasses.types";
import { IEpalClass, IEpalClassRecord, IEpalClassRecords } from "./epalclasses/epalclasses.types";
import { ILoginInfoToken, ILoginInfo } from "./logininfo/logininfo.types";
export {
......@@ -28,7 +28,8 @@ ISectorCourse,
IStudentDataFieldRecord,
IStudentDataFieldRecords,
IEpalClass,
IEpalClasses,
IEpalClassRecord,
IEpalClassRecords,
ILoginInfo,
};
......
......@@ -5,7 +5,6 @@ import {recordify} from "typed-immutable-record";
import {
SECTORCOURSES_RECEIVED,
SECTORCOURSES_SECTOR_SELECTED_SAVE,
SECTORCOURSES_SELECTED_SAVE,
SECTORCOURSES_INIT
} from "../../constants";
......@@ -29,14 +28,6 @@ export function sectorCoursesReducer(state: ISectorRecords = SECTOR_COURSES_INIT
});
return List(newSectors);
case SECTORCOURSES_SECTOR_SELECTED_SAVE:
return state.withMutations(function(list) {
if (action.payload.prevChoice >= 0)
list.setIn([action.payload.prevChoice, "sector_selected"], false);
if (action.payload.newChoice >= 0)
list.setIn([action.payload.newChoice, "sector_selected"], true);
});
case SECTORCOURSES_SELECTED_SAVE:
return state.withMutations(function(list) {
list.setIn([action.payload.oldSIndex, "sector_selected"], false);
......@@ -45,19 +36,6 @@ export function sectorCoursesReducer(state: ISectorRecords = SECTOR_COURSES_INIT
list.setIn([action.payload.sIndex, "courses"], list.get(action.payload.sIndex).get("courses").setIn([action.payload.cIndex, "selected"], action.payload.checked));
});
/* let sectorsWithSelections = Array<ISector>();
let ind = 0;
j = 0;
state.forEach(sector => {
sectorsWithSelections.push(<ISector>{ sector_id: sector.sector_id, sector_name: sector.sector_name, sector_selected: action.payload.sectorSelected[ind], courses: Array<ISectorCourse>() });
sector.courses.forEach(course => {
sectorsWithSelections[ind].courses.push(<ISectorCourse>{ course_id: course.course_id, course_name: course.course_name, globalIndex: course.globalIndex, selected: action.payload.sectorCoursesSelected[j] });
j++;
});
ind++;
});
return Seq(sectorsWithSelections).map(n => n).toList(); */
case SECTORCOURSES_INIT:
return SECTOR_COURSES_INITIAL_STATE;
default: return state;
......
......@@ -9,4 +9,3 @@ export interface ISectorField {
export interface ISectorFieldRecord extends TypedRecord<ISectorFieldRecord>, ISectorField { };
export type ISectorFieldRecords = List<ISectorFieldRecord>;
// export type ISectorFields = List<ISectorField>;
......@@ -11,7 +11,7 @@ export interface IAppState {
regions?: regions.IRegionRecords;
sectors?: sectors.ISectorRecords;
studentDataFields?: studentDataFields.IStudentDataFieldRecords;
epalclasses?: epalclasses.IEpalClasses;
epalclasses?: epalclasses.IEpalClassRecords;
loginInfo?: loginInfo.ILoginInfo;
};
......
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