Commit b12c6a9b7fffb33abd74796beeb0bbff8e5a3059
Exists in
master
Merge branch 'master' into 'master'
Primera version See merge request !1
Showing
9 changed files
Show diff stats
.gitignore
File was created | 1 | /node_modules | |
2 | /dist | ||
3 | /tmp | ||
4 | package-lock\.json | ||
5 | src/etc/develop\.js | ||
6 |
.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": false, | ||
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 |
gulpfile.js
File was created | 1 | const templateCache = require('gulp-angular-templatecache'); | |
2 | const concat = require('gulp-concat'); | ||
3 | const htmlmin = require('gulp-htmlmin'); | ||
4 | const rename = require('gulp-rename'); | ||
5 | const uglify = require('gulp-uglify'); | ||
6 | const gulp = require('gulp'); | ||
7 | const pump = require('pump'); | ||
8 | const jshint = require('gulp-jshint'); | ||
9 | const replace = require('gulp-replace'); | ||
10 | const connect = require('gulp-connect'); | ||
11 | const clean = require('gulp-clean'); | ||
12 | |||
13 | var paths = { | ||
14 | srcJS: 'src/js/*.js', | ||
15 | srcViews: 'src/views/*.html', | ||
16 | tmp: 'tmp', | ||
17 | dist: 'dist/' | ||
18 | }; | ||
19 | |||
20 | gulp.task('templates', function() { | ||
21 | return pump( | ||
22 | [ | ||
23 | gulp.src(paths.srcViews), | ||
24 | replace('views/', ''), | ||
25 | htmlmin(), | ||
26 | templateCache('views.js', { | ||
27 | module: 'focaModalPuntoDescarga', | ||
28 | root: '' | ||
29 | }), | ||
30 | gulp.dest(paths.tmp) | ||
31 | ] | ||
32 | ); | ||
33 | }); | ||
34 | |||
35 | gulp.task('uglify', ['templates'], function() { | ||
36 | return pump( | ||
37 | [ | ||
38 | gulp.src([ | ||
39 | paths.srcJS, | ||
40 | 'tmp/views.js' | ||
41 | ]), | ||
42 | concat('foca-modal-punto-descarga.js'), | ||
43 | replace('src/views/', ''), | ||
44 | replace("['ui.bootstrap', 'focaDirectivas', 'angular-ladda']", '[]'), | ||
45 | gulp.dest(paths.tmp), | ||
46 | rename('foca-modal-punto-descarga.min.js'), | ||
47 | uglify(), | ||
48 | gulp.dest(paths.dist) | ||
49 | ] | ||
50 | ); | ||
51 | }); | ||
52 | |||
53 | gulp.task('pre-commit', function() { | ||
54 | return pump( | ||
55 | [ | ||
56 | gulp.src(paths.srcJS), | ||
57 | jshint('.jshintrc'), | ||
58 | jshint.reporter('default'), | ||
59 | jshint.reporter('fail') | ||
60 | ] | ||
61 | ); | ||
62 | |||
63 | gulp.start('uglify'); | ||
64 | }); | ||
65 | |||
66 | gulp.task('webserver', function() { | ||
67 | pump [ | ||
68 | connect.server({port: 3000}) | ||
69 | ] | ||
70 | }); | ||
71 | |||
72 | gulp.task('clean-post-install', function() { | ||
73 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', | ||
74 | 'index.html'], {read: false}) | ||
75 | .pipe(clean()); | ||
76 | }); | ||
77 | |||
78 | gulp.task('default', ['webserver']); | ||
79 | |||
80 | gulp.task('watch', function() { | ||
81 | gulp.watch([paths.srcJS, paths.srcViews], ['uglify']) | ||
82 | }); | ||
83 |
package.json
File was created | 1 | { | |
2 | "name": "foca-modal-punto-descarga", | ||
3 | "version": "0.0.1", | ||
4 | "description": "Modal para seleccionar punto de descarga", | ||
5 | "main": "index.js", | ||
6 | "scripts": { | ||
7 | "test": "echo \"Error: no test specified\" && exit 1", | ||
8 | "gulp-pre-commit": "gulp pre-commit", | ||
9 | "compile": "gulp uglify", | ||
10 | "postinstall": "npm run compile && gulp clean-post-install", | ||
11 | "install-dev": "npm i --ignore-scripts" | ||
12 | }, | ||
13 | "pre-commit": [ | ||
14 | "gulp-pre-commit" | ||
15 | ], | ||
16 | "repository": { | ||
17 | "type": "git", | ||
18 | "url": "http://git.focasoftware.com/npm/foca-modal-punto-descarga.git" | ||
19 | }, | ||
20 | "author": "Foca Software", | ||
21 | "license": "ISC", | ||
22 | "peerDependencies": { | ||
23 | "angular": "^1.7.4", | ||
24 | "bootstrap": "^4.1.3", | ||
25 | "font-awesome": "^4.7.0", | ||
26 | "ui-bootstrap4": "^3.0.4", | ||
27 | "gulp": "^3.9.1", | ||
28 | "gulp-angular-templatecache": "^2.2.1", | ||
29 | "gulp-concat": "^2.6.1", | ||
30 | "gulp-connect": "^5.6.1", | ||
31 | "gulp-htmlmin": "^5.0.1", | ||
32 | "gulp-rename": "^1.4.0", | ||
33 | "gulp-replace": "^1.0.0", | ||
34 | "gulp-uglify": "^3.0.1", | ||
35 | "jquery": "^3.3.1", | ||
36 | "pump": "^3.0.0", | ||
37 | "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git" | ||
38 | }, | ||
39 | "devDependencies": { | ||
40 | "angular": "^1.7.5", | ||
41 | "angular-ladda": "^0.4.3", | ||
42 | "bootstrap": "^4.1.3", | ||
43 | "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git", | ||
44 | "font-awesome": "^4.7.0", | ||
45 | "gulp": "^3.9.1", | ||
46 | "gulp-angular-templatecache": "^2.2.5", | ||
47 | "gulp-clean": "^0.4.0", | ||
48 | "gulp-concat": "^2.6.1", | ||
49 | "gulp-connect": "^5.6.1", | ||
50 | "gulp-htmlmin": "^5.0.1", | ||
51 | "gulp-jshint": "^2.1.0", | ||
52 | "gulp-rename": "^1.4.0", | ||
53 | "gulp-replace": "^1.0.0", | ||
54 | "gulp-uglify": "^3.0.1", | ||
55 | "jasmine-core": "^3.3.0", | ||
56 | "jquery": "^3.3.1", | ||
57 | "jshint": "^2.9.6", | ||
58 | "ladda": "^1.0.6", | ||
59 | "pre-commit": "^1.2.2", | ||
60 | "pump": "^3.0.0", | ||
61 | "ui-bootstrap4": "^3.0.5" | ||
62 | } | ||
63 | } | ||
64 |
src/etc/develop.js.ejemplo
File was created | 1 | angular.module('focaModalProvincia') | |
2 | .constant("API_ENDPOINT", { | ||
3 | 'URL': '//127.0.0.1:9000' | ||
4 | }); | ||
5 |
src/js/app.js
File was created | 1 | angular.module('focaModalPuntoDescarga', ['ui.bootstrap', 'focaDirectivas', 'angular-ladda']); | |
2 |
src/js/controller.js
File was created | 1 | angular.module('focaModalPuntoDescarga') | |
2 | .controller('focaModalPuntoDescargaController', [ | ||
3 | '$timeout', | ||
4 | '$filter', | ||
5 | '$scope', | ||
6 | '$uibModalInstance', | ||
7 | 'focaModalPuntoDescargaService', | ||
8 | 'filters', | ||
9 | function($timeout, $filter, $scope, $uibModalInstance, | ||
10 | focaModalPuntoDescargaService, filters) { | ||
11 | |||
12 | $scope.ivas = []; | ||
13 | $scope.puntoDescarga = { | ||
14 | id: 0, | ||
15 | id_cliente: filters.idCliente, | ||
16 | id_da_config_0: filters.idDomicilio | ||
17 | }; | ||
18 | |||
19 | focaModalPuntoDescargaService | ||
20 | .getPuntosDescargaByClienDom(filters.idDomicilio, filters.idCliente) | ||
21 | .then(function(res) { | ||
22 | $scope.puntosDescarga = res.data; | ||
23 | }); | ||
24 | |||
25 | $scope.cancel = function() { | ||
26 | if($scope.ingreso){ | ||
27 | $scope.ingreso = false; | ||
28 | }else { | ||
29 | $uibModalInstance.dismiss('cancel'); | ||
30 | } | ||
31 | }; | ||
32 | |||
33 | $scope.select = function(iva) { | ||
34 | $uibModalInstance.close(iva); | ||
35 | }; | ||
36 | |||
37 | $scope.guardar = function() { | ||
38 | focaModalPuntoDescargaService | ||
39 | .guardarPuntoDescarga($scope.puntoDescarga) | ||
40 | .then(function(res) {}); | ||
41 | }; | ||
42 | }] | ||
43 | ); | ||
44 |
src/js/service.js
File was created | 1 | angular.module('focaModalPuntoDescarga') | |
2 | .factory('focaModalPuntoDescargaService', | ||
3 | ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { | ||
4 | return { | ||
5 | getPuntosDescarga: function() { | ||
6 | return $http.get(API_ENDPOINT.URL + '/punto-descarga'); | ||
7 | }, | ||
8 | getPuntosDescargaByClienDom: function(idDomicilio, idCliente) { | ||
9 | return $http.get(API_ENDPOINT.URL + '/punto-descarga/' + | ||
10 | idDomicilio + '/' + idCliente); | ||
11 | }, | ||
12 | guardarPuntoDescarga: function(puntoDescarga) { | ||
13 | return $http.post(API_ENDPOINT.URL + '/punto-descarga', | ||
14 | {puntoDescarga: puntoDescarga}); | ||
15 | } | ||
16 | }; | ||
17 | }]); | ||
18 |
src/views/modal-punto-descarga.html
File was created | 1 | <div class="modal-header d-flex"> | |
2 | <h5 class="modal-title my-1" ng-hide="ingreso">Búsqueda de puntos de descarga</h5> | ||
3 | <h5 class="modal-title my-1" ng-show="ingreso">Crear punto de descarga</h5> | ||
4 | <button | ||
5 | class="btn btn-primary" | ||
6 | ng-click="ingreso = true" | ||
7 | ng-hide="ingreso"> | ||
8 | <i class="fa fa-plus" aria-hidden="true"></i> | ||
9 | </button> | ||
10 | </div> | ||
11 | <div class="modal-body" id="modal-body"> | ||
12 | <table | ||
13 | class="table table-striped table-sm col-12" | ||
14 | ng-hide="ingreso"> | ||
15 | <thead> | ||
16 | <tr> | ||
17 | <th>Código</th> | ||
18 | <th>Latitud</th> | ||
19 | <th>Longitud</th> | ||
20 | <th></th> | ||
21 | </tr> | ||
22 | </thead> | ||
23 | <tbody> | ||
24 | <tr ng-show="puntosDescarga.length == 0"> | ||
25 | <td colspan="3"> | ||
26 | No se encontraron resultados. | ||
27 | </td> | ||
28 | </tr> | ||
29 | <tr class="selected" | ||
30 | ng-repeat="(key, puntoDescarga) in puntosDescarga | filter: filters" | ||
31 | ng-click="select(puntoDescarga)" | ||
32 | > | ||
33 | <td ng-bind="puntoDescarga.id | rellenarDigitos: 3: 0"></td> | ||
34 | <td ng-bind="puntoDescarga.latitud"></td> | ||
35 | <td ng-bind="puntoDescarga.longitud"></td> | ||
36 | <td class="d-md-none text-primary"> | ||
37 | <i class="fa fa-circle-thin" aria-hidden="true"></i> | ||
38 | </td> | ||
39 | <td class="d-none d-md-table-cell"> | ||
40 | <button | ||
41 | type="button" | ||
42 | class="btn btn-xs p-1 float-right" | ||
43 | ng-class="{ | ||
44 | 'btn-secondary': selectedProvincia != key, | ||
45 | 'btn-primary': selectedProvincia == key | ||
46 | }" | ||
47 | foca-focus="selectedProvincia == {{key}}" | ||
48 | ng-keydown="itemProvincia($event.keyCode)"> | ||
49 | <i class="fa fa-circle-thin" aria-hidden="true"></i> | ||
50 | </button> | ||
51 | </td> | ||
52 | </tr> | ||
53 | </tbody> | ||
54 | </table> | ||
55 | <form ng-show="ingreso"> | ||
56 | <div class="row"> | ||
57 | <div class="col-6"> | ||
58 | <label>Latitud</label> | ||
59 | <input | ||
60 | type="text" | ||
61 | class="form-control form-control-sm" | ||
62 | ng-model="puntoDescarga.latitud" | ||
63 | ng-required="true" | ||
64 | /> | ||
65 | </div> | ||
66 | <div class="col-6"> | ||
67 | <label>Longitud</label> | ||
68 | <input | ||
69 | type="text" | ||
70 | class="form-control form-control-sm" | ||
71 | ng-model="puntoDescarga.longitud" | ||
72 | ng-required="true" | ||
73 | /> | ||
74 | </div> | ||
75 | </div> | ||
76 | <div class="row"> | ||
77 | <div class="col-12"> | ||
78 | <label>Descripción</label> | ||
79 | <textarea | ||
80 | class="form-control form-control-sm" | ||
81 | cols="30" | ||
82 | rows="5" | ||
83 | ng-model="puntoDescarga.descripcion"></textarea> | ||
84 | </div> | ||
85 | </div> | ||
86 | </form> | ||
87 | </div> | ||
88 | <div class="modal-footer"> | ||
89 | <button class="btn btn-sm btn-secondary my-1" type="button" ng-click="cancel()">Cancelar</button> | ||
90 | <button | ||
91 | class="btn btn-sm btn-primary my-1" | ||
92 | type="button" | ||
93 | ng-click="guardar()" | ||
94 | ng-show="ingreso">Guardar</button> | ||
95 | </div> | ||
96 |