-
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 new and edit API integrations (#114)
- Add Admins setOnSubSidebar - Add Students setOnSubSidebar - Add Courses setOnSubSidebar - Add admins new and edit views API integration - Add students new and edit views API integration - Add courses new and edit views API integration - Add admins index filter - Add students index authorities on buttons - If user is a student, only show my profile button - Add front filters on - Admins index - Students index - Courses index - Fix sidebar issue - Logging in as admin, logout, then as student may cause Admins sidebar section being enabled - Fix small issues - Students grades career percentage text displaying with decimals - Date issue on admins and students new and edit views - Genre value on admins and students new and edit views - Update admins and students form validations on new and edit views
- Loading branch information
1 parent
433471b
commit 9bb30a5
Showing
27 changed files
with
408 additions
and
210 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,36 @@ | ||
'use strict'; | ||
|
||
define(['paw'], function(paw) { | ||
paw.controller('AdminsEditCtrl', [ | ||
'$routeParams', | ||
'$log', | ||
'$window', | ||
'Paths', | ||
function($routeParams, $log, $window, Paths) { | ||
var _this = this; | ||
define(['paw', 'services/Admins', 'services/flashMessages'], function(paw) { | ||
paw.controller('AdminsEditCtrl', | ||
['$window', 'Paths', 'Admins', 'flashMessages', '$route', '$log', '$filter', '$routeParams', | ||
function($window, Paths, Admins, flashMessages, $route, $log, $filter, $routeParams) { | ||
var _this = this; | ||
|
||
var dni = $routeParams.adminDni; | ||
var dni = $routeParams.adminDni; | ||
|
||
this.admin = { | ||
firstName: 'Matías', | ||
lastName: 'Mercado', | ||
email: 'mmercado@itba.edu.ar', | ||
genre: 'Masculino', | ||
dni: '38917403', | ||
birthday: '1995-05-04', | ||
address: { | ||
country: 'Argentina', | ||
city: 'Buenos Aires', | ||
neighborhood: 'Almagro', | ||
number: '682', | ||
street: 'Corrientes', | ||
floor: '2', | ||
door: 'A', | ||
telephone: '1544683390', | ||
zipCode: '1100' | ||
} | ||
}; | ||
Admins.get(dni).then(function(admin) { | ||
_this.admin = admin; | ||
Admins.setOnSubSidebar(admin); | ||
_this.admin.birthday = new Date(_this.admin.birthday); | ||
// Restangular method to clone the current admin object | ||
_this.editedAdmin = Admins.copy(admin); | ||
}); | ||
|
||
this.editedAdmin = angular.copy(this.admin); | ||
this.update = function(admin) { | ||
var editedAdmin = Admins.copy(admin); | ||
editedAdmin.birthday = $filter('date')(admin.birthday, 'yyyy-MM-dd'); | ||
Admins.update(editedAdmin).then(function(response) { | ||
flashMessages.setSuccess('i18nAdminSuccessfullyUpdated'); | ||
Paths.get().admins(_this.admin).go(); | ||
}, function(response) { | ||
$log.warn(JSON.stringify(response)); | ||
flashMessages.setError('i18nFormErrors'); | ||
$route.reload(); | ||
}); | ||
}; | ||
|
||
this.cancel = function() { | ||
$window.history.back(); | ||
}; | ||
|
||
this.update = function(editedAdmin) { | ||
var path = Paths.get().admins(_this.admin); | ||
$log.info('POST ' + path.absolutePath() + ' ' + JSON.stringify(editedAdmin)); | ||
path.go(); | ||
}; | ||
}]); | ||
}); | ||
this.cancel = function() { | ||
$window.history.back(); | ||
}; | ||
}]); | ||
}); |
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 |
---|---|---|
@@ -1,31 +1,41 @@ | ||
'use strict'; | ||
|
||
define(['paw', 'services/Paths'], function(paw) { | ||
paw.controller('CoursesEditCtrl', [ | ||
'$routeParams', | ||
'$log', | ||
'$window', | ||
'Paths', | ||
function($routeParams, $log, $window, Paths) { | ||
var _this = this; | ||
define(['paw', 'services/Courses', 'services/flashMessages'], function(paw) { | ||
paw.controller('CoursesEditCtrl', | ||
['$window', 'Paths', 'Courses', 'flashMessages', '$route', '$log', '$filter', '$routeParams', | ||
function($window, Paths, Courses, flashMessages, $route, $log, $filter, $routeParams) { | ||
var _this = this; | ||
|
||
this.course = { | ||
courseId: '72.03', | ||
credits: 3, | ||
name: 'Introducción a Informática', | ||
semester: 1 | ||
}; | ||
var courseId = $routeParams.courseId; | ||
|
||
this.editedCourse = angular.copy(this.course); | ||
Courses.get(courseId).then(function(course) { | ||
_this.course = course; | ||
Courses.setOnSubSidebar(course); | ||
// Restangular method to clone the current course object | ||
_this.editedCourse = Courses.copy(course); | ||
}); | ||
|
||
this.update = function(editedCourse) { | ||
var path = Paths.get().courses(_this.course); | ||
$log.info('POST ' + path.absolutePath() + ' ' + JSON.stringify(editedCourse)); | ||
path.go(); | ||
}; | ||
this.update = function(course) { | ||
_this.errors = []; | ||
Courses.update(_this.course, course).then(function(response) { | ||
flashMessages.setSuccess('i18nCourseSuccessfullyUpdated'); | ||
// redirect to the new course, possibly with new Id | ||
Paths.get().courses({courseId: course.courseId}).go(); | ||
}, function(response) { | ||
if (response.status === 409) { // course id repeated | ||
_this.errors = [ | ||
'i18nCourseWithCourseIdAlreadyExists' | ||
]; | ||
return; | ||
} | ||
$log.warn(JSON.stringify(response)); | ||
flashMessages.setError('i18nFormErrors'); | ||
$route.reload(); | ||
}); | ||
}; | ||
|
||
this.cancel = function() { | ||
$window.history.back(); | ||
}; | ||
this.cancel = function() { | ||
$window.history.back(); | ||
}; | ||
}]); | ||
}); |
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 |
---|---|---|
@@ -1,47 +1,36 @@ | ||
'use strict'; | ||
|
||
define(['paw', 'services/Paths'], function(paw) { | ||
paw.controller('StudentsEditCtrl', [ | ||
'$routeParams', | ||
'$log', | ||
'$window', | ||
'Paths', | ||
function($routeParams, $log, $window, Paths) { | ||
var _this = this; | ||
define(['paw', 'services/Students', 'services/flashMessages'], function(paw) { | ||
paw.controller('StudentsEditCtrl', | ||
['$window', 'Paths', 'Students', 'flashMessages', '$route', '$log', '$filter', '$routeParams', | ||
function($window, Paths, Students, flashMessages, $route, $log, $filter, $routeParams) { | ||
var _this = this; | ||
|
||
var docket = $routeParams.docket; | ||
var docket = $routeParams.docket; | ||
|
||
this.student = { | ||
docket: '55019', | ||
firstName: 'Matías', | ||
lastName: 'Mercado', | ||
email: 'mmercado@itba.edu.ar', | ||
genre: 'Masculino', | ||
dni: '38917403', | ||
birthday: '1995-05-04', | ||
address: { | ||
country: 'Argentina', | ||
city: 'Buenos Aires', | ||
neighborhood: 'Almagro', | ||
number: '682', | ||
street: 'Corrientes', | ||
floor: '2', | ||
door: 'A', | ||
telephone: '1544683390', | ||
zipCode: '1100' | ||
} | ||
}; | ||
Students.get(docket).then(function(student) { | ||
_this.student = student; | ||
Students.setOnSubSidebar(student); | ||
_this.student.birthday = new Date(_this.student.birthday) || new Date(); | ||
// Restangular method to clone the current student object | ||
_this.editedStudent = Students.copy(student); | ||
}); | ||
|
||
this.editedStudent = angular.copy(this.student); | ||
this.update = function(student) { | ||
var editedStudent = Students.copy(student); | ||
editedStudent.birthday = $filter('date')(student.birthday, 'yyyy-MM-dd'); | ||
Students.update(editedStudent).then(function(response) { | ||
flashMessages.setSuccess('i18nStudentSuccessfullyUpdated'); | ||
Paths.get().students(_this.student).go(); | ||
}, function(response) { | ||
$log.warn(JSON.stringify(response)); | ||
flashMessages.setError('i18nFormErrors'); | ||
$route.reload(); | ||
}); | ||
}; | ||
|
||
this.cancel = function() { | ||
$window.history.back(); | ||
}; | ||
|
||
this.update = function(editedStudent) { | ||
var path = Paths.get().students(_this.student); | ||
$log.info('POST ' + path.absolutePath() + ' ' + JSON.stringify(editedStudent)); | ||
path.go(); | ||
}; | ||
}]); | ||
}); | ||
this.cancel = function() { | ||
$window.history.back(); | ||
}; | ||
}]); | ||
}); |
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.