Merge branch 'edge_v4' into 'develop_v4'

Restructured IStudentDataFields

See merge request !240
parents 5cee655c f109b9cf
...@@ -4,7 +4,7 @@ import { Injectable } from "@angular/core"; ...@@ -4,7 +4,7 @@ import { Injectable } from "@angular/core";
import { Router } from "@angular/router"; import { Router } from "@angular/router";
import { NgRedux, select } from "@angular-redux/store"; import { NgRedux, select } from "@angular-redux/store";
import { StudentDataFieldsActions } from "../../actions/studentdatafields.actions"; import { StudentDataFieldsActions } from "../../actions/studentdatafields.actions";
import { IStudentDataFields } from "../../store/studentdatafields/studentdatafields.types"; import { IStudentDataFieldRecords } from "../../store/studentdatafields/studentdatafields.types";
import { IAppState } from "../../store/store"; import { IAppState } from "../../store/store";
import { VALID_NAMES_PATTERN, VALID_UCASE_NAMES_PATTERN, VALID_ADDRESS_PATTERN, VALID_ADDRESSTK_PATTERN, VALID_DIGITS_PATTERN, import { VALID_NAMES_PATTERN, VALID_UCASE_NAMES_PATTERN, VALID_ADDRESS_PATTERN, VALID_ADDRESSTK_PATTERN, VALID_DIGITS_PATTERN,
VALID_DATE_PATTERN, FIRST_SCHOOL_YEAR, VALID_YEAR_PATTERN, VALID_TELEPHONE_PATTERN } from "../../constants"; VALID_DATE_PATTERN, FIRST_SCHOOL_YEAR, VALID_YEAR_PATTERN, VALID_TELEPHONE_PATTERN } from "../../constants";
...@@ -30,7 +30,7 @@ import { ...@@ -30,7 +30,7 @@ import {
@Injectable() export default class StudentApplicationMain implements OnInit { @Injectable() export default class StudentApplicationMain implements OnInit {
private loginInfo$: BehaviorSubject<ILoginInfo>; private loginInfo$: BehaviorSubject<ILoginInfo>;
private studentDataFields$: BehaviorSubject<IStudentDataFields>; private studentDataFields$: BehaviorSubject<IStudentDataFieldRecords>;
private studentDataFieldsSub: Subscription; private studentDataFieldsSub: Subscription;
private loginInfoSub: Subscription; private loginInfoSub: Subscription;
...@@ -112,23 +112,23 @@ import { ...@@ -112,23 +112,23 @@ import {
this.studentDataFieldsSub = this._ngRedux.select("studentDataFields") this.studentDataFieldsSub = this._ngRedux.select("studentDataFields")
.subscribe(studentDataFields => { .subscribe(studentDataFields => {
let sdfds = <IStudentDataFields>studentDataFields; let sdfds = <IStudentDataFieldRecords>studentDataFields;
if (sdfds.size > 0) { if (sdfds.size > 0) {
sdfds.reduce(({}, studentDataField) => { sdfds.reduce(({}, studentDataField) => {
this.studentDataGroup.controls["name"].setValue(studentDataField.name); this.studentDataGroup.controls["name"].setValue(studentDataField.get("name"));
this.studentDataGroup.controls["studentsurname"].setValue(studentDataField.studentsurname); this.studentDataGroup.controls["studentsurname"].setValue(studentDataField.get("studentsurname"));
this.studentDataGroup.controls["fatherfirstname"].setValue(studentDataField.fatherfirstname); this.studentDataGroup.controls["fatherfirstname"].setValue(studentDataField.get("fatherfirstname"));
this.studentDataGroup.controls["motherfirstname"].setValue(studentDataField.motherfirstname); this.studentDataGroup.controls["motherfirstname"].setValue(studentDataField.get("motherfirstname"));
this.studentDataGroup.controls["regionaddress"].setValue(studentDataField.regionaddress); this.studentDataGroup.controls["regionaddress"].setValue(studentDataField.get("regionaddress"));
this.studentDataGroup.controls["regiontk"].setValue(studentDataField.regiontk); this.studentDataGroup.controls["regiontk"].setValue(studentDataField.get("regiontk"));
this.studentDataGroup.controls["regionarea"].setValue(studentDataField.regionarea); this.studentDataGroup.controls["regionarea"].setValue(studentDataField.get("regionarea"));
this.studentDataGroup.controls["lastschool_schoolname"].setValue(studentDataField.lastschool_schoolname); this.studentDataGroup.controls["lastschool_schoolname"].setValue(studentDataField.get("lastschool_schoolname"));
this.studentDataGroup.controls["lastschool_schoolyear"].setValue(studentDataField.lastschool_schoolyear); this.studentDataGroup.controls["lastschool_schoolyear"].setValue(studentDataField.get("lastschool_schoolyear"));
this.studentDataGroup.controls["lastschool_class"].setValue(studentDataField.lastschool_class); this.studentDataGroup.controls["lastschool_class"].setValue(studentDataField.get("lastschool_class"));
this.studentDataGroup.controls["relationtostudent"].setValue(studentDataField.relationtostudent); this.studentDataGroup.controls["relationtostudent"].setValue(studentDataField.get("relationtostudent"));
this.studentDataGroup.controls["telnum"].setValue(studentDataField.telnum); this.studentDataGroup.controls["telnum"].setValue(studentDataField.get("telnum"));
this.studentDataGroup.controls["studentbirthdate"].setValue(this.populateDate(studentDataField.studentbirthdate)); this.studentDataGroup.controls["studentbirthdate"].setValue(this.populateDate(studentDataField.get("studentbirthdate")));
return studentDataField; return studentDataField;
}, {}); }, {});
} }
......
...@@ -4,7 +4,7 @@ import { IAppState, rootReducer, deimmutify } from "./store"; ...@@ -4,7 +4,7 @@ import { IAppState, rootReducer, deimmutify } from "./store";
import { ISectorFieldRecord, ISectorFieldRecords } from "./sectorfields/sectorfields.types"; import { ISectorFieldRecord, ISectorFieldRecords } from "./sectorfields/sectorfields.types";
import { IRRegion, IRRegionSchool, IRegionRecord, IRegionRecords, IRegionSchoolRecord, IRegionSchoolRecords } from "./regionschools/regionschools.types"; import { IRRegion, IRRegionSchool, IRegionRecord, IRegionRecords, IRegionSchoolRecord, IRegionSchoolRecords } from "./regionschools/regionschools.types";
import { ISectors, ISector, ISectorCourse } from "./sectorcourses/sectorcourses.types"; import { ISectors, ISector, ISectorCourse } from "./sectorcourses/sectorcourses.types";
import { IStudentDataField, IStudentDataFields } from "./studentdatafields/studentdatafields.types"; import { IStudentDataFieldRecord, IStudentDataFieldRecords } from "./studentdatafields/studentdatafields.types";
import { IEpalClass, IEpalClasses } from "./epalclasses/epalclasses.types"; import { IEpalClass, IEpalClasses } from "./epalclasses/epalclasses.types";
import { ILoginInfoToken, ILoginInfo } from "./logininfo/logininfo.types"; import { ILoginInfoToken, ILoginInfo } from "./logininfo/logininfo.types";
...@@ -22,8 +22,8 @@ IRRegionSchool, ...@@ -22,8 +22,8 @@ IRRegionSchool,
ISectors, ISectors,
ISector, ISector,
ISectorCourse, ISectorCourse,
IStudentDataField, IStudentDataFieldRecord,
IStudentDataFields, IStudentDataFieldRecords,
IEpalClass, IEpalClass,
IEpalClasses, IEpalClasses,
ILoginInfo, ILoginInfo,
......
/* import { List } from "immutable";
import { ISectorField } from "./sectorfields.types";
export const SECTOR_FIELDS_INITIAL_STATE = List<ISectorField>(); */
import { List } from "immutable"; import { List } from "immutable";
import { ISectorFieldRecord, ISectorField } from "./sectorfields.types"; import { ISectorFieldRecord } from "./sectorfields.types";
import {recordify} from "typed-immutable-record";
export const SECTOR_FIELDS_INITIAL_STATE = List<ISectorFieldRecord>(); export const SECTOR_FIELDS_INITIAL_STATE = List<ISectorFieldRecord>();
import { ISectorFieldRecords, ISectorFieldRecord, ISectorField } from "./sectorfields.types"; import { ISectorFieldRecords, ISectorFieldRecord, ISectorField } from "./sectorfields.types";
import { SECTOR_FIELDS_INITIAL_STATE } from "./sectorfields.initial-state"; import { SECTOR_FIELDS_INITIAL_STATE } from "./sectorfields.initial-state";
import { Seq, List } from "immutable"; import { List } from "immutable";
import {recordify} from "typed-immutable-record"; import {recordify} from "typed-immutable-record";
import { import {
......
...@@ -10,7 +10,7 @@ export interface IAppState { ...@@ -10,7 +10,7 @@ export interface IAppState {
sectorFields?: sectorFields.ISectorFieldRecords; sectorFields?: sectorFields.ISectorFieldRecords;
regions?: regions.IRegionRecords; regions?: regions.IRegionRecords;
sectors?: sectors.ISectors; sectors?: sectors.ISectors;
studentDataFields?: studentDataFields.IStudentDataFields; studentDataFields?: studentDataFields.IStudentDataFieldRecords;
epalclasses?: epalclasses.IEpalClasses; epalclasses?: epalclasses.IEpalClasses;
loginInfo?: loginInfo.ILoginInfo; loginInfo?: loginInfo.ILoginInfo;
}; };
......
import { IStudentDataField, IStudentDataFields } from "./studentdatafields.types"; import { IStudentDataFieldRecord, IStudentDataFieldRecords } from "./studentdatafields.types";
import { studentDataFieldsReducer } from "./studentdatafields.reducer"; import { studentDataFieldsReducer } from "./studentdatafields.reducer";
import { deimmutifyStudentDataFields } from "./studentdatafields.transformers"; import { deimmutifyStudentDataFields } from "./studentdatafields.transformers";
export { export {
IStudentDataField, IStudentDataFieldRecord,
IStudentDataFields, IStudentDataFieldRecords,
studentDataFieldsReducer, studentDataFieldsReducer,
deimmutifyStudentDataFields, deimmutifyStudentDataFields,
}; };
import { List } from "immutable"; import { List } from "immutable";
import { IStudentDataField } from "./studentdatafields.types"; import { IStudentDataFieldRecord } from "./studentdatafields.types";
export const STUDENT_DATA_FIELDS_INITIAL_STATE = List<IStudentDataField>(); export const STUDENT_DATA_FIELDS_INITIAL_STATE = List<IStudentDataFieldRecord>();
import { IStudentDataFields, IStudentDataField } from "./studentdatafields.types"; import { IStudentDataFieldRecords, IStudentDataFieldRecord, IStudentDataField } from "./studentdatafields.types";
import { STUDENT_DATA_FIELDS_INITIAL_STATE } from "./studentdatafields.initial-state"; import { STUDENT_DATA_FIELDS_INITIAL_STATE } from "./studentdatafields.initial-state";
import { Seq } from "immutable"; import {recordify} from "typed-immutable-record";
import { List } from "immutable";
import { STUDENTDATAFIELDS_SAVE, STUDENTDATAFIELDS_INIT } from "../../constants"; import { STUDENTDATAFIELDS_SAVE, STUDENTDATAFIELDS_INIT } from "../../constants";
export function studentDataFieldsReducer(state: IStudentDataFields = STUDENT_DATA_FIELDS_INITIAL_STATE, action): IStudentDataFields { export function studentDataFieldsReducer(state: IStudentDataFieldRecords = STUDENT_DATA_FIELDS_INITIAL_STATE, action): IStudentDataFieldRecords {
switch (action.type) { switch (action.type) {
case STUDENTDATAFIELDS_SAVE: case STUDENTDATAFIELDS_SAVE:
let studentDataFields = Array<IStudentDataField>(); let studentDataFields = Array<IStudentDataFieldRecord>();
let ind = 0;
action.payload.studentDataFields.forEach(studentDataField => { action.payload.studentDataFields.forEach(studentDataField => {
let transformedDate = ""; let transformedDate = "";
...@@ -16,16 +16,12 @@ export function studentDataFieldsReducer(state: IStudentDataFields = STUDENT_DAT ...@@ -16,16 +16,12 @@ export function studentDataFieldsReducer(state: IStudentDataFields = STUDENT_DAT
transformedDate += studentDataField.studentbirthdate.date.month < 10 ? "0" + studentDataField.studentbirthdate.date.month + "-" : studentDataField.studentbirthdate.date.month + "-"; transformedDate += studentDataField.studentbirthdate.date.month < 10 ? "0" + studentDataField.studentbirthdate.date.month + "-" : studentDataField.studentbirthdate.date.month + "-";
transformedDate += studentDataField.studentbirthdate.date.day < 10 ? "0" + studentDataField.studentbirthdate.date.day : studentDataField.studentbirthdate.date.day; transformedDate += studentDataField.studentbirthdate.date.day < 10 ? "0" + studentDataField.studentbirthdate.date.day : studentDataField.studentbirthdate.date.day;
} }
// transformedDate = studentDataField.studentbirthdate.jsDate;
studentDataField.studentbirthdate = transformedDate; studentDataField.studentbirthdate = transformedDate;
studentDataFields.push(recordify<IStudentDataField, IStudentDataFieldRecord>(studentDataField));
studentDataFields.push(<IStudentDataField>studentDataField);
ind++;
}); });
return Seq(studentDataFields).map(n => n).toList(); return List(studentDataFields);
case STUDENTDATAFIELDS_INIT: case STUDENTDATAFIELDS_INIT:
return STUDENT_DATA_FIELDS_INITIAL_STATE; return STUDENT_DATA_FIELDS_INITIAL_STATE;
default: return state; default: return state;
......
import { IStudentDataFields, IStudentDataField } from "./studentdatafields.types"; import { IStudentDataFieldRecords } from "./studentdatafields.types";
export function deimmutifyStudentDataFields(state: IStudentDataFields): IStudentDataField[] { export function deimmutifyStudentDataFields(state: IStudentDataFieldRecords): IStudentDataFieldRecords {
let fetchedStudentDataFields = new Array(); return state;
state.forEach(studentdataField => {
fetchedStudentDataFields.push(<IStudentDataField>{
epaluser_id: studentdataField.epaluser_id,
name: studentdataField.name, studentsurname: studentdataField.studentsurname, studentbirthdate: studentdataField.studentbirthdate,
fatherfirstname: studentdataField.fatherfirstname, fathersurname: studentdataField.fathersurname,
motherfirstname: studentdataField.motherfirstname, mothersurname: studentdataField.mothersurname,
studentamka: studentdataField.studentamka, regionaddress: studentdataField.regionaddress,
regiontk: studentdataField.regiontk, regionarea: studentdataField.regionarea,
lastschool_schoolname: studentdataField.lastschool_schoolname,
lastschool_schoolyear: studentdataField.lastschool_schoolyear,
lastschool_class: studentdataField.lastschool_class,
relationtostudent: studentdataField.relationtostudent,
currentclass: studentdataField.currentclass, points: studentdataField.points
});
});
return fetchedStudentDataFields;
}; };
import { List } from "immutable"; import { List } from "immutable";
import {TypedRecord} from "typed-immutable-record";
export interface IStudentDataField { export interface IStudentDataField {
epaluser_id: number; epaluser_id: number;
...@@ -22,4 +23,6 @@ export interface IStudentDataField { ...@@ -22,4 +23,6 @@ export interface IStudentDataField {
telnum: string; telnum: string;
} }
export type IStudentDataFields = List<IStudentDataField>; export interface IStudentDataFieldRecord extends TypedRecord<IStudentDataFieldRecord>, IStudentDataField { };
export type IStudentDataFieldRecords = List<IStudentDataFieldRecord>;
// export type IStudentDataFields = List<IStudentDataField>;
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