Commit 6736a9a55323703f45b2ccf4f3c600ca67c9f61f
1 parent
ca13fa1e85
Exists in
master
and in
2 other branches
errores tipeo
Showing
5 changed files
with
9 additions
and
9 deletions
Show diff stats
src/js/app.js
| 1 | angular.module('focaAbmChofer', ['ngRoute', 'focaModal', 'ui.bootstrap']); | ||
| 1 | angular.module('focaAbmChofer', ['ngRoute', 'focaModal', 'ui.bootstrap']); |
src/js/controller.js
| 1 | angular.module('focaAbmChofer') | 1 | angular.module('focaAbmChofer') |
| 2 | .controller('focaAbmChoferesController', [ | 2 | .controller('focaAbmChoferesController', [ |
| 3 | '$scope', 'focaAbmChoferService', '$location', 'focaModalService', | 3 | '$scope', 'focaAbmChoferService', '$location', 'focaModalService', |
| 4 | function($scope, focaAbmChoferService, $location, focaModalService) { | 4 | function($scope, focaAbmChoferService, $location, focaModalService) { |
| 5 | 5 | ||
| 6 | $scope.filters = ''; | 6 | $scope.filters = ''; |
| 7 | $scope.choferes = []; | 7 | $scope.choferes = []; |
| 8 | $scope.choferesFiltrados = []; | 8 | $scope.choferesFiltrados = []; |
| 9 | 9 | ||
| 10 | focaAbmChoferService.getChoferes().then(function(datos) { | 10 | focaAbmChoferService.getChoferes().then(function(datos) { |
| 11 | $scope.choferes = datos.data; | 11 | $scope.choferes = datos.data; |
| 12 | $scope.choferesFiltrados = $scope.choferes; | 12 | $scope.choferesFiltrados = $scope.choferes; |
| 13 | }); | 13 | }); |
| 14 | 14 | ||
| 15 | 15 | ||
| 16 | 16 | ||
| 17 | $scope.editar = function(id) { | 17 | $scope.editar = function(id) { |
| 18 | $location.path('/chofer/' + id); | 18 | $location.path('/chofer/' + id); |
| 19 | }; | 19 | }; |
| 20 | 20 | ||
| 21 | $scope.solicitarConfirmacion = function(chofer) { | 21 | $scope.solicitarConfirmacion = function(chofer) { |
| 22 | focaModalService.confirm('¿Está seguro que desea borrar el chofer '+ | 22 | focaModalService.confirm('¿Está seguro que desea borrar el chofer ' + |
| 23 | chofer.nombre + ' ?').then( function(confirmed) { | 23 | chofer.nombre + ' ?').then(function(confirmed) { |
| 24 | if(confirmed){ | 24 | if(confirmed) { |
| 25 | focaAbmChoferService.deleteChofer(chofer.id); | 25 | focaAbmChoferService.deleteChofer(chofer.id); |
| 26 | $scope.choferes.splice($scope.choferes.indexOf(chofer), 1); | 26 | $scope.choferes.splice($scope.choferes.indexOf(chofer), 1); |
| 27 | } | 27 | } |
| 28 | }); | 28 | }); |
| 29 | }; | 29 | }; |
| 30 | 30 | ||
| 31 | 31 | ||
| 32 | } | 32 | } |
| 33 | ]) | 33 | ]) |
| 34 | .controller('focaAbmChoferController', [ | 34 | .controller('focaAbmChoferController', [ |
| 35 | '$scope', 'focaAbmChoferService', '$routeParams', '$location', | 35 | '$scope', 'focaAbmChoferService', '$routeParams', '$location', |
| 36 | function($scope, focaAbmChoferService, $routeParams, $location) { | 36 | function($scope, focaAbmChoferService, $routeParams, $location) { |
| 37 | 37 | ||
| 38 | $scope.chofer = {}; | 38 | $scope.chofer = {}; |
| 39 | $scope.transportistas = []; | 39 | $scope.transportistas = []; |
| 40 | 40 | ||
| 41 | focaAbmChoferService.getChofer($routeParams.id).then(function(res) { | 41 | focaAbmChoferService.getChofer($routeParams.id).then(function(res) { |
| 42 | if (res.data) $scope.chofer = res.data; | 42 | if(res.data) $scope.chofer = res.data; |
| 43 | }); | 43 | }); |
| 44 | 44 | ||
| 45 | focaAbmChoferService.getTransportistas().then(function(res) { | 45 | focaAbmChoferService.getTransportistas().then(function(res) { |
| 46 | $scope.transportistas = res.data; | 46 | $scope.transportistas = res.data; |
| 47 | }); | 47 | }); |
| 48 | 48 | ||
| 49 | $scope.cancelar = function() { | 49 | $scope.cancelar = function() { |
| 50 | $location.path('/chofer'); | 50 | $location.path('/chofer'); |
| 51 | }; | 51 | }; |
| 52 | 52 | ||
| 53 | $scope.guardar = function() { | 53 | $scope.guardar = function() { |
| 54 | $scope.chofer.idTransportista = $scope.chofer.transportista.COD; | 54 | $scope.chofer.idTransportista = $scope.chofer.transportista.COD; |
| 55 | delete $scope.chofer.transportista; | 55 | delete $scope.chofer.transportista; |
| 56 | focaAbmChoferService.guardarChofer($scope.chofer).then(function() { | 56 | focaAbmChoferService.guardarChofer($scope.chofer).then(function() { |
| 57 | $location.path('/chofer'); | 57 | $location.path('/chofer'); |
| 58 | }); | 58 | }); |
| 59 | }; | 59 | }; |
| 60 | 60 | ||
| 61 | } | 61 | } |
| 62 | ]); | ||
| 62 | ]); |
src/js/route.js
| 1 | angular.module('focaAbmChofer') | 1 | angular.module('focaAbmChofer') |
| 2 | .config([ | 2 | .config([ |
| 3 | '$routeProvider', | 3 | '$routeProvider', |
| 4 | function($routeProvider) { | 4 | function($routeProvider) { |
| 5 | $routeProvider.when('/chofer', { | 5 | $routeProvider.when('/chofer', { |
| 6 | controller: 'focaAbmChoferesController', | 6 | controller: 'focaAbmChoferesController', |
| 7 | templateUrl: 'src/views/foca-abm-choferes-listado.html' | 7 | templateUrl: 'src/views/foca-abm-choferes-listado.html' |
| 8 | }); | 8 | }); |
| 9 | } | 9 | } |
| 10 | ]) | 10 | ]) |
| 11 | .config([ | 11 | .config([ |
| 12 | '$routeProvider', | 12 | '$routeProvider', |
| 13 | function($routeProvider) { | 13 | function($routeProvider) { |
| 14 | $routeProvider.when('/chofer/:id', { | 14 | $routeProvider.when('/chofer/:id', { |
| 15 | controller: 'focaAbmChoferController', | 15 | controller: 'focaAbmChoferController', |
| 16 | templateUrl: 'src/views/foca-abm-choferes-item.html' | 16 | templateUrl: 'src/views/foca-abm-choferes-item.html' |
| 17 | }); | 17 | }); |
| 18 | } | 18 | } |
| 19 | ]); | ||
| 19 | ]); |
src/views/foca-abm-choferes-item.html
| 1 | <h4 class="pt-4">Chofer</h4> | 1 | <h4 class="pt-4">Chofer</h4> |
| 2 | <form name="formChofer"> | 2 | <form name="formChofer"> |
| 3 | <input type="hidden" name="id" ng-model="chofer.id" /> | 3 | <input type="hidden" name="id" ng-model="chofer.id" /> |
| 4 | <div class="form-group row"> | 4 | <div class="form-group row"> |
| 5 | <label class="offset-sm-1 col-sm-2 col-form-label">Transportista</label> | 5 | <label class="offset-sm-1 col-sm-2 col-form-label">Transportista</label> |
| 6 | <div class="col-sm-4"> | 6 | <div class="col-sm-4"> |
| 7 | <select class="form-control" ng-model="chofer.transportista" | 7 | <select class="form-control" ng-model="chofer.transportista" |
| 8 | ng-options="transportista as transportista.NOM for transportista in transportistas" | 8 | ng-options="transportista as transportista.NOM for transportista in transportistas" |
| 9 | > | 9 | > |
| 10 | </select> | 10 | </select> |
| 11 | </div> | 11 | </div> |
| 12 | </div> | 12 | </div> |
| 13 | <div class="form-group row"> | 13 | <div class="form-group row"> |
| 14 | <label class="offset-sm-1 col-sm-2 col-form-label">Nombre</label> | 14 | <label class="offset-sm-1 col-sm-2 col-form-label">Nombre</label> |
| 15 | <div class="col-sm-4"> | 15 | <div class="col-sm-4"> |
| 16 | <input | 16 | <input |
| 17 | class="form-control" | 17 | class="form-control" |
| 18 | type="text" | 18 | type="text" |
| 19 | teclado-virtual | 19 | teclado-virtual |
| 20 | ng-model="chofer.nombre" | 20 | ng-model="chofer.nombre" |
| 21 | ng-required="true" | 21 | ng-required="true" |
| 22 | /> | 22 | /> |
| 23 | </div> | 23 | </div> |
| 24 | </div> | 24 | </div> |
| 25 | <div class="form-group row"> | 25 | <div class="form-group row"> |
| 26 | <label class="offset-sm-1 col-sm-2 col-form-label">DNI</label> | 26 | <label class="offset-sm-1 col-sm-2 col-form-label">DNI</label> |
| 27 | <div class="col-sm-4"> | 27 | <div class="col-sm-4"> |
| 28 | <input | 28 | <input |
| 29 | class="form-control" | 29 | class="form-control" |
| 30 | type="text" | 30 | type="text" |
| 31 | teclado-virtual | 31 | teclado-virtual |
| 32 | ng-model="chofer.dni" | 32 | ng-model="chofer.dni" |
| 33 | ng-required="true" | 33 | ng-required="true" |
| 34 | /> | 34 | /> |
| 35 | </div> | 35 | </div> |
| 36 | </div> | 36 | </div> |
| 37 | <div class="form-group row"> | 37 | <div class="form-group row"> |
| 38 | <label class="offset-sm-1 col-sm-2 col-form-label">Teléfono</label> | 38 | <label class="offset-sm-1 col-sm-2 col-form-label">Teléfono</label> |
| 39 | <div class="col-sm-4"> | 39 | <div class="col-sm-4"> |
| 40 | <input | 40 | <input |
| 41 | class="form-control" | 41 | class="form-control" |
| 42 | type="text" | 42 | type="text" |
| 43 | teclado-virtual | 43 | teclado-virtual |
| 44 | ng-model="chofer.telefono" | 44 | ng-model="chofer.telefono" |
| 45 | ng-required="true" | 45 | ng-required="true" |
| 46 | /> | 46 | /> |
| 47 | </div> | 47 | </div> |
| 48 | </div> | 48 | </div> |
| 49 | <div class="form-group row"> | 49 | <div class="form-group row"> |
| 50 | <div class="col-sm-7 text-right"> | 50 | <div class="col-sm-7 text-right"> |
| 51 | <button | 51 | <button |
| 52 | class="btn btn-primary" | 52 | class="btn btn-primary" |
| 53 | ng-click="guardar()" | 53 | ng-click="guardar()" |
| 54 | ng-disabled="!formChofer.$valid" | 54 | ng-disabled="!formChofer.$valid" |
| 55 | >Guardar</button> | 55 | >Guardar</button> |
| 56 | <button class="btn btn-default" ng-click="cancelar()">Cancelar</button> | 56 | <button class="btn btn-default" ng-click="cancelar()">Cancelar</button> |
| 57 | </div> | 57 | </div> |
| 58 | </div> | 58 | </div> |
| 59 | </form> | ||
| 59 | </form> |
src/views/foca-abm-choferes-listado.html
| 1 | <div class="col-12 pt-4"> | 1 | <div class="col-12 pt-4"> |
| 2 | <h4>Choferes</h4> | 2 | <h4>Choferes</h4> |
| 3 | <div class="form-group"> | 3 | <div class="form-group"> |
| 4 | <input | 4 | <input |
| 5 | type="text" | 5 | type="text" |
| 6 | class="form-control form-control-sm" | 6 | class="form-control form-control-sm" |
| 7 | placeholder="Búsqueda" | 7 | placeholder="Búsqueda" |
| 8 | ng-model="filtros" | 8 | ng-model="filtros" |
| 9 | teclado-virtual | 9 | teclado-virtual |
| 10 | /> | 10 | /> |
| 11 | </div> | 11 | </div> |
| 12 | <table class="table table-sm table-striped table-dark"> | 12 | <table class="table table-sm table-striped table-dark"> |
| 13 | <thead> | 13 | <thead> |
| 14 | <tr> | 14 | <tr> |
| 15 | <th>Código</th> | 15 | <th>Código</th> |
| 16 | <th>Nombre</th> | 16 | <th>Nombre</th> |
| 17 | <th>DNI</th> | 17 | <th>DNI</th> |
| 18 | <th>Teléfono</th> | 18 | <th>Teléfono</th> |
| 19 | <th>Transportista</th> | 19 | <th>Transportista</th> |
| 20 | <th class="text-center"> | 20 | <th class="text-center"> |
| 21 | <button class="btn btn-default boton-accion" ng-click="editar(0)"> | 21 | <button class="btn btn-default boton-accion" ng-click="editar(0)"> |
| 22 | <i class="fa fa-plus"></i> | 22 | <i class="fa fa-plus"></i> |
| 23 | </button> | 23 | </button> |
| 24 | </th> | 24 | </th> |
| 25 | </tr> | 25 | </tr> |
| 26 | </thead> | 26 | </thead> |
| 27 | <tbody> | 27 | <tbody> |
| 28 | <tr ng-repeat="chofer in choferesFiltrados | filter:filtros"> | 28 | <tr ng-repeat="chofer in choferesFiltrados | filter:filtros"> |
| 29 | <td ng-bind="chofer.id"></td> | 29 | <td ng-bind="chofer.id"></td> |
| 30 | <td ng-bind="chofer.nombre"></td> | 30 | <td ng-bind="chofer.nombre"></td> |
| 31 | <td ng-bind="chofer.dni"></td> | 31 | <td ng-bind="chofer.dni"></td> |
| 32 | <td ng-bind="chofer.telefono"></td> | 32 | <td ng-bind="chofer.telefono"></td> |
| 33 | <td ng-bind="chofer.transportista.NOM || 'No tiene'"></td> | 33 | <td ng-bind="chofer.transportista.NOM || 'No tiene'"></td> |
| 34 | <td class="text-center"> | 34 | <td class="text-center"> |
| 35 | <button | 35 | <button |
| 36 | class="btn btn-default boton-accion" | 36 | class="btn btn-default boton-accion" |
| 37 | ng-click="editar(chofer.id)" | 37 | ng-click="editar(chofer.id)" |
| 38 | > | 38 | > |
| 39 | <i class="fa fa-pencil"></i> | 39 | <i class="fa fa-pencil"></i> |
| 40 | </button> | 40 | </button> |
| 41 | <button | 41 | <button |
| 42 | class="btn btn-default boton-accion" | 42 | class="btn btn-default boton-accion" |
| 43 | ng-click="solicitarConfirmacion(chofer)" | 43 | ng-click="solicitarConfirmacion(chofer)" |
| 44 | > | 44 | > |
| 45 | <i class="fa fa-trash"></i> | 45 | <i class="fa fa-trash"></i> |
| 46 | </button> | 46 | </button> |
| 47 | </td> | 47 | </td> |
| 48 | </tr> | 48 | </tr> |
| 49 | </body> | 49 | </body> |
| 50 | </table> | 50 | </table> |
| 51 | <a href="#!/" title="Salir" | 51 | <a href="#!/" title="Salir" |
| 52 | class="btn btn-secondary btn-block float-right col-md-2" | 52 | class="btn btn-secondary btn-block float-right col-md-2" |
| 53 | > | 53 | > |
| 54 | Salir | 54 | Salir |
| 55 | </a> | 55 | </a> |
| 56 | </div> | ||
| 56 | </div> |