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
$users = $this->entityTypeManager->getStorage('user')->loadByProperties(array('name' => $authToken));
$user = reset($users);
if ($user) {
$userRoles = $user->getRoles();
$userRole = '';
foreach ($userRoles as $tmpRole) {
if ( ($tmpRole === 'regioneduadmin') || ($tmpRole === 'eduadmin')) {
$userRole = $tmpRole;
}
}
$postData = null;
if ($content = $request->getContent())
{
......@@ -273,13 +281,19 @@ public function findGroupsForMerging(Request $request,$firstid, $classId, $secto
}
//$recordsformerges = reset($recordsformerge)
if ($recordsformerge)
{
foreach ($recordsformerge as $recordsformerges)
{
$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->save();
}
......@@ -288,21 +302,21 @@ public function findGroupsForMerging(Request $request,$firstid, $classId, $secto
} else {
return $this->respondWithStatus([
'error_code' => '1001'.$firstid.$secondid."//".$speciality."///".$classId,
'error_code' => '1001',
], Response::HTTP_FORBIDDEN);
}
return $this->respondWithStatus([
'error_code' => '0'.$firstid.$secondid,
'error_code' => '0',
], Response::HTTP_OK);
} else {
return $this->respondWithStatus([
'error_code' => '1002'.$firstid.$secondid,
'error_code' => '1002',
], Response::HTTP_BAD_REQUEST);
}
} else {
return $this->respondWithStatus([
'error_code' => '1003'.$firstid.$secondid,
'error_code' => '1003',
], Response::HTTP_FORBIDDEN);
}
}
......@@ -576,6 +590,16 @@ public function findMergingSchoolsforUndo(Request $request, $classId, $sector, $
$users = $this->entityTypeManager->getStorage('user')->loadByProperties(array('name' => $authToken));
$user = reset($users);
if ($user) {
$userRoles = $user->getRoles();
$userRole = '';
foreach ($userRoles as $tmpRole) {
if ( ($tmpRole === 'regioneduadmin') || ($tmpRole === 'eduadmin')) {
$userRole = $tmpRole;
}
}
$postData = null;
if ($content = $request->getContent())
{
......@@ -583,6 +607,7 @@ public function findMergingSchoolsforUndo(Request $request, $classId, $sector, $
$firstid = $postData->firstid;
$secondid = $postData->secondid;
if ($classId == 1){
$recordsforundomerge = $this->entityTypeManager->getStorage('epal_student_class')->loadByProperties(array('initial_epal_id' => $firstid, 'specialization_id' => -1));
}
......@@ -599,13 +624,25 @@ public function findMergingSchoolsforUndo(Request $request, $classId, $sector, $
if ($recordsforundomerge)
{
$merging_role = reset($recordsforundomerge);
$role_forundomerge = $merging_role -> merging_role -> value;
if (( $role_forundomerge == 'regioneduadmin') && ($userRole == 'eduadmin'))
{
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 {
return $this->respondWithStatus([
......@@ -613,7 +650,7 @@ public function findMergingSchoolsforUndo(Request $request, $classId, $sector, $
], Response::HTTP_FORBIDDEN);
}
return $this->respondWithStatus([
'error_code' => '0',
'error_code' => '0' ,
], Response::HTTP_OK);
} else {
return $this->respondWithStatus([
......
......@@ -179,7 +179,8 @@ class EpalStudentClass extends ContentEntityBase implements EpalStudentClassInte
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
->setDisplayConfigurable('form', 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;
}
......
......@@ -45,7 +45,7 @@ import { FormBuilder, FormGroup } from "@angular/forms";
<div *ngFor="let CoursesforMerges$ of School$ | async; let j=index; let isOdd=odd;
let isEven=even" class="row list-group-item isclickable"
[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)">
......@@ -154,7 +154,7 @@ import { FormBuilder, FormGroup } from "@angular/forms";
class="row list-group-item isclickable"
[class.oddout]="isOdd" [class.evenout]="isEven"
style="margin: 0px 2px 0px 2px;"
(click)="setActiveSchoolforCClass(CoursesforMerges$.id)"
(click)="setActiveCourses(CoursesforMerges$.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-3" style=" font-weight: bold;" >{{CoursesforMerges$.studentcount}}</div>
......@@ -273,6 +273,12 @@ import { FormBuilder, FormGroup } from "@angular/forms";
setActiveSector(ind)
{
this.aclassActive = -1;
this.SectorActiveforBClass = -1;
this.regionActive = -1;
this.courseActive = -1;
this.specialActive = -1;
this.courseActiveforCClass = -1;
this.Specialit$.next([{}]);
if (ind === this.regionActive) {
ind = -1;
......@@ -301,7 +307,12 @@ import { FormBuilder, FormGroup } from "@angular/forms";
setActive(ind)
{
this.aclassActive = -1;
this.SectorActiveforBClass = -1;
this.regionActive = -1;
this.courseActive = -1;
this.specialActive = -1;
this.courseActiveforCClass = -1;
this.School$.next([{}]);
if (ind === this.SectorActiveforBClass) {
ind = -1;
......@@ -356,7 +367,7 @@ import { FormBuilder, FormGroup } from "@angular/forms";
setActiveSchoolforCClass(ind){
setActiveCourses(ind){
if (this.courseActive === ind) {
ind = -1;
......@@ -380,7 +391,13 @@ import { FormBuilder, FormGroup } from "@angular/forms";
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)
{
ind = -1;
......
......@@ -30,6 +30,29 @@ import { HelperDataService } from "../../services/helper-data-service";
</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>
......@@ -267,15 +290,27 @@ import { HelperDataService } from "../../services/helper-data-service";
(<any>$("#undoMergeConfirm")).modal("hide");
}
public showErrorModal(): void {
(<any>jQuery("#UndoMergeError")).modal("show");
}
public hideErrorModal(): void {
(<any>jQuery("#UndoMergeError")).modal("hide");
}
ngOnDestroy()
{
(<any>$("#undoMergeConfirm")).remove();
(<any>jQuery("#UndoMergeError")).remove();
}
ngOnInit() {
this.findsectors();
this.retrievedSch.next(false);
(<any>$("#undoMergeConfirm")).appendTo("body");
(<any>jQuery("#UndoMergeError")).appendTo("body");
}
......@@ -294,7 +329,9 @@ import { HelperDataService } from "../../services/helper-data-service";
setActiveclass(ind)
{
this.SectorActiveforBClass = -1;
this.SectorActiveforCClass = -1;
this.courseActive = -1;
if (this.aclassActive === ind)
{
ind = -1;
......@@ -355,6 +392,11 @@ import { HelperDataService } from "../../services/helper-data-service";
setActiveSectorBClass(ind)
{
this.SectorActiveforCClass = -1;
this.courseActive = -1;
this.aclassActive =-1;
if (this.SectorActiveforBClass === ind){
ind = -1
}
......@@ -369,6 +411,10 @@ import { HelperDataService } from "../../services/helper-data-service";
setActiveSectorCClass(ind)
{
this.SectorActiveforBClass = -1;
this.courseActive = -1;
this.aclassActive =-1;
if (this.SectorActiveforCClass === ind){
ind = -1
}
......@@ -437,7 +483,8 @@ import { HelperDataService } from "../../services/helper-data-service";
})
.catch(err => {
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