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:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\DirectorView::FindCapacityPerSchool'
requirements:
_user_is_logged_in: 'TRUE'
epal.applicant.creationpdf:
path: '/epal/pdf-application'
options:
......
......@@ -26,76 +26,50 @@ import {
template: `
<div class = "loading" *ngIf="(showLoader | async) === true"></div>
<div style="min-height: 500px;">
<form [formGroup]="formGroup">
<label for="taxi">Τάξη</label><br/>
<div class="form-group">
<select #txoption class="form-control" (change)="verifyclass(txoption)" formControlName="taxi">
<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>
<form [formGroup]="formGroup">
<p style="margin-top: 20px; line-height: 2em;"> Στην παρακάτω'λίστα βλέπετε τα τμήματα του σχολείου σας με την αντίστοιχη δυναμίκη τους σε αίθουσες. Παρακαλώ για να τροποποποιήσετε τη δυναμικήαυτή κάντε κλικ στον αντίστοιχο αριθμό,
επιλέξτε τη νέα δυναμική και πατήστε το σύμβολο <i>ok</i>. Προσοχή! Κανένα τμήμα δεν πρέπει να έχει δυναμική 0.</p>
<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" >
<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>
</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">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<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')">
<span aria-hidden="true"><i class="fa fa-times"></i></span>
</button>
</div>
<div class="modal-body">
<p>Η αποθήκευση δε μπορεί να γίνει αν δεν συμπληρώσετε όλα τα στοιχεία της φόρμας!</p>
<p>Η αποθήκευση δε μπορεί να γίνει αν δεν συμπληρώσετε έναν αριθμό μεταξυ 1 και 10!</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal">Κλείσιμο</button>
......@@ -104,26 +78,7 @@ import {
</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 {
@Injectable() export default class DirectorClassCapacity implements OnInit, OnDestroy {
public formGroup: FormGroup;
private StudentSelected$: BehaviorSubject<any>;
private StudentSelectedSub: Subscription;
private StudentSelectedSpecial$: BehaviorSubject<any>;
private StudentSelectedSpecialSub: Subscription;
private CapacityPerCourse$: BehaviorSubject<any>;
private CapacityPerCourseSub: Subscription;
private saveCapacitySub: Subscription;
private selectionBClass: BehaviorSubject<boolean>;
private selectiontype: BehaviorSubject<boolean>;
private selectionCClass: BehaviorSubject<boolean>;
private newvalue:number;
private isEdit: boolean;
private courseActive = <number>-1;
private showLoader: BehaviorSubject<boolean>;
private School$: BehaviorSubject<any>;
private SchoolSub: Subscription;
private CapacityPerCourse$: BehaviorSubject<any>;
private CapacityPerCourseSub: Subscription;
private selectiontype: BehaviorSubject<boolean>;
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 {
private _hds: HelperDataService,
private activatedRoute: ActivatedRoute,
private router: Router) {
this.StudentSelected$ = new BehaviorSubject([{}]);
this.StudentSelectedSpecial$ = new BehaviorSubject([{}]);
this.classCapacity$ = 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.isEdit = false;
this.School$ = new BehaviorSubject([{}]);
this.selectiontype = new BehaviorSubject(true);
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");
//(<any>$('#distributionWaitingNotice')).modal('show');
(<any>$(popupMsgId)).modal('show');
......@@ -205,28 +138,14 @@ import {
}
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() {
(<any>$('#capacitysaved')).appendTo("body");
(<any>$('#checksaved')).appendTo("body");
this.retrievedStudent.next(false);
this.SchoolSub = this._hds.gettypeofschool().subscribe(x => {
(<any>$('#checksaved')).appendTo("body");
this.SchoolSub = this._hds.gettypeofschool().subscribe(x => {
this.School$.next(x);
console.log(x[0].type, "schoolid!");
this.SchoolId = x[0].type;
......@@ -242,8 +161,10 @@ import {
() => console.log("Getting School "));
this.CapacityPerCourseSub = this._hds.FindCapacityPerSchool().subscribe(x => {
this.CapacityPerCourse$.next(x);
this.CapacityPerCourse$.next(x);
},
error => {
this.CapacityPerCourse$.next([{}]);
......@@ -258,148 +179,24 @@ import {
}
verifyclass(txop) {
console.log(this.formGroup.value.specialit, "speciality");
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$);
}
handleChange ( e: Event) {
this.newvalue = e.target['value'];
}
saveCapacity(spec,sect,taxi,oldvalue){
checkbclass(tmop, txop) {
var sectorint = +this.formGroup.value.tomeas;
console.log(tmop, txop, "tomeas!!!!");
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)
)
console.log(taxi, sect, spec);
console.log(this.newvalue,"newvalue", oldvalue);
if (this.newvalue!= null)
{
if (this.newvalue <=0 || this.newvalue >10)
{
this.showModal("#checksaved");
} else
{
this.showLoader.next(true);
this.saveCapacitySub = this._hds.saveCapacity(this.formGroup.value.taxi, tomeas, specialit, this.formGroup.value.capacity).subscribe(data => {
}
else
{
this.showLoader.next(true);
this.saveCapacitySub = this._hds.saveCapacity(taxi, sect, spec, this.newvalue).subscribe(data => {
this.showLoader.next(false);
this.CapacityPerCourseSub = this._hds.FindCapacityPerSchool().subscribe(x => {
......@@ -417,15 +214,21 @@ import {
},
() =>{
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