-
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.
Integrate Courses Students Index Integrated Students Passed Index Integrated Courses Final Inscriptions Show Clean Code Add courseName to FinalInscriptionIndexDTO Integrated Students Final Inscriptions Index Unify Enroll & Unenroll Modal
- Loading branch information
1 parent
9bb30a5
commit a58c5ac
Showing
23 changed files
with
478 additions
and
309 deletions.
There are no files selected for viewing
70 changes: 18 additions & 52 deletions
70
app/scripts/controllers/courses/CoursesFinalInscriptionShowCtrl.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 |
---|---|---|
@@ -1,62 +1,28 @@ | ||
'use strict'; | ||
|
||
define(['paw'], function(paw) { | ||
paw.controller('CoursesFinalInscriptionShowCtrl', ['$routeParams', function($routeParams) { | ||
define(['paw','services/Courses','services/Paths'], function(paw) { | ||
paw.controller('CoursesFinalInscriptionShowCtrl', ['$routeParams', 'Courses', '$log', 'Paths', function($routeParams, Courses, $log, Paths) { | ||
|
||
var _this = this; | ||
var courseId = $routeParams.courseId; | ||
var inscriptionId = $routeParams.inscriptionId; | ||
|
||
this.formatDate = function(finalExamDate) { | ||
var date = finalExamDate.split('T')[0]; | ||
var time = finalExamDate.split('T')[1]; | ||
return date.split('-')[2] + '/' + date.split('-')[1] + '/' + date.split('-')[0] + ' ' + time; | ||
}; | ||
|
||
this.course = { | ||
courseId: '72.03', | ||
credits: 3, | ||
name: 'Introducción a Informática', | ||
semester: 1, | ||
inscription: { | ||
id: '1', | ||
courseId: '93.42', | ||
vacancy: '12', | ||
maxVacancy: '50', | ||
finalExamDate: '2017-01-20T18:45', | ||
state: 'OPEN', | ||
students: [ | ||
{ | ||
firstName: 'Matías', | ||
lastName: 'Mercado', | ||
docket: '55019' | ||
}, | ||
{ | ||
firstName: 'Facundo', | ||
lastName: 'Mercado', | ||
docket: '51202' | ||
}, | ||
{ | ||
firstName: 'Gibar', | ||
lastName: 'Sin', | ||
docket: '54655' | ||
}, | ||
{ | ||
firstName: 'Obi Wan', | ||
lastName: 'Kenobi', | ||
docket: '12000' | ||
}, | ||
{ | ||
firstName: 'Darth', | ||
lastName: 'Vader', | ||
docket: '66666' | ||
}, | ||
{ | ||
firstName: 'Luke', | ||
lastName: 'Skywalker', | ||
docket: '53222' | ||
} | ||
] | ||
Courses.get(courseId).then(function(course) { | ||
_this.course = course; | ||
_this.course.all('finalInscriptions').get(inscriptionId).then(function(finalInscription) { | ||
_this.course.inscription = finalInscription; | ||
_this.course.inscription.students = finalInscription.history; | ||
}); | ||
}, function(response) { | ||
$log.info('Response status: ' + response.status); | ||
if (response.status === 404) { | ||
Paths.get().notFound().go(); | ||
} | ||
}); | ||
|
||
this.getStudentPath = function(docket) { | ||
return Paths.get().students({docket: docket}).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
78 changes: 28 additions & 50 deletions
78
app/scripts/controllers/courses/CoursesStudentsIndexCtrl.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 |
---|---|---|
@@ -1,56 +1,34 @@ | ||
'use strict'; | ||
|
||
define(['paw'], function(paw) { | ||
paw.controller('CoursesStudentsIndexCtrl', ['$routeParams', function($routeParams) { | ||
define(['paw','services/Courses','services/Paths', 'controllers/modals/UnenrollController'], function(paw) { | ||
paw.controller('CoursesStudentsIndexCtrl', ['$routeParams', 'Courses', '$log', 'Paths', function($routeParams, Courses, $log, Paths) { | ||
var _this = this; | ||
var courseId = $routeParams.courseId; // For future Service calls | ||
var courseId = $routeParams.courseId; | ||
|
||
this.course = { | ||
courseId: '72.03', | ||
name: 'Introducción a Informática', | ||
credits: 3, | ||
semester: 1, | ||
students: [ | ||
{ | ||
firstName: 'Matías', | ||
lastName: 'Mercado', | ||
docket: '55019' | ||
}, | ||
{ | ||
firstName: 'Facundo', | ||
lastName: 'Mercado', | ||
docket: '51202' | ||
}, | ||
{ | ||
firstName: 'Gibar', | ||
lastName: 'Sin', | ||
docket: '54655' | ||
}, | ||
{ | ||
firstName: 'Obi Wan', | ||
lastName: 'Kenobi', | ||
docket: '12000' | ||
}, | ||
{ | ||
firstName: 'Darth', | ||
lastName: 'Vader', | ||
docket: '66666' | ||
}, | ||
{ | ||
firstName: 'Luke', | ||
lastName: 'Skywalker', | ||
docket: '53222' | ||
}] | ||
}; | ||
this.filter = { | ||
docket: $routeParams.docket, | ||
firstName: $routeParams.firstName, | ||
lastName: $routeParams.lastName | ||
}; | ||
|
||
this.filter = { | ||
docket: $routeParams.docket, | ||
firstName: $routeParams.firstName, | ||
lastName: $routeParams.lastName | ||
}; | ||
this.resetSearch = function() { | ||
this.filter = {}; | ||
}; | ||
|
||
this.resetSearch = function() { | ||
this.filter = {}; | ||
}; | ||
}]); | ||
}); | ||
Courses.get(courseId).then(function(course) { | ||
_this.course = course; | ||
_this.course.getList('students').then(function(students) { | ||
_this.course.students = students; | ||
}); | ||
}, function(response) { | ||
$log.info('Response status: ' + response.status); | ||
if (response.status === 404) { | ||
Paths.get().notFound().go(); | ||
} | ||
}); | ||
|
||
this.getStudentPath = function(docket) { | ||
return Paths.get().students({docket: docket}).path; | ||
}; | ||
}]); | ||
}); |
84 changes: 28 additions & 56 deletions
84
app/scripts/controllers/courses/CoursesStudentsPassedCtrl.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 |
---|---|---|
@@ -1,62 +1,34 @@ | ||
'use strict'; | ||
|
||
define(['paw'], function(paw) { | ||
paw.controller('CoursesStudentsPassedCtrl', ['$routeParams', function($routeParams) { | ||
define(['paw','services/Courses','services/Paths'], function(paw) { | ||
paw.controller('CoursesStudentsPassedCtrl', ['$routeParams', 'Courses', '$log', 'Paths', function($routeParams, Courses, $log, Paths) { | ||
var _this = this; | ||
var courseId = $routeParams.courseId; // For future Service calls | ||
var courseId = $routeParams.courseId; | ||
|
||
this.course = { | ||
courseId: '72.03', | ||
name: 'Introducción a Informática', | ||
credits: 3, | ||
semester: 1, | ||
passedStudents: [ | ||
{ | ||
grade: '4', | ||
firstName: 'Matías', | ||
lastName: 'Mercado', | ||
docket: '55019' | ||
}, | ||
{ | ||
grade: '10', | ||
firstName: 'Facundo', | ||
lastName: 'Mercado', | ||
docket: '51202' | ||
}, | ||
{ | ||
grade: '9.50', | ||
firstName: 'Gibar', | ||
lastName: 'Sin', | ||
docket: '54655' | ||
}, | ||
{ | ||
grade: '8.50', | ||
firstName: 'Obi Wan', | ||
lastName: 'Kenobi', | ||
docket: '12000' | ||
}, | ||
{ | ||
grade: '10', | ||
firstName: 'Darth', | ||
lastName: 'Vader', | ||
docket: '66666' | ||
}, | ||
{ | ||
grade: '8', | ||
firstName: 'Luke', | ||
lastName: 'Skywalker', | ||
docket: '53222' | ||
}] | ||
}; | ||
this.filter = { | ||
docket: $routeParams.docket, | ||
firstName: $routeParams.firstName, | ||
lastName: $routeParams.lastName | ||
}; | ||
|
||
this.filter = { | ||
docket: $routeParams.docket, | ||
firstName: $routeParams.firstName, | ||
lastName: $routeParams.lastName | ||
}; | ||
this.resetSearch = function() { | ||
this.filter = {}; | ||
}; | ||
|
||
this.resetSearch = function() { | ||
this.filter = {}; | ||
}; | ||
}]); | ||
}); | ||
Courses.get(courseId).then(function(course) { | ||
_this.course = course; | ||
_this.course.all('students').customGET('passed').then(function(students) { | ||
_this.course.passedStudents = students; | ||
}); | ||
}, function(response) { | ||
$log.info('Response status: ' + response.status); | ||
if (response.status === 404) { | ||
Paths.get().notFound().go(); | ||
} | ||
}); | ||
|
||
this.getStudentPath = function(docket) { | ||
return Paths.get().students({docket: docket}).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,75 @@ | ||
'use strict'; | ||
|
||
define(['paw', 'services/modalFactory', 'services/Students', 'services/flashMessages'], function(paw) { | ||
paw.controller('EnrollController', | ||
['modalFactory', '$log', 'Students', '$route', 'flashMessages', | ||
function (modalFactory, $log, Students, $route, flashMessages) { | ||
var modalTemplateUrl = 'views/modals/enroll.html'; | ||
var onSuccess = function(result) { | ||
Students.enroll(result.docket, result.courseId) | ||
.then(function(response) { | ||
flashMessages.setSuccess('i18nEnrollSuccess'); | ||
$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, title, docket, fullName, courseName, courseId) { | ||
var resolve = getResolve(title, docket, fullName, courseId, courseName); | ||
modalFactory.create(size, 'EnrollModalInstanceController', modalTemplateUrl, resolve, onSuccess, onFailure); | ||
}; | ||
}]); | ||
|
||
paw.controller('EnrollModalInstanceController', | ||
function($uibModalInstance, title, docket, fullName, courseId, courseName) { | ||
this.title = title; | ||
this.fullName = fullName; | ||
this.docket = docket; | ||
this.courseId = courseId; | ||
this.courseName = courseName; | ||
|
||
var _this = this; | ||
|
||
this.ok = function () { | ||
$uibModalInstance.close({ | ||
title: title, | ||
docket: docket, | ||
fullName: fullName, | ||
courseId: courseId, | ||
courseName: courseName | ||
}); | ||
}; | ||
|
||
this.cancel = function () { | ||
$uibModalInstance.dismiss('Enroll modal dismissed at: ' + new Date()); | ||
}; | ||
}); | ||
|
||
function getResolve(title, docket, fullName, courseId, courseName) { | ||
return { | ||
title: function() { | ||
return title; | ||
}, | ||
docket: function () { | ||
return docket; | ||
}, | ||
fullName: function() { | ||
return fullName; | ||
}, | ||
courseId: function () { | ||
return courseId; | ||
}, | ||
courseName: function () { | ||
return courseName; | ||
} | ||
}; | ||
}; | ||
} | ||
); |
Oops, something went wrong.