Commit 50b6958db1cc4476ad97e24237936abc193a90ca

Authored by Pablo Marco del Pont
1 parent 5c77da4537
Exists in master

- No mostrar plazos si no existe precio condición.

src/js/controller.js
1 angular.module('focaAbmPreciosCondiciones') 1 angular.module('focaAbmPreciosCondiciones')
2 .controller('focaAbmPreciosCondicionesController', [ 2 .controller('focaAbmPreciosCondicionesController', [
3 '$scope', 'focaAbmPreciosCondicionesService', '$location', '$uibModal', 3 '$scope', 'focaAbmPreciosCondicionesService', '$location', '$uibModal',
4 function($scope, focaAbmPreciosCondicionesService, $location, $uibModal) { 4 function($scope, focaAbmPreciosCondicionesService, $location, $uibModal) {
5 focaAbmPreciosCondicionesService.obtenerPreciosCondiciones().then(function(datos) { 5 focaAbmPreciosCondicionesService.obtenerPreciosCondiciones().then(function(datos) {
6 $scope.preciosCondiciones = datos.data; 6 $scope.preciosCondiciones = datos.data;
7 }); 7 });
8 $scope.editar = function(id) { 8 $scope.editar = function(id) {
9 $location.path('/precio-condicion/' + id); 9 $location.path('/precio-condicion/' + id);
10 }; 10 };
11 $scope.solicitarConfirmacion = function(precioCondicion) { 11 $scope.solicitarConfirmacion = function(precioCondicion) {
12 $uibModal.open({ 12 $uibModal.open({
13 templateUrl: 'foca-abm-precios-condiciones-modal-confirmar.html', 13 templateUrl: 'foca-abm-precios-condiciones-modal-confirmar.html',
14 controller: 'focaAbmPreciosCondicionesModalConfirmarController', 14 controller: 'focaAbmPreciosCondicionesModalConfirmarController',
15 animation: false, 15 animation: false,
16 backdrop: false, 16 backdrop: false,
17 resolve: {precioCondicion: function(){return precioCondicion;}} 17 resolve: {precioCondicion: function(){return precioCondicion;}}
18 }) 18 })
19 .result.then(function(precioCondicion){ 19 .result.then(function(precioCondicion){
20 focaAbmPreciosCondicionesService.borrarPrecioCondicion(precioCondicion.id); 20 focaAbmPreciosCondicionesService.borrarPrecioCondicion(precioCondicion.id);
21 $scope.preciosCondiciones.splice( 21 $scope.preciosCondiciones.splice(
22 $scope.preciosCondiciones.indexOf(precioCondicion), 1 22 $scope.preciosCondiciones.indexOf(precioCondicion), 1
23 ); 23 );
24 }); 24 });
25 }; 25 };
26 } 26 }
27 ]) 27 ])
28 .controller('focaAbmPrecioCondicionController', [ 28 .controller('focaAbmPrecioCondicionController', [
29 '$scope', 'focaAbmPreciosCondicionesService', 29 '$scope', 'focaAbmPreciosCondicionesService',
30 '$routeParams', '$location', '$uibModal', 30 '$routeParams', '$location', '$uibModal',
31 function( 31 function(
32 $scope, focaAbmPreciosCondicionesService, 32 $scope, focaAbmPreciosCondicionesService,
33 $routeParams, $location, $uibModal 33 $routeParams, $location, $uibModal
34 ) { 34 ) {
35 $scope.mostrarPlazos = $routeParams.id > 0;
35 focaAbmPreciosCondicionesService.obtenerPrecioCondicion($routeParams.id) 36 focaAbmPreciosCondicionesService.obtenerPrecioCondicion($routeParams.id)
36 .then(function(datos) { 37 .then(function(datos) {
37 $scope.precioCondicion = { 38 $scope.precioCondicion = {
38 id: 0, 39 id: 0,
39 codigo: '', 40 codigo: '',
40 nombre: '', 41 nombre: '',
41 descripcion: '', 42 descripcion: '',
42 idListaPrecio: 0, 43 idListaPrecio: 0,
43 vigencia: new Date() 44 vigencia: new Date()
44 }; 45 };
45 if(datos.data.id) { 46 if(datos.data.id) {
46 $scope.precioCondicion = datos.data; 47 $scope.precioCondicion = datos.data;
47 focaAbmPreciosCondicionesService.obtenerPlazoPago(datos.data.id) 48 focaAbmPreciosCondicionesService.obtenerPlazoPago(datos.data.id)
48 .then(function(datos){ 49 .then(function(datos){
49 $scope.precioCondicion.plazos = datos.data; 50 $scope.precioCondicion.plazos = datos.data;
50 }); 51 });
51 } 52 }
52 }); 53 });
53 $scope.cancelar = function() { 54 $scope.cancelar = function() {
54 $location.path('/precio-condicion'); 55 $location.path('/precio-condicion');
55 }; 56 };
56 $scope.guardar = function(precioCondicion) { 57 $scope.guardar = function(precioCondicion) {
57 focaAbmPreciosCondicionesService.guardarPrecioCondicion(precioCondicion) 58 focaAbmPreciosCondicionesService.guardarPrecioCondicion(precioCondicion)
58 .then(function() { 59 .then(function() {
59 $location.path('/precio-condicion'); 60 $location.path('/precio-condicion');
60 }); 61 });
61 }; 62 };
62 $scope.editarPlazoPago = function(id) { 63 $scope.editarPlazoPago = function(id) {
63 $location.path( 64 $location.path(
64 '/precio-condicion/' + $scope.precioCondicion.id + 65 '/precio-condicion/' + $scope.precioCondicion.id +
65 '/plazo-pago/' + id 66 '/plazo-pago/' + id
66 ); 67 );
67 }; 68 };
68 $scope.solicitarConfirmacionPlazoPago = function(plazoPago) { 69 $scope.solicitarConfirmacionPlazoPago = function(plazoPago) {
69 $uibModal.open({ 70 $uibModal.open({
70 templateUrl: 'foca-abm-plazos-pago-modal-confirmar.html', 71 templateUrl: 'foca-abm-plazos-pago-modal-confirmar.html',
71 controller: 'focaAbmPlazosPagosModalConfirmarController', 72 controller: 'focaAbmPlazosPagosModalConfirmarController',
72 animation: false, 73 animation: false,
73 backdrop: false, 74 backdrop: false,
74 resolve: {plazoPago: function(){return plazoPago;}} 75 resolve: {plazoPago: function(){return plazoPago;}}
75 }) 76 })
76 .result.then(function(plazoPago){ 77 .result.then(function(plazoPago){
77 focaAbmPreciosCondicionesService.borrarPlazoPago(plazoPago.id); 78 focaAbmPreciosCondicionesService.borrarPlazoPago(plazoPago.id);
78 $scope.precioCondicion.plazos.splice( 79 $scope.precioCondicion.plazos.splice(
79 $scope.precioCondicion.plazos.indexOf(plazoPago), 1 80 $scope.precioCondicion.plazos.indexOf(plazoPago), 1
80 ); 81 );
81 }); 82 });
82 }; 83 };
83 } 84 }
84 ]) 85 ])
85 .controller('focaAbmPreciosCondicionesModalConfirmarController', [ 86 .controller('focaAbmPreciosCondicionesModalConfirmarController', [
86 '$uibModalInstance', '$scope', 'precioCondicion', 87 '$uibModalInstance', '$scope', 'precioCondicion',
87 function($uibModalInstance, $scope, precioCondicion) { 88 function($uibModalInstance, $scope, precioCondicion) {
88 $scope.precioCondicion = precioCondicion; 89 $scope.precioCondicion = precioCondicion;
89 $scope.cancelar = function() { 90 $scope.cancelar = function() {
90 $uibModalInstance.dismiss(); 91 $uibModalInstance.dismiss();
91 }; 92 };
92 $scope.borrar = function() { 93 $scope.borrar = function() {
93 $uibModalInstance.close(precioCondicion); 94 $uibModalInstance.close(precioCondicion);
94 }; 95 };
95 } 96 }
96 ]) 97 ])
97 .controller('focaAbmPlazosPagosModalConfirmarController', [ 98 .controller('focaAbmPlazosPagosModalConfirmarController', [
98 '$uibModalInstance', '$scope', 'plazoPago', 99 '$uibModalInstance', '$scope', 'plazoPago',
99 function($uibModalInstance, $scope, plazoPago) { 100 function($uibModalInstance, $scope, plazoPago) {
100 $scope.plazoPago = plazoPago; 101 $scope.plazoPago = plazoPago;
101 $scope.cancelar = function() { 102 $scope.cancelar = function() {
102 $uibModalInstance.dismiss(); 103 $uibModalInstance.dismiss();
103 }; 104 };
104 $scope.borrar = function() { 105 $scope.borrar = function() {
105 $uibModalInstance.close(plazoPago); 106 $uibModalInstance.close(plazoPago);
106 }; 107 };
107 } 108 }
108 ]); 109 ]);
109 110
src/views/foca-abm-precios-condiciones-item.html
1 <h4>Precios y Condiciones</h4> 1 <h4>Precios y Condiciones</h4>
2 <form> 2 <form>
3 <input type="hidden" name="id" ng-model="precioCondicion.id" /> 3 <input type="hidden" name="id" ng-model="precioCondicion.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">Código</label> 5 <label class="offset-sm-1 col-sm-2 col-form-label">Código</label>
6 <div class="col-sm-4"> 6 <div class="col-sm-4">
7 <input 7 <input
8 class="form-control" 8 class="form-control"
9 type="text" 9 type="text"
10 name="codigo" 10 name="codigo"
11 ng-model="precioCondicion.codigo" 11 ng-model="precioCondicion.codigo"
12 autocomplete="off"
12 /> 13 />
13 </div> 14 </div>
14 </div> 15 </div>
15 <div class="form-group row"> 16 <div class="form-group row">
16 <label class="offset-sm-1 col-sm-2 col-form-label">Nombre</label> 17 <label class="offset-sm-1 col-sm-2 col-form-label">Nombre</label>
17 <div class="col-sm-4"> 18 <div class="col-sm-4">
18 <input 19 <input
19 class="form-control" 20 class="form-control"
20 type="text" 21 type="text"
21 name="nombre" 22 name="nombre"
22 ng-model="precioCondicion.nombre" 23 ng-model="precioCondicion.nombre"
24 autocomplete="off"
23 /> 25 />
24 </div> 26 </div>
25 </div> 27 </div>
26 <div class="form-group row"> 28 <div class="form-group row">
27 <label class="offset-sm-1 col-sm-2 col-form-label">Descripción</label> 29 <label class="offset-sm-1 col-sm-2 col-form-label">Descripción</label>
28 <div class="col-sm-4"> 30 <div class="col-sm-4">
29 <input 31 <input
30 class="form-control" 32 class="form-control"
31 type="text" 33 type="text"
32 name="nombre" 34 name="nombre"
33 ng-model="precioCondicion.descripcion" 35 ng-model="precioCondicion.descripcion"
36 autocomplete="off"
34 /> 37 />
35 </div> 38 </div>
36 </div> 39 </div>
37 <div class="form-group row"> 40 <div class="form-group row">
38 <label class="offset-sm-1 col-sm-2 col-form-label">Lista de precios</label> 41 <label class="offset-sm-1 col-sm-2 col-form-label">Lista de precios</label>
39 <div class="col-sm-4"> 42 <div class="col-sm-4">
40 <input 43 <input
41 class="form-control" 44 class="form-control"
42 type="number" 45 type="number"
43 name="nombre" 46 name="nombre"
44 ng-model="precioCondicion.idListaPrecio" 47 ng-model="precioCondicion.idListaPrecio"
48 autocomplete="off"
45 /> 49 />
46 </div> 50 </div>
47 </div> 51 </div>
48 <div class="form-group row"> 52 <div class="form-group row" ng-show="mostrarPlazos">
49 <label class="offset-sm-1 col-sm-2 col-form-label">Plazos</label> 53 <label class="offset-sm-1 col-sm-2 col-form-label">Plazos</label>
50 <div class="col-sm-4"> 54 <div class="col-sm-4">
51 <table class="table table-sm table-hover"> 55 <table class="table table-sm table-hover lista">
52 <tr> 56 <thead>
53 <th>Item</th> 57 <tr>
54 <th>Dias</th> 58 <th>Item</th>
55 <th colspan="2" class="text-center"> 59 <th>Dias</th>
56 <button class="btn btn-default" ng-click="editarPlazoPago(0)"> 60 <th colspan="2" class="text-center">
57 <i class="fa fa-plus"></i> 61 <button class="btn btn-default boton-accion" ng-click="editarPlazoPago(0)">
58 </button> 62 <i class="fa fa-plus"></i>
59 </th> 63 </button>
60 </tr> 64 </th>
61 <tr ng-repeat="plazo in precioCondicion.plazos"> 65 </tr>
62 <td ng-bind="plazo.item"></td> 66 </thead>
63 <td ng-bind="plazo.dias"></td> 67 <tbody>
64 <td class="text-center"> 68 <tr ng-repeat="plazo in precioCondicion.plazos">
65 <button class="btn btn-default" ng-click="editarPlazoPago(plazo.id)"> 69 <td ng-bind="plazo.item"></td>
66 <i class="fa fa-pencil"></i> 70 <td ng-bind="plazo.dias"></td>
67 </button> 71 <td class="text-center">
68 <button 72 <button class="btn btn-default boton-accion" ng-click="editarPlazoPago(plazo.id)">
69 class="btn btn-default" 73 <i class="fa fa-pencil"></i>
70 ng-click="solicitarConfirmacionPlazoPago(plazo)" 74 </button>
71 > 75 <button
72 <i class="fa fa-trash"></i> 76 class="btn btn-default boton-accion"
73 </button> 77 ng-click="solicitarConfirmacionPlazoPago(plazo)"
74 </td> 78 >
75 </tr> 79 <i class="fa fa-trash"></i>
80 </button>
81 </td>
82 </tr>
83 </tbody>
76 </table> 84 </table>
77 </div> 85 </div>
78 </div> 86 </div>
79 <div class="form-group row"> 87 <div class="form-group row">
80 <div class="col-sm-7 text-right"> 88 <div class="col-sm-7 text-right">
81 <button class="btn btn-primary" ng-click="guardar(precioCondicion)">Guardar</button> 89 <button class="btn btn-primary" ng-click="guardar(precioCondicion)">Guardar</button>
82 <button class="btn btn-default" ng-click="cancelar()">Cancelar</button> 90 <button class="btn btn-default" ng-click="cancelar()">Cancelar</button>
83 </div> 91 </div>
84 </div> 92 </div>
85 </form> 93 </form>
86 94
src/views/foca-abm-precios-condiciones-listado.html
1 <h4>Precios y Condiciones</h4> 1 <div class="lista">
2 <table class="table table-sm table-hover table-nonfluid"> 2 <h4>Precios y Condiciones</h4>
3 <tr> 3 <table class="table table-sm table-hover table-nonfluid">
4 <th>Código</th> 4 <thead>
5 <th>Nombre</th> 5 <tr>
6 <th colspan="2" class="text-center"> 6 <th>Código</th>
7 <button class="btn btn-default" ng-click="editar(0)"> 7 <th>Nombre</th>
8 <i class="fa fa-plus"></i> 8 <th colspan="2" class="text-center">
9 </button> 9 <button class="btn btn-default boton-accion" ng-click="editar(0)">
10 </th> 10 <i class="fa fa-plus"></i>
11 </tr> 11 </button>
12 <tr ng-repeat="precioCondicion in preciosCondiciones"> 12 </th>
13 <td ng-bind="precioCondicion.codigo"></td> 13 </tr>
14 <td ng-bind="precioCondicion.nombre"></td> 14 </thead>
15 <td> 15 <tbody>
16 <button class="btn btn-default" ng-click="editar(precioCondicion.id)"> 16 <tr ng-repeat="precioCondicion in preciosCondiciones">
17 <i class="fa fa-pencil"></i> 17 <td ng-bind="precioCondicion.codigo"></td>
18 </button> 18 <td ng-bind="precioCondicion.nombre"></td>
19 <button class="btn btn-default" ng-click="solicitarConfirmacion(precioCondicion)"> 19 <td>
20 <i class="fa fa-trash"></i> 20 <button class="btn btn-default boton-accion" ng-click="editar(precioCondicion.id)">
21 </button> 21 <i class="fa fa-pencil"></i>
22 </td> 22 </button>
23 </tr> 23 <button class="btn btn-default boton-accion" ng-click="solicitarConfirmacion(precioCondicion)">
24 </table> 24 <i class="fa fa-trash"></i>
25 </button>
26 </td>
27 </tr>
28 </tbody>
29 </table>
30 </div>
25 31