Commit 7bed244e754a89ef500aa2b762c9c22d52575479
1 parent
55c6822be8
Exists in
master
and in
2 other branches
img's checked
Showing
3 changed files
with
47 additions
and
17 deletions
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,21 +5,13 @@ 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(); | |
| 21 | 9 | }; |
| 22 | 10 | |
| 11 | + this.$onChanges = function(p) { | |
| 12 | + ordenarBotones(); | |
| 13 | + } | |
| 14 | + | |
| 23 | 15 | function nombreFuncion(string) { |
| 24 | 16 | var texto = 'seleccionar'; |
| 25 | 17 | var arr = string.split(' '); |
| ... | ... | @@ -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
| ... | ... | @@ -2,6 +2,19 @@ |
| 2 | 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 | 20 | class="btn btn-default btn-block btn-xs text-center py-1 rounded border border-light foca-overflow-hidden" |
| ... | ... | @@ -9,7 +22,7 @@ |
| 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> |