Commit f936a489960a5a1b0821a1925468a611b8f12c9e
Exists in
master
Merge branch 'master' into 'master'
Master See merge request !8
Showing
4 changed files
Show diff stats
gulpfile.js
1 | const templateCache = require('gulp-angular-templatecache'); | 1 | const templateCache = require('gulp-angular-templatecache'); |
2 | const concat = require('gulp-concat'); | 2 | const concat = require('gulp-concat'); |
3 | const htmlmin = require('gulp-htmlmin'); | 3 | const htmlmin = require('gulp-htmlmin'); |
4 | const rename = require('gulp-rename'); | 4 | const rename = require('gulp-rename'); |
5 | const uglify = require('gulp-uglify'); | 5 | const uglify = require('gulp-uglify'); |
6 | const gulp = require('gulp'); | 6 | const gulp = require('gulp'); |
7 | const pump = require('pump'); | 7 | const pump = require('pump'); |
8 | const jshint = require('gulp-jshint'); | 8 | const jshint = require('gulp-jshint'); |
9 | const replace = require('gulp-replace'); | 9 | const replace = require('gulp-replace'); |
10 | const connect = require('gulp-connect'); | 10 | const connect = require('gulp-connect'); |
11 | const clean = require('gulp-clean'); | 11 | const clean = require('gulp-clean'); |
12 | 12 | ||
13 | var paths = { | 13 | var paths = { |
14 | srcJS: 'src/js/*.js', | 14 | srcJS: 'src/js/*.js', |
15 | srcViews: 'src/views/*.html', | 15 | srcViews: 'src/views/*.html', |
16 | tmp: 'tmp', | 16 | tmp: 'tmp', |
17 | dist: 'dist/' | 17 | dist: 'dist/' |
18 | }; | 18 | }; |
19 | 19 | ||
20 | gulp.task('templates', function() { | 20 | gulp.task('templates', function() { |
21 | return pump( | 21 | return pump( |
22 | [ | 22 | [ |
23 | gulp.src(paths.srcViews), | 23 | gulp.src(paths.srcViews), |
24 | htmlmin(), | 24 | htmlmin(), |
25 | templateCache('views.js', { | 25 | templateCache('views.js', { |
26 | module: 'focaModalDomicilio', | 26 | module: 'focaModalDomicilio', |
27 | root: '' | 27 | root: '' |
28 | }), | 28 | }), |
29 | gulp.dest(paths.tmp) | 29 | gulp.dest(paths.tmp) |
30 | ] | 30 | ] |
31 | ); | 31 | ); |
32 | }); | 32 | }); |
33 | 33 | ||
34 | gulp.task('uglify', ['templates'], function() { | 34 | gulp.task('uglify', ['templates'], function() { |
35 | return pump( | 35 | return pump( |
36 | [ | 36 | [ |
37 | gulp.src([ | 37 | gulp.src([ |
38 | paths.srcJS, | 38 | paths.srcJS, |
39 | 'tmp/views.js' | 39 | 'tmp/views.js' |
40 | ]), | 40 | ]), |
41 | concat('foca-modal-domicilios.js'), | 41 | concat('foca-modal-domicilios.js'), |
42 | replace('src/views/', ''), | 42 | replace('src/views/', ''), |
43 | replace("['ui.bootstrap', 'focaDirectivas']", '[]'), | 43 | replace("['ui.bootstrap', 'focaDirectivas', 'focaModal']", '[]'), |
44 | gulp.dest(paths.tmp), | 44 | gulp.dest(paths.tmp), |
45 | rename('foca-modal-domicilios.min.js'), | 45 | rename('foca-modal-domicilios.min.js'), |
46 | uglify(), | 46 | uglify(), |
47 | gulp.dest(paths.dist) | 47 | gulp.dest(paths.dist) |
48 | ] | 48 | ] |
49 | ); | 49 | ); |
50 | }); | 50 | }); |
51 | 51 | ||
52 | gulp.task('pre-commit', function() { | 52 | gulp.task('pre-commit', function() { |
53 | return pump( | 53 | return pump( |
54 | [ | 54 | [ |
55 | gulp.src(paths.srcJS), | 55 | gulp.src(paths.srcJS), |
56 | jshint('.jshintrc'), | 56 | jshint('.jshintrc'), |
57 | jshint.reporter('default'), | 57 | jshint.reporter('default'), |
58 | jshint.reporter('fail') | 58 | jshint.reporter('fail') |
59 | ] | 59 | ] |
60 | ); | 60 | ); |
61 | 61 | ||
62 | gulp.start('uglify'); | 62 | gulp.start('uglify'); |
63 | }); | 63 | }); |
64 | 64 | ||
65 | gulp.task('webserver', function() { | 65 | gulp.task('webserver', function() { |
66 | pump [ | 66 | pump [ |
67 | connect.server({port: 3000}) | 67 | connect.server({port: 3000}) |
68 | ] | 68 | ] |
69 | }); | 69 | }); |
70 | 70 | ||
71 | gulp.task('clean-post-install', function(){ | 71 | gulp.task('clean-post-install', function(){ |
72 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', | 72 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', |
73 | 'index.html'], {read: false}) | 73 | 'index.html'], {read: false}) |
74 | .pipe(clean()); | 74 | .pipe(clean()); |
75 | }); | 75 | }); |
76 | 76 | ||
77 | gulp.task('default', ['webserver']); | 77 | gulp.task('default', ['webserver']); |
78 | 78 | ||
79 | gulp.task('watch', function() { | 79 | gulp.task('watch', function() { |
80 | gulp.watch([paths.srcJS, paths.srcViews], ['uglify']) | 80 | gulp.watch([paths.srcJS, paths.srcViews], ['uglify']) |
81 | }); | 81 | }); |
82 | 82 |
package.json
1 | { | 1 | { |
2 | "name": "foca-modal-domicilio", | 2 | "name": "foca-modal-domicilio", |
3 | "version": "0.0.1", | 3 | "version": "0.0.1", |
4 | "description": "Modal para busqueda de domicilios", | 4 | "description": "Modal para busqueda de domicilios", |
5 | "scripts": { | 5 | "scripts": { |
6 | "test": "echo \"Error: no test specified\" && exit 1", | 6 | "test": "echo \"Error: no test specified\" && exit 1", |
7 | "gulp-pre-commit": "gulp pre-commit", | 7 | "gulp-pre-commit": "gulp pre-commit", |
8 | "compile": "gulp uglify", | 8 | "compile": "gulp uglify", |
9 | "postinstall": "npm run compile && gulp clean-post-install", | 9 | "postinstall": "npm run compile && gulp clean-post-install", |
10 | "install-dev": "npm install -D angular bootstrap font-awesome gulp gulp-angular-templatecache gulp-concat gulp-connect gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-uglify gulp-clean jasmine-core jquery jshint pre-commit pump ui-bootstrap4 && npm i -D git+ssh://git@git.focasoftware.com:npm/foca-directivas" | 10 | "install-dev": "npm install -D angular bootstrap font-awesome gulp gulp-angular-templatecache gulp-concat gulp-connect gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-uglify gulp-clean jasmine-core jquery jshint pre-commit pump ui-bootstrap4 && npm i -D git+ssh://git@git.focasoftware.com:npm/foca-directivas" |
11 | }, | 11 | }, |
12 | "pre-commit": [ | 12 | "pre-commit": [ |
13 | "gulp-pre-commit" | 13 | "gulp-pre-commit" |
14 | ], | 14 | ], |
15 | "repository": { | 15 | "repository": { |
16 | "type": "git", | 16 | "type": "git", |
17 | "url": "https://debo.suite.repo/modulos-npm/foca-modal-domicilio.git" | 17 | "url": "http://git.focasoftware.com/npm/foca-modal-domicilio.git" |
18 | }, | 18 | }, |
19 | "author": "Foca Software", | 19 | "author": "Foca Software", |
20 | "license": "ISC", | 20 | "license": "ISC", |
21 | "peerDependencies": { | 21 | "peerDependencies": { |
22 | "angular": "^1.7.4", | 22 | "angular": "^1.7.4", |
23 | "bootstrap": "^4.1.3", | 23 | "bootstrap": "^4.1.3", |
24 | "font-awesome": "^4.7.0", | 24 | "font-awesome": "^4.7.0", |
25 | "ui-bootstrap4": "^3.0.4", | 25 | "ui-bootstrap4": "^3.0.4", |
26 | "gulp": "^3.9.1", | 26 | "gulp": "^3.9.1", |
27 | "gulp-angular-templatecache": "^2.2.1", | 27 | "gulp-angular-templatecache": "^2.2.1", |
28 | "gulp-concat": "^2.6.1", | 28 | "gulp-concat": "^2.6.1", |
29 | "gulp-connect": "^5.6.1", | 29 | "gulp-connect": "^5.6.1", |
30 | "gulp-htmlmin": "^5.0.1", | 30 | "gulp-htmlmin": "^5.0.1", |
31 | "gulp-rename": "^1.4.0", | 31 | "gulp-rename": "^1.4.0", |
32 | "gulp-replace": "^1.0.0", | 32 | "gulp-replace": "^1.0.0", |
33 | "gulp-uglify": "^3.0.1", | 33 | "gulp-uglify": "^3.0.1", |
34 | "jquery": "^3.3.1", | 34 | "jquery": "^3.3.1", |
35 | "pump": "^3.0.0", | 35 | "pump": "^3.0.0", |
36 | "foca-directivas": "git+ssh://git@git.focasoftware.com:npm/foca-directivas" | 36 | "foca-directivas": "git+ssh://git@git.focasoftware.com:npm/foca-directivas" |
37 | }, | 37 | }, |
38 | "devDependencies": { | 38 | "devDependencies": { |
39 | "angular": "^1.7.5", | 39 | "angular": "^1.7.5", |
40 | "bootstrap": "^4.1.3", | 40 | "bootstrap": "^4.1.3", |
41 | "foca-directivas": "git+ssh://git@git.focasoftware.com:npm/foca-directivas", | 41 | "foca-directivas": "git+ssh://git@git.focasoftware.com:npm/foca-directivas", |
42 | "font-awesome": "^4.7.0", | 42 | "font-awesome": "^4.7.0", |
43 | "gulp": "^3.9.1", | 43 | "gulp": "^3.9.1", |
44 | "gulp-angular-templatecache": "^2.2.3", | 44 | "gulp-angular-templatecache": "^2.2.3", |
45 | "gulp-clean": "^0.4.0", | 45 | "gulp-clean": "^0.4.0", |
46 | "gulp-concat": "^2.6.1", | 46 | "gulp-concat": "^2.6.1", |
47 | "gulp-connect": "^5.6.1", | 47 | "gulp-connect": "^5.6.1", |
48 | "gulp-htmlmin": "^5.0.1", | 48 | "gulp-htmlmin": "^5.0.1", |
49 | "gulp-jshint": "^2.1.0", | 49 | "gulp-jshint": "^2.1.0", |
50 | "gulp-rename": "^1.4.0", | 50 | "gulp-rename": "^1.4.0", |
51 | "gulp-replace": "^1.0.0", | 51 | "gulp-replace": "^1.0.0", |
52 | "gulp-uglify": "^3.0.1", | 52 | "gulp-uglify": "^3.0.1", |
53 | "jasmine-core": "^3.3.0", | 53 | "jasmine-core": "^3.3.0", |
54 | "jquery": "^3.3.1", | 54 | "jquery": "^3.3.1", |
55 | "jshint": "^2.9.6", | 55 | "jshint": "^2.9.6", |
56 | "pre-commit": "^1.2.2", | 56 | "pre-commit": "^1.2.2", |
57 | "pump": "^3.0.0", | 57 | "pump": "^3.0.0", |
58 | "ui-bootstrap4": "^3.0.5" | 58 | "ui-bootstrap4": "^3.0.5" |
59 | } | 59 | } |
60 | } | 60 | } |
61 | 61 |
src/js/controller.js
1 | angular.module('focaModalDomicilio') | 1 | angular.module('focaModalDomicilio') |
2 | .controller('focaModalDomicilioController', | 2 | .controller('focaModalDomicilioController', |
3 | [ | 3 | [ |
4 | '$timeout', | 4 | '$timeout', |
5 | '$filter', | 5 | '$filter', |
6 | '$scope', | 6 | '$scope', |
7 | '$uibModalInstance', | 7 | '$uibModalInstance', |
8 | 'focaModalDomicilioService', | 8 | 'focaModalDomicilioService', |
9 | '$uibModal', | 9 | '$uibModal', |
10 | 'idCliente', | 10 | 'idCliente', |
11 | 'esNuevo', | 11 | 'esNuevo', |
12 | 'articulos', | 12 | 'articulos', |
13 | function($timeout, $filter, $scope, $uibModalInstance, focaModalDomicilioService, | 13 | function($timeout, $filter, $scope, $uibModalInstance, focaModalDomicilioService, |
14 | $uibModal, idCliente, esNuevo, articulos) { | 14 | $uibModal, idCliente, esNuevo, articulos) { |
15 | 15 | ||
16 | $scope.buscar = function() { | 16 | $scope.buscar = function() { |
17 | focaModalDomicilioService | 17 | focaModalDomicilioService |
18 | .getDomiciliosEntregaByIdCliente($scope.idCliente) | 18 | .getDomiciliosEntregaByIdCliente($scope.idCliente) |
19 | .then(function(res) { | 19 | .then(function(res) { |
20 | $scope.domicilios = res.data; | 20 | $scope.domicilios = res.data; |
21 | $scope.search(); | 21 | $scope.search(); |
22 | $scope.primerBusqueda = true; | 22 | $scope.primerBusqueda = true; |
23 | } | 23 | } |
24 | ); | 24 | ); |
25 | }; | 25 | }; |
26 | $scope.filters = ''; | 26 | $scope.filters = ''; |
27 | $scope.idCliente = idCliente; | 27 | $scope.idCliente = idCliente; |
28 | $scope.buscar(); | 28 | $scope.buscar(); |
29 | $scope.ingreso = esNuevo; | 29 | $scope.ingreso = esNuevo; |
30 | $scope.primerBusqueda = false; | 30 | $scope.primerBusqueda = false; |
31 | $scope.contactos = [{}]; | 31 | $scope.contactos = [{}]; |
32 | // pagination | 32 | // pagination |
33 | $scope.numPerPage = 5; | 33 | $scope.numPerPage = 5; |
34 | $scope.currentPage = 1; | 34 | $scope.currentPage = 1; |
35 | $scope.filteredDomicilios = []; | 35 | $scope.filteredDomicilios = []; |
36 | $scope.currentPageDomicilios = []; | 36 | $scope.currentPageDomicilios = []; |
37 | $scope.selectedDomicilio = -1; | 37 | $scope.selectedDomicilio = -1; |
38 | $scope.focused = 1; | ||
38 | var puntosDescarga = []; | 39 | var puntosDescarga = []; |
39 | 40 | ||
40 | //METODOS | 41 | //METODOS |
41 | $scope.search = function(pressed) { | 42 | $scope.search = function(pressed) { |
42 | $scope.filteredDomicilios = $filter('filter')( | 43 | $scope.filteredDomicilios = $filter('filter')( |
43 | $scope.domicilios, | 44 | $scope.domicilios, |
44 | {$: $scope.filters} | 45 | {$: $scope.filters} |
45 | ); | 46 | ); |
46 | 47 | ||
47 | if(pressed) { | 48 | if(pressed) { |
48 | if($scope.filteredDomicilios.length === 0) { | 49 | if($scope.filteredDomicilios.length === 0) { |
49 | $timeout(function() { | 50 | $timeout(function() { |
50 | angular.element('#search')[0].focus(); | 51 | angular.element('#search')[0].focus(); |
51 | $scope.filters = ''; | 52 | $scope.filters = ''; |
52 | }); | 53 | }); |
53 | }else { | 54 | }else { |
54 | primera(); | 55 | primera(); |
55 | } | 56 | } |
56 | } | 57 | } |
57 | 58 | ||
58 | $scope.lastPage = Math.ceil( | 59 | $scope.lastPage = Math.ceil( |
59 | $scope.filteredDomicilios.length / $scope.numPerPage | 60 | $scope.filteredDomicilios.length / $scope.numPerPage |
60 | ); | 61 | ); |
61 | 62 | ||
62 | $scope.resetPage(); | 63 | $scope.resetPage(); |
63 | }; | 64 | }; |
64 | 65 | ||
65 | $scope.resetPage = function() { | 66 | $scope.resetPage = function() { |
66 | $scope.currentPage = 1; | 67 | $scope.currentPage = 1; |
67 | $scope.selectPage(1); | 68 | $scope.selectPage(1); |
68 | }; | 69 | }; |
69 | 70 | ||
70 | $scope.selectPage = function(page) { | 71 | $scope.selectPage = function(page) { |
71 | var start = (page - 1) * $scope.numPerPage; | 72 | var start = (page - 1) * $scope.numPerPage; |
72 | var end = start + $scope.numPerPage; | 73 | var end = start + $scope.numPerPage; |
73 | $scope.paginas = []; | 74 | $scope.paginas = []; |
74 | $scope.paginas = calcularPages(page); | 75 | $scope.paginas = calcularPages(page); |
75 | $scope.currentPageDomicilios = $scope.filteredDomicilios.slice(start, end); | 76 | $scope.currentPageDomicilios = $scope.filteredDomicilios.slice(start, end); |
76 | $scope.currentPage = page; | 77 | $scope.currentPage = page; |
77 | }; | 78 | }; |
78 | 79 | ||
79 | $scope.select = function(domicilio) { | 80 | $scope.select = function(domicilio) { |
80 | $uibModalInstance.close(domicilio); | 81 | $uibModalInstance.close(domicilio); |
81 | }; | 82 | }; |
82 | 83 | ||
83 | $scope.cancel = function() { | 84 | $scope.cancel = function() { |
84 | $uibModalInstance.dismiss('cancel'); | 85 | $uibModalInstance.dismiss('cancel'); |
85 | }; | 86 | }; |
86 | 87 | ||
87 | $scope.busquedaDown = function(key) { | 88 | $scope.busquedaDown = function(key) { |
88 | if (key === 40) { | 89 | if (key === 40) { |
89 | primera(key); | 90 | primera(key); |
90 | } | 91 | } |
91 | }; | 92 | }; |
92 | 93 | ||
93 | $scope.busquedaPress = function(key) { | 94 | $scope.busquedaPress = function(key) { |
94 | if (key === 13) { | 95 | if (key === 13) { |
95 | $scope.search(true); | 96 | $scope.search(true); |
96 | } | 97 | } |
97 | }; | 98 | }; |
98 | 99 | ||
99 | $scope.itemDomicilio = function(key) { | 100 | $scope.itemDomicilio = function(key) { |
100 | if (key === 38) { | 101 | if (key === 38) { |
101 | anterior(key); | 102 | anterior(key); |
102 | } | 103 | } |
103 | 104 | ||
104 | if (key === 40) { | 105 | if (key === 40) { |
105 | siguiente(key); | 106 | siguiente(key); |
106 | } | 107 | } |
107 | 108 | ||
108 | if (key === 37) { | 109 | if (key === 37) { |
109 | retrocederPagina(); | 110 | retrocederPagina(); |
110 | } | 111 | } |
111 | 112 | ||
112 | if (key === 39) { | 113 | if (key === 39) { |
113 | avanzarPagina(); | 114 | avanzarPagina(); |
114 | } | 115 | } |
115 | }; | 116 | }; |
116 | 117 | ||
117 | $scope.agregarDomicilio = function() { | 118 | $scope.agregarDomicilio = function() { |
118 | $scope.domicilio.valores = []; | 119 | $scope.domicilio.valores = []; |
119 | $scope.domicilio.idCliente = $scope.idCliente; | 120 | $scope.domicilio.idCliente = $scope.idCliente; |
120 | if($scope.domicilio.calle) { | 121 | if($scope.domicilio.calle) { |
121 | $scope.domicilio.valores.push({ | 122 | $scope.domicilio.valores.push({ |
122 | ID_ADAC_1: 1, | 123 | ID_ADAC_1: 1, |
123 | dato: $scope.domicilio.calle | 124 | dato: $scope.domicilio.calle |
124 | }); | 125 | }); |
125 | } | 126 | } |
126 | if($scope.domicilio.numeroCalle) { | 127 | if($scope.domicilio.numeroCalle) { |
127 | $scope.domicilio.valores.push({ | 128 | $scope.domicilio.valores.push({ |
128 | ID_ADAC_1: 2, | 129 | ID_ADAC_1: 2, |
129 | dato: $scope.domicilio.numeroCalle | 130 | dato: $scope.domicilio.numeroCalle |
130 | }); | 131 | }); |
131 | } | 132 | } |
132 | if($scope.domicilio.localidad) { | 133 | if($scope.domicilio.localidad) { |
133 | $scope.domicilio.valores.push({ | 134 | $scope.domicilio.valores.push({ |
134 | ID_ADAC_1: 3, | 135 | ID_ADAC_1: 3, |
135 | dato: $scope.domicilio.localidad | 136 | dato: $scope.domicilio.localidad |
136 | }); | 137 | }); |
137 | } | 138 | } |
138 | if($scope.domicilio.provincia) { | 139 | if($scope.domicilio.provincia) { |
139 | $scope.domicilio.valores.push({ | 140 | $scope.domicilio.valores.push({ |
140 | ID_ADAC_1: 4, | 141 | ID_ADAC_1: 4, |
141 | dato: $scope.domicilio.provincia | 142 | dato: $scope.domicilio.provincia |
142 | }); | 143 | }); |
143 | } | 144 | } |
145 | if($scope.domicilio.latitud) { | ||
146 | $scope.domicilio.valores.push({ | ||
147 | ID_ADAC_1: 23, | ||
148 | dato: $scope.domicilio.latitud | ||
149 | }); | ||
150 | } | ||
151 | if($scope.domicilio.longitud) { | ||
152 | $scope.domicilio.valores.push({ | ||
153 | ID_ADAC_1: 24, | ||
154 | dato: $scope.domicilio.longitud | ||
155 | }); | ||
156 | } | ||
144 | //domicilios de entrega corresponden al 1 | 157 | //domicilios de entrega corresponden al 1 |
145 | focaModalDomicilioService | 158 | focaModalDomicilioService |
146 | .obtenerUltimoPorNivelPadre(1) | 159 | .obtenerUltimoPorNivelPadre(1) |
147 | .then(function(res) { | 160 | .then(function(res) { |
148 | $scope.domicilio.nivel1 = 1;//domicilio de entrega corresponde 1 | 161 | $scope.domicilio.nivel1 = 1;//domicilio de entrega corresponde 1 |
149 | $scope.domicilio.nivel2 = res.data[0].ultimo + 1; | 162 | $scope.domicilio.nivel2 = res.data[0].ultimo + 1; |
150 | focaModalDomicilioService | 163 | focaModalDomicilioService |
151 | .guardarDomicilio($scope.domicilio) | 164 | .guardarDomicilio($scope.domicilio) |
152 | .then(function() { | 165 | .then(function() { |
153 | $scope.buscar(); | 166 | $scope.buscar(); |
154 | $scope.ingreso = false; | 167 | $scope.ingreso = false; |
155 | $scope.domicilio = {}; | 168 | $scope.domicilio = {}; |
156 | }); | 169 | }); |
157 | }); | 170 | }); |
158 | }; | 171 | }; |
159 | 172 | ||
160 | $scope.verPuntosDescarga = function(key) { | 173 | $scope.verPuntosDescarga = function(key) { |
161 | 174 | ||
162 | var modalInstance = $uibModal.open( | 175 | var modalInstance = $uibModal.open( |
163 | { | 176 | { |
164 | ariaLabelledBy: 'Busqueda de Puntos de descarga', | 177 | ariaLabelledBy: 'Busqueda de Puntos de descarga', |
165 | templateUrl: 'modal-punto-descarga.html', | 178 | templateUrl: 'modal-punto-descarga.html', |
166 | controller: 'focaModalPuntoDescargaController', | 179 | controller: 'focaModalPuntoDescargaController', |
167 | size: 'lg', | 180 | size: 'lg', |
168 | resolve: { | 181 | resolve: { |
169 | filters: { | 182 | filters: { |
170 | idDomicilio: $scope.domicilios[key].id, | 183 | idDomicilio: $scope.domicilios[key].id, |
171 | idCliente: idCliente, | 184 | idCliente: idCliente, |
172 | articulos: articulos | 185 | articulos: articulos |
173 | } | 186 | } |
174 | } | 187 | } |
175 | } | 188 | } |
176 | ); | 189 | ); |
177 | modalInstance.result.then(function(puntosDescarga) { | 190 | modalInstance.result.then(function(puntosDescarga) { |
178 | $scope.domicilios[key].puntosDescarga = puntosDescarga; | 191 | $scope.domicilios[key].puntosDescarga = puntosDescarga; |
179 | $scope.select($scope.domicilios[key]); | 192 | $scope.select($scope.domicilios[key]); |
180 | }, function() { | 193 | }, function() { |
181 | //TODO: función llamada cuando cancela el modal | 194 | //TODO: función llamada cuando cancela el modal |
182 | }); | 195 | }); |
183 | }; | 196 | }; |
184 | 197 | ||
198 | $scope.localizarDomicilio = function(localizar) { | ||
199 | var direccion = null; | ||
200 | if(localizar) { | ||
201 | direccion = { | ||
202 | calle: $scope.domicilio.calle, | ||
203 | numero: $scope.domicilio.numeroCalle, | ||
204 | localidad: $scope.domicilio.localidad, | ||
205 | provincia: $scope.domicilio.provincia | ||
206 | }; | ||
207 | } | ||
208 | var modalInstance = $uibModal.open( | ||
209 | { | ||
210 | ariaLabelledBy: 'Buscar domicilio', | ||
211 | templateUrl: 'modal-localizar.html', | ||
212 | controller: 'focaModalLocalizarController', | ||
213 | size: 'lg', | ||
214 | resolve: { | ||
215 | direccion: direccion | ||
216 | } | ||
217 | } | ||
218 | ); | ||
219 | modalInstance.result.then(function(res) { | ||
220 | $scope.domicilio.latitud = res.latitud; | ||
221 | $scope.domicilio.longitud = res.longitud; | ||
222 | }, function() { | ||
223 | //TODO: función llamada cuando cancela el modal | ||
224 | }); | ||
225 | }; | ||
226 | |||
227 | $scope.next = function(key) { | ||
228 | if(key === 13) $scope.focused++; | ||
229 | }; | ||
230 | |||
185 | function calcularPages(paginaActual) { | 231 | function calcularPages(paginaActual) { |
186 | var paginas = []; | 232 | var paginas = []; |
187 | paginas.push(paginaActual); | 233 | paginas.push(paginaActual); |
188 | 234 | ||
189 | if (paginaActual - 1 > 1) { | 235 | if (paginaActual - 1 > 1) { |
190 | 236 | ||
191 | paginas.unshift(paginaActual - 1); | 237 | paginas.unshift(paginaActual - 1); |
192 | if (paginaActual - 2 > 1) { | 238 | if (paginaActual - 2 > 1) { |
193 | paginas.unshift(paginaActual - 2); | 239 | paginas.unshift(paginaActual - 2); |
194 | } | 240 | } |
195 | } | 241 | } |
196 | 242 | ||
197 | if (paginaActual + 1 < $scope.lastPage) { | 243 | if (paginaActual + 1 < $scope.lastPage) { |
198 | paginas.push(paginaActual + 1); | 244 | paginas.push(paginaActual + 1); |
199 | if (paginaActual + 2 < $scope.lastPage) { | 245 | if (paginaActual + 2 < $scope.lastPage) { |
200 | paginas.push(paginaActual + 2); | 246 | paginas.push(paginaActual + 2); |
201 | } | 247 | } |
202 | } | 248 | } |
203 | 249 | ||
204 | if (paginaActual !== 1) { | 250 | if (paginaActual !== 1) { |
205 | paginas.unshift(1); | 251 | paginas.unshift(1); |
206 | } | 252 | } |
207 | 253 | ||
208 | if (paginaActual !== $scope.lastPage) { | 254 | if (paginaActual !== $scope.lastPage) { |
209 | paginas.push($scope.lastPage); | 255 | paginas.push($scope.lastPage); |
210 | } | 256 | } |
211 | 257 | ||
212 | return paginas; | 258 | return paginas; |
213 | } | 259 | } |
214 | 260 | ||
215 | function primera() { | 261 | function primera() { |
216 | $scope.selectedDomicilio = 0; | 262 | $scope.selectedDomicilio = 0; |
217 | } | 263 | } |
218 | 264 | ||
219 | function anterior() { | 265 | function anterior() { |
220 | if ($scope.selectedDomicilio === 0 && $scope.currentPage > 1) { | 266 | if ($scope.selectedDomicilio === 0 && $scope.currentPage > 1) { |
221 | retrocederPagina(); | 267 | retrocederPagina(); |
222 | } else { | 268 | } else { |
223 | $scope.selectedDomicilio--; | 269 | $scope.selectedDomicilio--; |
224 | } | 270 | } |
225 | } | 271 | } |
226 | 272 | ||
227 | function siguiente() { | 273 | function siguiente() { |
228 | if ($scope.selectedDomicilio < $scope.currentPageDomicilios.length ) { | 274 | if ($scope.selectedDomicilio < $scope.currentPageDomicilios.length ) { |
229 | $scope.selectedDomicilio++; | 275 | $scope.selectedDomicilio++; |
230 | } else { | 276 | } else { |
231 | avanzarPagina(); | 277 | avanzarPagina(); |
232 | } | 278 | } |
233 | } | 279 | } |
234 | 280 | ||
235 | function retrocederPagina() { | 281 | function retrocederPagina() { |
236 | if ($scope.currentPage > 1) { | 282 | if ($scope.currentPage > 1) { |
237 | $scope.selectPage($scope.currentPage - 1); | 283 | $scope.selectPage($scope.currentPage - 1); |
238 | $scope.selectedDomicilio = $scope.numPerPage - 1; | 284 | $scope.selectedDomicilio = $scope.numPerPage - 1; |
239 | } | 285 | } |
240 | } | 286 | } |
241 | 287 | ||
242 | function avanzarPagina() { | 288 | function avanzarPagina() { |
243 | if ($scope.currentPage < $scope.lastPage) { | 289 | if ($scope.currentPage < $scope.lastPage) { |
244 | $scope.selectPage($scope.currentPage + 1); | 290 | $scope.selectPage($scope.currentPage + 1); |
245 | $scope.selectedDomicilio = 0; | 291 | $scope.selectedDomicilio = 0; |
246 | } | 292 | } |
247 | } | 293 | } |
248 | } | 294 | } |
249 | ] | 295 | ] |
250 | ); | 296 | ); |
251 | 297 |
src/views/modal-domicilio.html
1 | <div class="modal-header py-1"> | 1 | <div class="modal-header py-1"> |
2 | <div class="row w-100"> | 2 | <div class="row w-100"> |
3 | <div class="col-lg-6"> | 3 | <div class="col-lg-6"> |
4 | <h5 class="modal-title my-1" ng-hide="ingreso">Búsqueda de Domicilios</h5> | 4 | <h5 class="modal-title my-1" ng-hide="ingreso">Búsqueda de Domicilios</h5> |
5 | <h5 class="modal-title my-1" ng-show="ingreso">Crear domicilio</h5> | 5 | <h5 class="modal-title my-1" ng-show="ingreso">Crear domicilio</h5> |
6 | </div> | 6 | </div> |
7 | <div class="input-group col-lg-6 pr-0 my-2"> | 7 | <div class="input-group col-lg-6 pr-0 my-2"> |
8 | <input | 8 | <input |
9 | type="text" | 9 | type="text" |
10 | class="form-control form-control-sm" | 10 | class="form-control form-control-sm" |
11 | id="search" | 11 | id="search" |
12 | placeholder="Búsqueda" | 12 | placeholder="Búsqueda" |
13 | ng-model="filters" | 13 | ng-model="filters" |
14 | ng-change="search()" | 14 | ng-change="search()" |
15 | ng-keydown="busquedaDown($event.keyCode)" | 15 | ng-keydown="busquedaDown($event.keyCode)" |
16 | ng-keypress="busquedaPress($event.keyCode)" | 16 | ng-keypress="busquedaPress($event.keyCode)" |
17 | foca-focus="selectedDomicilio == -1" | 17 | foca-focus="selectedDomicilio == -1" |
18 | ng-focus="selectedDomicilio = -1" | 18 | ng-focus="selectedDomicilio = -1" |
19 | teclado-virtual | 19 | teclado-virtual |
20 | > | 20 | > |
21 | <div class="input-group-append"> | 21 | <div class="input-group-append"> |
22 | <button | 22 | <button |
23 | ladda="searchLoading" | 23 | ladda="searchLoading" |
24 | class="btn btn-outline-secondary" | 24 | class="btn btn-outline-secondary" |
25 | type="button" | 25 | type="button" |
26 | ng-click="busquedaPress(13)" | 26 | ng-click="busquedaPress(13)" |
27 | > | 27 | > |
28 | <i class="fa fa-search" aria-hidden="true"></i> | 28 | <i class="fa fa-search" aria-hidden="true"></i> |
29 | </button> | 29 | </button> |
30 | </div> | 30 | </div> |
31 | </div> | 31 | </div> |
32 | </div> | 32 | </div> |
33 | </div> | 33 | </div> |
34 | <div class="modal-body" id="modal-body"> | 34 | <div class="modal-body" id="modal-body"> |
35 | 35 | ||
36 | <div ng-show="!primerBusqueda"> | 36 | <div ng-show="!primerBusqueda"> |
37 | Debe realizar una primer búsqueda. | 37 | Debe realizar una primer búsqueda. |
38 | </div> | 38 | </div> |
39 | 39 | ||
40 | <div ng-show="!ingreso"> | 40 | <div ng-show="!ingreso"> |
41 | <table ng-show="!ingreso" class="table table-striped table-sm"> | 41 | <table ng-show="!ingreso" class="table table-striped table-sm"> |
42 | <thead> | 42 | <thead> |
43 | <tr> | 43 | <tr> |
44 | <th>Titulo</th> | 44 | <th>Titulo</th> |
45 | <th>Calle</th> | 45 | <th>Calle</th> |
46 | <th>Localidad</th> | 46 | <th>Localidad</th> |
47 | <th>Provincia</th> | 47 | <th>Provincia</th> |
48 | <th></th> | 48 | <th></th> |
49 | <th></th> | 49 | <th></th> |
50 | </tr> | 50 | </tr> |
51 | </thead> | 51 | </thead> |
52 | <tbody> | 52 | <tbody> |
53 | <tr ng-show="currentPageDomicilios.length == 0 && primerBusqueda"> | 53 | <tr ng-show="currentPageDomicilios.length == 0 && primerBusqueda"> |
54 | <td colspan="5"> | 54 | <td colspan="5"> |
55 | No se encontraron resultados. | 55 | No se encontraron resultados. |
56 | </td> | 56 | </td> |
57 | </tr> | 57 | </tr> |
58 | <tr> | 58 | <tr> |
59 | <td colspan="6" ng-show="!ingreso"> | 59 | <td colspan="6" ng-show="!ingreso"> |
60 | <input | 60 | <input |
61 | class="form-control form-control-sm" | 61 | class="form-control form-control-sm" |
62 | type="text" | 62 | type="text" |
63 | placeholder="Nuevo domicilio" | 63 | placeholder="Nuevo domicilio" |
64 | readonly | 64 | readonly |
65 | ng-click="ingreso = !ingreso" | 65 | ng-click="ingreso = !ingreso" |
66 | /> | 66 | /> |
67 | </td> | 67 | </td> |
68 | </tr> | 68 | </tr> |
69 | <tr class="selectable" | 69 | <tr class="selectable" |
70 | ng-repeat="(key,domicilio) in currentPageDomicilios"> | 70 | ng-repeat="(key,domicilio) in currentPageDomicilios"> |
71 | <td | 71 | <td |
72 | ng-bind="domicilio.titulo" | 72 | ng-bind="domicilio.titulo" |
73 | ng-click="select(domicilio)" | 73 | ng-click="select(domicilio)" |
74 | ></td> | 74 | ></td> |
75 | <td | 75 | <td |
76 | ng-bind="domicilio.Calle + ' ' + domicilio.Numero" | 76 | ng-bind="domicilio.Calle + ' ' + domicilio.Numero" |
77 | ng-click="select(domicilio)" | 77 | ng-click="select(domicilio)" |
78 | ></td> | 78 | ></td> |
79 | <td | 79 | <td |
80 | ng-bind="domicilio.Localidad" | 80 | ng-bind="domicilio.Localidad" |
81 | ng-click="select(domicilio)" | 81 | ng-click="select(domicilio)" |
82 | ></td> | 82 | ></td> |
83 | <td | 83 | <td |
84 | ng-bind="domicilio.Provincia" | 84 | ng-bind="domicilio.Provincia" |
85 | ng-click="select(domicilio)" | 85 | ng-click="select(domicilio)" |
86 | ></td> | 86 | ></td> |
87 | <td> | 87 | <td> |
88 | <button | 88 | <button |
89 | type="button" | 89 | type="button" |
90 | class="btn btn-sm p-1 float-right btn-secondary" | 90 | class="btn btn-sm p-1 float-right btn-secondary" |
91 | ng-click="verPuntosDescarga(key)" | 91 | ng-click="verPuntosDescarga(key)" |
92 | title="Puntos de descarga" | 92 | title="Puntos de descarga" |
93 | > | 93 | > |
94 | <small>PD</small> | 94 | <small>PD</small> |
95 | </button> | 95 | </button> |
96 | </td> | 96 | </td> |
97 | <td> | 97 | <td> |
98 | <button | 98 | <button |
99 | type="button" | 99 | type="button" |
100 | class="btn btn-sm p-1 float-right" | 100 | class="btn btn-sm p-1 float-right" |
101 | ng-class="{ | 101 | ng-class="{ |
102 | 'btn-secondary': selectedDomicilio != key + 1, | 102 | 'btn-secondary': selectedDomicilio != key + 1, |
103 | 'btn-primary': selectedDomicilio == key + 1 | 103 | 'btn-primary': selectedDomicilio == key + 1 |
104 | }" | 104 | }" |
105 | foca-focus="selectedDomicilio == {{key + 1}}" | 105 | foca-focus="selectedDomicilio == {{key + 1}}" |
106 | ng-keydown="itemDomicilio($event.keyCode)" | 106 | ng-keydown="itemDomicilio($event.keyCode)" |
107 | ng-click="select(domicilio)" | 107 | ng-click="select(domicilio)" |
108 | title="Seleccionar" | 108 | title="Seleccionar" |
109 | > | 109 | > |
110 | <i class="fa fa-circle-thin" aria-hidden="true"></i> | 110 | <i class="fa fa-circle-thin" aria-hidden="true"></i> |
111 | </button> | 111 | </button> |
112 | </td> | 112 | </td> |
113 | </tr> | 113 | </tr> |
114 | </tbody> | 114 | </tbody> |
115 | </table> | 115 | </table> |
116 | </div> | 116 | </div> |
117 | <form name="formDomicilio" ng-show="ingreso"> | 117 | <form name="formDomicilio" ng-show="ingreso"> |
118 | <input | ||
119 | type="hidden" | ||
120 | ng-model="domicilio.latitud" | ||
121 | ng-required="true"> | ||
122 | <input | ||
123 | type="hidden" | ||
124 | ng-model="domicilio.longitud" | ||
125 | ng-required="true"> | ||
118 | <div class="row"> | 126 | <div class="row"> |
119 | <div class="col-4"> | 127 | <div class="col-4"> |
120 | <label>Tipo</label> | 128 | <label>Tipo</label> |
121 | <select | 129 | <select |
122 | class="form-control" | 130 | class="form-control" |
123 | ng-disabled="true" | 131 | ng-disabled="true" |
124 | > | 132 | > |
125 | <option ng-value="2">Entrega</option> | 133 | <option ng-value="2">Entrega</option> |
126 | </select> | 134 | </select> |
127 | </div> | 135 | </div> |
128 | <div class="col-8"> | 136 | <div class="col-8"> |
129 | <label>Titulo</label> | 137 | <label>Titulo</label> |
130 | <input | 138 | <input |
131 | type="text" | 139 | type="text" |
132 | foca-focus="ingreso" | 140 | foca-focus="ingreso" |
133 | class="form-control" | 141 | class="form-control" |
134 | ng-model="domicilio.titulo" | 142 | ng-model="domicilio.titulo" |
135 | placeholder="Ingrese título" | 143 | placeholder="Ingrese título" |
136 | ng-required="true" | 144 | ng-required="true" |
145 | ng-keypress="next($event.keyCode)" | ||
146 | ng-focus="focused = 1" | ||
147 | foca-focus="focused == 1" | ||
137 | teclado-virtual | 148 | teclado-virtual |
138 | /> | 149 | /> |
139 | </div> | 150 | </div> |
140 | <div class="col-9"> | 151 | <div class="col-9"> |
141 | <label>Calle</label> | 152 | <label>Calle</label> |
142 | <input | 153 | <input |
143 | type="text" | 154 | type="text" |
144 | class="form-control" | 155 | class="form-control" |
145 | ng-model="domicilio.calle" | 156 | ng-model="domicilio.calle" |
146 | placeholder="Ingrese calle" | 157 | placeholder="Ingrese calle" |
147 | ng-required="true" | 158 | ng-required="true" |
159 | ng-keypress="next($event.keyCode)" | ||
160 | ng-focus="focused = 2" | ||
161 | foca-focus="focused == 2" | ||
162 | teclado-virtual | ||
148 | /> | 163 | /> |
149 | </div> | 164 | </div> |
150 | <div class="col-3"> | 165 | <div class="col-3"> |
151 | <label>Nº</label> | 166 | <label>Nº</label> |
152 | <input | 167 | <input |
153 | type="text" | 168 | type="text" |
154 | class="form-control" | 169 | class="form-control" |
155 | ng-model="domicilio.numeroCalle" | 170 | ng-model="domicilio.numeroCalle" |
156 | placeholder="Ingrese Numero" | 171 | placeholder="Ingrese Numero" |
157 | ng-required="true" | 172 | ng-required="true" |
173 | ng-keypress="next($event.keyCode)" | ||
174 | ng-focus="focused = 3" | ||
175 | foca-focus="focused == 3" | ||
158 | teclado-virtual | 176 | teclado-virtual |
159 | /> | 177 | /> |
160 | </div> | 178 | </div> |
161 | <div class="col-6"> | 179 | <div class="col-6"> |
162 | <label>Localidad</label> | 180 | <label>Localidad</label> |
163 | <input | 181 | <input |
164 | type="text" | 182 | type="text" |
165 | class="form-control" | 183 | class="form-control" |
166 | ng-model="domicilio.localidad" | 184 | ng-model="domicilio.localidad" |
167 | placeholder="Ingrese localidad" | 185 | placeholder="Ingrese localidad" |
168 | ng-required="true" | 186 | ng-required="true" |
187 | ng-keypress="next($event.keyCode)" | ||
188 | ng-focus="focused = 4" | ||
189 | foca-focus="focused == 4" | ||
169 | teclado-virtual | 190 | teclado-virtual |
170 | /> | 191 | /> |
171 | </div> | 192 | </div> |
172 | <div class="col-6"> | 193 | <div class="col-6"> |
173 | <label>Provincia</label> | 194 | <label>Provincia</label> |
174 | <input | 195 | <input |
175 | type="text" | 196 | type="text" |
176 | class="form-control" | 197 | class="form-control" |
177 | ng-model="domicilio.provincia" | 198 | ng-model="domicilio.provincia" |
178 | placeholder="Ingrese provincia" | 199 | placeholder="Ingrese provincia" |
179 | ng-required="true" | 200 | ng-required="true" |
201 | ng-keypress="next($event.keyCode)" | ||
202 | ng-focus="focused = 5" | ||
203 | foca-focus="focused == 5" | ||
204 | teclado-virtual | ||
180 | /> | 205 | /> |
181 | </div> | 206 | </div> |
182 | </div> | 207 | </div> |
208 | <div class="row mt-3"> | ||
209 | <div class="col-12"> | ||
210 | <button | ||
211 | type="button" | ||
212 | class="btn btn-primary float-right ml-3" | ||
213 | ng-click="localizarDomicilio()">Buscar</button> | ||
214 | <button | ||
215 | type="button" | ||
216 | class="btn btn-primary float-right" | ||
217 | ng-disabled="!domicilio.calle || !domicilio.numeroCalle || !domicilio.localidad || !domicilio.provincia" | ||
218 | ng-click="localizarDomicilio(true)">Localizar</button> | ||
219 | </div> | ||
220 | </div> | ||
183 | </form> | 221 | </form> |
184 | </div> | 222 | </div> |
185 | <div class="modal-footer"> | 223 | <div class="modal-footer"> |
186 | <nav ng-show="currentPageDomicilios.length > 0 && !ingreso" class="mr-auto"> | 224 | <nav ng-show="currentPageDomicilios.length > 0 && !ingreso" class="mr-auto"> |
187 | <ul class="pagination pagination-sm mb-0 justify-content-end"> | 225 | <ul class="pagination pagination-sm mb-0 justify-content-end"> |
188 | <li class="page-item" ng-class="{'disabled': currentPage == 1}"> | 226 | <li class="page-item" ng-class="{'disabled': currentPage == 1}"> |
189 | <a class="page-link" href="javascript:void();" ng-click="selectPage(currentPage - 1)"> | 227 | <a class="page-link" href="javascript:void();" ng-click="selectPage(currentPage - 1)"> |
190 | <span aria-hidden="true">«</span> | 228 | <span aria-hidden="true">«</span> |
191 | <span class="sr-only">Anterior</span> | 229 | <span class="sr-only">Anterior</span> |
192 | </a> | 230 | </a> |
193 | </li> | 231 | </li> |
194 | <li | 232 | <li |
195 | class="page-item" | 233 | class="page-item" |
196 | ng-repeat="pagina in paginas" | 234 | ng-repeat="pagina in paginas" |
197 | ng-class="{'active': pagina == currentPage}" | 235 | ng-class="{'active': pagina == currentPage}" |
198 | > | 236 | > |
199 | <a | 237 | <a |
200 | class="page-link" | 238 | class="page-link" |
201 | href="javascript:void();" | 239 | href="javascript:void();" |
202 | ng-click="selectPage(pagina)" | 240 | ng-click="selectPage(pagina)" |
203 | ng-bind="pagina" | 241 | ng-bind="pagina" |
204 | ></a> | 242 | ></a> |
205 | </li> | 243 | </li> |
206 | <li class="page-item" ng-class="{'disabled': currentPage == lastPage}"> | 244 | <li class="page-item" ng-class="{'disabled': currentPage == lastPage}"> |
207 | <a class="page-link" href="javascript:void();" ng-click="selectPage(currentPage + 1)"> | 245 | <a class="page-link" href="javascript:void();" ng-click="selectPage(currentPage + 1)"> |
208 | <span aria-hidden="true">»</span> | 246 | <span aria-hidden="true">»</span> |
209 | <span class="sr-only">Siguiente</span> | 247 | <span class="sr-only">Siguiente</span> |
210 | </a> | 248 | </a> |
211 | </li> | 249 | </li> |
212 | </ul> | 250 | </ul> |
213 | </nav> | 251 | </nav> |
214 | <button | 252 | <button |
215 | ng-show="!ingreso" | 253 | ng-show="!ingreso" |
216 | class="btn btn-sm btn-secondary" | 254 | class="btn btn-sm btn-secondary" |
217 | type="button" | 255 | type="button" |
218 | ng-click="cancel()" | 256 | ng-click="cancel()" |
219 | >Volver | 257 | >Volver |
220 | </button> | 258 | </button> |
221 | <button | 259 | <button |
222 | ng-show="ingreso" | 260 | ng-show="ingreso" |
223 | class="btn btn-secondary btn-sm" | 261 | class="btn btn-secondary btn-sm" |
224 | type="button" | 262 | type="button" |
225 | ng-click="ingreso = !ingreso; domicilio = {}; contactos = [{}]" | 263 | ng-click="ingreso = !ingreso; domicilio = {}; contactos = [{}]" |
226 | >Cancelar | 264 | >Cancelar |
227 | </button> | 265 | </button> |
228 | <button | 266 | <button |
229 | ng-show="ingreso" | 267 | ng-show="ingreso" |
230 | class="btn btn-sm btn-primary" | 268 | class="btn btn-sm btn-primary" |
231 | type="button" | 269 | type="button" |
232 | ng-click="agregarDomicilio()" | 270 | ng-click="agregarDomicilio()" |
233 | ng-disabled="!formDomicilio.$valid" | 271 | ng-disabled="!formDomicilio.$valid" |
234 | >Agregar domicilio | 272 | >Agregar domicilio |
235 | </button> | 273 | </button> |
236 | </div> | 274 | </div> |
237 | 275 |