Merge branch 'edge_v4' into 'develop_v4'

Restructured ISectors

See merge request !241
parents b4746228 e0a77286
import { SECTORCOURSES_RECEIVED, SECTORCOURSES_SELECTED_SAVE, SECTORCOURSES_INIT } from "../constants";
import { SECTORCOURSES_RECEIVED, SECTORCOURSES_SECTOR_SELECTED_SAVE, SECTORCOURSES_SELECTED_SAVE, SECTORCOURSES_INIT } from "../constants";
import { Injectable } from "@angular/core";
import { NgRedux } from "@angular-redux/store";
import { IAppState } from "../store";
......@@ -33,12 +33,29 @@ export class SectorCoursesActions {
});
};
saveSectorCoursesSelected = (sectorCoursesSelected, sectorSelected) => {
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,
payload: {
sectorCoursesSelected,
sectorSelected
oldSIndex: oldSIndex,
oldCIndex: oldCIndex,
checked: checked,
sIndex: i,
cIndex: j
// sectorCoursesSelected,
// sectorSelected
}
});
};
......
......@@ -9,7 +9,7 @@ import { SectorCoursesActions } from "../../actions/sectorcourses.actions";
import { RegionSchoolsActions } from "../../actions/regionschools.actions";
import { EpalClassesActions } from "../../actions/epalclass.actions";
import { ISectorFieldRecords } from "../../store/sectorfields/sectorfields.types";
import { ISectors } from "../../store/sectorcourses/sectorcourses.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 {AppSettings} from "../../app.settings";
......@@ -45,21 +45,21 @@ import { SECTOR_FIELDS_INITIAL_STATE } from "../../store/sectorfields/sectorfiel
<div *ngFor="let sectorField$ of sectorFields$ | async">
<ul class="list-group left-side-view">
<li class="list-group-item active" *ngIf="sectorField$.selected === true" >
{{sectorField$.name}}
<li class="list-group-item active" *ngIf="sectorField$.get('selected') === true" >
{{sectorField$.get("name")}}
</li>
</ul>
</div>
<div *ngFor="let sector$ of sectors$ | async;">
<ul class="list-group left-side-view" style="margin-bottom: 20px;" *ngIf="sector$.sector_selected === true">
<li class="list-group-item active" *ngIf="sector$.sector_selected === true" >
{{sector$.sector_name }}
<ul class="list-group left-side-view" style="margin-bottom: 20px;" *ngIf="sector$.get('sector_selected') === true">
<li class="list-group-item active" *ngIf="sector$.get('sector_selected') === true" >
{{sector$.get("sector_name") }}
</li>
<div *ngFor="let course$ of sector$.courses;" >
<li class="list-group-item" *ngIf="course$.selected === true">
{{course$.course_name }}
{{course$.get("course_name") }}
</li>
</div>
......@@ -79,7 +79,7 @@ import { SECTOR_FIELDS_INITIAL_STATE } from "../../store/sectorfields/sectorfiel
})
@Injectable() export default class ApplicationPreview implements OnInit {
private sectors$: BehaviorSubject<ISectors>;
private sectors$: BehaviorSubject<ISectorRecords>;
private regions$: BehaviorSubject<IRegionRecords>;
private selectedSchools$: BehaviorSubject<Array<IRegionSchoolRecord>> = new BehaviorSubject(Array());
private sectorFields$: BehaviorSubject<ISectorFieldRecords>;
......@@ -108,12 +108,12 @@ import { SECTOR_FIELDS_INITIAL_STATE } from "../../store/sectorfields/sectorfiel
ngOnInit() {
this.currentUrl = this.router.url;
this.sectorsSub = this._ngRedux.select("sectors")
.subscribe(sectors => {
let scs = <ISectors>sectors;
.map(sectors => <ISectorRecords>sectors)
.subscribe(scs => {
scs.reduce((prevSector, sector) => {
sector.courses.reduce((prevCourse, course) => {
if (course.selected === true) {
this.courseActive = course.course_id;
sector.get("courses").reduce((prevCourse, course) => {
if (course.get("selected") === true) {
this.courseActive = course.get("course_id");
}
return course;
......
......@@ -7,7 +7,7 @@ import { NgRedux, select } from "@angular-redux/store";
import { IAppState } from "../../store/store";
import { IStudentDataFieldRecords } from "../../store/studentdatafields/studentdatafields.types";
import { IRegionRecord, IRegionRecords, IRegionSchoolRecord } from "../../store/regionschools/regionschools.types";
import { ISectors } from "../../store/sectorcourses/sectorcourses.types";
import { ISectorRecords } from "../../store/sectorcourses/sectorcourses.types";
import { ISectorFieldRecords } from "../../store/sectorfields/sectorfields.types";
import { IEpalClasses } from "../../store/epalclasses/epalclasses.types";
import { STUDENT_DATA_FIELDS_INITIAL_STATE } from "../../store/studentdatafields/studentdatafields.initial-state";
......@@ -235,13 +235,13 @@ import { HelperDataService } from "../../services/helper-data-service";
this.sectorsSub = this._ngRedux.select("sectors")
.subscribe(sectors => {
let scs = <ISectors>sectors;
.map(sectors => <ISectorRecords>sectors)
.subscribe(scs => {
console.log("SELECTOR2");
scs.reduce((prevSector, sector) => {
sector.courses.reduce((prevCourse, course) => {
if (course.selected === true) {
this.courseSelected = course.course_id;
sector.get("courses").reduce((prevCourse, course) => {
if (course.get("selected") === true) {
this.courseSelected = course.get("course_id");
}
return course;
}, {});
......
......@@ -6,7 +6,7 @@ import { RegionSchoolsActions } from "../../actions/regionschools.actions";
import { NgRedux, select } from "@angular-redux/store";
import { IRegionRecord, IRegionRecords } from "../../store/regionschools/regionschools.types";
import { REGION_SCHOOLS_INITIAL_STATE } from "../../store/regionschools/regionschools.initial-state";
import { ISectors } from "../../store/sectorcourses/sectorcourses.types";
import { ISectorRecords } from "../../store/sectorcourses/sectorcourses.types";
import { IAppState } from "../../store/store";
import { RemoveSpaces } from "../../pipes/removespaces";
import { IEpalClasses } from "../../store/epalclasses/epalclasses.types";
......@@ -277,14 +277,14 @@ import {AppSettings} from "../../app.settings";
else if (epalClass === "3" || epalClass === "4") {
this.sectorsSub = this._ngRedux.select("sectors")
.map(sectors => <ISectors>sectors)
.map(sectors => <ISectorRecords>sectors)
.subscribe(sectors => {
console.log("sectorsSub");
sectors.reduce((prevSector, sector) => {
if (sector.sector_selected === true) {
sector.courses.reduce((prevCourse, course) => {
if (course.selected === true) {
this.courseActive = parseInt(course.course_id);
if (sector.get("sector_selected") === true) {
sector.get("courses").reduce((prevCourse, course) => {
if (course.get("selected") === true) {
this.courseActive = parseInt(course.get("course_id"));
// this._rsa.getRegionSchools(3,this.courseActive, false);
this._rsa.getRegionSchools(parseInt(epalClass), this.courseActive, false);
}
......
......@@ -3,7 +3,7 @@ import { Router } from "@angular/router";
import { BehaviorSubject, Subscription } from "rxjs/Rx";
import { Injectable } from "@angular/core";
import { SectorCoursesActions } from "../../actions/sectorcourses.actions";
import { ISectors } from "../../store/sectorcourses/sectorcourses.types";
import { ISectorRecords } from "../../store/sectorcourses/sectorcourses.types";
import { SECTOR_COURSES_INITIAL_STATE } from "../../store/sectorcourses/sectorcourses.initial-state";
import { NgRedux, select } from "@angular-redux/store";
import { IAppState } from "../../store/store";
......@@ -52,20 +52,20 @@ import {AppSettings} from "../../app.settings";
<ul class="list-group">
<div *ngFor="let sector$ of sectors$ | async; let i=index; let isOdd=odd; let isEven=even">
<li class="list-group-item isclickable" (click)="setActiveSector(i)" [class.oddout]="isOdd" [class.evenout]="isEven" [class.selectedout]="sectorActive === i">
<h5>{{sector$.sector_name}}</h5>
<h5>{{sector$.get("sector_name")}}</h5>
</li>
<div *ngFor="let course$ of sector$.courses; let j=index; let isOdd2=odd; let isEven2=even" [class.oddin]="isOdd2" [class.evenin]="isEven2" [hidden]="i !== sectorActive">
<div class="row">
<div *ngFor="let course$ of sector$.get('courses'); let j=index; let isOdd2=odd; let isEven2=even" [class.oddin]="isOdd2" [class.evenin]="isEven2" [hidden]="i !== sectorActive">
<div class="row">
<div class="col-md-2 col-md-offset-1">
<input #cb type="checkbox" formControlName="{{ course$.globalIndex }}"
(change)="updateCheckedOptions(course$.globalIndex, cb)"
[checked] = " course$.globalIndex === idx "
<input #cb type="checkbox" formControlName="{{ course$.get('globalIndex') }}"
(change)="updateCheckedOptions(course$.get('globalIndex'), i, j, cb)"
[checked] = " course$.get('globalIndex') === idx "
>
</div>
<div class="col-md-8 col-md-offset-1 isclickable">
{{course$.course_name | removeSpaces}}
</div>
</div>
</div>
</div>
</div>
</ul>
......@@ -87,12 +87,17 @@ import {AppSettings} from "../../app.settings";
`
})
@Injectable() export default class SectorCoursesSelect implements OnInit, OnDestroy {
private sectors$: BehaviorSubject<ISectors>;
private sectors$: BehaviorSubject<ISectorRecords>;
private sectorsSub: Subscription;
private formGroup: FormGroup;
private rss = new FormArray([]);
private scsControls = new FormArray([]);
private sectorActive = <number>-1;
private sectorBelonging = <number>-1;
private sectorBelongingPrev = <number>-1;
private courseSelected = <number>-1;
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>;
......@@ -108,7 +113,7 @@ import {AppSettings} from "../../app.settings";
this.sectors$ = new BehaviorSubject(SECTOR_COURSES_INITIAL_STATE);
this.formGroup = this.fb.group({
formArray: this.rss
formArray: this.scsControls
});
this.modalTitle = new BehaviorSubject("");
this.modalText = new BehaviorSubject("");
......@@ -119,31 +124,46 @@ import {AppSettings} from "../../app.settings";
ngOnInit() {
(<any>$("#sectorCourseNotice")).appendTo("body");
this._sca.getSectorCourses(false);
let ids = 0;
this.sectorsSub = this._ngRedux.select("sectors").subscribe(sectors => {
let scs = <ISectors>sectors;
scs.reduce((prevSector, sector) => {
this.sectorsList[ids] = sector.sector_selected;
ids++;
// In case we want to preserve last checked option when we revisit the form
if (sector.sector_selected === true)
this.sectorActive = ids - 1;
sector.courses.reduce((prevCourse, course) => {
this.rss.push(new FormControl(course.selected, []));
// this.retrieveCheck();
if (course.selected === true) {
// In case we want to preserve last checked option when we revisit the form
this.idx = course.globalIndex;
}
return course;
let ids = 0, idc = 0;
this.sectorsSub = this._ngRedux.select("sectors")
.map(sectors => <ISectorRecords>sectors)
.subscribe(scs => {
let pushControls = false;
if (this.scsControls.length === 0)
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;
}, {});
ids++;
idc = 0;
return sector;
}, {});
return sector;
}, {});
ids = 0;
this.sectors$.next(scs);
}, error => { console.log("error selecting sectors"); });
}
ids = 0;
this.sectors$.next(scs);
}, error => { console.log("error selecting sectors"); });
};
ngOnDestroy() {
(<any>$("#sectorCourseNotice")).remove();
......@@ -164,17 +184,10 @@ import {AppSettings} from "../../app.settings";
}
setActiveSector(ind) {
if (ind === this.sectorActive)
ind = -1;
// this._sca.selectSector(this.sectorActive, ind);
this.sectorActive = ind;
}
saveSelected() {
this._sca.saveSectorCoursesSelected(this.formGroup.value.formArray, this.sectorsList);
this._rsa.initRegionSchools();
}
navigateToSchools() {
if (this.idx === -1) {
......@@ -187,19 +200,35 @@ import {AppSettings} from "../../app.settings";
}
}
updateCheckedOptions(globalIndex, cb) {
updateCheckedOptions(globalIndex, i, j, cb) {
this.sectorBelongingPrev = this.sectorBelonging;
this.sectorBelonging = i;
this.courseSelectedPrev = this.courseSelected;
this.courseSelected = j;
this.idxPrev = this.idx;
this.idx = globalIndex;
for (let i = 0; i < this.formGroup.value.formArray.length; i++)
this.formGroup.value.formArray[i] = false;
this.formGroup.value.formArray[globalIndex] = cb.checked;
if (cb.checked === false)
/* 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;
}
this._rsa.initRegionSchools();
for (let i = 0; i < this.sectorsList.length; i++)
/* for (let i = 0; i < this.sectorsList.length; i++)
this.sectorsList[i] = false;
this.sectorsList[this.sectorActive] = true;
this.sectorsList[this.sectorActive] = true; */
this.saveSelected();
// this.saveSelected();
}
}
......@@ -16,6 +16,7 @@ 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";
......
......@@ -4,7 +4,7 @@ import { BehaviorSubject, Subscription } from "rxjs/Rx";
import "rxjs/add/operator/map";
import { ISectorField } from "../store/sectorfields/sectorfields.types";
import { IRegionRecord, IRegionSchoolRecord, IRRegion, IRRegionSchool } from "../store/regionschools/regionschools.types";
import { ISector, ISectors, ISectorCourse } from "../store/sectorcourses/sectorcourses.types";
import { ISectorRecord, ISectorRecords, ISectorCourse } from "../store/sectorcourses/sectorcourses.types";
import { AppSettings } from "../app.settings";
import { NgRedux, select } from "@angular-redux/store";
import { IAppState } from "../store/store";
......@@ -276,7 +276,7 @@ export class HelperDataService implements OnInit, OnDestroy {
}
transformSectorCoursesSchema(sectorCourses: any) {
let rsa = Array<ISector>();
let rsa = Array<any>();
let trackSectorId: string;
let trackIndex: number;
......@@ -287,7 +287,7 @@ export class HelperDataService implements OnInit, OnDestroy {
sectorCourses.forEach(sectorCourse => {
if (trackSectorId !== sectorCourse.sector_id) {
trackIndex++;
rsa.push(<ISector>{ "sector_id": sectorCourse.sector_id, "sector_name": sectorCourse.sector_name, "sector_selected": false, "courses": Array<ISectorCourse>() });
rsa.push(<any>{ "sector_id": sectorCourse.sector_id, "sector_name": sectorCourse.sector_name, "sector_selected": false, "courses": Array<any>() });
trackSectorId = sectorCourse.sector_id;
}
rsa[trackIndex].courses.push(<ISectorCourse>{ "course_id": sectorCourse.course_id, "course_name": sectorCourse.course_name, "globalIndex": j, "selected": false });
......
......@@ -3,7 +3,7 @@ import {createLogger} from "redux-logger";
import { IAppState, rootReducer, deimmutify } from "./store";
import { ISectorFieldRecord, ISectorFieldRecords } from "./sectorfields/sectorfields.types";
import { IRRegion, IRRegionSchool, IRegionRecord, IRegionRecords, IRegionSchoolRecord, IRegionSchoolRecords } from "./regionschools/regionschools.types";
import { ISectors, ISector, ISectorCourse } from "./sectorcourses/sectorcourses.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 { ILoginInfoToken, ILoginInfo } from "./logininfo/logininfo.types";
......@@ -19,8 +19,11 @@ IRegionRecords,
IRegionSchoolRecord,
IRegionSchoolRecords,
IRRegionSchool,
ISectors,
ISectorRecords,
ISectorRecord,
ISector,
ISectorCourseRecords,
ISectorCourseRecord,
ISectorCourse,
IStudentDataFieldRecord,
IStudentDataFieldRecords,
......
import { List } from "immutable";
import { IRegionRecord, IRRegion, IRRegionSchool, IRegionSchoolRecord, IRegionSchoolRecords } from "./regionschools.types";
import {recordify} from "typed-immutable-record";
import { IRegionRecord } from "./regionschools.types";
export const REGION_SCHOOLS_INITIAL_STATE = List<IRegionRecord>();
import { IRRegion, IRRegionSchool, IRegionSchoolRecord, IRegionSchoolRecords, IRegionRecord, IRegionRecords } from "./regionschools.types";
import { REGION_SCHOOLS_INITIAL_STATE } from "./regionschools.initial-state";
import { Seq, Map, fromJS, List } from "immutable";
import { List } from "immutable";
import {recordify} from "typed-immutable-record";
import {
......@@ -29,10 +29,8 @@ export function regionSchoolsReducer(state: IRegionRecords = REGION_SCHOOLS_INIT
});
return List(newRegions);
case REGIONSCHOOLS_SELECTED_SAVE:
let ind = 0;
return state.withMutations(function(list) {
list.setIn([action.payload.rIndex, "epals"], state.get(action.payload.rIndex).get("epals").setIn([action.payload.sIndex, "selected"], action.payload.checked));
list.setIn([action.payload.rIndex, "epals"], list.get(action.payload.rIndex).get("epals").setIn([action.payload.sIndex, "selected"], action.payload.checked));
});
case REGIONSCHOOLS_ORDER_SAVE:
......
import { ISectors, ISector, ISectorCourse } from "./sectorcourses.types";
import { ISectorRecords, ISectorRecord, ISector, ISectorCourseRecords, ISectorCourseRecord, ISectorCourse } from "./sectorcourses.types";
import { sectorCoursesReducer } from "./sectorcourses.reducer";
import { deimmutifySectorCourses } from "./sectorcourses.transformers";
export {
ISectorRecords,
ISectorRecord,
ISector,
ISectors,
ISectorCourseRecords,
ISectorCourseRecord,
ISectorCourse,
sectorCoursesReducer,
deimmutifySectorCourses,
......
import { List } from "immutable";
import { ISector } from "./sectorcourses.types";
import { ISectorRecord } from "./sectorcourses.types";
export const SECTOR_COURSES_INITIAL_STATE = List<ISector>();
export const SECTOR_COURSES_INITIAL_STATE = List<ISectorRecord>();
import { ISectors, ISector, ISectorCourse } from "./sectorcourses.types";
import { ISectorRecords, ISectorRecord, ISectorCourseRecord, ISector, ISectorCourse } from "./sectorcourses.types";
import { SECTOR_COURSES_INITIAL_STATE } from "./sectorcourses.initial-state";
import { Seq } from "immutable";
import { List } from "immutable";
import {recordify} from "typed-immutable-record";
import {
SECTORCOURSES_RECEIVED,
SECTORCOURSES_SECTOR_SELECTED_SAVE,
SECTORCOURSES_SELECTED_SAVE,
SECTORCOURSES_INIT
} from "../../constants";
export function sectorCoursesReducer(state: ISectors = SECTOR_COURSES_INITIAL_STATE, action): ISectors {
export function sectorCoursesReducer(state: ISectorRecords = SECTOR_COURSES_INITIAL_STATE, action): ISectorRecords {
switch (action.type) {
case SECTORCOURSES_RECEIVED:
let newSectors = Array<ISector>();
let i = 0;
action.payload.sectors.forEach(sector => {
newSectors.push(<ISector>{ sector_id: sector.sector_id, sector_name: sector.sector_name, sector_selected: sector.sector_selected, courses: Array<ISectorCourse>() });
sector.courses.forEach(course => {
newSectors[i].courses.push(<ISectorCourse>{ course_id: course.course_id, course_name: course.course_name, globalIndex: course.globalIndex, selected: course.selected });
});
i++;
let newSectors = Array<ISectorRecord>();
let newCourses = Array<ISectorCourseRecord>();
let i = 0, j = 0;
let ii = 0;
action.payload.sectors.forEach(sector => {
sector.courses.forEach(course => {
newCourses.push(recordify<ISectorCourse, ISectorCourseRecord>({ course_id: course.course_id, course_name: course.course_name, globalIndex: course.globalIndex, selected: course.selected }));
ii++;
});
newSectors.push(recordify<ISector, ISectorRecord>({ sector_id: sector.sector_id, sector_name: sector.sector_name, sector_selected: sector.sector_selected, courses: List(newCourses) }));
newCourses = Array<ISectorCourseRecord>();
i++;
});
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);
});
return Seq(newSectors).map(n => n).toList();
case SECTORCOURSES_SELECTED_SAVE:
let sectorsWithSelections = Array<ISector>();
let ind = 0, j = 0;
return state.withMutations(function(list) {
list.setIn([action.payload.oldSIndex, "sector_selected"], false);
list.setIn([action.payload.sIndex, "sector_selected"], true);
list.setIn([action.payload.oldSIndex, "courses"], list.get(action.payload.oldSIndex).get("courses").setIn([action.payload.oldCIndex, "selected"], false));
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 => {
......@@ -33,7 +57,7 @@ export function sectorCoursesReducer(state: ISectors = SECTOR_COURSES_INITIAL_ST
});
ind++;
});
return Seq(sectorsWithSelections).map(n => n).toList();
return Seq(sectorsWithSelections).map(n => n).toList(); */
case SECTORCOURSES_INIT:
return SECTOR_COURSES_INITIAL_STATE;
default: return state;
......
import { ISectors, ISector, ISectorCourse } from "./sectorcourses.types";
import { ISectorRecords } from "./sectorcourses.types";
export function deimmutifySectorCourses(state: ISectors): ISector[] {
let fetchedSectors = new Array<ISector>();
let i = 0;
state.forEach(sector => {
fetchedSectors.push(<ISector>{ sector_id: sector.sector_id, sector_name: sector.sector_name, sector_selected: sector.sector_selected, courses: Array<ISectorCourse>() });
sector.courses.forEach(course => {
fetchedSectors[i].courses.push(<ISectorCourse>{ course_id: course.course_id, course_name: course.course_name, globalIndex: course.globalIndex, selected: course.selected });
});
i++;
});
return fetchedSectors;
export function deimmutifySectorCourses(state: ISectorRecords): ISectorRecords {
return state;
};
import { List } from "immutable";
import {TypedRecord} from "typed-immutable-record";
export interface ISector {
sector_id: string;
sector_name: string;
sector_selected: boolean;
courses: ISectorCourse[];
courses: List<ISectorCourse>;
}
export interface ISectorCourse {
......@@ -14,4 +15,7 @@ export interface ISectorCourse {
selected: boolean;
}
export type ISectors = List<ISector>;
export interface ISectorRecord extends TypedRecord<ISectorRecord>, ISector { };
export type ISectorRecords = List<ISectorRecord>;
export interface ISectorCourseRecord extends TypedRecord<ISectorCourseRecord>, ISectorCourse { };
export type ISectorCourseRecords = List<ISectorCourseRecord>;
......@@ -9,7 +9,7 @@ import * as loginInfo from "./logininfo";
export interface IAppState {
sectorFields?: sectorFields.ISectorFieldRecords;
regions?: regions.IRegionRecords;
sectors?: sectors.ISectors;
sectors?: sectors.ISectorRecords;
studentDataFields?: studentDataFields.IStudentDataFieldRecords;
epalclasses?: epalclasses.IEpalClasses;
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