Commit d5dac011fec8bb3ace53fd2f594f12ede5b5589e
1 parent
bad1ea0f4a
Exists in
master
subir fotos mobile
Showing
3 changed files
with
95 additions
and
12 deletions
Show diff stats
package.json
... | ... | @@ -20,23 +20,23 @@ |
20 | 20 | "author": "Foca Software", |
21 | 21 | "license": "ISC", |
22 | 22 | "devDependencies": { |
23 | - "angular": "^1.7.5", | |
24 | - "bootstrap": "^4.1.3", | |
23 | + "angular": "^1.7.7", | |
24 | + "bootstrap": "^4.3.1", | |
25 | 25 | "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git", |
26 | 26 | "font-awesome": "^4.7.0", |
27 | 27 | "gulp": "^3.9.1", |
28 | - "gulp-angular-templatecache": "^2.2.5", | |
28 | + "gulp-angular-templatecache": "^2.2.6", | |
29 | 29 | "gulp-clean": "^0.4.0", |
30 | 30 | "gulp-concat": "^2.6.1", |
31 | - "gulp-connect": "^5.6.1", | |
31 | + "gulp-connect": "^5.7.0", | |
32 | 32 | "gulp-htmlmin": "^5.0.1", |
33 | 33 | "gulp-jshint": "^2.1.0", |
34 | 34 | "gulp-rename": "^1.4.0", |
35 | 35 | "gulp-replace": "^1.0.0", |
36 | 36 | "gulp-uglify": "^3.0.1", |
37 | 37 | "jquery": "^3.3.1", |
38 | - "jshint": "^2.9.6", | |
38 | + "jshint": "^2.10.1", | |
39 | 39 | "pump": "^3.0.0", |
40 | - "ui-bootstrap4": "^3.0.5" | |
40 | + "ui-bootstrap4": "^3.0.6" | |
41 | 41 | } |
42 | 42 | } |
src/js/controller.js
... | ... | @@ -4,15 +4,18 @@ angular.module('focaModalDetalles') |
4 | 4 | '$scope', |
5 | 5 | '$uibModalInstance', |
6 | 6 | 'focaModalService', |
7 | + 'APP', | |
8 | + '$timeout', | |
7 | 9 | 'sugerido', |
8 | - function($scope, $uibModalInstance, focaModalService, sugerido) { | |
10 | + function($scope, $uibModalInstance, focaModalService, APP, $timeout, sugerido) { | |
11 | + $scope.mobile = APP === 'cobranza'; | |
9 | 12 | $scope.files = []; |
10 | 13 | $scope.importe = Math.abs(sugerido); |
11 | 14 | |
12 | 15 | $scope.$watch('files', function() { |
13 | 16 | validarExtSize(); |
14 | 17 | }); |
15 | - | |
18 | + | |
16 | 19 | $scope.eliminarImg = function(key) { |
17 | 20 | $scope.files.splice(key, 1); |
18 | 21 | }; |
... | ... | @@ -20,7 +23,9 @@ angular.module('focaModalDetalles') |
20 | 23 | $scope.cancel = function() { |
21 | 24 | $uibModalInstance.dismiss('cancel'); |
22 | 25 | }; |
26 | + | |
23 | 27 | $scope.aceptar = function() { |
28 | + console.log($scope.files); | |
24 | 29 | $uibModalInstance.close({ |
25 | 30 | observacion: $scope.observaciones, |
26 | 31 | monto: $scope.importe, |
... | ... | @@ -28,6 +33,52 @@ angular.module('focaModalDetalles') |
28 | 33 | }); |
29 | 34 | }; |
30 | 35 | |
36 | + $scope.seleccionarFoto = function() { | |
37 | + var srcType = Camera.PictureSourceType.SAVEDPHOTOALBUM; | |
38 | + var options = setOptions(srcType); | |
39 | + navigator.camera.getPicture(cameraSuccess, cameraError, options); | |
40 | + }; | |
41 | + | |
42 | + $scope.tomarFoto = function() { | |
43 | + navigator.camera.getPicture(cameraSuccess, cameraError, | |
44 | + { | |
45 | + destinationType: Camera.DestinationType.DATA_URL, | |
46 | + quality: 100 | |
47 | + }); | |
48 | + }; | |
49 | + | |
50 | + function cameraSuccess(imageBase64) { | |
51 | + | |
52 | + var fecha = new Date(); | |
53 | + var size = (imageBase64.length * (3/4)); | |
54 | + | |
55 | + var imagen = { | |
56 | + name: 'imagen_' + fecha.getTime() + '.jpg', | |
57 | + size: size, | |
58 | + base64: imageBase64, | |
59 | + }; | |
60 | + $timeout(function() { | |
61 | + $scope.files.push(imagen); | |
62 | + }); | |
63 | + } | |
64 | + function cameraError(err) { | |
65 | + console.log(err); | |
66 | + } | |
67 | + function setOptions(srcType) { | |
68 | + var options = { | |
69 | + // Some common settings are 20, 50, and 100 | |
70 | + quality: 100, | |
71 | + destinationType: Camera.DestinationType.DATA_URL, | |
72 | + sourceType: srcType, | |
73 | + | |
74 | + encodingType: Camera.EncodingType.JPEG, | |
75 | + mediaType: Camera.MediaType.PICTURE, | |
76 | + allowEdit: true, | |
77 | + correctOrientation: true | |
78 | + } | |
79 | + return options; | |
80 | + } | |
81 | + | |
31 | 82 | function validarExtSize() { |
32 | 83 | var totalSize = 0; |
33 | 84 | var invalidExt = false; |
src/views/modal-detalles.html
... | ... | @@ -20,7 +20,7 @@ |
20 | 20 | <div class="col-12 col-md-2"> |
21 | 21 | <label class="form-control-sm p-0">Monto cubierto:</label> |
22 | 22 | </div> |
23 | - <div class="col-6 col-md-5 input-group mb-2"> | |
23 | + <div class="col-12 col-md-5 input-group mb-2"> | |
24 | 24 | <div class="input-group-prepend"> |
25 | 25 | <div class="input-group-text form-control form-control-sm">$</div> |
26 | 26 | </div> |
... | ... | @@ -35,8 +35,8 @@ |
35 | 35 | foca-focus="focused == 6" |
36 | 36 | ng-focus="focused = 6"/> |
37 | 37 | </div> |
38 | - <div class="col-md-5"> | |
39 | - <input | |
38 | + <div class="col-md-5" ng-if="!mobile"> | |
39 | + <input | |
40 | 40 | type="file" |
41 | 41 | class="form-control-file" |
42 | 42 | ng-file-model="files" |
... | ... | @@ -44,9 +44,29 @@ |
44 | 44 | accept=".jpg,.png"> |
45 | 45 | <small>Solo .jpg y .png - Tamaño máximo 150mb</small> |
46 | 46 | </div> |
47 | + <div class="col-6 mb-2" ng-if="mobile"> | |
48 | + <button | |
49 | + type="button" | |
50 | + ng-if="mobile" | |
51 | + class="form-control form-control-sm" | |
52 | + ng-click="seleccionarFoto()"> | |
53 | + Seleccione imagen</button> | |
54 | + </div> | |
55 | + <div class="col-6 mb-2" ng-if="mobile"> | |
56 | + <button | |
57 | + type="button" | |
58 | + ng-if="mobile" | |
59 | + class="form-control form-control-sm" | |
60 | + ng-click="tomarFoto()"> | |
61 | + Tome imagen | |
62 | + </button> | |
63 | + </div> | |
64 | + <div class="col-12" ng-if="mobile"> | |
65 | + <small>Solo .jpg y .png - Tamaño máximo 150mb</small> | |
66 | + </div> | |
47 | 67 | </div> |
48 | 68 | </form> |
49 | - <div class="row"> | |
69 | + <div class="row" ng-if="!mobile"> | |
50 | 70 | <div class="col-md-3" ng-repeat="(key, file) in files"> |
51 | 71 | <img ng-src="{{file.url}}" alt="" class="col-md-12 p-0"> |
52 | 72 | <button |
... | ... | @@ -58,6 +78,18 @@ |
58 | 78 | </button> |
59 | 79 | </div> |
60 | 80 | </div> |
81 | + <div class="row" ng-if="mobile"> | |
82 | + <div class="col-12 d-flex justify-content-between" ng-repeat="(key, file) in files"> | |
83 | + <strong ng-bind="file.name"></strong> | |
84 | + <button | |
85 | + type="button" | |
86 | + class="btn p-0" | |
87 | + title="Eliminar" | |
88 | + ng-click="eliminarImg(key)"> | |
89 | + <i class="fa fa-times" aria-hidden="true"></i> | |
90 | + </button> | |
91 | + </div> | |
92 | + </div> | |
61 | 93 | </div> |
62 | 94 | <div class="modal-footer"> |
63 | 95 | <button |