Commit 4171c77462fe8decb48d1150f1c3accbdcf40328
Exists in
master
Merge branch 'develop' into 'master'
Develop See merge request !16
Showing
3 changed files
Show diff stats
src/js/app.js
... | ... | @@ -2,8 +2,8 @@ angular.module('focaBotoneraFacturador', []) |
2 | 2 | .component('focaBotoneraFacturador', { |
3 | 3 | templateUrl: 'src/views/botonera-facturador.html', |
4 | 4 | controller: 'focaBotoneraFacturadorController', |
5 | - bindings: { | |
6 | - botones: '<', | |
7 | - max: '<' | |
5 | + bindings: { | |
6 | + max: '<', | |
7 | + botones: '<' | |
8 | 8 | } |
9 | 9 | }); |
src/js/controller.js
... | ... | @@ -5,19 +5,11 @@ angular.module('focaBotoneraFacturador') |
5 | 5 | 'APP', |
6 | 6 | function($scope, $window, APP) { |
7 | 7 | this.$onInit = function() { |
8 | - $scope.botones = $scope.$ctrl.botones; | |
9 | - //TODO: controlar que no se estiren los botones | |
10 | - if(APP) return; | |
11 | - var max = ($scope.$ctrl.max) ? $scope.$ctrl.max : 12; | |
12 | - if($window.innerWidth > 576) { | |
13 | - while(($scope.botones.length % max) !== 0) { | |
14 | - $scope.botones.push(''); | |
15 | - } | |
16 | - }else { | |
17 | - while(($scope.botones.length % 4) !== 0) { | |
18 | - $scope.botones.push(''); | |
19 | - } | |
20 | - } | |
8 | + ordenarBotones(); | |
9 | + }; | |
10 | + | |
11 | + this.$onChanges = function() { | |
12 | + ordenarBotones(); | |
21 | 13 | }; |
22 | 14 | |
23 | 15 | function nombreFuncion(string) { |
... | ... | @@ -33,4 +25,29 @@ angular.module('focaBotoneraFacturador') |
33 | 25 | $scope.ejecutarFuncion = function(nombre) { |
34 | 26 | $scope.$parent[nombreFuncion(nombre)](); |
35 | 27 | }; |
28 | + | |
29 | + $scope.ejecutarFuncionDelete = function(variable) { | |
30 | + $scope.$parent['clean' + variable](); | |
31 | + }; | |
32 | + | |
33 | + $scope.existeFuncionDelete = function(variable) { | |
34 | + if ($scope.$parent['clean' + variable]) return true; | |
35 | + return false; | |
36 | + }; | |
37 | + | |
38 | + function ordenarBotones() { | |
39 | + $scope.botones = $scope.$ctrl.botones; | |
40 | + //TODO: controlar que no se estiren los botones | |
41 | + if(APP) return; | |
42 | + var max = ($scope.$ctrl.max) ? $scope.$ctrl.max : 12; | |
43 | + if ($window.innerWidth > 576) { | |
44 | + while(($scope.botones.length % max) !== 0) { | |
45 | + $scope.botones.push(''); | |
46 | + } | |
47 | + } else { | |
48 | + while(($scope.botones.length % 4) !== 0) { | |
49 | + $scope.botones.push(''); | |
50 | + } | |
51 | + } | |
52 | + } | |
36 | 53 | }]); |
src/views/botonera-facturador.html
1 | 1 | <div |
2 | - class="col-3 col-sm-2 px-1 py-1 m-auto m-md-0" | |
2 | + class="col-4 col-sm-2 px-1 py-1 m-auto m-md-0" | |
3 | 3 | ng-repeat="boton in botones track by $index" |
4 | 4 | ng-class="{'d-md-grid': boton == ''}"> |
5 | + <img | |
6 | + ng-src="./img/tilde_.png" | |
7 | + class="w-25 position-absolute foca-boton-facturador-right" | |
8 | + ng-show="boton != '' && boton.checked" | |
9 | + uib-tooltip="Parámetro seleccionado" | |
10 | + tooltip-append-to-body="true"> | |
11 | + <img | |
12 | + uib-tooltip="Limpiar parámetro" | |
13 | + tooltip-append-to-body="true" | |
14 | + ng-src="./img/cruz-gris.png" | |
15 | + class="w-25 position-absolute" | |
16 | + ng-show="boton != '' && boton.checked && existeFuncionDelete(boton.variable)" | |
17 | + ng-click="ejecutarFuncionDelete(boton.variable)"> | |
5 | 18 | <button |
6 | 19 | type="button" |
7 | - class="btn btn-default btn-block btn-xs text-center py-1 rounded border border-light foca-overflow-hidden" | |
20 | + class="btn btn-block btn-xs text-center py-1 rounded border border-light foca-overflow-hidden" | |
8 | 21 | ng-click="(boton != '') ? ejecutarFuncion(boton.label) : null" |
9 | 22 | ng-class="{'d-sm-block h-100': boton == ''}" |
10 | 23 | ng-disabled="boton.disable" |
11 | 24 | > |
12 | - <img ng-src="./img/{{boton.image}}" alt=""> | |
25 | + <img ng-src="./img/{{boton.image}}" alt="" ng-show="boton != ''"> | |
13 | 26 | <span>{{boton.label}}</span> |
14 | 27 | </button> |
15 | 28 | </div> |