Commit 547bcae879da77882d39e460545db9ba0aae2474
0 parents
Exists in
master
Primera versión estable.
Showing
12 changed files
with
436 additions
and
0 deletions
Show diff stats
.gitignore
.jshintrc
... | ... | @@ -0,0 +1,64 @@ |
1 | +{ | |
2 | + /* | |
3 | + * ENVIRONMENTS | |
4 | + * ================= | |
5 | + */ | |
6 | + | |
7 | + // Define globals exposed by modern browsers. | |
8 | + "browser": true, | |
9 | + | |
10 | + // Define globals exposed by jQuery. | |
11 | + "jquery": true, | |
12 | + | |
13 | + // Define globals exposed by Node.js. | |
14 | + "node": true, | |
15 | + | |
16 | + // Allow ES6. | |
17 | + "esversion": 6, | |
18 | + | |
19 | + /* | |
20 | + * ENFORCING OPTIONS | |
21 | + * ================= | |
22 | + */ | |
23 | + | |
24 | + // Force all variable names to use either camelCase style or UPPER_CASE | |
25 | + // with underscores. | |
26 | + "camelcase": true, | |
27 | + | |
28 | + // Prohibit use of == and != in favor of === and !==. | |
29 | + "eqeqeq": true, | |
30 | + | |
31 | + // Enforce tab width of 2 spaces. | |
32 | + "indent": 4, | |
33 | + | |
34 | + // Prohibit use of a variable before it is defined. | |
35 | + "latedef": true, | |
36 | + | |
37 | + // Enforce line length to 100 characters | |
38 | + "maxlen": 100, | |
39 | + | |
40 | + // Require capitalized names for constructor functions. | |
41 | + "newcap": true, | |
42 | + | |
43 | + // Enforce use of single quotation marks for strings. | |
44 | + "quotmark": "single", | |
45 | + | |
46 | + // Enforce placing 'use strict' at the top function scope | |
47 | + "strict": false, | |
48 | + | |
49 | + // Prohibit use of explicitly undeclared variables. | |
50 | + "undef": true, | |
51 | + | |
52 | + // Warn when variables are defined but never used. | |
53 | + "unused": true, | |
54 | + | |
55 | + // Para que funcione en angular | |
56 | + "predef": ["angular", "alert", "spyOn", "expect", "it", "inject", "beforeEach", "describe"], | |
57 | + /* | |
58 | + * RELAXING OPTIONS | |
59 | + * ================= | |
60 | + */ | |
61 | + | |
62 | + // Suppress warnings about == null comparisons. | |
63 | + "eqnull": true | |
64 | +} |
README.md
gulpfile.js
... | ... | @@ -0,0 +1,62 @@ |
1 | +const templateCache = require('gulp-angular-templatecache'); | |
2 | +const concat = require('gulp-concat'); | |
3 | +const clean = require('gulp-clean'); | |
4 | +const htmlmin = require('gulp-htmlmin'); | |
5 | +const rename = require('gulp-rename'); | |
6 | +const uglify = require('gulp-uglify-es').default; | |
7 | +const gulp = require('gulp'); | |
8 | +const pump = require('pump'); | |
9 | +const jshint = require('gulp-jshint'); | |
10 | + | |
11 | +var paths = { | |
12 | + srcJS: 'src/js/*.js', | |
13 | + srcViews: 'src/views/*.html', | |
14 | + tmp: 'tmp', | |
15 | + dist: 'dist/' | |
16 | +}; | |
17 | + | |
18 | +gulp.task('templates', function() { | |
19 | + return pump( | |
20 | + [ | |
21 | + gulp.src(paths.srcViews), | |
22 | + htmlmin(), | |
23 | + templateCache('views.js', { | |
24 | + module: 'focaAbmPreciosCondiciones', | |
25 | + root: '' | |
26 | + }), | |
27 | + gulp.dest(paths.tmp) | |
28 | + ] | |
29 | + ); | |
30 | +}); | |
31 | + | |
32 | +gulp.task('uglify', ['templates'], function() { | |
33 | + return pump( | |
34 | + [ | |
35 | + gulp.src([ | |
36 | + paths.srcJS, | |
37 | + 'tmp/views.js' | |
38 | + ]), | |
39 | + concat('foca-abm-precios-condiciones.js'), | |
40 | + gulp.dest(paths.tmp), | |
41 | + rename('foca-abm-precios-condiciones.min.js'), | |
42 | + uglify(), | |
43 | + gulp.dest(paths.dist) | |
44 | + ] | |
45 | + ); | |
46 | +}); | |
47 | + | |
48 | +gulp.task('clean', function(){ | |
49 | + return gulp.src(['tmp', 'dist'], {read: false}) | |
50 | + .pipe(clean()); | |
51 | +}); | |
52 | + | |
53 | +gulp.task('pre-commit', function() { | |
54 | + pump( | |
55 | + [ | |
56 | + gulp.src(paths.srcJS), | |
57 | + jshint('.jshintrc'), | |
58 | + jshint.reporter('default'), | |
59 | + jshint.reporter('fail') | |
60 | + ] | |
61 | + ); | |
62 | +}); |
package.json
... | ... | @@ -0,0 +1,55 @@ |
1 | +{ | |
2 | + "name": "foca-abm-precios-condiciones", | |
3 | + "version": "1.0.0", | |
4 | + "description": "ABM de precios y condiciones", | |
5 | + "main": "dist/foca-abm-precios-condiciones.js", | |
6 | + "scripts": { | |
7 | + "test": "echo \"Error: no test specified\" && exit 1", | |
8 | + "compile": "gulp uglify", | |
9 | + "pre-commit": [ | |
10 | + "gulp-pre-commit" | |
11 | + ], | |
12 | + "postinstall": "npm run compile && rm -R src && rm index.html && rm .jshintrc && rm gulpfile.js" | |
13 | + }, | |
14 | + "repository": { | |
15 | + "type": "git", | |
16 | + "url": "https://192.168.0.11/modulos-npm/foca-abm-precios-condiciones.git" | |
17 | + }, | |
18 | + "author": "Foca Software", | |
19 | + "license": "ISC", | |
20 | + "peerDependencies": { | |
21 | + "angular": "^1.7.x", | |
22 | + "bootstrap": "^4.1.x", | |
23 | + "jquery": "^3.3.x", | |
24 | + "font-awesome": "^4.7.x", | |
25 | + "gulp": "^3.9.x", | |
26 | + "gulp-concat": "2.6.x", | |
27 | + "gulp-jshint": "^2.1.x", | |
28 | + "gulp-rename": "^1.4.x", | |
29 | + "gulp-replace": "^1.0.x", | |
30 | + "gulp-uglify-es": "^1.0.x", | |
31 | + "jshint": "^2.9.x", | |
32 | + "pump": "^3.0.x" | |
33 | + }, | |
34 | + "devDependencies": { | |
35 | + "gulp-connect": "^5.6.1", | |
36 | + "jasmine-core": "3.2.1", | |
37 | + "pre-commit": "^1.2.2" | |
38 | + }, | |
39 | + "dependencies": { | |
40 | + "angular": "1.7.4", | |
41 | + "bootstrap": "4.1.3", | |
42 | + "font-awesome": "4.7.0", | |
43 | + "gulp-angular-templatecache": "2.2.1", | |
44 | + "gulp-clean": "0.4.0", | |
45 | + "gulp-htmlmin": "5.0.1", | |
46 | + "gulp-jshint": "2.1.0", | |
47 | + "gulp-rename": "1.4.0", | |
48 | + "gulp-replace": "1.0.0", | |
49 | + "gulp-sequence": "1.0.0", | |
50 | + "gulp-uglify-es": "1.0.4", | |
51 | + "jquery": "3.3.1", | |
52 | + "jshint": "2.9.6", | |
53 | + "pump": "3.0.0" | |
54 | + } | |
55 | +} |
src/js/app.js
... | ... | @@ -0,0 +1 @@ |
1 | +angular.module('focaAbmPreciosCondiciones', []); |
src/js/controller.js
... | ... | @@ -0,0 +1,74 @@ |
1 | +angular.module('focaAbmPreciosCondiciones') | |
2 | + .controller('focaAbmPreciosCondicionesController', [ | |
3 | + '$scope', 'focaAbmPreciosCondicionesService', '$location', '$uibModal', | |
4 | + function($scope, focaAbmPreciosCondicionesService, $location, $uibModal) { | |
5 | + focaAbmPreciosCondicionesService.obtenerPreciosCondiciones().then(function(datos) { | |
6 | + $scope.preciosCondiciones = datos.data; | |
7 | + }); | |
8 | + $scope.editar = function(id) { | |
9 | + $location.path('/precio-condicion/' + id); | |
10 | + }; | |
11 | + $scope.solicitarConfirmacion = function(precioCondicion) { | |
12 | + $uibModal.open({ | |
13 | + templateUrl: 'foca-abm-precios-condiciones-modal-confirmar.html', | |
14 | + controller: 'focaAbmPreciosCondicionesModalConfirmarController', | |
15 | + animation: false, | |
16 | + backdrop: false, | |
17 | + resolve: {precioCondicion: function(){return precioCondicion;}} | |
18 | + }) | |
19 | + .result.then(function(precioCondicion){ | |
20 | + focaAbmPreciosCondicionesService.borrarPrecioCondicion(precioCondicion.id); | |
21 | + $scope.preciosCondiciones.splice( | |
22 | + $scope.preciosCondiciones.indexOf(precioCondicion), 1 | |
23 | + ); | |
24 | + }); | |
25 | + }; | |
26 | + } | |
27 | + ]) | |
28 | + .controller('focaAbmPrecioCondicionController', [ | |
29 | + '$scope', 'focaAbmPreciosCondicionesService', 'focaAbmPlazoPagoService', | |
30 | + '$routeParams', '$location', | |
31 | + function( | |
32 | + $scope, focaAbmPreciosCondicionesService, focaAbmPlazoPagoService, | |
33 | + $routeParams, $location | |
34 | + ) { | |
35 | + focaAbmPreciosCondicionesService.obtenerPrecioCondicion($routeParams.id) | |
36 | + .then(function(datos) { | |
37 | + $scope.precioCondicion = { | |
38 | + id: 0, | |
39 | + codigo: '', | |
40 | + nombre: '', | |
41 | + poseeAforadores: 0, | |
42 | + imagen: '' | |
43 | + }; | |
44 | + if(datos.data.id) { | |
45 | + $scope.precioCondicion = datos.data; | |
46 | + focaAbmPlazoPagoService.obtenerPlazoPago(datos.data.id) | |
47 | + .then(function(datos){ | |
48 | + $scope.precioCondicion.plazos = datos.data; | |
49 | + }); | |
50 | + } | |
51 | + }); | |
52 | + $scope.cancelar = function() { | |
53 | + $location.path('/precio-condicion'); | |
54 | + }; | |
55 | + $scope.guardar = function(precioCondicion) { | |
56 | + focaAbmPreciosCondicionesService.guardarPrecioCondicion(precioCondicion) | |
57 | + .then(function() { | |
58 | + $location.path('/precio-condicion'); | |
59 | + }); | |
60 | + }; | |
61 | + } | |
62 | + ]) | |
63 | + .controller('focaAbmPreciosCondicionesModalConfirmarController', [ | |
64 | + '$uibModalInstance', '$scope', 'precioCondicion', | |
65 | + function($uibModalInstance, $scope, precioCondicion) { | |
66 | + $scope.precioCondicion = precioCondicion; | |
67 | + $scope.cancelar = function() { | |
68 | + $uibModalInstance.dismiss(); | |
69 | + }; | |
70 | + $scope.borrar = function() { | |
71 | + $uibModalInstance.close(precioCondicion); | |
72 | + }; | |
73 | + } | |
74 | + ]); |
src/js/route.js
... | ... | @@ -0,0 +1,19 @@ |
1 | +angular.module('focaAbmPreciosCondiciones') | |
2 | + .config([ | |
3 | + '$routeProvider', | |
4 | + function($routeProvider) { | |
5 | + $routeProvider.when('/precio-condicion', { | |
6 | + controller: 'focaAbmPreciosCondicionesController', | |
7 | + templateUrl: 'foca-abm-precios-condiciones-listado.html' | |
8 | + }); | |
9 | + } | |
10 | + ]) | |
11 | + .config([ | |
12 | + '$routeProvider', | |
13 | + function($routeProvider) { | |
14 | + $routeProvider.when('/precio-condicion/:id', { | |
15 | + controller: 'focaAbmPrecioCondicionController', | |
16 | + templateUrl: 'foca-abm-precios-condiciones-item.html' | |
17 | + }); | |
18 | + } | |
19 | + ]); |
src/js/service.js
... | ... | @@ -0,0 +1,35 @@ |
1 | +angular.module('focaAbmPreciosCondiciones') | |
2 | + .service('focaAbmPreciosCondicionesService', [ | |
3 | + '$http', 'API_ENDPOINT', | |
4 | + function($http, API_ENDPOINT) { | |
5 | + return { | |
6 | + obtenerPreciosCondiciones: function() { | |
7 | + return $http.get(API_ENDPOINT.URL + '/precio-condicion'); | |
8 | + }, | |
9 | + obtenerPrecioCondicion: function(id) { | |
10 | + return $http.get(API_ENDPOINT.URL + '/precio-condicion/' + id); | |
11 | + }, | |
12 | + guardarPrecioCondicion: function(precioCondicion) { | |
13 | + return $http.post( | |
14 | + API_ENDPOINT.URL + '/precio-condicion', | |
15 | + {precioCondicion: precioCondicion} | |
16 | + ); | |
17 | + }, | |
18 | + borrarPrecioCondicion: function(id) { | |
19 | + return $http.delete(API_ENDPOINT.URL + '/precio-condicion/' + id); | |
20 | + } | |
21 | + }; | |
22 | + } | |
23 | + ]) | |
24 | + .service('focaAbmPlazoPagoService', [ | |
25 | + '$http', 'API_ENDPOINT', | |
26 | + function($http, API_ENDPOINT) { | |
27 | + return { | |
28 | + obtenerPlazoPago: function(idPrecioCondicion) { | |
29 | + return $http.get( | |
30 | + API_ENDPOINT.URL + '/plazo-pago/precio-condicion/' + idPrecioCondicion | |
31 | + ); | |
32 | + } | |
33 | + }; | |
34 | + } | |
35 | + ]); |
src/views/foca-abm-precios-condiciones-item.html
... | ... | @@ -0,0 +1,84 @@ |
1 | +<form> | |
2 | + <input type="hidden" name="id" ng-model="precioCondicion.id" /> | |
3 | + <div class="form-group row"> | |
4 | + <label class="offset-sm-1 col-sm-2 col-form-label">Código</label> | |
5 | + <div class="col-sm-4"> | |
6 | + <input | |
7 | + class="form-control" | |
8 | + type="text" | |
9 | + name="codigo" | |
10 | + ng-model="precioCondicion.codigo" | |
11 | + /> | |
12 | + </div> | |
13 | + </div> | |
14 | + <div class="form-group row"> | |
15 | + <label class="offset-sm-1 col-sm-2 col-form-label">Nombre</label> | |
16 | + <div class="col-sm-4"> | |
17 | + <input | |
18 | + class="form-control" | |
19 | + type="text" | |
20 | + name="nombre" | |
21 | + ng-model="precioCondicion.nombre" | |
22 | + /> | |
23 | + </div> | |
24 | + </div> | |
25 | + <div class="form-group row"> | |
26 | + <label class="offset-sm-1 col-sm-2 col-form-label">Descripción</label> | |
27 | + <div class="col-sm-4"> | |
28 | + <input | |
29 | + class="form-control" | |
30 | + type="text" | |
31 | + name="nombre" | |
32 | + ng-model="precioCondicion.descripcion" | |
33 | + /> | |
34 | + </div> | |
35 | + </div> | |
36 | + <div class="form-group row"> | |
37 | + <label class="offset-sm-1 col-sm-2 col-form-label">Lista de precios</label> | |
38 | + <div class="col-sm-4"> | |
39 | + <input | |
40 | + class="form-control" | |
41 | + type="text" | |
42 | + name="nombre" | |
43 | + ng-model="precioCondicion.idListaPrecio" | |
44 | + /> | |
45 | + </div> | |
46 | + </div> | |
47 | + <div class="form-group row"> | |
48 | + <label class="offset-sm-1 col-sm-2 col-form-label">Plazos</label> | |
49 | + <div class="col-sm-4"> | |
50 | + <table class="table table-sm table-hover"> | |
51 | + <tr> | |
52 | + <th>Item</th> | |
53 | + <th>Dias</th> | |
54 | + <th colspan="2" class="text-center"> | |
55 | + <button class="btn btn-default" ng-click="editar(0)"> | |
56 | + <i class="fa fa-plus"></i> | |
57 | + </button> | |
58 | + </th> | |
59 | + </tr> | |
60 | + <tr ng-repeat="plazo in precioCondicion.plazos"> | |
61 | + <td ng-bind="plazo.item"></td> | |
62 | + <td ng-bind="plazo.dias"></td> | |
63 | + <td class="text-center"> | |
64 | + <button class="btn btn-default" ng-click="editarPlazo(plazo.id)"> | |
65 | + <i class="fa fa-pencil"></i> | |
66 | + </button> | |
67 | + <button | |
68 | + class="btn btn-default" | |
69 | + ng-click="solicitarConfirmacionPlazo(plazo)" | |
70 | + > | |
71 | + <i class="fa fa-trash"></i> | |
72 | + </button> | |
73 | + </td> | |
74 | + </tr> | |
75 | + </table> | |
76 | + </div> | |
77 | + </div> | |
78 | + <div class="form-group row"> | |
79 | + <div class="col-sm-7 text-right"> | |
80 | + <button class="btn btn-primary" ng-click="guardar(precioCondicion)">Guardar</button> | |
81 | + <button class="btn btn-default" ng-click="cancelar()">Cancelar</button> | |
82 | + </div> | |
83 | + </div> | |
84 | +</form> |
src/views/foca-abm-precios-condiciones-listado.html
... | ... | @@ -0,0 +1,23 @@ |
1 | +<table class="table table-sm table-hover table-nonfluid"> | |
2 | + <tr> | |
3 | + <th>Código</th> | |
4 | + <th>Nombre</th> | |
5 | + <th colspan="2" class="text-center"> | |
6 | + <button class="btn btn-default" ng-click="editar(0)"> | |
7 | + <i class="fa fa-plus"></i> | |
8 | + </button> | |
9 | + </th> | |
10 | + </tr> | |
11 | + <tr ng-repeat="precioCondicion in preciosCondiciones"> | |
12 | + <td ng-bind="precioCondicion.codigo"></td> | |
13 | + <td ng-bind="precioCondicion.nombre"></td> | |
14 | + <td> | |
15 | + <button class="btn btn-default" ng-click="editar(precioCondicion.id)"> | |
16 | + <i class="fa fa-pencil"></i> | |
17 | + </button> | |
18 | + <button class="btn btn-default" ng-click="solicitarConfirmacion(precioCondicion)"> | |
19 | + <i class="fa fa-trash"></i> | |
20 | + </button> | |
21 | + </td> | |
22 | + </tr> | |
23 | +</table> |
src/views/foca-abm-precios-condiciones-modal-confirmar.html
... | ... | @@ -0,0 +1,13 @@ |
1 | +<div class="modal-header"> | |
2 | + <h4>Confirmar</h4> | |
3 | +</div> | |
4 | +<div class="modal-body"> | |
5 | + <p> | |
6 | + ¿Está seguro que desea borrar el precio condición | |
7 | + {{precioCondicion.codigo}} {{precioCondicion.nombre}}? | |
8 | + </p> | |
9 | +</div> | |
10 | +<div class="modal-footer"> | |
11 | + <button class="btn btn-danger" ng-click="borrar()">Borrar</button> | |
12 | + <button class="btn btn-default" ng-click="cancelar()">Cancelar</button> | |
13 | +</div> |