Commit 451b831d authored by Open Source Developer's avatar Open Source Developer

min max value check

parent 77fa887c
...@@ -362,6 +362,13 @@ public function SaveCapacity(Request $request,$taxi,$tomeas,$specialit) ...@@ -362,6 +362,13 @@ public function SaveCapacity(Request $request,$taxi,$tomeas,$specialit)
{ {
$postData = json_decode($content); $postData = json_decode($content);
$cap = $postData->capacity; $cap = $postData->capacity;
if ($cap<= 0 || $cap > 99)
{
return $this->respondWithStatus([
'message' => t("Number out of limits!"),
], Response::HTTP_BAD_REQUEST);
}
if (($tomeas == 0) && ($specialit == 0)) if (($tomeas == 0) && ($specialit == 0))
{ {
$CapacityPerClass = $this->entityTypeManager->getStorage('eepal_school')->loadByProperties(array('id' => $schoolid )); $CapacityPerClass = $this->entityTypeManager->getStorage('eepal_school')->loadByProperties(array('id' => $schoolid ));
......
...@@ -9,6 +9,9 @@ import { IAppState } from '../../store/store'; ...@@ -9,6 +9,9 @@ import { IAppState } from '../../store/store';
import {Router, ActivatedRoute, Params} from '@angular/router'; import {Router, ActivatedRoute, Params} from '@angular/router';
import { BehaviorSubject, Subscription } from 'rxjs/Rx'; import { BehaviorSubject, Subscription } from 'rxjs/Rx';
import { ILoginInfo } from '../../store/logininfo/logininfo.types'; import { ILoginInfo } from '../../store/logininfo/logininfo.types';
import { VALID_CAPACITY_PATTERN} from '../../constants';
import {maxValue} from '../../constants';
import { import {
FormBuilder, FormBuilder,
...@@ -48,7 +51,14 @@ import { ...@@ -48,7 +51,14 @@ import {
<p style="margin-top: 20px; line-height: 2em;"> Αλλάξτε παρακαλώ τον αριθμό των τμημάτων που μπορείτε να δημιουργήσετε στο σχολείο σας και πατήστε <i>Αποθήκευση</i>.</p> <p style="margin-top: 20px; line-height: 2em;"> Αλλάξτε παρακαλώ τον αριθμό των τμημάτων που μπορείτε να δημιουργήσετε στο σχολείο σας και πατήστε <i>Αποθήκευση</i>.</p>
<input type="number" formControlName="capacity" min="1" max="10"> <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('required')">
Παρακαλώ συμπληρώστε ένα μικρότερο αριθμό!
</div>
<button type="button" class="btn-primary btn-sm pull-right" (click) ="saveCapacity()"> <button type="button" class="btn-primary btn-sm pull-right" (click) ="saveCapacity()">
Αποθήκευση Αποθήκευση
...@@ -148,11 +158,15 @@ import { ...@@ -148,11 +158,15 @@ import {
tomeas: ['', []], tomeas: ['', []],
taxi: ['', []], taxi: ['', []],
specialit: ['', []], specialit: ['', []],
capacity: ['', []], capacity: ['', [Validators.pattern(VALID_CAPACITY_PATTERN),Validators.required, maxValue(99)]],
}); });
} }
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');
...@@ -325,8 +339,6 @@ import { ...@@ -325,8 +339,6 @@ import {
} }
saveCapacity() { saveCapacity() {
var taxi = +this.formGroup.value.taxi; var taxi = +this.formGroup.value.taxi;
...@@ -336,7 +348,9 @@ import { ...@@ -336,7 +348,9 @@ import {
if ((taxi === 2 && tomeas === 0) || (taxi === 3 && tomeas === 0 ) || (taxi ===3 && specialit === 0 ) if ((taxi === 2 && tomeas === 0) || (taxi === 3 && tomeas === 0 ) || (taxi ===3 && specialit === 0 )
|| (taxi === 4 && tomeas === 0 ) || (taxi ===4 && specialit === 0 ) || (taxi = 0) || (capc ===0)) || (taxi === 4 && tomeas === 0 ) || (taxi ===4 && specialit === 0 ) || (taxi = 0) || (this.formGroup.invalid)
)
{ {
this.showModal("#checksaved"); this.showModal("#checksaved");
} else } else
......
...@@ -19,13 +19,16 @@ import { ...@@ -19,13 +19,16 @@ import {
@Component({ @Component({
selector: 'eduadmin-view', selector: 'eduadmin-view',
template: ` template: `
<h3> Αριθμός Μαθητών ανα τμήμα σχολείου </h3> <h4> Αριθμός Μαθητών ανα τμήμα σχολείου!!! </h4>
<div class = "loading" *ngIf="(SchoolsPerPerf$ | async).size === 0">
</div>
<ul class="list-group main-view"> <ul class="list-group main-view">
<div *ngFor="let SchoolNames$ of SchoolsPerPerf$ | async; let i=index; let isOdd=odd; let isEven=even" > <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 === false" [class.oddout]="isOdd" [class.evenout]="isEven" [class.selectedout]="regionActive === SchoolNames$.id" > <li class="list-group-item isclickable" (click)="setActiveRegion(SchoolNames$.id)" [class.changelistcolor]= "SchoolNames$.status === false" [class.oddout]="isOdd" [class.evenout]="isEven" [class.selectedout]="regionActive === SchoolNames$.id" >
<h5> {{SchoolNames$.name}}</h5> <h5> {{SchoolNames$.name}}</h5>
</li> </li>
<div class = "loading" *ngIf="(CoursesPerPerf$ | async).size === 0">
</div>
<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 *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>
......
import {ValidatorFn} from '@angular/forms';
import {AbstractControl} from '@angular/forms';
export const COURSEFIELDS_RECEIVED = 'COURSEFIELDS_RECEIVED'; export const COURSEFIELDS_RECEIVED = 'COURSEFIELDS_RECEIVED';
export const COURSEFIELDS_SELECTED_SAVE = 'COURSEFIELDS_SELECTED_SAVE'; export const COURSEFIELDS_SELECTED_SAVE = 'COURSEFIELDS_SELECTED_SAVE';
...@@ -40,6 +45,8 @@ export const VALID_NAMES_PATTERN = '[A-Za-zΑ-ΩΆΈΉΊΙΎΌΏα-ωάέήίΐ ...@@ -40,6 +45,8 @@ export const VALID_NAMES_PATTERN = '[A-Za-zΑ-ΩΆΈΉΊΙΎΌΏα-ωάέήίΐ
export const VALID_ADDRESS_PATTERN = '[0-9A-Za-zΑ-ΩΆΈΉΊΎΌΏα-ωάέήίύόώ ]*$'; export const VALID_ADDRESS_PATTERN = '[0-9A-Za-zΑ-ΩΆΈΉΊΎΌΏα-ωάέήίύόώ ]*$';
export const VALID_ADDRESSTK_PATTERN = '[0-9 ]*$'; export const VALID_ADDRESSTK_PATTERN = '[0-9 ]*$';
export const VALID_DIGITS_PATTERN = '69[0-9]*$'; export const VALID_DIGITS_PATTERN = '69[0-9]*$';
export const VALID_CAPACITY_PATTERN = '[0-9]*$';
export const VALID_EMAIL_PATTERN = '[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,64}'; export const VALID_EMAIL_PATTERN = '[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,64}';
...@@ -57,3 +64,14 @@ export const STUDENT_ROLE = 'student'; ...@@ -57,3 +64,14 @@ export const STUDENT_ROLE = 'student';
export const PDE_ROLE = 'pde'; export const PDE_ROLE = 'pde';
export const DIDE_ROLE = 'dide'; export const DIDE_ROLE = 'dide';
export const MINISTRY_ROLE = 'supervisor'; export const MINISTRY_ROLE = 'supervisor';
export function maxValue(max: Number): ValidatorFn {
return (control: AbstractControl): {[key: string]: any} => {
const input = control.value,
isValid = input > 99;
if(isValid)
return { 'maxValue': {max} }
else
return null;
};
}
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