Commit 6f9920104f3c8a2f6ec15b2150aa374dc0afa6be

Authored by Eric Fernandez
1 parent 54166f231f
Exists in master and in 1 other branch develop

send boton to function

src/js/controllerTarjetas.js
1 angular.module('focaBotoneraFacturador') 1 angular.module('focaBotoneraFacturador')
2 .controller('focaBotoneraTarjetasController', [ 2 .controller('focaBotoneraTarjetasController', [
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 $scope.botones = $scope.$ctrl.botones;
9 //TODO: controlar que no se estiren los botones 9 //TODO: controlar que no se estiren los botones
10 if (APP) return; 10 if (APP) return;
11 var max = ($scope.$ctrl.max) ? $scope.$ctrl.max : 12; 11 var max = ($scope.$ctrl.max) ? $scope.$ctrl.max : 12;
12 if ($window.innerWidth > 576) { 12 if ($window.innerWidth > 576) {
13 while (($scope.botones.length % max) !== 0) { 13 while (($scope.botones.length % max) !== 0) {
14 $scope.botones.push(''); 14 $scope.botones.push('');
15 } 15 }
16 } else { 16 } else {
17 while (($scope.botones.length % 4) !== 0) { 17 while (($scope.botones.length % 4) !== 0) {
18 $scope.botones.push(''); 18 $scope.botones.push('');
19 } 19 }
20 } 20 }
21 }; 21 };
22 22
23 function nombreFuncion(string) { 23 function nombreFuncion(string) {
24 var texto = 'seleccionar'; 24 var texto = 'seleccionar';
25 var arr = string.split(' '); 25 var arr = string.split(' ');
26 arr.forEach(function (palabra) { 26 arr.forEach(function (palabra) {
27 palabra = palabra.charAt(0).toUpperCase() + palabra.slice(1); 27 palabra = palabra.charAt(0).toUpperCase() + palabra.slice(1);
28 texto += palabra; 28 texto += palabra;
29 }); 29 });
30 return texto; 30 return texto;
31 } 31 }
32 32
33 $scope.ejecutarFuncion = function (nombre) { 33 $scope.ejecutarFuncion = function (boton) {
34 $scope.$parent[nombreFuncion(nombre)](); 34 $scope.$parent[nombreFuncion(boton.label)](boton);
35 }; 35 };
36 36
37 $scope.activarBoton = function (boton) { 37 $scope.activarBoton = function (boton) {
38 $scope.botones.forEach(function (boton) { 38 $scope.botones.forEach(function (boton) {
39 boton.active = false; 39 boton.active = false;
40 }); 40 });
41 boton.active = true; 41 boton.active = true;
42 }; 42 };
43 }]); 43 }]);
44 44
src/views/botonera-forma-pago.html
1 <div 1 <div
2 class="col-6 col-lg-3 py-2" 2 class="col-6 col-lg-3 py-2"
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 <button 5 <button
6 type="button" 6 type="button"
7 class="btn btn-block btn-xs text-center rounded border border-light foca-overflow-hidden" 7 class="btn btn-block btn-xs text-center rounded border border-light foca-overflow-hidden"
8 ng-disabled="boton.disabled" 8 ng-disabled="boton.disabled"
9 ng-click=" 9 ng-click="
10 (boton != '') ? ejecutarFuncion(boton.label) : null; 10 (boton != '') ? ejecutarFuncion(boton) : null;
11 activarBoton(boton);" 11 activarBoton(boton);"
12 > 12 >
13 <img ng-src="./img/{{boton.image}}" alt=""> 13 <img ng-src="./img/{{boton.image}}" alt="">
14 <span>{{ boton.label }}</span> 14 <span>{{ boton.label }}</span>
15 </button> 15 </button>
16 </div> 16 </div>
17 17
src/views/botonera-tarjetas.html
1 <div 1 <div
2 class="col-4 col-lg-2 pb-3" 2 class="col-4 col-lg-2 pb-3"
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 <button 5 <button
6 type="button" 6 type="button"
7 class="btn btn-block btn-tarjeta rounded border p-1" 7 class="btn btn-block btn-tarjeta rounded border p-1"
8 ng-click=" 8 ng-click="
9 (boton != '') ? ejecutarFuncion(boton.label) : null; 9 (boton != '') ? ejecutarFuncion(boton) : null;
10 activarBoton(boton);" 10 activarBoton(boton);"
11 ng-class=" 11 ng-class="
12 { 12 {
13 'd-sm-block h-100': boton == '', 13 'd-sm-block h-100': boton == '',
14 'border-light': !boton.active, 14 'border-light': !boton.active,
15 'border-warning': boton.active 15 'border-warning': boton.active
16 }" 16 }"
17 ng-disabled="boton.disable" 17 ng-disabled="boton.disable"
18 > 18 >
19 <img ng-src="./img/{{boton.image}}" alt=""> 19 <img ng-src="./img/{{boton.image || boton.imageDefault}}" alt="">
20 <label ng-if="!boton.image" ng-bind="boton.nombre"></label>
20 </button> 21 </button>
21 </div> 22 </div>
22 23