From 547bcae879da77882d39e460545db9ba0aae2474 Mon Sep 17 00:00:00 2001 From: Pablo Marco del Pont Date: Mon, 8 Oct 2018 11:58:31 -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 | 74 +++++++++++++++++++ src/js/route.js | 19 +++++ src/js/service.js | 35 +++++++++ src/views/foca-abm-precios-condiciones-item.html | 84 ++++++++++++++++++++++ .../foca-abm-precios-condiciones-listado.html | 23 ++++++ ...ca-abm-precios-condiciones-modal-confirmar.html | 13 ++++ 12 files changed, 436 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-precios-condiciones-item.html create mode 100644 src/views/foca-abm-precios-condiciones-listado.html create mode 100644 src/views/foca-abm-precios-condiciones-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..0b664fc --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +ABM Precios y Condiciones +========================= diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..72e8245 --- /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: 'focaAbmPreciosCondiciones', + root: '' + }), + gulp.dest(paths.tmp) + ] + ); +}); + +gulp.task('uglify', ['templates'], function() { + return pump( + [ + gulp.src([ + paths.srcJS, + 'tmp/views.js' + ]), + concat('foca-abm-precios-condiciones.js'), + gulp.dest(paths.tmp), + rename('foca-abm-precios-condiciones.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..e9db584 --- /dev/null +++ b/package.json @@ -0,0 +1,55 @@ +{ + "name": "foca-abm-precios-condiciones", + "version": "1.0.0", + "description": "ABM de precios y condiciones", + "main": "dist/foca-abm-precios-condiciones.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-precios-condiciones.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..62a075f --- /dev/null +++ b/src/js/app.js @@ -0,0 +1 @@ +angular.module('focaAbmPreciosCondiciones', []); diff --git a/src/js/controller.js b/src/js/controller.js new file mode 100644 index 0000000..36079f2 --- /dev/null +++ b/src/js/controller.js @@ -0,0 +1,74 @@ +angular.module('focaAbmPreciosCondiciones') + .controller('focaAbmPreciosCondicionesController', [ + '$scope', 'focaAbmPreciosCondicionesService', '$location', '$uibModal', + function($scope, focaAbmPreciosCondicionesService, $location, $uibModal) { + focaAbmPreciosCondicionesService.obtenerPreciosCondiciones().then(function(datos) { + $scope.preciosCondiciones = datos.data; + }); + $scope.editar = function(id) { + $location.path('/precio-condicion/' + id); + }; + $scope.solicitarConfirmacion = function(precioCondicion) { + $uibModal.open({ + templateUrl: 'foca-abm-precios-condiciones-modal-confirmar.html', + controller: 'focaAbmPreciosCondicionesModalConfirmarController', + animation: false, + backdrop: false, + resolve: {precioCondicion: function(){return precioCondicion;}} + }) + .result.then(function(precioCondicion){ + focaAbmPreciosCondicionesService.borrarPrecioCondicion(precioCondicion.id); + $scope.preciosCondiciones.splice( + $scope.preciosCondiciones.indexOf(precioCondicion), 1 + ); + }); + }; + } + ]) + .controller('focaAbmPrecioCondicionController', [ + '$scope', 'focaAbmPreciosCondicionesService', 'focaAbmPlazoPagoService', + '$routeParams', '$location', + function( + $scope, focaAbmPreciosCondicionesService, focaAbmPlazoPagoService, + $routeParams, $location + ) { + focaAbmPreciosCondicionesService.obtenerPrecioCondicion($routeParams.id) + .then(function(datos) { + $scope.precioCondicion = { + id: 0, + codigo: '', + nombre: '', + poseeAforadores: 0, + imagen: '' + }; + if(datos.data.id) { + $scope.precioCondicion = datos.data; + focaAbmPlazoPagoService.obtenerPlazoPago(datos.data.id) + .then(function(datos){ + $scope.precioCondicion.plazos = datos.data; + }); + } + }); + $scope.cancelar = function() { + $location.path('/precio-condicion'); + }; + $scope.guardar = function(precioCondicion) { + focaAbmPreciosCondicionesService.guardarPrecioCondicion(precioCondicion) + .then(function() { + $location.path('/precio-condicion'); + }); + }; + } + ]) + .controller('focaAbmPreciosCondicionesModalConfirmarController', [ + '$uibModalInstance', '$scope', 'precioCondicion', + function($uibModalInstance, $scope, precioCondicion) { + $scope.precioCondicion = precioCondicion; + $scope.cancelar = function() { + $uibModalInstance.dismiss(); + }; + $scope.borrar = function() { + $uibModalInstance.close(precioCondicion); + }; + } + ]); diff --git a/src/js/route.js b/src/js/route.js new file mode 100644 index 0000000..6921de4 --- /dev/null +++ b/src/js/route.js @@ -0,0 +1,19 @@ +angular.module('focaAbmPreciosCondiciones') + .config([ + '$routeProvider', + function($routeProvider) { + $routeProvider.when('/precio-condicion', { + controller: 'focaAbmPreciosCondicionesController', + templateUrl: 'foca-abm-precios-condiciones-listado.html' + }); + } + ]) + .config([ + '$routeProvider', + function($routeProvider) { + $routeProvider.when('/precio-condicion/:id', { + controller: 'focaAbmPrecioCondicionController', + templateUrl: 'foca-abm-precios-condiciones-item.html' + }); + } + ]); diff --git a/src/js/service.js b/src/js/service.js new file mode 100644 index 0000000..6d12c27 --- /dev/null +++ b/src/js/service.js @@ -0,0 +1,35 @@ +angular.module('focaAbmPreciosCondiciones') + .service('focaAbmPreciosCondicionesService', [ + '$http', 'API_ENDPOINT', + function($http, API_ENDPOINT) { + return { + obtenerPreciosCondiciones: function() { + return $http.get(API_ENDPOINT.URL + '/precio-condicion'); + }, + obtenerPrecioCondicion: function(id) { + return $http.get(API_ENDPOINT.URL + '/precio-condicion/' + id); + }, + guardarPrecioCondicion: function(precioCondicion) { + return $http.post( + API_ENDPOINT.URL + '/precio-condicion', + {precioCondicion: precioCondicion} + ); + }, + borrarPrecioCondicion: function(id) { + return $http.delete(API_ENDPOINT.URL + '/precio-condicion/' + id); + } + }; + } + ]) + .service('focaAbmPlazoPagoService', [ + '$http', 'API_ENDPOINT', + function($http, API_ENDPOINT) { + return { + obtenerPlazoPago: function(idPrecioCondicion) { + return $http.get( + API_ENDPOINT.URL + '/plazo-pago/precio-condicion/' + idPrecioCondicion + ); + } + }; + } + ]); diff --git a/src/views/foca-abm-precios-condiciones-item.html b/src/views/foca-abm-precios-condiciones-item.html new file mode 100644 index 0000000..603328a --- /dev/null +++ b/src/views/foca-abm-precios-condiciones-item.html @@ -0,0 +1,84 @@ +
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + + + + + + + + + + +
ItemDias + +
+ + +
+
+
+
+
+ + +
+
+
diff --git a/src/views/foca-abm-precios-condiciones-listado.html b/src/views/foca-abm-precios-condiciones-listado.html new file mode 100644 index 0000000..03bb5d7 --- /dev/null +++ b/src/views/foca-abm-precios-condiciones-listado.html @@ -0,0 +1,23 @@ + + + + + + + + + + + +
CódigoNombre + +
+ + +
diff --git a/src/views/foca-abm-precios-condiciones-modal-confirmar.html b/src/views/foca-abm-precios-condiciones-modal-confirmar.html new file mode 100644 index 0000000..dd6ce7b --- /dev/null +++ b/src/views/foca-abm-precios-condiciones-modal-confirmar.html @@ -0,0 +1,13 @@ + + + -- 1.9.1