diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..44f11df --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +/node_modules +/dist +/tmp +package-lock\.json +src/etc/develop\.js 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/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..209ccfd --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,70 @@ +const templateCache = require('gulp-angular-templatecache'); +const concat = require('gulp-concat'); +const htmlmin = require('gulp-htmlmin'); +const rename = require('gulp-rename'); +const uglify = require('gulp-uglify'); +const gulp = require('gulp'); +const pump = require('pump'); +const jshint = require('gulp-jshint'); +const replace = require('gulp-replace'); +const connect = require('gulp-connect'); + +var paths = { + srcJS: 'src/js/*.js', + srcViews: 'src/views/*.html', + tmp: 'tmp', + dist: 'dist/' +}; + +gulp.task('templates', function() { + pump( + [ + gulp.src(paths.srcViews), + replace('views/', ''), + htmlmin(), + templateCache('views.js', { + module: 'focaBusquedaProductos', + root: '' + }), + gulp.dest(paths.tmp) + ] + ); +}); + +gulp.task('uglify', function() { + pump( + [ + gulp.src([ + paths.srcJS, + 'tmp/views.js' + ]), + concat('foca-busqueda-productos.js'), + gulp.dest(paths.tmp), + rename('foca-busqueda-productos.min.js'), + uglify(), + gulp.dest(paths.dist) + ] + ); +}); + +gulp.task('pre-commit', function() { + pump( + [ + gulp.src(paths.srcJS), + jshint('.jshintrc'), + jshint.reporter('default'), + jshint.reporter('fail') + ] + ); + + gulp.start('uglify'); + gulp.start('templates'); +}); + +gulp.task('webserver', function() { + pump [ + connect.server({port: 3000}) + ] +}); + +gulp.task('default', ['webserver']); \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..c67a861 --- /dev/null +++ b/index.html @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..4a25376 --- /dev/null +++ b/package.json @@ -0,0 +1,57 @@ +{ + "name": "foca-navegacion-doble", + "version": "0.0.1", + "description": "Menu de navegacion de doble entrada", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "compile": "gulp templates && gulp uglify", + "pre-commit": [ + "gulp-pre-commit" + ], + "postinstall": "npm run compile && rm -R src && rm index.html && rm .jshintrc && rm gulpfile.js", + "install-dev": "npm install angular bootstrap jquery font-awesome gulp gulp-concat gulp-jshint gulp-rename gulp-replace gulp-uglify-es jshint pump gulp-connect jasmine-core pre-commit" + }, + "repository": { + "type": "git", + "url": "https://192.168.0.11/modulos-npm/foca-navegacion-doble" + }, + "author": "Nicolás Guarnieri", + "license": "ISC", + "peerDependencies": { + "angular": "^1.7.4", + "bootstrap": "^4.1.3", + "font-awesome": "^4.7.0", + "ui-bootstrap4": "^3.0.4", + "gulp": "^3.9.1", + "gulp-angular-templatecache": "^2.2.1", + "gulp-concat": "^2.6.1", + "gulp-connect": "^5.6.1", + "gulp-htmlmin": "^5.0.1", + "gulp-rename": "^1.4.0", + "gulp-replace": "^1.0.0", + "gulp-uglify": "^3.0.1", + "jquery": "^3.3.1", + "pump": "^3.0.0" + }, + "devDependencies": { + "angular": "^1.7.4", + "bootstrap": "^4.1.3", + "font-awesome": "^4.7.0", + "gulp": "^3.9.1", + "gulp-angular-templatecache": "^2.2.1", + "gulp-concat": "^2.6.1", + "gulp-connect": "^5.6.1", + "gulp-htmlmin": "^5.0.1", + "gulp-jshint": "^2.1.0", + "gulp-rename": "^1.4.0", + "gulp-replace": "^1.0.0", + "gulp-uglify": "^3.0.1", + "jasmine-core": "^3.2.1", + "jquery": "^3.3.1", + "jshint": "^2.9.6", + "pre-commit": "^1.2.2", + "pump": "^3.0.0", + "ui-bootstrap4": "^3.0.4" + } +} diff --git a/src/etc/develop.js.ejemplo b/src/etc/develop.js.ejemplo new file mode 100644 index 0000000..506b1e5 --- /dev/null +++ b/src/etc/develop.js.ejemplo @@ -0,0 +1,4 @@ +angular.module('focaBusquedaProductos') + .constant("API_ENDPOINT", { + 'URL': '//127.0.0.1:9000' + }); diff --git a/src/js/app.js b/src/js/app.js new file mode 100644 index 0000000..23f627e --- /dev/null +++ b/src/js/app.js @@ -0,0 +1 @@ +angular.module('focaModalPetroleras', ['ui.bootstrap']); diff --git a/src/js/controller.js b/src/js/controller.js new file mode 100644 index 0000000..e87c32f --- /dev/null +++ b/src/js/controller.js @@ -0,0 +1,54 @@ +angular.module('focaModalPetroleras') + .controller('modalPetrolerasCtrl', [ + '$filter', + '$scope', + '$uibModalInstance', + 'focaPetrolerasService', + function ($filter, $scope, $uibModalInstance, focaPetrolerasService) { + var json = { + razonCuitCod: '' + } + focaPetrolerasService.getPetroleras(json).then( + function (res) { + $scope.vendedores = res.data; + $scope.search(); + }); + + // pagination + $scope.numPerPage = 10; + $scope.currentPage = 1; + $scope.filteredPetroleras = []; + $scope.currentPagePetroleras = []; + $scope.selectPetroleras = 0; + + $scope.search = function () { + $scope.filteredPetroleras = $filter('filter')($scope.vendedores, { $: $scope.filters }); + $scope.resetPage(); + } + + $scope.resetPage = function () { + $scope.currentPage = 1; + $scope.selectPage(1); + } + + $scope.selectPage = function (page) { + var start = (page - 1) * $scope.numPerPage; + var end = start + $scope.numPerPage; + $scope.currentPagePetroleras = $scope.filteredPetroleras.slice(start, end); + } + + $scope.select = function(vendedor) { + $uibModalInstance.close(vendedor); + } + + $scope.cancel = function() { + $uibModalInstance.dismiss('cancel'); + } + + $scope.enter = function(key) { + if (key === 13) { + console.table($scope.currentPagePetroleras); + } + } + }] + ) diff --git a/src/js/service.js b/src/js/service.js new file mode 100644 index 0000000..e603374 --- /dev/null +++ b/src/js/service.js @@ -0,0 +1,9 @@ +angular.module('focaModalPetroleras') + .service('focaPetrolerasService', ['$http', function($http) { + var configRoute ='http://localhost:9900'; + return { + getPetroleras: function(json) { + return $http.post(configRoute + '/petroleras', json); + } + } + }]) diff --git a/src/views/modal-petroleras.html b/src/views/modal-petroleras.html new file mode 100644 index 0000000..42d1634 --- /dev/null +++ b/src/views/modal-petroleras.html @@ -0,0 +1,40 @@ + + +