Skip to content

Commit

Permalink
Merge pull request #154 from Want100Cookies/feature/periods-fix
Browse files Browse the repository at this point in the history
Feature/periods fix
  • Loading branch information
jstrating authored Jan 25, 2018
2 parents ea1a641 + 0627e78 commit bc427da
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
};
Expand All @@ -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();
Expand Down
9 changes: 5 additions & 4 deletions src/main/resources/public/app/js/groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit bc427da

Please sign in to comment.