Fix courses issue
This commit is contained in:
@@ -6,31 +6,22 @@
|
||||
.controller('listarMateriaCtrl',listarMateriaCtrl)
|
||||
.controller('crearMateriaCtrl', crearMateriaCtrl)
|
||||
|
||||
|
||||
|
||||
listarMateriaCtrl.$inject =
|
||||
['$scope', '$rootScope', '$location', 'courses', '$modal'];
|
||||
function listarMateriaCtrl($scope, $rootScope, $location, courses, $modal) {
|
||||
var vm = this;
|
||||
$rootScope.table = false;
|
||||
var array = [];
|
||||
|
||||
var materiaArreglo = [];
|
||||
courses.query(
|
||||
function(data){
|
||||
vm.materia = data;
|
||||
angular.forEach(vm.materia, function (value){
|
||||
materiaArreglo.push({
|
||||
Codigo:value.Codigo,
|
||||
Nombre:value.Nombre,
|
||||
Creditos:value.Creditos,
|
||||
Descripcion:value.Descripcion
|
||||
});
|
||||
});
|
||||
$rootScope.table = true;
|
||||
vm.listaMateria = materiaArreglo;
|
||||
},
|
||||
function(data){
|
||||
console.log("Error al obtener los datos.");
|
||||
function (successResult){
|
||||
vm.course = successResult;
|
||||
},
|
||||
function (){
|
||||
console.log("Error al obtener los datos.");
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
vm.eliminarMateriaModal = function (index) {
|
||||
$rootScope.index = index;
|
||||
@@ -38,7 +29,6 @@
|
||||
$rootScope.otroBotonOk = false;
|
||||
$rootScope.botonCancelar = true;
|
||||
$rootScope.rsplice = false;
|
||||
$rootScope.loading = false;
|
||||
$rootScope.mensaje = "¿Seguro que desea eliminar la materia?";
|
||||
|
||||
$scope.modalInstance = $modal.open({
|
||||
@@ -56,27 +46,25 @@
|
||||
};
|
||||
|
||||
vm.eliminarMateria = function (index) {
|
||||
$rootScope.loadingListarForm = true;
|
||||
$rootScope.botonOk = false;
|
||||
$rootScope.otroBotonOk = true;
|
||||
$rootScope.botonCancelar = false;
|
||||
$rootScope.urlLo = 'listarMateria';
|
||||
$rootScope.rsplice = true;
|
||||
var name = vm.course[index].name;
|
||||
|
||||
courses.delete({ id: vm.materia[index]._id },
|
||||
function() {
|
||||
$rootScope.loadingListarForm = false;
|
||||
$rootScope.mensaje = "Materia eliminada";
|
||||
courses.delete({ id: vm.course[index]._id },
|
||||
function () {
|
||||
$rootScope.rsplice = true;
|
||||
$rootScope.mensaje = "Materia " + name + " eliminada";
|
||||
},
|
||||
function() {
|
||||
$rootScope.loadingListarForm = false;
|
||||
$rootScope.mensaje = "Error eliminado materia";
|
||||
function () {
|
||||
$rootScope.mensaje = "Error eliminando la materia" + name;
|
||||
});
|
||||
};
|
||||
|
||||
vm.eliminarMateriaSplice = function(index, rsplice) {
|
||||
if(rsplice){
|
||||
vm.listaMateria.splice(index, 1);
|
||||
vm.course.splice(index, 1);
|
||||
$rootScope.rsplice = false;
|
||||
}
|
||||
};
|
||||
@@ -116,11 +104,10 @@
|
||||
|
||||
if (vm.data_input_form.$valid){
|
||||
vm.course = {
|
||||
|
||||
"Codigo": vm.materia.Codigo,
|
||||
"Nombre": vm.materia.Nombre,
|
||||
"Creditos": vm.materia.Creditos,
|
||||
"Descripcion" : vm.materia.Description,
|
||||
"code": vm.course.code,
|
||||
"name": vm.course.name,
|
||||
"credits": vm.course.credits,
|
||||
"description" : vm.course.description,
|
||||
};
|
||||
|
||||
$scope.modalInstance = $modal.open({
|
||||
@@ -141,13 +128,13 @@
|
||||
$rootScope.botonOk = true;
|
||||
$rootScope.urlLo = 'listarMateria';
|
||||
$rootScope.mensaje =
|
||||
"Materia " + vm.materia.Nombre + " creada";
|
||||
"Materia " + vm.course.name + " creada";
|
||||
},
|
||||
function(){
|
||||
$rootScope.botonOk = true;
|
||||
$rootScope.urlLo = 'listarMateria';
|
||||
$rootScope.mensaje =
|
||||
"Error creando la materia " + vm.materia.Nombre;
|
||||
"Error creando la materia " + vm.course.name;
|
||||
});
|
||||
}else{
|
||||
|
||||
|
@@ -3,11 +3,10 @@
|
||||
|
||||
angular
|
||||
.module('app.course')
|
||||
.factory('courses', courses)
|
||||
.value('id',{});
|
||||
.factory('courses', courses);
|
||||
|
||||
courses.$inject = ['$resource','$rootScope'];
|
||||
function courses($resource, $rootScope){
|
||||
return $resource('http://'+$rootScope.domainUrl+'/courses/:id', null);
|
||||
return $resource('http://'+$rootScope.domainUrl+'/courses/:id', null);
|
||||
};
|
||||
})();
|
||||
|
@@ -11,17 +11,10 @@
|
||||
function listarMatriculaCtrl ( $scope, $rootScope, $location, sections, $modal, matriculaSeleccionada ){
|
||||
|
||||
var vm = this;
|
||||
vm.lista = true;
|
||||
$rootScope.actOk = false;
|
||||
$rootScope.loading = true;
|
||||
$rootScope.table = false;
|
||||
|
||||
vm.submit = function() {
|
||||
}
|
||||
|
||||
var matriculaArray = [];
|
||||
|
||||
sections.query(
|
||||
function(successResult){
|
||||
function (successResult){
|
||||
vm.matricula = successResult;
|
||||
angular.forEach(vm.matricula, function (value){
|
||||
matriculaArray.push({
|
||||
@@ -32,11 +25,9 @@
|
||||
student: value.student
|
||||
});
|
||||
});
|
||||
$rootScope.loading = false;
|
||||
$rootScope.table = true;
|
||||
vm.listaMatricula = matriculaArray;
|
||||
},
|
||||
function(data){
|
||||
function (){
|
||||
console.log("Error al obtener los datos.");
|
||||
|
||||
});
|
||||
@@ -47,19 +38,18 @@
|
||||
confirmar su decision llama automaticamente a la funcion que hara la
|
||||
llamada a servicio que borrara la matricula de la base de datos.
|
||||
*/
|
||||
|
||||
vm.eliminarMatriculaModal = function (index) {
|
||||
|
||||
$rootScope.index = index;
|
||||
$rootScope.botonOk = true;
|
||||
$rootScope.otroBotonOk = false;
|
||||
$rootScope.botonCancelar = true;
|
||||
$rootScope.rsplice = false;
|
||||
$rootScope.eliminarLoading = false;
|
||||
$rootScope.mensaje = "¿Seguro que desea eliminar la matricula?";
|
||||
$rootScope.mensaje = "¿Seguro que desea eliminar la sección?";
|
||||
|
||||
$scope.modalInstance = $modal.open({
|
||||
animation: $rootScope.animationsEnabled,
|
||||
templateUrl: 'partials/section/modal/delete_section_modal.html',
|
||||
templateUrl: '/partials/section/modal/delete_section_modal.html',
|
||||
scope: $scope,
|
||||
size: 'sm',
|
||||
resolve: {
|
||||
@@ -70,24 +60,20 @@
|
||||
});
|
||||
};
|
||||
|
||||
vm.eliminarMatricula= function (index) {
|
||||
vm.eliminarMatricula = function (index) {
|
||||
$rootScope.botonOk = false;
|
||||
$rootScope.otroBotonOk = true;
|
||||
$rootScope.botonCancelar = false;
|
||||
$rootScope.urlLo = 'listarMatricula';
|
||||
$rootScope.eliminarLoading = true;
|
||||
var name = vm.matricula[index].Nombre;
|
||||
var name = vm.matricula[index].section;
|
||||
|
||||
sections.delete({ id: vm.matricula[index]._id },
|
||||
function (successResult) {
|
||||
$rootScope.eliminarLoading = false;
|
||||
function () {
|
||||
$rootScope.rsplice = true;
|
||||
$rootScope.mensaje = "Sección " + name + " eliminada.";
|
||||
$rootScope.mensaje = "Sección " + name + " eliminada";
|
||||
},
|
||||
function (errorResult) {
|
||||
$rootScope.eliminarLoading = false;
|
||||
$rootScope.mensaje = "Error al eliminar la sección " + name;
|
||||
console.log('Could not delete from server');
|
||||
function () {
|
||||
$rootScope.mensaje = "Error eliminando la sección " + name;
|
||||
});
|
||||
};
|
||||
|
||||
@@ -185,6 +171,36 @@
|
||||
}
|
||||
};
|
||||
|
||||
var xlf = document.getElementById('xlf');
|
||||
function handleFile(e) {
|
||||
console.log("DO SOME STUFF");
|
||||
/*rABS = document.getElementsByName("userabs")[0].checked;
|
||||
use_worker = document.getElementsByName("useworker")[0].checked;
|
||||
var files = e.target.files;
|
||||
var f = files[0];
|
||||
{
|
||||
var reader = new FileReader();
|
||||
var name = f.name;
|
||||
reader.onload = function(e) {
|
||||
if(typeof console !== 'undefined') console.log("onload", new Date(), rABS, use_worker);
|
||||
var data = e.target.result;
|
||||
if(use_worker) {
|
||||
xw(data, process_wb);
|
||||
} else {
|
||||
var wb;
|
||||
if(rABS) {
|
||||
wb = X.read(data, {type: 'binary'});
|
||||
} else {
|
||||
var arr = fixdata(data);
|
||||
wb = X.read(btoa(arr), {type: 'base64'});
|
||||
}
|
||||
process_wb(wb);
|
||||
}
|
||||
};
|
||||
if(rABS) reader.readAsBinaryString(f);
|
||||
else reader.readAsArrayBuffer(f);
|
||||
}*/
|
||||
}
|
||||
vm.cargarEstudiantes = function () {
|
||||
|
||||
};
|
||||
|
@@ -4,7 +4,6 @@
|
||||
angular
|
||||
.module('app.section')
|
||||
.factory('sections', sections)
|
||||
.factory('courses', courses)
|
||||
.value('matriculaSeleccionada',{});
|
||||
|
||||
sections.$inject = ['$resource','$rootScope'];
|
||||
@@ -14,10 +13,4 @@
|
||||
'update': {method:'PUT'}
|
||||
});
|
||||
};
|
||||
|
||||
courses.$inject = ['$resource','$rootScope'];
|
||||
function courses($resource, $rootScope){
|
||||
return $resource('http://'+$rootScope.domainUrl+'/courses');
|
||||
};
|
||||
|
||||
})();
|
Reference in New Issue
Block a user