From a5d9bb2a234af6fe6577a323abc3509df83062cd Mon Sep 17 00:00:00 2001 From: Pablo Marco del Pont Date: Mon, 8 Oct 2018 18:46:53 -0300 Subject: [PATCH] =?UTF-8?q?Primera=20versi=C3=B3n=20estable.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 4 ++ .jshintrc | 64 ++++++++++++++++++++ README.md | 2 + gulpfile.js | 62 +++++++++++++++++++ package.json | 55 +++++++++++++++++ src/js/app.js | 1 + src/js/controller.js | 69 ++++++++++++++++++++++ src/js/route.js | 19 ++++++ src/js/service.js | 23 ++++++++ src/views/foca-abm-plazos-pago-item.html | 34 +++++++++++ src/views/foca-abm-plazos-pago-listado.html | 23 ++++++++ .../foca-abm-plazos-pago-modal-confirmar.html | 13 ++++ 12 files changed, 369 insertions(+) create mode 100644 .gitignore create mode 100644 .jshintrc create mode 100644 README.md create mode 100644 gulpfile.js create mode 100644 package.json create mode 100644 src/js/app.js create mode 100644 src/js/controller.js create mode 100644 src/js/route.js create mode 100644 src/js/service.js create mode 100644 src/views/foca-abm-plazos-pago-item.html create mode 100644 src/views/foca-abm-plazos-pago-listado.html create mode 100644 src/views/foca-abm-plazos-pago-modal-confirmar.html diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7d22e37 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/node_modules +/dist +/tmp +package-lock\.json diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..dd429f7 --- /dev/null +++ b/.jshintrc @@ -0,0 +1,64 @@ +{ + /* + * ENVIRONMENTS + * ================= + */ + + // Define globals exposed by modern browsers. + "browser": true, + + // Define globals exposed by jQuery. + "jquery": true, + + // Define globals exposed by Node.js. + "node": true, + + // Allow ES6. + "esversion": 6, + + /* + * ENFORCING OPTIONS + * ================= + */ + + // Force all variable names to use either camelCase style or UPPER_CASE + // with underscores. + "camelcase": true, + + // Prohibit use of == and != in favor of === and !==. + "eqeqeq": true, + + // Enforce tab width of 2 spaces. + "indent": 4, + + // Prohibit use of a variable before it is defined. + "latedef": true, + + // Enforce line length to 100 characters + "maxlen": 100, + + // Require capitalized names for constructor functions. + "newcap": true, + + // Enforce use of single quotation marks for strings. + "quotmark": "single", + + // Enforce placing 'use strict' at the top function scope + "strict": false, + + // Prohibit use of explicitly undeclared variables. + "undef": true, + + // Warn when variables are defined but never used. + "unused": true, + + // Para que funcione en angular + "predef": ["angular", "alert", "spyOn", "expect", "it", "inject", "beforeEach", "describe"], + /* + * RELAXING OPTIONS + * ================= + */ + + // Suppress warnings about == null comparisons. + "eqnull": true +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..ddfc32d --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +ABM Plazos de Pago +================== diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..b0c8268 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,62 @@ +const templateCache = require('gulp-angular-templatecache'); +const concat = require('gulp-concat'); +const clean = require('gulp-clean'); +const htmlmin = require('gulp-htmlmin'); +const rename = require('gulp-rename'); +const uglify = require('gulp-uglify-es').default; +const gulp = require('gulp'); +const pump = require('pump'); +const jshint = require('gulp-jshint'); + +var paths = { + srcJS: 'src/js/*.js', + srcViews: 'src/views/*.html', + tmp: 'tmp', + dist: 'dist/' +}; + +gulp.task('templates', function() { + return pump( + [ + gulp.src(paths.srcViews), + htmlmin(), + templateCache('views.js', { + module: 'focaAbmPlazoPago', + root: '' + }), + gulp.dest(paths.tmp) + ] + ); +}); + +gulp.task('uglify', ['templates'], function() { + return pump( + [ + gulp.src([ + paths.srcJS, + 'tmp/views.js' + ]), + concat('foca-abm-plazo-pago.js'), + gulp.dest(paths.tmp), + rename('foca-abm-plazo-pago.min.js'), + uglify(), + gulp.dest(paths.dist) + ] + ); +}); + +gulp.task('clean', function(){ + return gulp.src(['tmp', 'dist'], {read: false}) + .pipe(clean()); +}); + +gulp.task('pre-commit', function() { + pump( + [ + gulp.src(paths.srcJS), + jshint('.jshintrc'), + jshint.reporter('default'), + jshint.reporter('fail') + ] + ); +}); diff --git a/package.json b/package.json new file mode 100644 index 0000000..c7505ee --- /dev/null +++ b/package.json @@ -0,0 +1,55 @@ +{ + "name": "foca-abm-plazo-pago", + "version": "1.0.0", + "description": "ABM de Plazos de Pago", + "main": "dist/foca-abm-plazo-pago.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "compile": "gulp uglify", + "pre-commit": [ + "gulp-pre-commit" + ], + "postinstall": "npm run compile && rm -R src && rm index.html && rm .jshintrc && rm gulpfile.js" + }, + "repository": { + "type": "git", + "url": "https://192.168.0.11/modulos-npm/foca-abm-plazo-pago.git" + }, + "author": "Foca Software", + "license": "ISC", + "peerDependencies": { + "angular": "^1.7.x", + "bootstrap": "^4.1.x", + "jquery": "^3.3.x", + "font-awesome": "^4.7.x", + "gulp": "^3.9.x", + "gulp-concat": "2.6.x", + "gulp-jshint": "^2.1.x", + "gulp-rename": "^1.4.x", + "gulp-replace": "^1.0.x", + "gulp-uglify-es": "^1.0.x", + "jshint": "^2.9.x", + "pump": "^3.0.x" + }, + "devDependencies": { + "gulp-connect": "^5.6.1", + "jasmine-core": "3.2.1", + "pre-commit": "^1.2.2" + }, + "dependencies": { + "angular": "1.7.4", + "bootstrap": "4.1.3", + "font-awesome": "4.7.0", + "gulp-angular-templatecache": "2.2.1", + "gulp-clean": "0.4.0", + "gulp-htmlmin": "5.0.1", + "gulp-jshint": "2.1.0", + "gulp-rename": "1.4.0", + "gulp-replace": "1.0.0", + "gulp-sequence": "1.0.0", + "gulp-uglify-es": "1.0.4", + "jquery": "3.3.1", + "jshint": "2.9.6", + "pump": "3.0.0" + } +} diff --git a/src/js/app.js b/src/js/app.js new file mode 100644 index 0000000..449e551 --- /dev/null +++ b/src/js/app.js @@ -0,0 +1 @@ +angular.module('focaAbmPlazoPago', []); diff --git a/src/js/controller.js b/src/js/controller.js new file mode 100644 index 0000000..a77f64a --- /dev/null +++ b/src/js/controller.js @@ -0,0 +1,69 @@ +angular.module('focaAbmPlazoPago') + .controller('focaAbmPlazosPagoController', [ + '$scope', 'focaAbmPlazoPagoService', '$location', '$uibModal', + function($scope, focaAbmPlazoPagoService, $location, $uibModal) { + focaAbmPlazoPagoService.obtenerPlazosPago().then(function(datos) { + $scope.plazosPago = datos.data; + }); + $scope.editar = function(id) { + $location.path('/plazo-pago/' + id); + }; + $scope.solicitarConfirmacion = function(plazoPago) { + $uibModal.open({ + templateUrl: 'foca-abm-plazos-pago-modal-confirmar.html', + controller: 'focaAbmPlazosPagoModalConfirmarController', + animation: false, + backdrop: false, + resolve: {plazoPago: function(){return plazoPago;}} + }) + .result.then(function(plazoPago){ + focaAbmPlazoPagoService.borrarPlazoPago(plazoPago.id); + $scope.plazosPago.splice( + $scope.plazosPago.indexOf(plazoPago), 1 + ); + }); + }; + } + ]) + .controller('focaAbmPlazoPagoController', [ + '$scope', 'focaAbmPlazoPagoService', + '$routeParams', '$location', + function( + $scope, focaAbmPlazoPagoService, + $routeParams, $location + ) { + focaAbmPlazoPagoService.obtenerPlazoPago($routeParams.id) + .then(function(datos) { + $scope.plazoPago = { + id: 0, + idPreciosCondiciones: $routeParams.idPreciosCondiciones, + item: '', + dias: '' + }; + if(datos.data.id) { + $scope.plazoPago = datos.data; + } + }); + $scope.cancelar = function() { + $location.path('/plazo-pago'); + }; + $scope.guardar = function(plazoPago) { + focaAbmPlazoPagoService.guardarPlazoPago(plazoPago) + .then(function() { + $location.path('/precio-condicion/' + $routeParams.idPreciosCondiciones); + }); + }; + } + ]) + .controller('focaAbmPlazosPagoModalConfirmarController', [ + '$uibModalInstance', '$scope', 'plazoPago', + function($uibModalInstance, $scope, plazoPago) { + $scope.plazoPago = plazoPago; + $scope.cancelar = function() { + $uibModalInstance.dismiss(); + }; + $scope.borrar = function() { + $uibModalInstance.close(plazoPago); + }; + } + ]); diff --git a/src/js/route.js b/src/js/route.js new file mode 100644 index 0000000..b48b52d --- /dev/null +++ b/src/js/route.js @@ -0,0 +1,19 @@ +angular.module('focaAbmPlazoPago') + .config([ + '$routeProvider', + function($routeProvider) { + $routeProvider.when('/plazo-pago', { + controller: 'focaAbmPlazosPagoController', + templateUrl: 'foca-abm-plazos-pago-listado.html' + }); + } + ]) + .config([ + '$routeProvider', + function($routeProvider) { + $routeProvider.when('/precio-condicion/:idPreciosCondiciones/plazo-pago/:id', { + controller: 'focaAbmPlazoPagoController', + templateUrl: 'foca-abm-plazos-pago-item.html' + }); + } + ]); diff --git a/src/js/service.js b/src/js/service.js new file mode 100644 index 0000000..6e3f3e3 --- /dev/null +++ b/src/js/service.js @@ -0,0 +1,23 @@ +angular.module('focaAbmPlazoPago') + .service('focaAbmPlazoPagoService', [ + '$http', 'API_ENDPOINT', + function($http, API_ENDPOINT) { + return { + obtenerPlazosPago: function() { + return $http.get(API_ENDPOINT.URL + '/plazo-pago'); + }, + obtenerPlazoPago: function(id) { + return $http.get(API_ENDPOINT.URL + '/plazo-pago/' + id); + }, + guardarPlazoPago: function(plazoPago) { + return $http.post( + API_ENDPOINT.URL + '/plazo-pago', + {plazoPago: plazoPago} + ); + }, + borrarPlazoPago: function(id) { + return $http.delete(API_ENDPOINT.URL + '/plazo-pago/' + id); + } + }; + } + ]); diff --git a/src/views/foca-abm-plazos-pago-item.html b/src/views/foca-abm-plazos-pago-item.html new file mode 100644 index 0000000..336d7df --- /dev/null +++ b/src/views/foca-abm-plazos-pago-item.html @@ -0,0 +1,34 @@ +
+ + +
+ +
+ +
+
+
+ +
+ +
+
+
+
+ + +
+
+
diff --git a/src/views/foca-abm-plazos-pago-listado.html b/src/views/foca-abm-plazos-pago-listado.html new file mode 100644 index 0000000..5157c8c --- /dev/null +++ b/src/views/foca-abm-plazos-pago-listado.html @@ -0,0 +1,23 @@ + + + + + + + + + + + +
ItemDias + +
+ + +
diff --git a/src/views/foca-abm-plazos-pago-modal-confirmar.html b/src/views/foca-abm-plazos-pago-modal-confirmar.html new file mode 100644 index 0000000..33ae881 --- /dev/null +++ b/src/views/foca-abm-plazos-pago-modal-confirmar.html @@ -0,0 +1,13 @@ + + + -- 1.9.1