Update repo with several changes
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
<div class="modal-header">
|
||||
<h3 class="modal-title">Modificar Estudiante</h3>
|
||||
<h3 class="modal-title">Actualizar Estudiante</h3>
|
||||
</div>
|
||||
<div style="text-align: center" class="modal-body">
|
||||
{{ mensaje }}
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-primary" ng-show="botonOk" type="button"
|
||||
ng-click="ok(urlLo)">Aceptar</button>
|
||||
ng-click="ok()">Aceptar</button>
|
||||
<button class="btn btn-warning" ng-show="botonCancelar" type="button"
|
||||
ng-click="cancel()">Cancelar</button>
|
||||
</div>
|
||||
@@ -34,5 +34,22 @@
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('StudentUpdate', {
|
||||
url: '/StudentUpdate',
|
||||
views: {
|
||||
sidebar: {
|
||||
templateUrl: 'partials/sidebar/sidebar.html',
|
||||
controller: 'SidebarCtrl'
|
||||
},
|
||||
navbar: {
|
||||
templateUrl: 'partials/sidebar/navbar.html'
|
||||
},
|
||||
content: {
|
||||
templateUrl: 'partials/students/student_update.html',
|
||||
controller: 'StudentUpdateCtrl',
|
||||
controllerAs: 'vm'
|
||||
}
|
||||
}
|
||||
})
|
||||
};
|
||||
})();
|
||||
|
||||
82
app/partials/students/student_update.controller.js
Normal file
82
app/partials/students/student_update.controller.js
Normal file
@@ -0,0 +1,82 @@
|
||||
(function(){
|
||||
'use strict';
|
||||
|
||||
angular
|
||||
.module('app.student')
|
||||
.controller('StudentUpdateCtrl', StudentUpdateCtrl)
|
||||
|
||||
StudentUpdateCtrl.$inject = ['$scope', '$rootScope', '$state', 'professors', '$modal', 'selectedSection', 'selectedCourse', 'data'];
|
||||
function StudentUpdateCtrl($scope, $rootScope, $state, professors, $modal, selectedSection, selectedCourse, data){
|
||||
|
||||
var vm = this;
|
||||
var professorid = $rootScope.professorId;
|
||||
vm.professor = {};
|
||||
$rootScope.mensaje = "";
|
||||
$rootScope.actOk = false;
|
||||
vm.newMail = null;
|
||||
vm.student = data.Student
|
||||
|
||||
professors.get({ id: professorid },
|
||||
function (successResult){
|
||||
vm.professor = successResult;
|
||||
angular.forEach (vm.professor.courses[selectedCourse.index].sections,
|
||||
function (value, key){
|
||||
if (value._id == selectedSection._id ) {
|
||||
selectedSection.index = key;
|
||||
vm.students = value.students;
|
||||
vm.section = value;
|
||||
}
|
||||
});
|
||||
},
|
||||
function (){
|
||||
console.log("Error al obtener los datos.");
|
||||
});
|
||||
|
||||
vm.submit = function() {
|
||||
|
||||
if (vm.data_input_form.$valid){
|
||||
vm.student.email = vm.newMail;
|
||||
$rootScope.crearEstudianteLoading = true;
|
||||
$rootScope.botonOk = false;
|
||||
$scope.modalInstance = $modal.open({
|
||||
animation: $rootScope.animationsEnabled,
|
||||
templateUrl: 'partials/students/modal/update_students_modal.html',
|
||||
scope: $scope,
|
||||
size: 'sm',
|
||||
resolve: {
|
||||
items: function () {
|
||||
return $rootScope.items;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
vm.professor.courses[selectedCourse.index].sections[selectedSection.index].students.splice(data.Index, 1);
|
||||
|
||||
vm.professor.courses[selectedCourse.index].sections[selectedSection.index].students.push(vm.student);
|
||||
|
||||
professors.update({ id: professorid }, vm.professor,
|
||||
function(){
|
||||
$rootScope.botonOk = true;
|
||||
$rootScope.mensaje = "Estudiante " + vm.student.lastname + ", " + vm.student.name + " actualizado";
|
||||
},
|
||||
function(){
|
||||
$rootScope.botonOk = true;
|
||||
$rootScope.mensaje = "Error al actualizar al estudiante " + vm.estudiante.Apellido + ", " + vm.estudiante.Nombre;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
$scope.ok = function (urlLo) {
|
||||
$state.go('SectionUpdate');
|
||||
$scope.modalInstance.dismiss('cancel');
|
||||
};
|
||||
|
||||
$scope.cancel = function () {
|
||||
$scope.modalInstance.dismiss('cancel');
|
||||
};
|
||||
|
||||
vm.back = function () {
|
||||
$state.go('SectionUpdate');
|
||||
};
|
||||
};
|
||||
})();
|
||||
54
app/partials/students/student_update.html
Normal file
54
app/partials/students/student_update.html
Normal file
@@ -0,0 +1,54 @@
|
||||
<div>
|
||||
<form name="vm.data_input_form" role="form" novalidate
|
||||
ng-submit="vm.submit()">
|
||||
<div class="row clearfix">
|
||||
<h4>Correo Electronico del Alumno {{vm.student.lastname}}, {{vm.student.name}}</h4>
|
||||
<div class="row clearfix">
|
||||
<div class="col-md-12 column">
|
||||
<br><br>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4 column">
|
||||
<label for="correo">Dirección de Correo Actual</label>
|
||||
<input class="form-control"
|
||||
ng-model="vm.student.email"
|
||||
readonly="readonly"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4 column">
|
||||
<label for="correo">Nueva Dirección de Correo</label>
|
||||
<input type="correo" class="form-control"
|
||||
name="correo" ng-model="vm.newMail"
|
||||
ng-pattern="/^[a-z]+[a-z0-9._]+@[a-z]+\.[a-z.]{2,5}$/" placeholder="me@example.com" required/>
|
||||
<div class="error" ng-show="vm.submitted &&
|
||||
vm.data_input_form.correo.$invalid">
|
||||
<small class="error"
|
||||
ng-show="vm.data_input_form.correo.$error.required">
|
||||
El Correo del Alumno es obligatorio.
|
||||
</small>
|
||||
<small class="error"
|
||||
ng-show="vm.data_input_form.correo.$error.pattern">
|
||||
El formato del Correo del Alumno es incorrecto.
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row clearfix">
|
||||
<div class="col-md-2 column">
|
||||
<div class="form-group">
|
||||
<label> </label>
|
||||
<p class="input-group">
|
||||
<span class="input-group-btn">
|
||||
<button type="submit" class="btn-success btn">
|
||||
Actualizar Dirección de Correo</button>
|
||||
<button type="button" class="btn-warning btn" style="margin: 10px" ng-click="vm.back()">Regresar</button>
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@@ -1,69 +0,0 @@
|
||||
<div class="row clearfix">
|
||||
<div class="col-md-12 column">
|
||||
</div>
|
||||
</div>
|
||||
<form name="vm.data_input_form" role="form" novalidate ng-submit="vm.submit()">
|
||||
<div class="row clearfix">
|
||||
<h4>Modificar Estudiante</h4>
|
||||
<br>
|
||||
<div class="col-md-12 column well">
|
||||
<div class="row">
|
||||
<div class="col-md-4 column">
|
||||
<label for="cedula">Cedula</label>
|
||||
<input type="nmumeric" class="form-control"
|
||||
name="cedula" readonly="readonly"
|
||||
ng-model="vm.estudiante.Cedula" />
|
||||
</div>
|
||||
<div class="col-md-4 column">
|
||||
<label for="nombre">Nombre</label>
|
||||
<input type="text" class="form-control"
|
||||
name="nombre" readonly="readonly"
|
||||
ng-model="vm.estudiante.Nombre" />
|
||||
</div>
|
||||
<div class="col-md-4 column">
|
||||
<label for="apellido">Apellido</label>
|
||||
<input type="text" class="form-control"
|
||||
name="apellido" readonly="readonly"
|
||||
ng-model="vm.estudiante.Apellido" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row clearfix"><div class="col-md-12 column"><br><br>
|
||||
</div></div>
|
||||
<div class="row">
|
||||
<div class="col-md-4 column">
|
||||
<label for="email">Direccion de Correo Electronico</label>
|
||||
<input type="email" class="form-control"
|
||||
name="email" ng-model="vm.estudiante.Correo"
|
||||
ng-pattern="/^[a-z]+[a-z0-9._]+@[a-z]+\.[a-z.]{2,5}$/" placeholder="me@example.com"/>
|
||||
<small class="error"
|
||||
ng-show="vm.data_input_form.correo.$error.pattern">
|
||||
El formato del Correo del Alumno es incorrecto.
|
||||
</small>
|
||||
</div>
|
||||
<div class="col-md-4 column">
|
||||
<label for="telefono">Numero de Telefono</label>
|
||||
<input type="phone" class="form-control"
|
||||
name="telefono" ng-model="vm.estudiante.Telefono"
|
||||
ng-pattern="/\d{4}-\d{3}-\d{4}/" maxlength="13"
|
||||
placeholder="0212-574-1234"/>
|
||||
<small class="error"
|
||||
ng-show="vm.data_input_form.telefono.$error.pattern">
|
||||
El formato del Teléfono debe ser: 0212-789-5551.
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row clearfix">
|
||||
<div class="col-md-2 column">
|
||||
<div class="form-group">
|
||||
<label> </label>
|
||||
<p class="input-group">
|
||||
<span class="input-group-btn">
|
||||
<button type="submit" class="btn-primary btn">Modificar Estudiante</button>
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
Reference in New Issue
Block a user