-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add POST API integration - Add flash messages service - BodyCtrl is in charge of flash messages usage - Add handling error service - Add actions behavior on view - Show edit course grade if not final taken - Add edit course grade modal - Add alert directive - Add some style to server side errors
- Loading branch information
1 parent
3d535bc
commit 311e962
Showing
19 changed files
with
459 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
app/scripts/controllers/modals/EditCourseGradeController.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
'use strict'; | ||
|
||
define(['paw', 'services/modalFactory', 'services/Students', 'services/flashMessages'], function(paw) { | ||
paw.controller('EditCourseGradeController', | ||
['modalFactory', '$log', 'Students', '$route', 'flashMessages', | ||
function (modalFactory, $log, Students, $route, flashMessages) { | ||
var modalTemplateUrl = 'views/modals/edit_course_grade.html'; | ||
var onSuccess = function(result) { | ||
Students.updateGrade(result.docket, result.gradeId, result.courseId, result.newGrade) | ||
.then(function(response) { | ||
flashMessages.setSuccess('i18nEditSuccess'); | ||
$route.reload(); | ||
}, function(response) { | ||
flashMessages.setError('i18nFormErrors'); | ||
$log.warn('[ERROR] - Response: ' + JSON.stringify(response)); | ||
$route.reload(); | ||
}); | ||
}; | ||
|
||
var onFailure = function(msg) { | ||
$log.info(msg); | ||
}; | ||
|
||
this.open = function (size, docket, fullName, courseId, courseName, grade, gradeId) { | ||
var resolve = getResolve(docket, fullName, courseId, courseName, grade, gradeId); | ||
modalFactory.create(size, 'EditCourseGradeModalInstanceController', modalTemplateUrl, resolve, onSuccess, onFailure); | ||
}; | ||
}]); | ||
|
||
paw.controller('EditCourseGradeModalInstanceController', | ||
function($uibModalInstance, docket, fullName, courseId, courseName, grade, gradeId) { | ||
this.docket = docket; | ||
this.fullName = fullName; | ||
this.courseId = courseId; | ||
this.courseName = courseName; | ||
this.grade = grade; | ||
this.gradeId = gradeId; | ||
|
||
var _this = this; | ||
|
||
this.ok = function () { | ||
$uibModalInstance.close({ | ||
docket: docket, | ||
gradeId: gradeId, | ||
courseId: courseId, | ||
newGrade: _this.grade | ||
}); | ||
}; | ||
|
||
this.cancel = function () { | ||
$uibModalInstance.dismiss('Edit course grade modal dismissed at: ' + new Date()); | ||
}; | ||
}); | ||
|
||
function getResolve(docket, fullName, courseId, courseName, grade, gradeId) { | ||
return { | ||
docket: function () { | ||
return docket; | ||
}, | ||
fullName: function () { | ||
return fullName; | ||
}, | ||
courseId: function () { | ||
return courseId; | ||
}, | ||
courseName: function () { | ||
return courseName; | ||
}, | ||
grade: function () { | ||
return grade; | ||
}, | ||
gradeId: function () { | ||
return gradeId; | ||
} | ||
}; | ||
}; | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
'use strict'; | ||
define( | ||
[ | ||
'paw', | ||
'services/Students', | ||
'services/Paths', | ||
'controllers/modals/EditCourseGradeController' | ||
], function(paw) { | ||
paw.controller('StudentsGradesCtrl', | ||
['$routeParams', | ||
'Students', | ||
'$log', | ||
'Paths', | ||
function($routeParams, Students, $log, Paths) { | ||
var _this = this; | ||
|
||
Students.get($routeParams.docket).then(function(student) { | ||
_this.student = student; | ||
_this.student.getList('grades').then(function(transcript) { | ||
_this.student.transcript = transcript; | ||
}); | ||
}, function(response) { | ||
$log.info('Response status: ' + response.status); | ||
if (response.status === 404) { | ||
Paths.get().notFound().go(); | ||
} | ||
}); | ||
|
||
this.getCoursePath = function(courseId) { | ||
return Paths.get().courses({courseId: courseId}).path; | ||
}; | ||
}]); | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'use strict'; | ||
|
||
define(['paw'], function(paw) { | ||
paw.directive('xalert', function () { | ||
return { | ||
link: link, | ||
restrict: 'E', | ||
scope: {}, | ||
bindToController: { | ||
msg: '@', | ||
type: '@' | ||
}, | ||
templateUrl: 'views/directives/alert.html', | ||
controller: function() {}, | ||
controllerAs: 'controller' | ||
}; | ||
|
||
function link(scope, element, attrs) { | ||
scope.show = true; | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
'use strict'; | ||
|
||
define(['paw'], function(paw) { | ||
paw.service('flashMessages', [ | ||
function() { | ||
var memory = this; | ||
|
||
memory.getErrors = function() { | ||
return memory.errors; | ||
}; | ||
|
||
memory.setError = function(error) { | ||
memory.errors.push(error); | ||
}; | ||
|
||
memory.getSuccesses = function() { | ||
return memory.successes; | ||
}; | ||
|
||
memory.setSuccess = function(success) { | ||
memory.successes.push(success); | ||
}; | ||
|
||
memory.clear = function() { | ||
memory.errors = []; | ||
memory.successes = []; | ||
}; | ||
|
||
// initialize errors and successes arrays | ||
memory.clear(); | ||
}]); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.