Commit 8662ff21b41d4b70cd982b2d6e0053f529a0155a

Authored by Mauricio Cattafi
Exists in develop

Merge branch 'develop' into 'master'

Develop

See merge request !24
1 { 1 {
2 "name": "foca-botonera-facturador", 2 "name": "foca-botonera-facturador",
3 "version": "0.0.1", 3 "version": "0.0.1",
4 "description": "Componente de botonera en facturadores", 4 "description": "Componente de botonera en facturadores",
5 "main": "index.js", 5 "main": "index.js",
6 "scripts": { 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 "test": "echo \"Error: no test specified\" && exit 1", 9 "test": "echo \"Error: no test specified\" && exit 1",
8 "compile": "gulp uglify", 10 "compile": "gulp uglify",
9 "gulp-pre-commit": "gulp pre-commit", 11 "gulp-pre-commit": "gulp pre-commit",
10 "postinstall": "npm run compile && gulp clean-post-install", 12 "postinstall": "npm run compile && gulp clean-post-install",
11 "install-dev": "npm install -D angular bootstrap font-awesome gulp gulp-angular-templatecache gulp-clean gulp-concat gulp-connect gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-uglify-es jasmine-core jquery jshint pre-commit pump && npm install angular-sanitize" 13 "install-dev": "npm install -D angular bootstrap font-awesome gulp gulp-angular-templatecache gulp-clean gulp-concat gulp-connect gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-uglify-es jasmine-core jquery jshint pre-commit pump && npm install angular-sanitize",
14 "frefresh": "gulp uglify && cp tmp/foca-botonera-facturador.js ../wrapper-facturador/node_modules/foca-botonera-facturador/dist/foca-botonera-facturador.min.js"
12 }, 15 },
13 "pre-commit": [ 16 "pre-commit": [
14 "gulp-pre-commit" 17 "gulp-pre-commit"
15 ], 18 ],
16 "repository": { 19 "repository": {
17 "type": "git", 20 "type": "git",
18 "url": "git+ssh://git@debonline.dyndns.org:npm/foca-botonera-facturador.git" 21 "url": "git+ssh://git@debonline.dyndns.org:npm/foca-botonera-facturador.git"
19 }, 22 },
20 "author": "Foca Software", 23 "author": "Foca Software",
21 "license": "ISC", 24 "license": "ISC",
22 "peerDependencies": { 25 "peerDependencies": {
23 "angular": "^1.7.x", 26 "angular": "^1.7.x",
24 "bootstrap": "^4.1.x", 27 "bootstrap": "^4.1.x",
25 "jquery": "^3.3.x", 28 "jquery": "^3.3.x",
26 "font-awesome": "^4.7.x", 29 "font-awesome": "^4.7.x",
27 "gulp": "^3.9.x", 30 "gulp": "^3.9.x",
28 "gulp-concat": "2.6.x", 31 "gulp-concat": "2.6.x",
29 "gulp-jshint": "^2.1.x", 32 "gulp-jshint": "^2.1.x",
30 "gulp-rename": "^1.4.x", 33 "gulp-rename": "^1.4.x",
31 "gulp-replace": "^1.0.x", 34 "gulp-replace": "^1.0.x",
32 "gulp-uglify-es": "^1.0.x", 35 "gulp-uglify-es": "^1.0.x",
33 "jshint": "^2.9.x", 36 "jshint": "^2.9.x",
34 "pump": "^3.0.x" 37 "pump": "^3.0.x"
35 }, 38 },
36 "devDependencies": { 39 "devDependencies": {
37 "angular": "^1.7.6", 40 "angular": "^1.7.6",
38 "angular-route": "^1.7.5", 41 "angular-route": "^1.7.5",
39 "angular-sanitize": "^1.7.6", 42 "angular-sanitize": "^1.7.6",
40 "bootstrap": "^4.2.1", 43 "bootstrap": "^4.2.1",
41 "font-awesome": "^4.7.0", 44 "font-awesome": "^4.7.0",
42 "gulp": "^3.9.1", 45 "gulp": "^3.9.1",
43 "gulp-angular-templatecache": "^2.2.6", 46 "gulp-angular-templatecache": "^2.2.6",
44 "gulp-clean": "^0.4.0", 47 "gulp-clean": "^0.4.0",
45 "gulp-concat": "^2.6.1", 48 "gulp-concat": "^2.6.1",
46 "gulp-connect": "^5.7.0", 49 "gulp-connect": "^5.7.0",
47 "gulp-htmlmin": "^5.0.1", 50 "gulp-htmlmin": "^5.0.1",
48 "gulp-jshint": "^2.1.0", 51 "gulp-jshint": "^2.1.0",
49 "gulp-rename": "^1.4.0", 52 "gulp-rename": "^1.4.0",
50 "gulp-replace": "^1.0.0", 53 "gulp-replace": "^1.0.0",
51 "gulp-sass": "^4.0.2", 54 "gulp-sass": "^4.0.2",
52 "gulp-uglify-es": "^1.0.4", 55 "gulp-uglify-es": "^1.0.4",
53 "jasmine-core": "^3.3.0", 56 "jasmine-core": "^3.3.0",
54 "jquery": "^3.3.1", 57 "jquery": "^3.3.1",
55 "jshint": "^2.9.7", 58 "jshint": "^2.9.7",
56 "pre-commit": "^1.2.2", 59 "pre-commit": "^1.2.2",
57 "pump": "^3.0.0" 60 "pump": "^3.0.0"
58 } 61 }
59 } 62 }
60 63
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 max: '<', 6 max: '<',
7 botones: '<' 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 });
10 34
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 ordenarBotones(); 8 ordenarBotones();
9 }; 9 };
10 10
11 this.$onChanges = function() { 11 this.$onChanges = function() {
12 ordenarBotones(); 12 ordenarBotones();
13 }; 13 };
14 14
15 function nombreFuncion(string) { 15 function nombreFuncion(string) {
16 var texto = 'seleccionar'; 16 var texto = 'seleccionar';
17 var arr = string.split(' '); 17 var arr = string.split(' ');
18 arr.forEach(function(palabra) { 18 arr.forEach(function(palabra) {
19 palabra = palabra.normalize('NFD').replace(/[\u0300-\u036f]/g,"");
19 palabra = palabra.charAt(0).toUpperCase() + palabra.slice(1); 20 palabra = palabra.charAt(0).toUpperCase() + palabra.slice(1);
20 texto += palabra; 21 texto += palabra;
21 }); 22 });
22 return texto; 23 return texto;
23 } 24 }
24 25
25 $scope.ejecutarFuncion = function(nombre) { 26 $scope.ejecutarFuncion = function(nombre) {
26 $scope.$parent[nombreFuncion(nombre)](); 27 $scope.$parent[nombreFuncion(nombre)]();
27 }; 28 };
28 29
29 $scope.ejecutarFuncionDelete = function(variable) { 30 $scope.ejecutarFuncionDelete = function(variable) {
30 $scope.$parent['clean' + variable](); 31 $scope.$parent['clean' + variable]();
31 }; 32 };
32 33
33 $scope.existeFuncionDelete = function(variable) { 34 $scope.existeFuncionDelete = function(variable) {
34 if ($scope.$parent['clean' + variable]) return true; 35 if ($scope.$parent['clean' + variable]) return true;
35 return false; 36 return false;
36 }; 37 };
37 38
38 function ordenarBotones() { 39 function ordenarBotones() {
39 $scope.botones = $scope.$ctrl.botones; 40 $scope.botones = $scope.$ctrl.botones;
40 //TODO: controlar que no se estiren los botones 41 //TODO: controlar que no se estiren los botones
41 if(APP) return; 42 if(APP) return;
42 var max = ($scope.$ctrl.max) ? $scope.$ctrl.max : 12; 43 var max = ($scope.$ctrl.max) ? $scope.$ctrl.max : 12;
43 if ($window.innerWidth > 576) { 44 if ($window.innerWidth > 576) {
44 while(($scope.botones.length % max) !== 0) { 45 while(($scope.botones.length % max) !== 0) {
45 $scope.botones.push(''); 46 $scope.botones.push('');
46 } 47 }
47 } else { 48 } else {
48 while(($scope.botones.length % 4) !== 0) { 49 while(($scope.botones.length % 4) !== 0) {
49 $scope.botones.push(''); 50 $scope.botones.push('');
50 } 51 }
51 } 52 }
52 } 53 }
53 }]); 54 }]);
54 55
src/js/controllerTarjetas.js
File was created 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 }]);
44
src/views/botonera-forma-pago.html
File was created 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>
17
src/views/botonera-productos.html
File was created 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>
15
src/views/botonera-tarjetas.html
File was created 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>
23