Commit f65b3633 authored by Open Source Developer's avatar Open Source Developer
Browse files

new capacity view

parent c67ef9d3
...@@ -268,6 +268,8 @@ epal.findcapacityperschool: ...@@ -268,6 +268,8 @@ epal.findcapacityperschool:
_auth: [ 'basic_auth' ] _auth: [ 'basic_auth' ]
defaults: defaults:
_controller: '\Drupal\epal\Controller\DirectorView::FindCapacityPerSchool' _controller: '\Drupal\epal\Controller\DirectorView::FindCapacityPerSchool'
requirements:
_user_is_logged_in: 'TRUE'
epal.applicant.creationpdf: epal.applicant.creationpdf:
path: '/epal/pdf-application' path: '/epal/pdf-application'
options: options:
......
...@@ -26,76 +26,50 @@ import { ...@@ -26,76 +26,50 @@ import {
template: ` template: `
<div class = "loading" *ngIf="(showLoader | async) === true"></div> <div class = "loading" *ngIf="(showLoader | async) === true"></div>
<div style="min-height: 500px;"> <div style="min-height: 500px;">
<form [formGroup]="formGroup"> <form [formGroup]="formGroup">
<label for="taxi">Τάξη</label><br/>
<div class="form-group"> <p style="margin-top: 20px; line-height: 2em;"> Στην παρακάτω'λίστα βλέπετε τα τμήματα του σχολείου σας με την αντίστοιχη δυναμίκη τους σε αίθουσες. Παρακαλώ για να τροποποποιήσετε τη δυναμικήαυτή κάντε κλικ στον αντίστοιχο αριθμό,
<select #txoption class="form-control" (change)="verifyclass(txoption)" formControlName="taxi"> επιλέξτε τη νέα δυναμική και πατήστε το σύμβολο <i>ok</i>. Προσοχή! Κανένα τμήμα δεν πρέπει να έχει δυναμική 0.</p>
<option value="1" >Α' Λυκείου</option>
<option value="2" >Β' Λυκείου</option>
<option value="3" >Γ' Λυκείου</option>
<option *ngIf="(selectiontype | async)" value="4" >Δ' Λυκείου</option>
</select>
</div>
<div class="form-group">
<select #tmop class="form-control" *ngIf="(selectionBClass | async)" (change)="checkbclass(tmop,txoption)" formControlName="tomeas">
<option *ngFor="let SectorSelection$ of StudentSelected$ | async; let i=index" [value] = "SectorSelection$.id"> {{SectorSelection$.sector_id}} </option>
</select>
</div>
<div class="form-group">
<select #spop class="form-control" *ngIf="(selectionCClass | async)" (change)="checkcclass(tmop,txoption,spop)" formControlName="specialit">
<option *ngFor="let SpecialSelection$ of StudentSelectedSpecial$ | async; let i=index" [value] = "SpecialSelection$.id"> {{SpecialSelection$.specialty_id}} </option>
</select>
</div>
<p style="margin-top: 20px; line-height: 2em;"> Αλλάξτε παρακαλώ τον αριθμό των τμημάτων που μπορείτε να δημιουργήσετε στο σχολείο σας και πατήστε <i>Αποθήκευση</i>.</p>
<input type="number" formControlName="capacity" min="1" max="10" ng-min="1" ng-max="99" >
<div class="alert alert-danger" *ngIf="formGroup.get('capacity').touched && formGroup.get('capacity').hasError('maxValue')">
Παρακαλώ συμπληρώστε ένα μικρότερο αριθμό!
</div>
<div class="alert alert-danger" *ngIf="formGroup.get('capacity').touched && formGroup.get('capacity').hasError('minValue')">
Παρακαλώ συμπληρώστε ένα μεγαλύτερο αριθμό!
</div>
<div class="alert alert-danger" *ngIf="formGroup.get('capacity').touched && formGroup.get('capacity').hasError('required')">
Συμπληρώστε την διαθεσιμότητα σας σε τμήματα !
</div>
<button type="button" class="btn-primary btn-sm pull-right" (click) ="saveCapacity()">
Αποθήκευση
</button>
</form>
<br>
<br>
<div class="row" style="margin-top: 20px; line-height: 2em;" > <b> Οι δηλώσεις σας </b></div> <div class="row" style="margin-top: 20px; line-height: 2em;" > <b> Οι δηλώσεις σας </b></div>
<div *ngFor="let CapacityPerCourses$ of CapacityPerCourse$ | async; let i=index; let isOdd=odd; let isEven=even" > <div *ngFor="let CapacityPerCourses$ of CapacityPerCourse$ | async; let i=index; let isOdd=odd; let isEven=even" >
<li *ngIf="(!(selectiontype | async) && (CapacityPerCourses$.class < 4)) ||((selectiontype | async) && (CapacityPerCourses$.class < 5))" class="list-group-item " [class.oddout]="isOdd" [class.evenout]="isEven" > <li *ngIf="(!(selectiontype | async) && (CapacityPerCourses$.class < 4)) ||((selectiontype | async) && (CapacityPerCourses$.class < 5))" class="list-group-item " [class.oddout]="isOdd" [class.evenout]="isEven" >
<h5 [class.changelistcolor]= "CapacityPerCourses$.capacity === null" >{{CapacityPerCourses$.taxi}}&nbsp; <b>{{CapacityPerCourses$.capacity}}</b></h5> <div class="row">
<div class="col-md-5">
<h5 [class.changelistcolor]= "CapacityPerCourses$.capacity === 0" >{{CapacityPerCourses$.taxi}}&nbsp; <b></b></h5>
</div>
<div class="col-md-4" col-md-offset-2>
<label *ngIf="!isEdit" (click)="isEdit=true" (click)="setActive(i)"> {{CapacityPerCourses$.capacity}} </label>
<input *ngIf="isEdit && CapacityPerCourses$.globalindex === courseActive"
id="{{CapacityPerCourses$.globalindex}}" type="number"
name="{{CapacityPerCourses$.globalindex}}" value ={{CapacityPerCourses$.capacity}}
(change)="handleChange($event)">
</div>
<div class="col-md-1">
<button *ngIf="isEdit && CapacityPerCourses$.globalindex === courseActive" type="button" class="btn-primary pull-right"
(click)="isEdit=false" (click) ="saveCapacity(CapacityPerCourses$.newspecialit, CapacityPerCourses$.newsector, CapacityPerCourses$.class, CapacityPerCourses$.capacity)">
<i class="fa fa-check" aria-hidden="true"></i>
</button>
</div>
</div>
</li> </li>
</div> </div>
</form>
</div>
</div> <div id="checksaved" (onHidden)="onHidden('#checksaved')"
<div id="checksaved" (onHidden)="onHidden('#checksaved')"
class="modal fade" tabindex="-1" role="dialog" aria-hidden="true"> class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-lg"> <div class="modal-dialog modal-lg">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header modal-header-danger"> <div class="modal-header modal-header-danger">
<h3 class="modal-title pull-left"><i class="fa fa-check-square-o"></i>&nbsp;&nbsp;Πρέπει να συπληρώσετε όλα τα πεδία</h3> <h3 class="modal-title pull-left"><i class="fa fa-check-square-o"></i>&nbsp;&nbsp;Πρέπει να συπληρώσετε σωστά τη δυναμική</h3>
<button type="button" class="close pull-right" aria-label="Close" (click)="hideModal('#checksaved')"> <button type="button" class="close pull-right" aria-label="Close" (click)="hideModal('#checksaved')">
<span aria-hidden="true"><i class="fa fa-times"></i></span> <span aria-hidden="true"><i class="fa fa-times"></i></span>
</button> </button>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<p>Η αποθήκευση δε μπορεί να γίνει αν δεν συμπληρώσετε όλα τα στοιχεία της φόρμας!</p> <p>Η αποθήκευση δε μπορεί να γίνει αν δεν συμπληρώσετε έναν αριθμό μεταξυ 1 και 10!</p>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal">Κλείσιμο</button> <button type="button" class="btn btn-default pull-left" data-dismiss="modal">Κλείσιμο</button>
...@@ -104,26 +78,7 @@ import { ...@@ -104,26 +78,7 @@ import {
</div> </div>
</div> </div>
<div id="capacitysaved" (onHidden)="onHidden('#capacitysaved')"
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;Αποθήκευση Δυναμικής</h3>
<button type="button" class="close pull-right" aria-label="Close" (click)="hideModal('#capacitysaved')">
<span aria-hidden="true"><i class="fa fa-times"></i></span>
</button>
</div>
<div class="modal-body">
<p>Η επιλογή σας έχει αποθηκευτεί.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal">Κλείσιμο</button>
</div>
</div>
</div>
</div>
...@@ -135,28 +90,18 @@ import { ...@@ -135,28 +90,18 @@ import {
@Injectable() export default class DirectorClassCapacity implements OnInit, OnDestroy { @Injectable() export default class DirectorClassCapacity implements OnInit, OnDestroy {
public formGroup: FormGroup; public formGroup: FormGroup;
private StudentSelected$: BehaviorSubject<any>;
private StudentSelectedSub: Subscription; private CapacityPerCourse$: BehaviorSubject<any>;
private StudentSelectedSpecial$: BehaviorSubject<any>; private CapacityPerCourseSub: Subscription;
private StudentSelectedSpecialSub: Subscription;
private saveCapacitySub: Subscription; private saveCapacitySub: Subscription;
private selectionBClass: BehaviorSubject<boolean>; private newvalue:number;
private selectiontype: BehaviorSubject<boolean>; private isEdit: boolean;
private selectionCClass: BehaviorSubject<boolean>; private courseActive = <number>-1;
private showLoader: BehaviorSubject<boolean>;
private School$: BehaviorSubject<any>; private School$: BehaviorSubject<any>;
private SchoolSub: Subscription; private SchoolSub: Subscription;
private CapacityPerCourse$: BehaviorSubject<any>; private selectiontype: BehaviorSubject<boolean>;
private CapacityPerCourseSub: Subscription;
private SchoolId; private SchoolId;
private currentclass: Number;
private classCapacity$: BehaviorSubject<any>;
private classCapacitySub: Subscription;
private retrievedStudent: BehaviorSubject<boolean>;
private modalTitle: BehaviorSubject<string>;
private modalText: BehaviorSubject<string>;
private modalHeader: BehaviorSubject<string>;
private showLoader: BehaviorSubject<boolean>;
...@@ -164,33 +109,21 @@ import { ...@@ -164,33 +109,21 @@ import {
private _hds: HelperDataService, private _hds: HelperDataService,
private activatedRoute: ActivatedRoute, private activatedRoute: ActivatedRoute,
private router: Router) { private router: Router) {
this.StudentSelected$ = new BehaviorSubject([{}]);
this.StudentSelectedSpecial$ = new BehaviorSubject([{}]);
this.classCapacity$ = new BehaviorSubject([{}]);
this.CapacityPerCourse$ = new BehaviorSubject([{}]); this.CapacityPerCourse$ = new BehaviorSubject([{}]);
this.selectionBClass = new BehaviorSubject(false);
this.selectiontype = new BehaviorSubject(true);
this.selectionCClass = new BehaviorSubject(false);
this.retrievedStudent = new BehaviorSubject(false);
this.School$ = new BehaviorSubject([{}]);
this.modalTitle = new BehaviorSubject("");
this.modalText = new BehaviorSubject("");
this.modalHeader = new BehaviorSubject("");
this.showLoader = new BehaviorSubject(false); this.showLoader = new BehaviorSubject(false);
this.isEdit = false;
this.School$ = new BehaviorSubject([{}]);
this.selectiontype = new BehaviorSubject(true);
this.formGroup = this.fb.group({ this.formGroup = this.fb.group({
tomeas: ['', []],
taxi: ['', []], });
specialit: ['', []],
capacity: ['', [Validators.pattern(VALID_CAPACITY_PATTERN),Validators.required, maxValue(99), minValue(1)]],
});
} }
public showModal(popupMsgId):void {
public showModal(popupMsgId):void {
console.log("about to show modal"); console.log("about to show modal");
//(<any>$('#distributionWaitingNotice')).modal('show'); //(<any>$('#distributionWaitingNotice')).modal('show');
(<any>$(popupMsgId)).modal('show'); (<any>$(popupMsgId)).modal('show');
...@@ -205,28 +138,14 @@ import { ...@@ -205,28 +138,14 @@ import {
} }
ngOnDestroy() { ngOnDestroy() {
if (this.StudentSelectedSub)
this.StudentSelectedSub.unsubscribe();
if (this.StudentSelectedSpecialSub)
this.StudentSelectedSpecialSub.unsubscribe();
if (this.selectionBClass)
this.selectionBClass.unsubscribe();
if (this.selectionCClass)
this.selectionCClass.unsubscribe();
if (this.classCapacitySub)
this.classCapacitySub.unsubscribe();
if (this.retrievedStudent)
this.retrievedStudent.unsubscribe();
} }
ngOnInit() { ngOnInit() {
(<any>$('#capacitysaved')).appendTo("body"); (<any>$('#checksaved')).appendTo("body");
(<any>$('#checksaved')).appendTo("body"); this.SchoolSub = this._hds.gettypeofschool().subscribe(x => {
this.retrievedStudent.next(false);
this.SchoolSub = this._hds.gettypeofschool().subscribe(x => {
this.School$.next(x); this.School$.next(x);
console.log(x[0].type, "schoolid!"); console.log(x[0].type, "schoolid!");
this.SchoolId = x[0].type; this.SchoolId = x[0].type;
...@@ -242,8 +161,10 @@ import { ...@@ -242,8 +161,10 @@ import {
() => console.log("Getting School ")); () => console.log("Getting School "));
this.CapacityPerCourseSub = this._hds.FindCapacityPerSchool().subscribe(x => { this.CapacityPerCourseSub = this._hds.FindCapacityPerSchool().subscribe(x => {
this.CapacityPerCourse$.next(x); this.CapacityPerCourse$.next(x);
}, },
error => { error => {
this.CapacityPerCourse$.next([{}]); this.CapacityPerCourse$.next([{}]);
...@@ -258,148 +179,24 @@ import { ...@@ -258,148 +179,24 @@ import {
} }
verifyclass(txop) { handleChange ( e: Event) {
console.log(this.formGroup.value.specialit, "speciality"); this.newvalue = e.target['value'];
if (txop.value === "1") {
this.selectionBClass.next(false);
this.selectionCClass.next(false);
this.formGroup.patchValue({
tomeas: '',
specialit: '',
capacity: '',
});
console.log("a class");
this.showLoader.next(true);
this.classCapacitySub = this._hds.getCapacityPerSchool(this.formGroup.value.taxi, 0, 0).subscribe(data => {
this.showLoader.next(false);
this.classCapacity$.next(data);
this.retrievedStudent.next(true);
this.formGroup.patchValue({
capacity : data[0].capacity,
});
},
error => {
this.classCapacity$.next([{}]);
console.log("Error Getting Capacity");
},
() => console.log("Getting Capacity"));
}
else if (txop.value === "2") {
this.formGroup.patchValue({
tomeas: '',
specialit: '',
capacity: '',
});
this.selectionBClass.next(true);
this.selectionCClass.next(false);
this.StudentSelected$ = new BehaviorSubject([{}]);
this.StudentSelectedSub = this._hds.getSectorPerSchool().subscribe(this.StudentSelected$);
}
else if (txop.value === "3" || txop.value === "4" ) {
this.formGroup.patchValue({
tomeas: '',
specialit: '',
capacity: '',
});
var sectorint = +this.formGroup.value.tomeas;
console.log(sectorint, "test");
if (this.formGroup.value.tomeas != '') {
var sectorint = +this.formGroup.value.tomeas;
this.StudentSelectedSpecial$ = new BehaviorSubject([{}]);
this.StudentSelectedSpecialSub = this._hds.getSpecialityPerSchool( sectorint).subscribe(this.StudentSelectedSpecial$);
}
this.selectionBClass.next(true);
this.selectionCClass.next(true);
this.StudentSelected$ = new BehaviorSubject([{}]);
this.StudentSelectedSub = this._hds.getSectorPerSchool().subscribe(this.StudentSelected$);
}
} }
saveCapacity(spec,sect,taxi,oldvalue){
checkbclass(tmop, txop) { console.log(taxi, sect, spec);
console.log(this.newvalue,"newvalue", oldvalue);
if (this.newvalue!= null)
var sectorint = +this.formGroup.value.tomeas; {
console.log(tmop, txop, "tomeas!!!!"); if (this.newvalue <=0 || this.newvalue >10)
if (txop.value === "2") {
console.log("b class");
this.showLoader.next(true);
this.classCapacitySub = this._hds.getCapacityPerSchool(this.formGroup.value.taxi, sectorint, 0).subscribe(data => {
this.classCapacity$.next(data);
this.retrievedStudent.next(true);
this.showLoader.next(false);
this.formGroup.patchValue({
capacity : data[0].capacity,
});
},
error => {
this.classCapacity$.next([{}]);
console.log("Error Getting Capacity");
},
() => console.log("Getting Capacity"));
}
if (txop.value === "3" || txop.value === "4") {
this.StudentSelectedSpecial$ = new BehaviorSubject([{}]);
this.StudentSelectedSpecialSub = this._hds.getSpecialityPerSchool(sectorint).subscribe(this.StudentSelectedSpecial$);
}
}
checkcclass(tmop, txop, spop) {
var sectorint = +this.formGroup.value.tomeas;
var specialint = +this.formGroup.value.specialit;
if (txop.value === "3" || txop.value === "4") {
console.log("c class");
console.log(sectorint, specialint, "cclass")
this.showLoader.next(true);
this.classCapacitySub = this._hds.getCapacityPerSchool(this.formGroup.value.taxi, sectorint, specialint).subscribe(data => {
this.classCapacity$.next(data);
this.retrievedStudent.next(true);
this.showLoader.next(false);
this.formGroup.patchValue({
capacity : data[0].capacity,
});
},
error => {
this.classCapacity$.next([{}]);
console.log("Error Getting Capacity");
},
() => console.log("Getting Capacity"));
}
}
saveCapacity() {
var taxi = +this.formGroup.value.taxi;
var tomeas = +this.formGroup.value.tomeas;
var specialit = +this.formGroup.value.specialit;
var capc = +this.formGroup.value.capacity;
if ((taxi === 2 && tomeas === 0) || (taxi === 3 && tomeas === 0 ) || (taxi ===3 && specialit === 0 )
|| (taxi === 4 && tomeas === 0 ) || (taxi ===4 && specialit === 0 ) || (taxi = 0) || (this.formGroup.invalid)
)
{ {
this.showModal("#checksaved"); this.showModal("#checksaved");
} else }
{ else
this.showLoader.next(true); {
this.saveCapacitySub = this._hds.saveCapacity(this.formGroup.value.taxi, tomeas, specialit, this.formGroup.value.capacity).subscribe(data => { this.showLoader.next(true);
this.saveCapacitySub = this._hds.saveCapacity(taxi, sect, spec, this.newvalue).subscribe(data => {
this.showLoader.next(false); this.showLoader.next(false);
this.CapacityPerCourseSub = this._hds.FindCapacityPerSchool().subscribe(x => { this.CapacityPerCourseSub = this._hds.FindCapacityPerSchool().subscribe(x => {
...@@ -417,15 +214,21 @@ import { ...@@ -417,15 +214,21 @@ import {
}, },
() =>{ () =>{
console.log("Saved Capacity"); console.log("Saved Capacity");
this.showModal("#capacitysaved"); });
});
} }
}
} }
setActive(ind) {
this.courseActive = ind;
console.log(this.courseActive, ind, "ind");
}
} }
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