bug fixes, added modal to application.submit

parent 83569662
......@@ -70,12 +70,6 @@ epal.application_submit:
_controller: '\Drupal\epal\Controller\ApplicationSubmit::appSubmit'
requirements:
_user_is_logged_in: 'TRUE'
epal.demo_data:
path: '/epal/demodata'
defaults:
_controller: '\Drupal\epal\Controller\CreateDemoData::createData'
requirements:
_access: 'TRUE'
epal.allocation:
path: '/epal/distribution'
options:
......
......@@ -87,5 +87,5 @@ class MyLocalization extends NgLocalization {
})
class AppModule {}
// enableProdMode();
enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule);
This diff is collapsed.
import {Router, ActivatedRoute, Params} from '@angular/router';
import {OnInit, Component} from '@angular/core';
import { LoginInfoActions } from '../../actions/logininfo.actions';
import { ILoginInfo } from '../../store/logininfo/logininfo.types';
import { NgRedux, select } from 'ng2-redux';
import { Observable } from 'rxjs/Rx';
import { IAppState } from '../../store/store';
import { HelperDataService } from '../../services/helper-data-service';
import { CookieService } from 'ngx-cookie';
import {
FormBuilder,
FormGroup,
FormControl,
FormArray
} from '@angular/forms';
import {Router} from '@angular/router';
import {OnInit, Component, Injectable} from '@angular/core';
import { API_ENDPOINT, API_ENDPOINT_PARAMS } from '../../app.settings';
@Component({
selector: 'director-buttons',
template: `
<div>
<form>
<div class="col-md-8 offset-md-4">
<button type="submit" class="btn-primary btn-lg" (click)="navigatedirector()">
Επιλεχθέντες Μαθητές<span class="glyphicon glyphicon-menu-right"></span>
<div class="row" style="margin-top: 130px; margin-bottom: 200px;">
<div class="col-md-3 offset-md-3">
<button type="submit" class="btn-primary btn-lg btn-block isclickable" style="margin: 0px; font-size: 1em; padding: 5px;" (click)="navigatedirector()">
Αιτηθέντες<br />Μαθητές
</button>
<br>
<br>
<button type="submit" class="btn-primary btn-lg" (click)="navigatecapacity()">
Δυναμική Τμημάτων<span class="glyphicon glyphicon-menu-right"></span>
</div>
<div class="col-md-6">
<button type="submit" class="btn-primary btn-lg btn-block isclickable" style="margin: 0px; font-size: 1em; padding: 5px;" (click)="navigatecapacity()">
Δυναμική<br />Τμημάτων
</button>
</div>
<br>
<br>
<br>
<br>
<br>
</form>
</div>
</div>
`
})
export default class DirectorButtom implements OnInit {
@Injectable() export default class DirectorButtons implements OnInit {
constructor(
private router: Router,
......@@ -54,7 +31,6 @@ export default class DirectorButtom implements OnInit {
}
navigatedirector(){
this.router.navigate(['/school/director-view']);
......@@ -64,6 +40,4 @@ export default class DirectorButtom implements OnInit {
this.router.navigate(['/school/director-classcapacity']);
}
}
import { Component, OnInit, OnDestroy, ElementRef, ViewChild} from "@angular/core";
import { Injectable } from "@angular/core";
import { Component, OnInit, OnDestroy, ElementRef, ViewChild, Injectable} from "@angular/core";
import { AppSettings } from '../../app.settings';
import { HelperDataService } from '../../services/helper-data-service';
import {Observable} from "rxjs/Observable";
......@@ -20,28 +19,28 @@ import {
@Component({
selector: 'perfecture-view',
template: `
<h3> Αριθμός Μαθητών ανα τμήμα σχολείου </h3>
<h3> Αριθμός Μαθητών ανα τμήμα σχολείου </h3>
<ul class="list-group main-view">
<div *ngFor="let SchoolNames$ of SchoolsPerPerf$ | async; let i=index; let isOdd=odd; let isEven=even" >
<li class="list-group-item isclickable" (click)="setActiveRegion(SchoolNames$.id)" [class.changelistcolor]= "SchoolNames$.status === true" [class.oddout]="isOdd" [class.evenout]="isEven" [class.selectedout]="regionActive === SchoolNames$.id" >
<h5> {{SchoolNames$.name}}</h5>
</li>
<div *ngFor="let CoursesNames$ of CoursesPerPerf$ | async; let j=index; let isOdd2=odd; let isEven2=even" [class.oddin]="isOdd2" [class.evenin]="isEven2" [class.changecolor]="calccolor(CoursesNames$.size,CoursesNames$.limitdown)" [hidden]="SchoolNames$.id !== regionActive" >
<div> {{CoursesNames$.name}}</div> <div class= "aastyle"><strong>Αριθμός Μαθητών:</strong>{{CoursesNames$.size}} </div>
<div> {{CoursesNames$.name}}</div> <div class= "aastyle"><strong>Αριθμός Μαθητών:</strong>{{CoursesNames$.size}} </div>
</div>
</div>
</div>
</ul>
</ul>
<div class="col-md-6">
<button type="button" class="btn-primary btn-lg pull-right" (click)="navigateToApplication()" >
<i class="fa fa-forward"></i>
</button>
</div>
</div>
`
})
......@@ -58,7 +57,7 @@ import {
private StudentsSizeSub: Subscription;
public perfecture = 1;
private regionActive = <number>-1;
constructor(private fb: FormBuilder,
private router: Router,
......@@ -94,10 +93,10 @@ import {
setActiveRegion(ind) {
if (ind === this.regionActive)
ind = -1;
this.regionActive = ind;
this.CoursesPerPerfSub = this._hds.getCoursePerPerfecture(this.regionActive).subscribe(data => {
this.CoursesPerPerf$.next(data);
......@@ -115,9 +114,9 @@ import {
navigateToApplication()
{
var id: string= String(this.regionActive);
this.router.navigate(['', {ids:id}]);
this.router.navigate(['', {ids:id}]);
}
......
import {Router, ActivatedRoute, Params} from '@angular/router';
import {OnInit, Component} from '@angular/core';
import {OnInit, OnDestroy, Component} from '@angular/core';
import { LoginInfoActions } from '../actions/logininfo.actions';
import { ILoginInfo } from '../store/logininfo/logininfo.types';
import { LOGININFO_INITIAL_STATE } from '../store/logininfo/logininfo.initial-state';
import { NgRedux, select } from 'ng2-redux';
import { Observable } from 'rxjs/Rx';
import { BehaviorSubject, Subscription } from 'rxjs/Rx';
import { IAppState } from '../store/store';
import { HelperDataService } from '../services/helper-data-service';
import { CookieService } from 'ngx-cookie';
......@@ -36,13 +37,14 @@ import { API_ENDPOINT, API_ENDPOINT_PARAMS } from '../app.settings';
`
})
export default class SchoolHome implements OnInit {
export default class SchoolHome implements OnInit, OnDestroy {
public formGroup: FormGroup;
private authToken: string;
private authRole: string;
private name: any;
private xcsrftoken: any;
private loginInfo$: Observable<ILoginInfo>;
private loginInfo$: BehaviorSubject<ILoginInfo>;
private loginInfoSub: Subscription;
private apiEndPoint = API_ENDPOINT;
private apiEndPointParams = API_ENDPOINT_PARAMS;
......@@ -57,10 +59,17 @@ export default class SchoolHome implements OnInit {
this.authToken = '';
this.authRole = '';
this.name = '';
this.loginInfo$ = new BehaviorSubject(LOGININFO_INITIAL_STATE);
this.formGroup = this.fb.group({
});
};
ngOnDestroy() {
if (this.loginInfoSub)
this.loginInfoSub.unsubscribe();
this.loginInfo$.unsubscribe();
};
ngOnInit() {
/* this.authToken = this.getCookie('auth_token');
this.authRole = this.getCookie('auth_role');
......@@ -70,23 +79,24 @@ export default class SchoolHome implements OnInit {
this.removeCookie('auth_role');
} */
this.loginInfo$ = this._ngRedux.select(state => {
this.loginInfoSub = this._ngRedux.select(state => {
if (state.loginInfo.size > 0) {
state.loginInfo.reduce(({}, loginInfoToken) => {
this.authToken = loginInfoToken.auth_token;
this.authRole = loginInfoToken.auth_role;
if (this.authToken && this.authToken.length > 0)
if (this.authRole = 'director')
console.log("ok");
if (this.authToken && this.authToken.length > 0) {
if (this.authRole === 'director') {
this.router.navigate(['/school/director-buttons']);
if (this.authRole = 'pde')
this.router.navigate(['/school/perfecture-view']);
}
else if (this.authRole === 'pde')
this.router.navigate(['/school/perfecture-view']);
}
return loginInfoToken;
}, {});
}
return state.loginInfo;
});
}).subscribe(this.loginInfo$);
// subscribe to router event
......
......@@ -25,10 +25,29 @@ import {AppSettings} from '../../app.settings';
@Component({
selector: 'application-submit',
template: `
<div class = "loading" *ngIf="(studentDataFields$ | async).size === 0 || (criteria$ | async).size === 0 || (regions$ | async).size === 0 || (epalclasses$ | async).size === 0 || (loginInfo$ | async).size === 0 || (showLoader | async) === true"></div>
<div id="studentFormSentNotice" (onHidden)="onHidden()" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header modal-header-success">
<h3 class="modal-title pull-left"><i class="fa fa-check-square-o"></i>&nbsp;&nbsp;{{ modalTitle | async }}</h3>
<button type="button" class="close pull-right" aria-label="Close" (click)="hideModal()">
<span aria-hidden="true"><i class="fa fa-times"></i></span>
</button>
</div>
<div class="modal-body">
<p>{{ modalText | async }}</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal">Κλείσιμο</button>
</div>
</div>
</div>
</div>
<div class="row">
<breadcrumbs></breadcrumbs>
</div>
<div class = "loading" *ngIf="(studentDataFields$ | async).size === 0 || (criteria$ | async).size === 0 || (regions$ | async).size === 0 || (epalclasses$ | async).size === 0 || (loginInfo$ | async).size === 0"></div>
<application-preview-select></application-preview-select>
<button type="button button-lg pull-right" *ngIf="(studentDataFields$ | async).size > 0 && (criteria$ | async).size > 0 && (regions$ | async).size > 0 && (epalclasses$ | async).size > 0 && (loginInfo$ | async).size > 0" class="btn-primary btn-lg pull-center" (click)="submitNow()">Υποβολή</button>
`
......@@ -59,6 +78,10 @@ import {AppSettings} from '../../app.settings';
private sectorFieldsSub: Subscription;
private epalclassesSub: Subscription;
private loginInfoSub: Subscription;
private modalTitle: BehaviorSubject<string>;
private modalText: BehaviorSubject<string>;
public isModalShown: BehaviorSubject<boolean>;
private showLoader: BehaviorSubject<boolean>;
constructor(private _ngRedux: NgRedux<IAppState>,
private router: Router,
......@@ -72,9 +95,15 @@ import {AppSettings} from '../../app.settings';
this.studentDataFields$ = new BehaviorSubject(STUDENT_DATA_FIELDS_INITIAL_STATE);
this.criteria$ = new BehaviorSubject(CRITERIA_INITIAL_STATE);
this.loginInfo$ = new BehaviorSubject(LOGININFO_INITIAL_STATE);
this.modalTitle = new BehaviorSubject("");
this.modalText = new BehaviorSubject("");
this.isModalShown = new BehaviorSubject(false);
this.showLoader = new BehaviorSubject(false);
};
ngOnInit() {
(<any>$('#studentFormSentNotice')).appendTo("body");
this.loginInfoSub = this._ngRedux.select(state => {
if (state.loginInfo.size > 0) {
state.loginInfo.reduce(({}, loginInfoToken) => {
......@@ -161,6 +190,7 @@ import {AppSettings} from '../../app.settings';
};
ngOnDestroy() {
(<any>$('#studentFormSentNotice')).remove();
if (this.studentDataFieldsSub) this.studentDataFieldsSub.unsubscribe();
if (this.criteriaSub) this.criteriaSub.unsubscribe();
if (this.regionsSub) this.regionsSub.unsubscribe();
......@@ -197,8 +227,6 @@ import {AppSettings} from '../../app.settings';
criteriaObj[i] =new StudentCriteriaChosen(null, null, this.studentCriteria[i]);
aitisiObj['2'] = criteriaObj;
console.log("Debugging..");
console.log(aitisiObj[0]['currentclass']);
//if (aitisiObj[0]['currentclass'] === "Β' Λυκείου" )
if (aitisiObj[0]['currentclass'] === "2" )
aitisiObj['3'] = new StudentSectorChosen(null, this.sectorSelected);
......@@ -207,36 +235,12 @@ import {AppSettings} from '../../app.settings';
aitisiObj['3'] = new StudentCourseChosen(null, this.courseSelected);
}
//console.log(aitisiObj);
this.submitRecord(aitisiObj);
}
submitRecord_ver1(entityName, record) {
let headers = new Headers({
"Authorization": "Basic bmthdHNhb3Vub3M6emVtcmFpbWU=",
"Accept": "*/*",
"Access-Control-Allow-Credentials": "true",
"Content-Type": "application/json",
// "Content-Type": "text/plain", // try to skip preflight
"X-CSRF-Token": "Me9oRh6jrAOAJ2rsnu_3lOLxqA_WMoJLeJ7dhe4HTBA"
});
let options = new RequestOptions({ headers: headers, withCredentials: true });
let connectionString = `${AppSettings.API_ENDPOINT}/entity/` + entityName;
//this.http.post(`${AppSettings.API_ENDPOINT}/entity/epal_student`, this.student, options)
this.http.post(connectionString, record, options)
// Call map on the response observable to get the parsed people object
.map((res: Response) => res.json())
.subscribe(success => {alert("Επιτυχής αποστολή στοιχείων στο entity: " + entityName); console.log("success post")}, // put the data returned from the server in our variable
error => {alert("Αποτυχία αποστολής στοιχείων στο entity: " + entityName); console.log("Error HTTP POST Service")}, // in case of failure show this message
() => console.log("write this message anyway"));//run this code in all cases);
}
submitRecord(record) {
let auth_str = this.authToken + ":" + this.authToken;
//let authTokenPost = "nkatsaounos" + ":" + "...";
let authTokenPost = this.authToken + ":" + this.authToken;
let headers = new Headers({
......@@ -244,43 +248,43 @@ import {AppSettings} from '../../app.settings';
"Accept": "*/*",
"Access-Control-Allow-Credentials": "true",
"Content-Type": "application/json",
// "X-CSRF-Token": "Pz3psGTGpc-EGNLm3tgzCpqEMg3HW0fCKf8xOnQLAsc"
});
//let headers = new Headers({
// "Authorization": "Basic bmthdHNhb3Vub3M6emVtcmFpbWU=",
// "Accept": "*/*",
// "Access-Control-Allow-Credentials": "true",
// "Content-Type": "application/json",
// "X-CSRF-Token": "Pz3psGTGpc-EGNLm3tgzCpqEMg3HW0fCKf8xOnQLAsc"
//});
let options = new RequestOptions({ headers: headers, method: "post", withCredentials: true });
let connectionString = `${AppSettings.API_ENDPOINT}/epal/appsubmit`;
this.showLoader.next(true);
this.http.post(connectionString, record, options)
// Call map on the response observable to get the parsed people object
.map((res: Response) => res.json())
.subscribe(
success => {alert("Επιτυχές post στο route υποβολής " ); console.log("success post"); }, // put the data returned from the server in our variable
error => {alert("Αποτυχές post στο route υποβολής " ); console.log("Error HTTP POST Service")}, // in case of failure show this message
() => console.log("write this message anyway"),
);//run this code in all cases);
success => {
this.modalTitle.next("Υποβολή Αίτησης Εγγραφής");
this.modalText.next("Η υποβολή της αίτησής σας πραγματοποιήθηκε. Μπορείτε να την εκτυπώσετε από την επιλογή 'Εξαγωγή σε PDF'. Θα ειδοποιηθείτε στο e-mail που δηλώσατε για την εξέλιξη της αίτησής σας");
this.showModal();
console.log("success post"); },
error => {
this.modalTitle.next("Υποβολή Αίτησης Εγγραφής");
this.modalText.next("Η υποβολή της αίτησής σας απέτυχε. Παρακαλούμε προσπαθήστε πάλι και αν το πρόβλημα συνεχίσει να υφίσταται, επικοινωνήστε με την ομάδα υποστήριξης");
this.showModal();
console.log("Error HTTP POST Service")},
() => {
console.log("write this message anyway");
this.showLoader.next(false);
},
);
//});
}
public showModal():void {
(<any>$('#studentFormSentNotice')).modal('show');
}
}
public hideModal():void {
(<any>$('#studentFormSentNotice')).modal('hide');
}
public onHidden():void {
this.isModalShown.next(false);
}
//Get Data - sync methods
/*
const { studentDataFields } = this._ngRedux.getState();
const { epalclasses } = this._ngRedux.getState();
const { regions } = this._ngRedux.getState();
const { amkafills } = this._ngRedux.getState();
const { sectors } = this._ngRedux.getState();
*/
}
<div class = "loading" *ngIf="(epalUserData$ | async).userEmail === '' || (showLoader | async) === true"></div>
<div id="emaiSentNotice" (onHidden)="onHidden()" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div id="emailSentNotice" (onHidden)="onHidden()" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header modal-header-success">
......
......@@ -58,11 +58,11 @@ import {AppSettings} from '../../app.settings';
public showModal():void {
console.log("about to show modal");
(<any>$('#emaiSentNotice')).modal('show');
(<any>$('#emailSentNotice')).modal('show');
}
public hideModal():void {
(<any>$('#emaiSentNotice')).modal('hide');
(<any>$('#emailSentNotice')).modal('hide');
}
public onHidden():void {
......@@ -70,7 +70,7 @@ import {AppSettings} from '../../app.settings';
}
ngOnInit() {
(<any>$('#emaiSentNotice')).appendTo("body");
(<any>$('#emailSentNotice')).appendTo("body");
this.epalUserDataSub = this.hds.getEpalUserData().subscribe(x => {
this.epalUserData$.next(x);
......@@ -106,7 +106,7 @@ import {AppSettings} from '../../app.settings';
}
ngOnDestroy() {
(<any>$('#emaiSentNotice')).remove();
(<any>$('#emailSentNotice')).remove();
if (this.epalUserDataSub) this.epalUserDataSub.unsubscribe();
if (this.userEmailSub) this.epalUserDataSub.unsubscribe();
this.epalUserData$.unsubscribe();
......
......@@ -53,7 +53,7 @@ import {AppSettings} from '../../app.settings';
<div class="col-md-2 col-md-offset-1">
<input #cb type="checkbox" formControlName="{{ epal$.globalIndex }}"
(change)="saveSelected(cb.checked,i,j)"
[hidden] = "numSelected === 3 && cb.checked === false"
[hidden] = "(numSelected | async) === 3 && cb.checked === false"
>
</div>
<div class="col-md-8 col-md-offset-1 isclickable">
......@@ -73,7 +73,7 @@ import {AppSettings} from '../../app.settings';
</button>
</div>
<div class="col-md-6">
<button type="button" class="btn-primary btn-lg pull-right" (click)="navigateToApplication()" [disabled] = "selectionLimitOptional === false && numSelected < selectionLimit " >
<button type="button" class="btn-primary btn-lg pull-right" (click)="navigateToApplication()" [disabled] = "(selectionLimitOptional | async) === false && (numSelected | async) < (selectionLimit | async)" >
<i class="fa fa-forward"></i>
</button>
</div>
......@@ -97,10 +97,12 @@ import {AppSettings} from '../../app.settings';
private regionActive = <number>-1;
private regionActiveId = <number>-1;
private courseActive = <number>-1;
private numSelected = <number>0;
private selectionLimit = <number>3;
private numSelected: BehaviorSubject<number>;
private selectionLimit: BehaviorSubject<number>;
private selectionLimitOptional: BehaviorSubject<boolean>;
// private selectionLimit = <number>3;
private regionSizeLimit = <number>3;
private selectionLimitOptional = <boolean>false;
// private selectionLimitOptional = <boolean>false;
//private schoolArray: Array<boolean> = new Array();
constructor(private fb: FormBuilder,
......@@ -119,6 +121,10 @@ import {AppSettings} from '../../app.settings';
});
this.numSelected = new BehaviorSubject(0);
this.selectionLimit = new BehaviorSubject(3);
this.selectionLimitOptional = new BehaviorSubject(false);
};
ngOnInit() {
......@@ -165,7 +171,7 @@ import {AppSettings} from '../../app.settings';
this.regionsSub = this._ngRedux.select(state => {
let numsel = 0;
let numreg = 0; //count reduced regions in order to set activeRegion when user comes back to his choices
this.selectionLimitOptional = false;
this.selectionLimitOptional.next(false);
state.regions.reduce((prevRegion, region) =>{
numreg++;
......@@ -174,21 +180,22 @@ import {AppSettings} from '../../app.settings';
if (epal.selected === true) {
numsel++;
if ( epal.epal_special_case === "1") {
this.selectionLimitOptional = true;
this.selectionLimitOptional.next(true);
}
this.regionActiveId = Number(region.region_id);
this.regionActive = numreg - 1;
}
if (Number(region.region_id) === this.regionActiveId) {
if (region.epals.length < this.regionSizeLimit)
this.selectionLimitOptional = true;
this.selectionLimitOptional.next(true);
}
return epal;
}, {});
return region;
}, {});
this.numSelected = numsel;
this.numSelected.next(numsel);
console.log("numselected=" + this.numSelected.getValue());
return state.regions;
}).subscribe(this.regions$);
}
......
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