Fix courses issue
This commit is contained in:
@@ -97,6 +97,7 @@
|
||||
<script src="bower_components/angular-bootstrap/ui-bootstrap-tpls.js"></script>
|
||||
<script src="bower_components/Chart.js/Chart.min.js"></script>
|
||||
<script src="bower_components/angular-chart.js/dist/angular-chart.js"></script>
|
||||
<script src="bower_components/js-xlsx/dist/xlsx.core.min.js"></script>
|
||||
|
||||
|
||||
<script>
|
||||
|
@@ -6,28 +6,19 @@
|
||||
.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 (successResult){
|
||||
vm.course = successResult;
|
||||
},
|
||||
function(data){
|
||||
function (){
|
||||
console.log("Error al obtener los datos.");
|
||||
|
||||
});
|
||||
@@ -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,8 +3,7 @@
|
||||
|
||||
angular
|
||||
.module('app.course')
|
||||
.factory('courses', courses)
|
||||
.value('id',{});
|
||||
.factory('courses', courses);
|
||||
|
||||
courses.$inject = ['$resource','$rootScope'];
|
||||
function courses($resource, $rootScope){
|
||||
|
@@ -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) {
|
||||
|
||||
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');
|
||||
};
|
||||
|
||||
})();
|
@@ -7,26 +7,26 @@
|
||||
<div class="col-md-12 column well">
|
||||
<div class="row">
|
||||
<div class="col-md-6 column">
|
||||
<label for="Codigo">Código de la Materia</label>
|
||||
<label for="code">Código de la Materia</label>
|
||||
<input type="numeric" class="form-control"
|
||||
name="Codigo" ng-model="vm.materia.Codigo"
|
||||
name="code" ng-model="vm.course.code"
|
||||
ng-pattern="/\d{4}/" maxlength="4" required/>
|
||||
<div class="error" ng-show="vm.submitted &&
|
||||
vm.data_input_form.Codigo.$invalid">
|
||||
vm.data_input_form.code.$invalid">
|
||||
<small class="error"
|
||||
ng-show="vm.data_input_form.Codigo.$error.required">
|
||||
ng-show="vm.data_input_form.code.$error.required">
|
||||
El Código de la Materia es Obligatorio.
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6 column">
|
||||
<label for="Nombre">Nombre de la Materia</label>
|
||||
<label for="name">Nombre de la Materia</label>
|
||||
<input type="text" class="form-control"
|
||||
name="Nombre" ng-model="vm.materia.Nombre" required/>
|
||||
name="name" ng-model="vm.course.name" required/>
|
||||
<div class="error" ng-show="vm.submitted &&
|
||||
vm.data_input_form.Nombre.$invalid">
|
||||
vm.data_input_form.name.$invalid">
|
||||
<small class="error"
|
||||
ng-show="vm.data_input_form.Nombre.$error.required">
|
||||
ng-show="vm.data_input_form.name.$error.required">
|
||||
El Nombre de la Materia es Obligatorio.
|
||||
</small>
|
||||
</div>
|
||||
@@ -36,27 +36,27 @@
|
||||
<br></div></div>
|
||||
<div class="row">
|
||||
<div class="col-md-6 column">
|
||||
<label for="Creditos">Cantidad de Creditos</label>
|
||||
<label for="credits">Cantidad de Creditos</label>
|
||||
<input type="numeric" class="form-control"
|
||||
name="Creditos" ng-model="vm.materia.Creditos"
|
||||
name="credits" ng-model="vm.course.credits"
|
||||
maxlength="1" placeholder="5" required/>
|
||||
<div class="error" ng-show="vm.submitted &&
|
||||
vm.data_input_form.Creditos.$invalid">
|
||||
vm.data_input_form.credits.$invalid">
|
||||
<small class="error"
|
||||
ng-show="vm.data_input_form.Creditos.$error.required">
|
||||
ng-show="vm.data_input_form.credits.$error.required">
|
||||
La Cantidad de Creditos es Obligatoria.
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6 column">
|
||||
<label for="Description">Descripción</label>
|
||||
<label for="description">Descripción</label>
|
||||
<input type="text" class="form-control"
|
||||
name="Description" ng-model="vm.materia.Description"
|
||||
name="description" ng-model="vm.course.description"
|
||||
required/>
|
||||
<div class="error" ng-show="vm.submitted &&
|
||||
vm.data_input_form.Description.$invalid">
|
||||
vm.data_input_form.description.$invalid">
|
||||
<small class="error"
|
||||
ng-show="vm.data_input_form.Description.$error.required">
|
||||
ng-show="vm.data_input_form.description.$error.required">
|
||||
Por favor, inserte una breve descripción.
|
||||
</small>
|
||||
</div>
|
||||
|
@@ -7,33 +7,33 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="10%">
|
||||
<a href="" ng-click="sortType = 'Codigo';
|
||||
<a href="" ng-click="sortType = 'code';
|
||||
sortReverse = !sortReverse">
|
||||
Código
|
||||
<span ng-show="sortType == 'Codigo' &&
|
||||
<span ng-show="sortType == 'code' &&
|
||||
!sortReverse" class="fa fa-caret-down"></span>
|
||||
<span ng-show="sortType == 'Codigo' &&
|
||||
<span ng-show="sortType == 'code' &&
|
||||
sortReverse" class="fa fa-caret-up"></span>
|
||||
</a>
|
||||
</th>
|
||||
<th width="20%">
|
||||
<a href="" ng-click="sortType = 'Nombre';
|
||||
<a href="" ng-click="sortType = 'name';
|
||||
sortReverse = !sortReverse">
|
||||
Nombre
|
||||
<span ng-show="sortType == 'Nombre' &&
|
||||
<span ng-show="sortType == 'name' &&
|
||||
!sortReverse" class="fa fa-caret-down"></span>
|
||||
<span ng-show="sortType == 'Nombre' &&
|
||||
<span ng-show="sortType == 'name' &&
|
||||
sortReverse" class="fa fa-caret-up"></span>
|
||||
</a>
|
||||
</th>
|
||||
<th width="10%">
|
||||
<a href=""
|
||||
ng-click="sortType = 'Creditos';
|
||||
ng-click="sortType = 'credits';
|
||||
sortReverse = !sortReverse">
|
||||
Creditos
|
||||
<span ng-show="sortType == 'Creditos' &&
|
||||
<span ng-show="sortType == 'credits' &&
|
||||
!sortReverse" class="fa fa-caret-down"></span>
|
||||
<span ng-show="sortType == 'Creditos' && sortReverse" class="fa fa-caret-up"></span>
|
||||
<span ng-show="sortType == 'credits' && sortReverse" class="fa fa-caret-up"></span>
|
||||
</a>
|
||||
</th>
|
||||
<th width="50%" style="text-align: center">
|
||||
@@ -48,11 +48,11 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="materia in vm.listaMateria | orderBy:sortType:sortReverse | filter:searchUser">
|
||||
<td style="vertical-align:middle">{{ materia.Codigo }}</td>
|
||||
<td style="vertical-align:middle">{{ materia.Nombre }}</td>
|
||||
<td style="vertical-align:middle">{{ materia.Creditos }}</td>
|
||||
<td style="vertical-align:middle">{{ materia.Descripcion }}</td>
|
||||
<tr ng-repeat="course in vm.course | orderBy:sortType:sortReverse | filter:searchUser">
|
||||
<td style="vertical-align:middle">{{ course.code }}</td>
|
||||
<td style="vertical-align:middle">{{ course.name }}</td>
|
||||
<td style="vertical-align:middle">{{ course.credits }}</td>
|
||||
<td style="vertical-align:middle">{{ course.description }}</td>
|
||||
<td style="text-align: center">
|
||||
<span
|
||||
title="Click aqui para Eliminar la Materia"
|
||||
|
@@ -7,19 +7,19 @@
|
||||
<div class="col-md-12 column well">
|
||||
<div class="row">
|
||||
<div class="col-md-6 column">
|
||||
<label for="Codigo">Código de la Materia</label>
|
||||
<label for="code">Código de la Materia</label>
|
||||
<input type="numeric" class="form-control"
|
||||
name="Codigo" ng-model="vm.materia.Codigo"
|
||||
name="code" ng-model="vm.course.code"
|
||||
readonly="readonly"/>
|
||||
</div>
|
||||
<div class="col-md-6 column">
|
||||
<label for="Nombre">Nombre de la Materia</label>
|
||||
<label for="name">Nombre de la Materia</label>
|
||||
<input type="text" class="form-control"
|
||||
name="Nombre" ng-model="vm.materia.Nombre" required/>
|
||||
name="name" ng-model="vm.course.name" required/>
|
||||
<div class="error" ng-show="vm.submitted &&
|
||||
vm.data_input_form.Nombre.$invalid">
|
||||
vm.data_input_form.name.$invalid">
|
||||
<small class="error"
|
||||
ng-show="vm.data_input_form.Nombre.$error.required">
|
||||
ng-show="vm.data_input_form.name.$error.required">
|
||||
El Nombre de la Materia es Obligatorio.
|
||||
</small>
|
||||
</div>
|
||||
@@ -28,30 +28,17 @@
|
||||
<div class="row clearfix"><div class="col-md-12 column"><br><br></div></div>
|
||||
<div class="row">
|
||||
<div class="col-md-6 column">
|
||||
<label for="Creditos">Cantidad de Creditos</label>
|
||||
<label for="credits">Cantidad de Creditos</label>
|
||||
<input type="numeric" class="form-control"
|
||||
name="Creditos" ng-model="vm.materia.Creditos" maxlength="1" placeholder="5" required/>
|
||||
name="credits" ng-model="vm.course.credits" maxlength="1" placeholder="5" required/>
|
||||
<div class="error" ng-show="vm.submitted &&
|
||||
vm.data_input_form.Creditos.$invalid">
|
||||
vm.data_input_form.credits.$invalid">
|
||||
<small class="error"
|
||||
ng-show="vm.data_input_form.Creditos.$error.required">
|
||||
ng-show="vm.data_input_form.credits.$error.required">
|
||||
La Cantidad de Creditos es Obligatoria.
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6 column">
|
||||
<label for="Semestre">Semestre</label>
|
||||
<input type="text" class="form-control"
|
||||
name="Semestre" ng-model="vm.materia.Semestre"
|
||||
required/>
|
||||
<div class="error" ng-show="vm.submitted &&
|
||||
vm.data_input_form.Semestre.$invalid">
|
||||
<small class="error"
|
||||
ng-show="vm.data_input_form.Semestre.$error.required">
|
||||
El Semestre es Obligatorio.
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row clearfix"><div class="col-md-12 column"><br><br></div></div>
|
||||
</div>
|
||||
|
@@ -11,16 +11,16 @@
|
||||
<select
|
||||
class="form-control"
|
||||
ng-model="vm.valorMateria"
|
||||
ng-options="materia.Nombre for materia in vm.materias"
|
||||
ng-options="materia.name for materia in vm.materias"
|
||||
>
|
||||
<option value="">{{materia.Nombre}}</option>
|
||||
<option value="">{{materia.name}}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-4 column">
|
||||
<label for="codigo">Codigo de la Materia</label>
|
||||
<input type="text" class="form-control"
|
||||
name="codigo" readonly="readonly"
|
||||
ng-model="vm.valorMateria.Codigo"/>
|
||||
ng-model="vm.valorMateria.code"/>
|
||||
</div>
|
||||
<div class="col-md-4 column">
|
||||
<label for="semestre">Semestre</label>
|
||||
@@ -52,11 +52,8 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 column"><br>
|
||||
<span class="input-group-btn">
|
||||
<button type="button"class="btn-warning btn"
|
||||
ng-click="vm.cargarEstudiantes()">
|
||||
Cargar Estudiantes
|
||||
</button>
|
||||
<label for="seccion">Cargar Estudiantes</label>
|
||||
<input type="file" name="xlfile" id="xlf"/></input>
|
||||
</span>
|
||||
</div>
|
||||
<div class="row clearfix"><div class="col-md-12 column"><br>
|
||||
|
@@ -81,7 +81,7 @@ app.post('/courses', function(req, res){
|
||||
})
|
||||
});
|
||||
|
||||
app.delete('courses/:id', function(req, res){
|
||||
app.delete('/courses/:id', function(req, res){
|
||||
console.log("Received delete request...");
|
||||
db.Courses.remove(
|
||||
{_id: new mongojs.ObjectId(req.params.id)}, function(err, docs){
|
||||
|
Reference in New Issue
Block a user