Commit 7bed244e754a89ef500aa2b762c9c22d52575479
1 parent
55c6822be8
Exists in
master
and in
1 other branch
img's checked
Showing
3 changed files
with
47 additions
and
17 deletions
Show diff stats
src/js/app.js
1 | angular.module('focaBotoneraFacturador', []) | 1 | angular.module('focaBotoneraFacturador', []) |
2 | .component('focaBotoneraFacturador', { | 2 | .component('focaBotoneraFacturador', { |
3 | templateUrl: 'src/views/botonera-facturador.html', | 3 | templateUrl: 'src/views/botonera-facturador.html', |
4 | controller: 'focaBotoneraFacturadorController', | 4 | controller: 'focaBotoneraFacturadorController', |
5 | bindings: { | 5 | bindings: { |
6 | botones: '<', | 6 | max: '<', |
7 | max: '<' | 7 | botones: '<' |
8 | } | 8 | } |
9 | }); | 9 | }); |
10 | 10 |
src/js/controller.js
1 | angular.module('focaBotoneraFacturador') | 1 | angular.module('focaBotoneraFacturador') |
2 | .controller('focaBotoneraFacturadorController', [ | 2 | .controller('focaBotoneraFacturadorController', [ |
3 | '$scope', | 3 | '$scope', |
4 | '$window', | 4 | '$window', |
5 | 'APP', | 5 | 'APP', |
6 | function($scope, $window, APP) { | 6 | function($scope, $window, APP) { |
7 | this.$onInit = function() { | 7 | this.$onInit = function() { |
8 | $scope.botones = $scope.$ctrl.botones; | 8 | ordenarBotones(); |
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 | } | ||
21 | }; | 9 | }; |
22 | 10 | ||
11 | this.$onChanges = function(p) { | ||
12 | ordenarBotones(); | ||
13 | } | ||
14 | |||
23 | function nombreFuncion(string) { | 15 | function nombreFuncion(string) { |
24 | var texto = 'seleccionar'; | 16 | var texto = 'seleccionar'; |
25 | var arr = string.split(' '); | 17 | var arr = string.split(' '); |
26 | arr.forEach(function(palabra) { | 18 | arr.forEach(function(palabra) { |
27 | palabra = palabra.charAt(0).toUpperCase() + palabra.slice(1); | 19 | palabra = palabra.charAt(0).toUpperCase() + palabra.slice(1); |
28 | texto += palabra; | 20 | texto += palabra; |
29 | }); | 21 | }); |
30 | return texto; | 22 | return texto; |
31 | } | 23 | } |
32 | 24 | ||
33 | $scope.ejecutarFuncion = function(nombre) { | 25 | $scope.ejecutarFuncion = function(nombre) { |
34 | $scope.$parent[nombreFuncion(nombre)](); | 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; |
src/views/botonera-facturador.html
1 | <div | 1 | <div |
2 | class="col-4 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 | ng-repeat="boton in botones track by $index" | 3 | ng-repeat="boton in botones track by $index" |
4 | ng-class="{'d-md-grid': boton == ''}"> | 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 | <button | 18 | <button |
6 | type="button" | 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-default btn-block btn-xs text-center py-1 rounded border border-light foca-overflow-hidden" |
8 | ng-click="(boton != '') ? ejecutarFuncion(boton.label) : null" | 21 | ng-click="(boton != '') ? ejecutarFuncion(boton.label) : null" |
9 | ng-class="{'d-sm-block h-100': boton == ''}" | 22 | ng-class="{'d-sm-block h-100': boton == ''}" |
10 | ng-disabled="boton.disable" | 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 | <span>{{boton.label}}</span> | 26 | <span>{{boton.label}}</span> |
14 | </button> | 27 | </button> |
15 | </div> | 28 | </div> |
16 | 29 |