Commit 0bd653fe authored by Νίκος Κατσαούνος's avatar Νίκος Κατσαούνος

Merge branch 'develop' of https://git.minedu.gov.gr/itminedu/e-epal into version2

parents b0702831 b0ff65ab
...@@ -252,6 +252,14 @@ public function findGroupsForMerging(Request $request,$firstid, $classId, $secto ...@@ -252,6 +252,14 @@ public function findGroupsForMerging(Request $request,$firstid, $classId, $secto
$users = $this->entityTypeManager->getStorage('user')->loadByProperties(array('name' => $authToken)); $users = $this->entityTypeManager->getStorage('user')->loadByProperties(array('name' => $authToken));
$user = reset($users); $user = reset($users);
if ($user) { if ($user) {
$userRoles = $user->getRoles();
$userRole = '';
foreach ($userRoles as $tmpRole) {
if ( ($tmpRole === 'regioneduadmin') || ($tmpRole === 'eduadmin')) {
$userRole = $tmpRole;
}
}
$postData = null; $postData = null;
if ($content = $request->getContent()) if ($content = $request->getContent())
{ {
...@@ -273,13 +281,19 @@ public function findGroupsForMerging(Request $request,$firstid, $classId, $secto ...@@ -273,13 +281,19 @@ public function findGroupsForMerging(Request $request,$firstid, $classId, $secto
} }
//$recordsformerges = reset($recordsformerge)
if ($recordsformerge) if ($recordsformerge)
{ {
foreach ($recordsformerge as $recordsformerges) foreach ($recordsformerge as $recordsformerges)
{ {
$recordsformerges->set('initial_epal_id', $secondid); $secondmerge = $recordsformerges -> getepalid() ;
if (($secondmerge == '0') || ($secondmerge == null))
{
$recordsformerges->set('initial_epal_id', $secondid);
$recordsformerges->set('merging_role', $userRole);
}
$recordsformerges->set('epal_id', $firstid); $recordsformerges->set('epal_id', $firstid);
$recordsformerges->save(); $recordsformerges->save();
} }
...@@ -288,21 +302,21 @@ public function findGroupsForMerging(Request $request,$firstid, $classId, $secto ...@@ -288,21 +302,21 @@ public function findGroupsForMerging(Request $request,$firstid, $classId, $secto
} else { } else {
return $this->respondWithStatus([ return $this->respondWithStatus([
'error_code' => '1001'.$firstid.$secondid."//".$speciality."///".$classId, 'error_code' => '1001',
], Response::HTTP_FORBIDDEN); ], Response::HTTP_FORBIDDEN);
} }
return $this->respondWithStatus([ return $this->respondWithStatus([
'error_code' => '0'.$firstid.$secondid, 'error_code' => '0',
], Response::HTTP_OK); ], Response::HTTP_OK);
} else { } else {
return $this->respondWithStatus([ return $this->respondWithStatus([
'error_code' => '1002'.$firstid.$secondid, 'error_code' => '1002',
], Response::HTTP_BAD_REQUEST); ], Response::HTTP_BAD_REQUEST);
} }
} else { } else {
return $this->respondWithStatus([ return $this->respondWithStatus([
'error_code' => '1003'.$firstid.$secondid, 'error_code' => '1003',
], Response::HTTP_FORBIDDEN); ], Response::HTTP_FORBIDDEN);
} }
} }
...@@ -576,6 +590,16 @@ public function findMergingSchoolsforUndo(Request $request, $classId, $sector, $ ...@@ -576,6 +590,16 @@ public function findMergingSchoolsforUndo(Request $request, $classId, $sector, $
$users = $this->entityTypeManager->getStorage('user')->loadByProperties(array('name' => $authToken)); $users = $this->entityTypeManager->getStorage('user')->loadByProperties(array('name' => $authToken));
$user = reset($users); $user = reset($users);
if ($user) { if ($user) {
$userRoles = $user->getRoles();
$userRole = '';
foreach ($userRoles as $tmpRole) {
if ( ($tmpRole === 'regioneduadmin') || ($tmpRole === 'eduadmin')) {
$userRole = $tmpRole;
}
}
$postData = null; $postData = null;
if ($content = $request->getContent()) if ($content = $request->getContent())
{ {
...@@ -583,6 +607,7 @@ public function findMergingSchoolsforUndo(Request $request, $classId, $sector, $ ...@@ -583,6 +607,7 @@ public function findMergingSchoolsforUndo(Request $request, $classId, $sector, $
$firstid = $postData->firstid; $firstid = $postData->firstid;
$secondid = $postData->secondid; $secondid = $postData->secondid;
if ($classId == 1){ if ($classId == 1){
$recordsforundomerge = $this->entityTypeManager->getStorage('epal_student_class')->loadByProperties(array('initial_epal_id' => $firstid, 'specialization_id' => -1)); $recordsforundomerge = $this->entityTypeManager->getStorage('epal_student_class')->loadByProperties(array('initial_epal_id' => $firstid, 'specialization_id' => -1));
} }
...@@ -600,12 +625,24 @@ public function findMergingSchoolsforUndo(Request $request, $classId, $sector, $ ...@@ -600,12 +625,24 @@ public function findMergingSchoolsforUndo(Request $request, $classId, $sector, $
if ($recordsforundomerge) if ($recordsforundomerge)
{ {
foreach ($recordsforundomerge as $recordsforundomerges) $merging_role = reset($recordsforundomerge);
{ $role_forundomerge = $merging_role -> merging_role -> value;
$recordsforundomerges->set('initial_epal_id', 0); if (( $role_forundomerge == 'regioneduadmin') && ($userRole == 'eduadmin'))
$recordsforundomerges->set('epal_id', $firstid); {
$recordsforundomerges->save(); return $this->respondWithStatus([
'error_code' => '2500',
], Response::HTTP_FORBIDDEN);
} }
else
{
foreach ($recordsforundomerge as $recordsforundomerges)
{
$recordsforundomerges->set('initial_epal_id', 0);
$recordsforundomerges->set('epal_id', $firstid);
$recordsforundomerges->set('merging_role', null);
$recordsforundomerges->save();
}
}
} else { } else {
return $this->respondWithStatus([ return $this->respondWithStatus([
...@@ -613,7 +650,7 @@ public function findMergingSchoolsforUndo(Request $request, $classId, $sector, $ ...@@ -613,7 +650,7 @@ public function findMergingSchoolsforUndo(Request $request, $classId, $sector, $
], Response::HTTP_FORBIDDEN); ], Response::HTTP_FORBIDDEN);
} }
return $this->respondWithStatus([ return $this->respondWithStatus([
'error_code' => '0', 'error_code' => '0' ,
], Response::HTTP_OK); ], Response::HTTP_OK);
} else { } else {
return $this->respondWithStatus([ return $this->respondWithStatus([
......
...@@ -179,7 +179,8 @@ class EpalStudentClass extends ContentEntityBase implements EpalStudentClassInte ...@@ -179,7 +179,8 @@ class EpalStudentClass extends ContentEntityBase implements EpalStudentClassInte
public function getepalid() { public function getepalid() {
return $this->get('epal_id')->target_id; return $this->get('initial_epal_id')->target_id;
// return $this->get('initial_epal_id')->id();
} }
...@@ -481,6 +482,27 @@ class EpalStudentClass extends ContentEntityBase implements EpalStudentClassInte ...@@ -481,6 +482,27 @@ class EpalStudentClass extends ContentEntityBase implements EpalStudentClassInte
->setDisplayConfigurable('form', TRUE) ->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE); ->setDisplayConfigurable('view', TRUE);
$fields['merging_role'] = BaseFieldDefinition::create('string')
->setLabel(t('Ο ρόλος του χρήστη που κάνει συγχώνευση'))
->setDescription(t('Ρόλος του χρήστη που κάνει συγχώνευση'))
->setSettings(array(
'max_length' => 50,
'text_processing' => 0,
))
->setDefaultValue('')
->setDisplayOptions('view', array(
'label' => 'above',
'type' => 'string',
'weight' => -4,
))
->setDisplayOptions('form', array(
'type' => 'string_textfield',
'weight' => -4,
))
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
return $fields; return $fields;
} }
......
...@@ -45,7 +45,7 @@ import { FormBuilder, FormGroup } from "@angular/forms"; ...@@ -45,7 +45,7 @@ import { FormBuilder, FormGroup } from "@angular/forms";
<div *ngFor="let CoursesforMerges$ of School$ | async; let j=index; let isOdd=odd; <div *ngFor="let CoursesforMerges$ of School$ | async; let j=index; let isOdd=odd;
let isEven=even" class="row list-group-item isclickable" let isEven=even" class="row list-group-item isclickable"
[class.oddout]="isOdd" [class.evenout]="isEven" style="margin: 0px 2px 0px 2px;" [class.oddout]="isOdd" [class.evenout]="isEven" style="margin: 0px 2px 0px 2px;"
(click)="setActiveSchoolforCClass(CoursesforMerges$.id)" (click)="setActiveCourses(CoursesforMerges$.id)"
(click)="findmergingcourse(CoursesforMerges$.id,1,0,0)"> (click)="findmergingcourse(CoursesforMerges$.id,1,0,0)">
...@@ -154,7 +154,7 @@ import { FormBuilder, FormGroup } from "@angular/forms"; ...@@ -154,7 +154,7 @@ import { FormBuilder, FormGroup } from "@angular/forms";
class="row list-group-item isclickable" class="row list-group-item isclickable"
[class.oddout]="isOdd" [class.evenout]="isEven" [class.oddout]="isOdd" [class.evenout]="isEven"
style="margin: 0px 2px 0px 2px;" style="margin: 0px 2px 0px 2px;"
(click)="setActiveSchoolforCClass(CoursesforMerges$.id)" (click)="setActiveCourses(CoursesforMerges$.id)"
(click)="findmergingcourse(CoursesforMerges$.id,3,SectorNames$.id, Courses$.id)"> (click)="findmergingcourse(CoursesforMerges$.id,3,SectorNames$.id, Courses$.id)">
<div class="col-md-8" style=" font-weight: bold;" >{{CoursesforMerges$.name}}</div> <div class="col-md-8" style=" font-weight: bold;" >{{CoursesforMerges$.name}}</div>
<div class="col-md-3" style=" font-weight: bold;" >{{CoursesforMerges$.studentcount}}</div> <div class="col-md-3" style=" font-weight: bold;" >{{CoursesforMerges$.studentcount}}</div>
...@@ -273,6 +273,12 @@ import { FormBuilder, FormGroup } from "@angular/forms"; ...@@ -273,6 +273,12 @@ import { FormBuilder, FormGroup } from "@angular/forms";
setActiveSector(ind) setActiveSector(ind)
{ {
this.aclassActive = -1;
this.SectorActiveforBClass = -1;
this.regionActive = -1;
this.courseActive = -1;
this.specialActive = -1;
this.courseActiveforCClass = -1;
this.Specialit$.next([{}]); this.Specialit$.next([{}]);
if (ind === this.regionActive) { if (ind === this.regionActive) {
ind = -1; ind = -1;
...@@ -301,7 +307,12 @@ import { FormBuilder, FormGroup } from "@angular/forms"; ...@@ -301,7 +307,12 @@ import { FormBuilder, FormGroup } from "@angular/forms";
setActive(ind) setActive(ind)
{ {
this.aclassActive = -1;
this.SectorActiveforBClass = -1;
this.regionActive = -1;
this.courseActive = -1;
this.specialActive = -1;
this.courseActiveforCClass = -1;
this.School$.next([{}]); this.School$.next([{}]);
if (ind === this.SectorActiveforBClass) { if (ind === this.SectorActiveforBClass) {
ind = -1; ind = -1;
...@@ -356,7 +367,7 @@ import { FormBuilder, FormGroup } from "@angular/forms"; ...@@ -356,7 +367,7 @@ import { FormBuilder, FormGroup } from "@angular/forms";
setActiveSchoolforCClass(ind){ setActiveCourses(ind){
if (this.courseActive === ind) { if (this.courseActive === ind) {
ind = -1; ind = -1;
...@@ -380,7 +391,13 @@ import { FormBuilder, FormGroup } from "@angular/forms"; ...@@ -380,7 +391,13 @@ import { FormBuilder, FormGroup } from "@angular/forms";
setActiveclass(ind) setActiveclass(ind)
{ {
this.aclassActive = -1;
this.SectorActiveforBClass = -1;
this.regionActive = -1;
this.courseActive = -1;
this.specialActive = -1;
this.courseActiveforCClass = -1;
this.School$.next([{}]);
if (this.aclassActive === ind) if (this.aclassActive === ind)
{ {
ind = -1; ind = -1;
......
...@@ -30,6 +30,29 @@ import { HelperDataService } from "../../services/helper-data-service"; ...@@ -30,6 +30,29 @@ import { HelperDataService } from "../../services/helper-data-service";
</div> </div>
<div id="UndoMergeError" (onHidden)="onHidden()" class="modal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static" data-keyboard="false">
<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-ban"></i>&nbsp;&nbsp;Αποτυχία Αναίρεσης Συνένωσης</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>Δεν έχετε δικαίωμα να αναιρέσετε τη συγκεκριμένη συνένωση!</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-right" data-dismiss="modal" (click)="hideErrorModal()">Κλείσιμο</button>
</div>
</div>
</div>
</div>
<div class = "loading" *ngIf="(showLoader | async) === true"></div> <div class = "loading" *ngIf="(showLoader | async) === true"></div>
...@@ -267,15 +290,27 @@ import { HelperDataService } from "../../services/helper-data-service"; ...@@ -267,15 +290,27 @@ import { HelperDataService } from "../../services/helper-data-service";
(<any>$("#undoMergeConfirm")).modal("hide"); (<any>$("#undoMergeConfirm")).modal("hide");
} }
public showErrorModal(): void {
(<any>jQuery("#UndoMergeError")).modal("show");
}
public hideErrorModal(): void {
(<any>jQuery("#UndoMergeError")).modal("hide");
}
ngOnDestroy() ngOnDestroy()
{ {
(<any>$("#undoMergeConfirm")).remove(); (<any>$("#undoMergeConfirm")).remove();
(<any>jQuery("#UndoMergeError")).remove();
} }
ngOnInit() { ngOnInit() {
this.findsectors(); this.findsectors();
this.retrievedSch.next(false); this.retrievedSch.next(false);
(<any>$("#undoMergeConfirm")).appendTo("body"); (<any>$("#undoMergeConfirm")).appendTo("body");
(<any>jQuery("#UndoMergeError")).appendTo("body");
} }
...@@ -294,7 +329,9 @@ import { HelperDataService } from "../../services/helper-data-service"; ...@@ -294,7 +329,9 @@ import { HelperDataService } from "../../services/helper-data-service";
setActiveclass(ind) setActiveclass(ind)
{ {
this.SectorActiveforBClass = -1;
this.SectorActiveforCClass = -1;
this.courseActive = -1;
if (this.aclassActive === ind) if (this.aclassActive === ind)
{ {
ind = -1; ind = -1;
...@@ -355,6 +392,11 @@ import { HelperDataService } from "../../services/helper-data-service"; ...@@ -355,6 +392,11 @@ import { HelperDataService } from "../../services/helper-data-service";
setActiveSectorBClass(ind) setActiveSectorBClass(ind)
{ {
this.SectorActiveforCClass = -1;
this.courseActive = -1;
this.aclassActive =-1;
if (this.SectorActiveforBClass === ind){ if (this.SectorActiveforBClass === ind){
ind = -1 ind = -1
} }
...@@ -369,6 +411,10 @@ import { HelperDataService } from "../../services/helper-data-service"; ...@@ -369,6 +411,10 @@ import { HelperDataService } from "../../services/helper-data-service";
setActiveSectorCClass(ind) setActiveSectorCClass(ind)
{ {
this.SectorActiveforBClass = -1;
this.courseActive = -1;
this.aclassActive =-1;
if (this.SectorActiveforCClass === ind){ if (this.SectorActiveforCClass === ind){
ind = -1 ind = -1
} }
...@@ -437,7 +483,8 @@ import { HelperDataService } from "../../services/helper-data-service"; ...@@ -437,7 +483,8 @@ import { HelperDataService } from "../../services/helper-data-service";
}) })
.catch(err => { .catch(err => {
this.showLoader.next(false); this.showLoader.next(false);
console.log("err"); this.showErrorModal();
console.log("error undoMerge");
}); });
} }
......
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