diff --git a/src/main/resources/public/app/components/teacherCard.component.js b/src/main/resources/public/app/components/teacherCard.component.js index c5f17a6..36386e0 100644 --- a/src/main/resources/public/app/components/teacherCard.component.js +++ b/src/main/resources/public/app/components/teacherCard.component.js @@ -115,6 +115,11 @@ function EditGroupDialogController($scope, $mdDialog, EducationService, group, G } }); + const groupPeriods = []; + for(const p of group.period){ + groupPeriods[p] = true; + } + $scope.vm = { formData: { groupName: group.groupName, @@ -127,9 +132,10 @@ function EditGroupDialogController($scope, $mdDialog, EducationService, group, G id: group.course.education.id } }, - period: group.period, + period: groupPeriods, }, }; + $scope.usersChange = (val) => { $scope.vm.formData.users = val; }; @@ -151,6 +157,12 @@ function EditGroupDialogController($scope, $mdDialog, EducationService, group, G if (Object.keys($scope.vm.formData.period).length !== 0 && $scope.vm.formData.users.length !== 0 && $scope.vm.formData.groupName != null && $scope.vm.formData.startYear != null && $scope.vm.formData.endYear != null && $scope.vm.formData.course != null) { + + const periods = []; + for(const p in $scope.vm.formData.period) { + if($scope.vm.formData.period[p] === true) periods.push(p); + } + $scope.vm.formData.period = periods; GroupService.editGroup($scope.vm.formData, $scope.group.id); $scope.showSimpleToast(); $scope.hide(); diff --git a/src/main/resources/public/app/js/groups.js b/src/main/resources/public/app/js/groups.js index a8ea415..b12f4ea 100644 --- a/src/main/resources/public/app/js/groups.js +++ b/src/main/resources/public/app/js/groups.js @@ -27,10 +27,10 @@ app.controller('TeacherGroupsCtrl', function ($scope, $mdDialog, UserService, Gr $scope.closed = []; $scope.pending = []; $scope.open = []; - - angular.forEach($scope.teacherGroupList, function(value, key) { - GroupService.getGradingStatus(value.id).then(function(response){ - switch(response.data.status){ + + angular.forEach($scope.teacherGroupList, function (value, key) { + GroupService.getGradingStatus(value.id).then(function (response) { + switch (response.data.status) { case "CLOSED": $scope.closed.push(value); break; @@ -109,6 +109,7 @@ app.controller('TeacherGroupsCtrl', function ($scope, $mdDialog, UserService, Gr if (Object.keys($scope.vm.formData.period).length !== 0 && $scope.vm.formData.users.length !== 0 && $scope.vm.formData.groupName != null && $scope.vm.formData.startYear != null && $scope.vm.formData.endYear != null && $scope.vm.formData.course != null) { + $scope.vm.formData.period = Object.keys($scope.vm.formData.period); GroupService.createGroup($scope.vm.formData); $scope.showSimpleToast(); $scope.hide();