Commit a5d9bb2a234af6fe6577a323abc3509df83062cd
0 parents
Exists in
master
Primera versión estable.
Showing
12 changed files
with
369 additions
and
0 deletions
Show diff stats
.gitignore
File was created | 1 | /node_modules | |
2 | /dist | ||
3 | /tmp | ||
4 | package-lock\.json | ||
5 |
.jshintrc
File was created | 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 | } | ||
65 |
README.md
File was created | 1 | ABM Plazos de Pago | |
2 | ================== | ||
3 |
gulpfile.js
File was created | 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: 'focaAbmPlazoPago', | ||
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-plazo-pago.js'), | ||
40 | gulp.dest(paths.tmp), | ||
41 | rename('foca-abm-plazo-pago.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 | }); | ||
63 |
package.json
File was created | 1 | { | |
2 | "name": "foca-abm-plazo-pago", | ||
3 | "version": "1.0.0", | ||
4 | "description": "ABM de Plazos de Pago", | ||
5 | "main": "dist/foca-abm-plazo-pago.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-plazo-pago.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 | } | ||
56 |
src/js/app.js
File was created | 1 | angular.module('focaAbmPlazoPago', []); | |
2 |
src/js/controller.js
File was created | 1 | angular.module('focaAbmPlazoPago') | |
2 | .controller('focaAbmPlazosPagoController', [ | ||
3 | '$scope', 'focaAbmPlazoPagoService', '$location', '$uibModal', | ||
4 | function($scope, focaAbmPlazoPagoService, $location, $uibModal) { | ||
5 | focaAbmPlazoPagoService.obtenerPlazosPago().then(function(datos) { | ||
6 | $scope.plazosPago = datos.data; | ||
7 | }); | ||
8 | $scope.editar = function(id) { | ||
9 | $location.path('/plazo-pago/' + id); | ||
10 | }; | ||
11 | $scope.solicitarConfirmacion = function(plazoPago) { | ||
12 | $uibModal.open({ | ||
13 | templateUrl: 'foca-abm-plazos-pago-modal-confirmar.html', | ||
14 | controller: 'focaAbmPlazosPagoModalConfirmarController', | ||
15 | animation: false, | ||
16 | backdrop: false, | ||
17 | resolve: {plazoPago: function(){return plazoPago;}} | ||
18 | }) | ||
19 | .result.then(function(plazoPago){ | ||
20 | focaAbmPlazoPagoService.borrarPlazoPago(plazoPago.id); | ||
21 | $scope.plazosPago.splice( | ||
22 | $scope.plazosPago.indexOf(plazoPago), 1 | ||
23 | ); | ||
24 | }); | ||
25 | }; | ||
26 | } | ||
27 | ]) | ||
28 | .controller('focaAbmPlazoPagoController', [ | ||
29 | '$scope', 'focaAbmPlazoPagoService', | ||
30 | '$routeParams', '$location', | ||
31 | function( | ||
32 | $scope, focaAbmPlazoPagoService, | ||
33 | $routeParams, $location | ||
34 | ) { | ||
35 | focaAbmPlazoPagoService.obtenerPlazoPago($routeParams.id) | ||
36 | .then(function(datos) { | ||
37 | $scope.plazoPago = { | ||
38 | id: 0, | ||
39 | idPreciosCondiciones: $routeParams.idPreciosCondiciones, | ||
40 | item: '', | ||
41 | dias: '' | ||
42 | }; | ||
43 | if(datos.data.id) { | ||
44 | $scope.plazoPago = datos.data; | ||
45 | } | ||
46 | }); | ||
47 | $scope.cancelar = function() { | ||
48 | $location.path('/plazo-pago'); | ||
49 | }; | ||
50 | $scope.guardar = function(plazoPago) { | ||
51 | focaAbmPlazoPagoService.guardarPlazoPago(plazoPago) | ||
52 | .then(function() { | ||
53 | $location.path('/precio-condicion/' + $routeParams.idPreciosCondiciones); | ||
54 | }); | ||
55 | }; | ||
56 | } | ||
57 | ]) | ||
58 | .controller('focaAbmPlazosPagoModalConfirmarController', [ | ||
59 | '$uibModalInstance', '$scope', 'plazoPago', | ||
60 | function($uibModalInstance, $scope, plazoPago) { | ||
61 | $scope.plazoPago = plazoPago; | ||
62 | $scope.cancelar = function() { | ||
63 | $uibModalInstance.dismiss(); | ||
64 | }; | ||
65 | $scope.borrar = function() { | ||
66 | $uibModalInstance.close(plazoPago); | ||
67 | }; | ||
68 | } | ||
69 | ]); | ||
70 |
src/js/route.js
File was created | 1 | angular.module('focaAbmPlazoPago') | |
2 | .config([ | ||
3 | '$routeProvider', | ||
4 | function($routeProvider) { | ||
5 | $routeProvider.when('/plazo-pago', { | ||
6 | controller: 'focaAbmPlazosPagoController', | ||
7 | templateUrl: 'foca-abm-plazos-pago-listado.html' | ||
8 | }); | ||
9 | } | ||
10 | ]) | ||
11 | .config([ | ||
12 | '$routeProvider', | ||
13 | function($routeProvider) { | ||
14 | $routeProvider.when('/precio-condicion/:idPreciosCondiciones/plazo-pago/:id', { | ||
15 | controller: 'focaAbmPlazoPagoController', | ||
16 | templateUrl: 'foca-abm-plazos-pago-item.html' | ||
17 | }); | ||
18 | } | ||
19 | ]); | ||
20 |
src/js/service.js
File was created | 1 | angular.module('focaAbmPlazoPago') | |
2 | .service('focaAbmPlazoPagoService', [ | ||
3 | '$http', 'API_ENDPOINT', | ||
4 | function($http, API_ENDPOINT) { | ||
5 | return { | ||
6 | obtenerPlazosPago: function() { | ||
7 | return $http.get(API_ENDPOINT.URL + '/plazo-pago'); | ||
8 | }, | ||
9 | obtenerPlazoPago: function(id) { | ||
10 | return $http.get(API_ENDPOINT.URL + '/plazo-pago/' + id); | ||
11 | }, | ||
12 | guardarPlazoPago: function(plazoPago) { | ||
13 | return $http.post( | ||
14 | API_ENDPOINT.URL + '/plazo-pago', | ||
15 | {plazoPago: plazoPago} | ||
16 | ); | ||
17 | }, | ||
18 | borrarPlazoPago: function(id) { | ||
19 | return $http.delete(API_ENDPOINT.URL + '/plazo-pago/' + id); | ||
20 | } | ||
21 | }; | ||
22 | } | ||
23 | ]); | ||
24 |
src/views/foca-abm-plazos-pago-item.html
File was created | 1 | <form> | |
2 | <input type="hidden" name="id" ng-model="plazoPago.id" /> | ||
3 | <input type="hidden" name="idPreciosCondiciones" ng-model="plazoPago.idPreciosCondiciones" /> | ||
4 | <div class="form-group row"> | ||
5 | <label class="offset-sm-1 col-sm-2 col-form-label">Item</label> | ||
6 | <div class="col-sm-4"> | ||
7 | <input | ||
8 | class="form-control" | ||
9 | type="number" | ||
10 | name="codigo" | ||
11 | ng-model="plazoPago.item" | ||
12 | autocomplete="off" | ||
13 | /> | ||
14 | </div> | ||
15 | </div> | ||
16 | <div class="form-group row"> | ||
17 | <label class="offset-sm-1 col-sm-2 col-form-label">Dias</label> | ||
18 | <div class="col-sm-4"> | ||
19 | <input | ||
20 | class="form-control" | ||
21 | type="number" | ||
22 | name="nombre" | ||
23 | ng-model="plazoPago.dias" | ||
24 | autocomplete="off" | ||
25 | /> | ||
26 | </div> | ||
27 | </div> | ||
28 | <div class="form-group row"> | ||
29 | <div class="col-sm-7 text-right"> | ||
30 | <button class="btn btn-primary" ng-click="guardar(plazoPago)">Guardar</button> | ||
31 | <button class="btn btn-default" ng-click="cancelar()">Cancelar</button> | ||
32 | </div> | ||
33 | </div> | ||
34 | </form> | ||
35 |
src/views/foca-abm-plazos-pago-listado.html
File was created | 1 | <table class="table table-sm table-hover table-nonfluid"> | |
2 | <tr> | ||
3 | <th>Item</th> | ||
4 | <th>Dias</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="plazoPago in plazosPago"> | ||
12 | <td ng-bind="plazoPago.item"></td> | ||
13 | <td ng-bind="plazoPago.dias"></td> | ||
14 | <td> | ||
15 | <button class="btn btn-default" ng-click="editar(plazoPago.id)"> | ||
16 | <i class="fa fa-pencil"></i> | ||
17 | </button> | ||
18 | <button class="btn btn-default" ng-click="solicitarConfirmacion(plazoPago)"> | ||
19 | <i class="fa fa-trash"></i> | ||
20 | </button> | ||
21 | </td> | ||
22 | </tr> | ||
23 | </table> | ||
24 |
src/views/foca-abm-plazos-pago-modal-confirmar.html
File was created | 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 plazo de pago | ||
7 | {{plazoPago.item}} {{plazoPago.dias}}? | ||
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> | ||
14 |