Merge branch 'front_end_async_fix' into 'develop'

Front end async fix

See merge request !33
parents 55f8da37 85678d8a
langcode: el
status: true
dependencies: { }
id: applicant
label: applicant
weight: 3
is_admin: null
permissions:
- 'add epal student class entities'
- 'add epal student entities'
- 'add epal student course field entities'
- 'add epal student epal chosen entities'
- 'add epal student sector field entities'
- 'add epal users entities'
- 'delete epal student class entities'
- 'delete epal student entities'
- 'delete epal student course field entities'
- 'delete epal student epal chosen entities'
- 'delete epal student sector field entities'
- 'delete epal users entities'
- 'edit epal student class entities'
- 'edit epal student entities'
- 'edit epal student course field entities'
- 'edit epal student epal chosen entities'
- 'edit epal student sector field entities'
- 'edit epal users entities'
- 'view published epal student class entities'
- 'view published epal student entities'
- 'view published epal student course field entities'
- 'view published epal student epal chosen entities'
- 'view published epal student sector field entities'
- 'view published epal users entities'
- 'view unpublished epal student class entities'
- 'view unpublished epal student entities'
- 'view unpublished epal student course field entities'
- 'view unpublished epal student epal chosen entities'
- 'view unpublished epal student sector field entities'
- 'view unpublished epal users entities'
- 'view published eepal admin area entities'
- 'view published eepal prefecture entities'
- 'view published eepal region entities'
- 'view published eepal school entities'
- 'view published eepal sectors entities'
- 'view published eepal sectors in epal entities'
- 'view published eepal specialties in epal entities'
- 'view published eepal specialty entities'
- 'view unpublished eepal admin area entities'
- 'view unpublished eepal prefecture entities'
- 'view unpublished eepal region entities'
- 'view unpublished eepal school entities'
- 'view unpublished eepal sectors entities'
- 'view unpublished eepal sectors in epal entities'
- 'view unpublished eepal specialties in epal entities'
- 'view unpublished eepal specialty entities'
- 'access content'
<div class = "loading" *ngIf="showLoader$ | async"></div> <div class = "loading" *ngIf="(criteria$ | async).size === 0"></div>
<div class="row equal">
<div class="col-md-12">
<form novalidate [formGroup]="studentDataGroup" #form> <form novalidate [formGroup]="studentDataGroup" #form>
<form [formGroup]="applicantDataGroup"> <form [formGroup]="applicantDataGroup">
<table> <table>
...@@ -18,8 +16,6 @@ ...@@ -18,8 +16,6 @@
</table> </table>
</form> </form>
<div *ngFor="let studentDataField$ of studentDataFields$ | async; "> </div>
<div class="form-group"> <div class="form-group">
<label for="name">Όνομα μαθητή</label><input class="form-control" type="text" formControlName="name"> <label for="name">Όνομα μαθητή</label><input class="form-control" type="text" formControlName="name">
</div> </div>
...@@ -173,7 +169,7 @@ ...@@ -173,7 +169,7 @@
</form> </form>
<div class="row" style="margin-top: 20px;" *ngIf="!(showLoader$ | async)"> <div class="row" style="margin-top: 20px;" *ngIf="(criteria$ | async).size > 0">
<div class="col-md-6"> <div class="col-md-6">
<button type="button" class="btn-primary btn-lg pull-left" (click)="navigateBack()"> <button type="button" class="btn-primary btn-lg pull-left" (click)="navigateBack()">
<i class="fa fa-backward"></i> <i class="fa fa-backward"></i>
...@@ -188,4 +184,3 @@ ...@@ -188,4 +184,3 @@
</div> </div>
</form> </form>
</div>
import { Component, OnInit } from '@angular/core'; import { Component, OnInit, OnDestroy } from '@angular/core';
import { Observable } from 'rxjs/Rx'; import { BehaviorSubject, Subscription } from 'rxjs/Rx';
import { Injectable } from "@angular/core"; import { Injectable } from "@angular/core";
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { NgRedux, select } from 'ng2-redux'; import { NgRedux, select } from 'ng2-redux';
...@@ -9,6 +9,8 @@ import { CriteriaActions } from '../../actions/criteria.actions'; ...@@ -9,6 +9,8 @@ import { CriteriaActions } from '../../actions/criteria.actions';
import { ICriter } from '../../store/criteria/criteria.types'; import { ICriter } from '../../store/criteria/criteria.types';
import { IAppState } from '../../store/store'; import { IAppState } from '../../store/store';
import { VALID_NAMES_PATTERN, VALID_ADDRESS_PATTERN, VALID_ADDRESSTK_PATTERN, VALID_DIGITS_PATTERN } from '../../constants'; import { VALID_NAMES_PATTERN, VALID_ADDRESS_PATTERN, VALID_ADDRESSTK_PATTERN, VALID_DIGITS_PATTERN } from '../../constants';
import { STUDENT_DATA_FIELDS_INITIAL_STATE } from '../../store/studentdatafields/studentdatafields.initial-state';
import { CRITERIA_INITIAL_STATE } from '../../store/criteria/criteria.initial-state';
import { import {
FormBuilder, FormBuilder,
...@@ -25,9 +27,11 @@ import { ...@@ -25,9 +27,11 @@ import {
@Injectable() export default class StudentApplicationMain implements OnInit { @Injectable() export default class StudentApplicationMain implements OnInit {
private studentDataFields$: Observable<IStudentDataFields>; private studentDataFields$: BehaviorSubject<IStudentDataFields>;
private criteria$: Observable<ICriter>; private criteria$: BehaviorSubject<ICriter>;
private showLoader$: Observable<boolean>;
private studentDataFieldsSub: Subscription;
private criteriaSub: Subscription;
public studentDataGroup: FormGroup; public studentDataGroup: FormGroup;
public applicantDataGroup: FormGroup; public applicantDataGroup: FormGroup;
...@@ -41,6 +45,9 @@ import { ...@@ -41,6 +45,9 @@ import {
private _sdfb: CriteriaActions, private _sdfb: CriteriaActions,
private _ngRedux: NgRedux<IAppState>, private _ngRedux: NgRedux<IAppState>,
private router: Router) { private router: Router) {
this.studentDataFields$ = new BehaviorSubject(STUDENT_DATA_FIELDS_INITIAL_STATE);
this.criteria$ = new BehaviorSubject(CRITERIA_INITIAL_STATE);
this.studentDataGroup = this.fb.group({ this.studentDataGroup = this.fb.group({
epaluser_id: [,[]], epaluser_id: [,[]],
name: ['ΝΙΚΟΣ', [Validators.pattern(VALID_NAMES_PATTERN),Validators.required]], name: ['ΝΙΚΟΣ', [Validators.pattern(VALID_NAMES_PATTERN),Validators.required]],
...@@ -70,7 +77,7 @@ import { ...@@ -70,7 +77,7 @@ import {
ngOnInit() { ngOnInit() {
this.studentDataFields$ = this._ngRedux.select(state => { this.studentDataFieldsSub = this._ngRedux.select(state => {
if (state.studentDataFields.size > 0) { if (state.studentDataFields.size > 0) {
state.studentDataFields.reduce(({}, studentDataField) => { state.studentDataFields.reduce(({}, studentDataField) => {
this.studentDataGroup.setValue(studentDataField); this.studentDataGroup.setValue(studentDataField);
...@@ -78,10 +85,10 @@ import { ...@@ -78,10 +85,10 @@ import {
}, {}); }, {});
} }
return state.studentDataFields; return state.studentDataFields;
}); }).subscribe(this.studentDataFields$);
this._sdfb.getCriteria(true); this._sdfb.getCriteria(true);
this.criteria$ = this._ngRedux.select(state => { this.criteriaSub = this._ngRedux.select(state => {
if (state.criter.size > 0) { if (state.criter.size > 0) {
state.criter.reduce(({}, criteria) => { state.criter.reduce(({}, criteria) => {
//this.studentCriteriaGroup.setValue(criteria); //this.studentCriteriaGroup.setValue(criteria);
...@@ -93,9 +100,13 @@ import { ...@@ -93,9 +100,13 @@ import {
}, {}); }, {});
} }
return state.criter; return state.criter;
}); }).subscribe(this.criteria$);
this.showLoader$ = this.criteria$.map(criter => criter.size === 0);
}
ngOnDestroy() {
if (this.studentDataFieldsSub) this.studentDataFieldsSub.unsubscribe();
if (this.criteriaSub) this.criteriaSub.unsubscribe();
} }
navigateBack() { navigateBack() {
...@@ -139,9 +150,5 @@ import { ...@@ -139,9 +150,5 @@ import {
else else
// Null means valid, believe it or not // Null means valid, believe it or not
return null; return null;
}
}
} }
...@@ -2,4 +2,4 @@ import { List } from 'immutable'; ...@@ -2,4 +2,4 @@ import { List } from 'immutable';
import { ICriteria } from './criteria.types'; import { ICriteria } from './criteria.types';
export const INITIAL_STATE = List<ICriteria>(); export const CRITERIA_INITIAL_STATE = List<ICriteria>();
import { ICriteria, ICriter } from './criteria.types'; import { ICriteria, ICriter } from './criteria.types';
import { INITIAL_STATE } from './criteria.initial-state'; import { CRITERIA_INITIAL_STATE } from './criteria.initial-state';
import { Seq } from 'immutable'; import { Seq } from 'immutable';
import { import {
...@@ -7,7 +7,7 @@ import { ...@@ -7,7 +7,7 @@ import {
CRITERIA_SAVE CRITERIA_SAVE
} from '../../constants'; } from '../../constants';
export function criteriaReducer(state: ICriter = INITIAL_STATE, action): ICriter { export function criteriaReducer(state: ICriter = CRITERIA_INITIAL_STATE, action): ICriter {
switch (action.type) { switch (action.type) {
case CRITERIA_RECEIVED: case CRITERIA_RECEIVED:
let newCriter = Array<ICriteria>(); let newCriter = Array<ICriteria>();
......
import { List } from 'immutable'; import { List } from 'immutable';
export interface ICriteria { export interface ICriteria {
/*
orphanmono: boolean;
orphantwice: boolean;
threechildren: boolean;
manychildren: boolean;
twins: boolean;
disability: boolean;
studies: boolean;
income: string;
*/
id: string; id: string;
name: string; name: string;
mutual_disabled_id: string, mutual_disabled_id: string,
......
...@@ -2,4 +2,4 @@ import { List } from 'immutable'; ...@@ -2,4 +2,4 @@ import { List } from 'immutable';
import { ILoginInfoToken } from './logininfo.types'; import { ILoginInfoToken } from './logininfo.types';
// export const INITIAL_STATE = List<ICourseField>([new CourseFieldRecord({})]); // export const INITIAL_STATE = List<ICourseField>([new CourseFieldRecord({})]);
export const INITIAL_STATE = List<ILoginInfoToken>(); export const LOGININFO_INITIAL_STATE = List<ILoginInfoToken>();
import { ILoginInfo, ILoginInfoToken } from './logininfo.types'; import { ILoginInfo, ILoginInfoToken } from './logininfo.types';
import { INITIAL_STATE } from './logininfo.initial-state'; import { LOGININFO_INITIAL_STATE } from './logininfo.initial-state';
import { Seq } from 'immutable'; import { Seq } from 'immutable';
import { import {
...@@ -7,7 +7,7 @@ import { ...@@ -7,7 +7,7 @@ import {
LOGININFO_INIT LOGININFO_INIT
} from '../../constants'; } from '../../constants';
export function loginInfoReducer(state: ILoginInfo = INITIAL_STATE, action): ILoginInfo { export function loginInfoReducer(state: ILoginInfo = LOGININFO_INITIAL_STATE, action): ILoginInfo {
switch (action.type) { switch (action.type) {
case LOGININFO_SAVE: case LOGININFO_SAVE:
let loginInfoTokens = Array<ILoginInfoToken>(); let loginInfoTokens = Array<ILoginInfoToken>();
...@@ -19,7 +19,7 @@ export function loginInfoReducer(state: ILoginInfo = INITIAL_STATE, action): ILo ...@@ -19,7 +19,7 @@ export function loginInfoReducer(state: ILoginInfo = INITIAL_STATE, action): ILo
return Seq(loginInfoTokens).map(n => n).toList(); return Seq(loginInfoTokens).map(n => n).toList();
case LOGININFO_INIT: case LOGININFO_INIT:
return INITIAL_STATE; return LOGININFO_INITIAL_STATE;
default: default:
return state; return state;
} }
......
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