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 [formGroup]="applicantDataGroup">
<table>
......@@ -18,8 +16,6 @@
</table>
</form>
<div *ngFor="let studentDataField$ of studentDataFields$ | async; "> </div>
<div class="form-group">
<label for="name">Όνομα μαθητή</label><input class="form-control" type="text" formControlName="name">
</div>
......@@ -173,7 +169,7 @@
</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">
<button type="button" class="btn-primary btn-lg pull-left" (click)="navigateBack()">
<i class="fa fa-backward"></i>
......@@ -188,4 +184,3 @@
</div>
</form>
</div>
import { Component, OnInit } from '@angular/core';
import { Observable } from 'rxjs/Rx';
import { Component, OnInit, OnDestroy } from '@angular/core';
import { BehaviorSubject, Subscription } from 'rxjs/Rx';
import { Injectable } from "@angular/core";
import { Router } from '@angular/router';
import { NgRedux, select } from 'ng2-redux';
......@@ -9,6 +9,8 @@ import { CriteriaActions } from '../../actions/criteria.actions';
import { ICriter } from '../../store/criteria/criteria.types';
import { IAppState } from '../../store/store';
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 {
FormBuilder,
......@@ -25,9 +27,11 @@ import {
@Injectable() export default class StudentApplicationMain implements OnInit {
private studentDataFields$: Observable<IStudentDataFields>;
private criteria$: Observable<ICriter>;
private showLoader$: Observable<boolean>;
private studentDataFields$: BehaviorSubject<IStudentDataFields>;
private criteria$: BehaviorSubject<ICriter>;
private studentDataFieldsSub: Subscription;
private criteriaSub: Subscription;
public studentDataGroup: FormGroup;
public applicantDataGroup: FormGroup;
......@@ -41,6 +45,9 @@ import {
private _sdfb: CriteriaActions,
private _ngRedux: NgRedux<IAppState>,
private router: Router) {
this.studentDataFields$ = new BehaviorSubject(STUDENT_DATA_FIELDS_INITIAL_STATE);
this.criteria$ = new BehaviorSubject(CRITERIA_INITIAL_STATE);
this.studentDataGroup = this.fb.group({
epaluser_id: [,[]],
name: ['ΝΙΚΟΣ', [Validators.pattern(VALID_NAMES_PATTERN),Validators.required]],
......@@ -70,7 +77,7 @@ import {
ngOnInit() {
this.studentDataFields$ = this._ngRedux.select(state => {
this.studentDataFieldsSub = this._ngRedux.select(state => {
if (state.studentDataFields.size > 0) {
state.studentDataFields.reduce(({}, studentDataField) => {
this.studentDataGroup.setValue(studentDataField);
......@@ -78,10 +85,10 @@ import {
}, {});
}
return state.studentDataFields;
});
}).subscribe(this.studentDataFields$);
this._sdfb.getCriteria(true);
this.criteria$ = this._ngRedux.select(state => {
this.criteriaSub = this._ngRedux.select(state => {
if (state.criter.size > 0) {
state.criter.reduce(({}, criteria) => {
//this.studentCriteriaGroup.setValue(criteria);
......@@ -93,9 +100,13 @@ import {
}, {});
}
return state.criter;
});
this.showLoader$ = this.criteria$.map(criter => criter.size === 0);
}).subscribe(this.criteria$);
}
ngOnDestroy() {
if (this.studentDataFieldsSub) this.studentDataFieldsSub.unsubscribe();
if (this.criteriaSub) this.criteriaSub.unsubscribe();
}
navigateBack() {
......@@ -139,9 +150,5 @@ import {
else
// Null means valid, believe it or not
return null;
}
}
}
......@@ -2,4 +2,4 @@ import { List } from 'immutable';
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 { INITIAL_STATE } from './criteria.initial-state';
import { CRITERIA_INITIAL_STATE } from './criteria.initial-state';
import { Seq } from 'immutable';
import {
......@@ -7,7 +7,7 @@ import {
CRITERIA_SAVE
} from '../../constants';
export function criteriaReducer(state: ICriter = INITIAL_STATE, action): ICriter {
export function criteriaReducer(state: ICriter = CRITERIA_INITIAL_STATE, action): ICriter {
switch (action.type) {
case CRITERIA_RECEIVED:
let newCriter = Array<ICriteria>();
......
import { List } from 'immutable';
export interface ICriteria {
/*
orphanmono: boolean;
orphantwice: boolean;
threechildren: boolean;
manychildren: boolean;
twins: boolean;
disability: boolean;
studies: boolean;
income: string;
*/
id: string;
name: string;
mutual_disabled_id: string,
......
......@@ -2,4 +2,4 @@ import { List } from 'immutable';
import { ILoginInfoToken } from './logininfo.types';
// 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 { INITIAL_STATE } from './logininfo.initial-state';
import { LOGININFO_INITIAL_STATE } from './logininfo.initial-state';
import { Seq } from 'immutable';
import {
......@@ -7,7 +7,7 @@ import {
LOGININFO_INIT
} from '../../constants';
export function loginInfoReducer(state: ILoginInfo = INITIAL_STATE, action): ILoginInfo {
export function loginInfoReducer(state: ILoginInfo = LOGININFO_INITIAL_STATE, action): ILoginInfo {
switch (action.type) {
case LOGININFO_SAVE:
let loginInfoTokens = Array<ILoginInfoToken>();
......@@ -19,7 +19,7 @@ export function loginInfoReducer(state: ILoginInfo = INITIAL_STATE, action): ILo
return Seq(loginInfoTokens).map(n => n).toList();
case LOGININFO_INIT:
return INITIAL_STATE;
return LOGININFO_INITIAL_STATE;
default:
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