Commit cd41d64eb356a369f58762da9a31cffa23867cd4

Authored by Mauricio Cattafi
Exists in fix_acentos

Merge branch 'develop' of git.focasoftware.com:mcattafi/foca-botonera-facturador into fix_acentos

... ... @@ -4,6 +4,8 @@
4 4 "description": "Componente de botonera en facturadores",
5 5 "main": "index.js",
6 6 "scripts": {
  7 + "frefresh": "gulp uglify && cp tmp/foca-botonera-facturador.js ../wrapper-facturador/node_modules/foca-botonera-facturador/dist/foca-botonera-facturador.min.js",
  8 + "refresh": "gulp uglify && cp tmp/foca-botonera-facturador.js ../wrapper-demo/node_modules/foca-botonera-facturador/dist/foca-botonera-facturador.min.js",
7 9 "test": "echo \"Error: no test specified\" && exit 1",
8 10 "compile": "gulp uglify",
9 11 "gulp-pre-commit": "gulp pre-commit",
... ... @@ -6,4 +6,28 @@ angular.module('focaBotoneraFacturador', [])
6 6 max: '<',
7 7 botones: '<'
8 8 }
  9 + })
  10 + .component('focaBotoneraFormaPago', {
  11 + templateUrl: 'src/views/botonera-forma-pago.html',
  12 + controller: 'focaBotoneraTarjetasController',
  13 + bindings: {
  14 + botones: '<',
  15 + max: '<'
  16 + }
  17 + })
  18 + .component('focaBotoneraTarjetas', {
  19 + templateUrl: 'src/views/botonera-tarjetas.html',
  20 + controller: 'focaBotoneraTarjetasController',
  21 + bindings: {
  22 + botones: '<',
  23 + max: '<'
  24 + }
  25 + })
  26 + .component('focaBotoneraProductos', {
  27 + templateUrl: 'src/views/botonera-productos.html',
  28 + controller: 'focaBotoneraTarjetasController',
  29 + bindings: {
  30 + botones: '<',
  31 + max: '<'
  32 + }
9 33 });
src/js/controllerTarjetas.js
... ... @@ -0,0 +1,43 @@
  1 +angular.module('focaBotoneraFacturador')
  2 + .controller('focaBotoneraTarjetasController', [
  3 + '$scope',
  4 + '$window',
  5 + 'APP',
  6 + function ($scope, $window, APP) {
  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 + }
  21 + };
  22 +
  23 + function nombreFuncion(string) {
  24 + var texto = 'seleccionar';
  25 + var arr = string.split(' ');
  26 + arr.forEach(function (palabra) {
  27 + palabra = palabra.charAt(0).toUpperCase() + palabra.slice(1);
  28 + texto += palabra;
  29 + });
  30 + return texto;
  31 + }
  32 +
  33 + $scope.ejecutarFuncion = function (boton) {
  34 + $scope.$parent[nombreFuncion(boton.label)](boton);
  35 + };
  36 +
  37 + $scope.activarBoton = function (boton) {
  38 + $scope.botones.forEach(function (boton) {
  39 + boton.active = false;
  40 + });
  41 + boton.active = true;
  42 + };
  43 + }]);
src/views/botonera-forma-pago.html
... ... @@ -0,0 +1,16 @@
  1 +<div
  2 + class="col-6 col-sm-3 py-2"
  3 + ng-repeat="boton in botones track by $index"
  4 + ng-class="{'d-md-grid': boton == ''}">
  5 + <button
  6 + type="button"
  7 + class="btn btn-block btn-xs text-center rounded border border-light foca-overflow-hidden"
  8 + ng-disabled="boton.disabled"
  9 + ng-click="
  10 + (boton != '') ? ejecutarFuncion(boton) : null;
  11 + activarBoton(boton);"
  12 + >
  13 + <img ng-src="./img/{{boton.image}}" alt="">
  14 + <span>{{ boton.label }}</span>
  15 + </button>
  16 +</div>
src/views/botonera-productos.html
... ... @@ -0,0 +1,14 @@
  1 +<div
  2 + class="col-6 col-sm-3 p-2"
  3 + ng-repeat="boton in botones track by $index"
  4 + ng-class="{'d-md-grid': boton == ''}">
  5 + <button
  6 + type="button"
  7 + class="btn btn-block rounded border border-light p-0"
  8 + ng-click="(boton != '') ? ejecutarFuncion(boton) : null;"
  9 + ng-class="{'btn-producto' : boton.image, 'btn-producto-default' : !boton.image}"
  10 + >
  11 + <img ng-src="./img/{{boton.image || boton.imageDefault}}" alt="">
  12 + <label ng-if="!boton.image" ng-bind="boton.label"></label>
  13 + </button>
  14 +</div>
src/views/botonera-tarjetas.html
... ... @@ -0,0 +1,22 @@
  1 +<div
  2 + class="col-4 col-lg-2 px-1 pb-3"
  3 + ng-repeat="boton in botones track by $index"
  4 + ng-class="{'d-md-grid': boton == ''}">
  5 + <button
  6 + type="button"
  7 + class="btn btn-block btn-tarjeta rounded border p-1"
  8 + ng-click="
  9 + (boton != '') ? ejecutarFuncion(boton) : null;
  10 + activarBoton(boton);"
  11 + ng-class="
  12 + {
  13 + 'd-sm-block h-100': boton == '',
  14 + 'border-light': !boton.active,
  15 + 'border-warning': boton.active
  16 + }"
  17 + ng-disabled="boton.disable"
  18 + >
  19 + <img ng-src="./img/{{boton.image || boton.imageDefault}}" alt="">
  20 + <label ng-if="!boton.image" ng-bind="boton.nombre"></label>
  21 + </button>
  22 +</div>