From 1caffe05d1f4f811308f6a0434bbe5e3c065778a Mon Sep 17 00:00:00 2001 From: mpuebla Date: Mon, 22 Jul 2019 12:41:54 -0300 Subject: [PATCH] Agregado modal de formas de pago. --- src/js/controller.js | 95 +++++++++++++++++++++++++++++++++++++++-- src/js/service.js | 51 +++++++++++++++++----- src/views/modal-forma-pago.html | 28 +++--------- src/views/modal-tarjetas.html | 70 ++++++++++++++++++++++++++++++ 4 files changed, 207 insertions(+), 37 deletions(-) create mode 100644 src/views/modal-tarjetas.html diff --git a/src/js/controller.js b/src/js/controller.js index eb43114..b9dd479 100644 --- a/src/js/controller.js +++ b/src/js/controller.js @@ -1,7 +1,96 @@ angular.module('focaModalFormaPago') .controller('focaModalFormaPagoController', [ - '$timeout', '$filter', '$scope', '$uibModalInstance', 'focaModalFormaPagoService', - function ($timeout, $filter, $scope, $uibModalInstance, focaModalFormaPagoService) { + '$timeout', '$filter', '$scope', '$uibModal', + '$uibModalInstance', 'focaModalFormaPagoService', + function ($timeout, $filter, $scope, $uibModal, + $uibModalInstance, focaModalFormaPagoService) { + + //#region Variables + $scope.botonesTarjetas = []; + //#endregion + + init(); + + function init() { + $scope.botonesTarjetas = focaModalFormaPagoService.getBotonera(); + } + + $scope.seleccionarContado = function () { + var modalInstance = abrirModal('modal-tarjetas.html', + 'focaModalTarjetasController'); + modalInstance.result + .then(function (data) { + console.log(data); + }) + .catch(function (e) { console.error(e); }); + }; + + $scope.seleccionarTarjetas = function () { + var modalInstance = abrirModal('modal-tarjetas.html', + 'focaModalTarjetasController'); + modalInstance.result + .then(function (data) { + console.log(data); + }) + .catch(function (e) { console.error(e); }); + }; + + $scope.seleccionarCheque = function () { + var modalInstance = abrirModal('modal-tarjetas.html', + 'focaModalTarjetasController'); + modalInstance.result + .then(function (data) { + console.log(data); + }) + .catch(function (e) { console.error(e); }); + }; + + $scope.seleccionarVales = function () { + var modalInstance = abrirModal('modal-tarjetas.html', + 'focaModalTarjetasController'); + modalInstance.result + .then(function (data) { + console.log(data); + }) + .catch(function (e) { console.error(e); }); + }; + + $scope.seleccionarPagoElectronico = function () { + var modalInstance = abrirModal('modal-tarjetas.html', + 'focaModalTarjetasController'); + modalInstance.result + .then(function (data) { + console.log(data); + }) + .catch(function (e) { console.error(e); }); + }; + + function abrirModal(templateUrl, controller) { + return $uibModal.open( + { + templateUrl: templateUrl, + controller: controller, + resolve: { + filters: function () { return null; }, + }, + size: 'lg', + } + ); + + } + + $scope.cancel = function () { + $uibModalInstance.dismiss('cancel'); + }; + + $scope.select = function (iva) { + $uibModalInstance.close(iva); + }; + }] + ) + .controller('focaModalTarjetasController', [ + '$timeout', '$filter', '$scope', '$uibModalInstance', 'focaModalTarjetasService', + function ($timeout, $filter, $scope, $uibModalInstance, focaModalTarjetasService) { //#region Variables $scope.botonesTarjetas = []; @@ -12,7 +101,7 @@ angular.module('focaModalFormaPago') init(); function init() { - $scope.botonesTarjetas = focaModalFormaPagoService.getBotonera(); + $scope.botonesTarjetas = focaModalTarjetasService.getBotonera(); } $scope.seleccionarTarjeta = function () { diff --git a/src/js/service.js b/src/js/service.js index 3ae839a..84d5689 100644 --- a/src/js/service.js +++ b/src/js/service.js @@ -1,10 +1,39 @@ angular.module('focaModalFormaPago') .factory('focaModalFormaPagoService', ['$http', 'API_ENDPOINT', function ($http, API_ENDPOINT) { return { - getFormasPago: function () { - //TODO: pasar filtro - return $http.get(API_ENDPOINT.URL + '/forma-pago'); - }, + getBotonera: function () { + return [ + { + label: 'Contado', + image: 'contado.png', + disabled: true + }, + { + label: 'Tarjetas', + image: 'tarjeta.png', + disabled: false + }, + { + label: 'Cheque', + image: 'cheque.png', + disabled: true + }, + { + label: 'Vales', + image: 'vale.png', + disabled: true + }, + { + label: 'Pago Electronico', + image: 'qr.png', + disabled: true + } + ]; + } + }; + }]) + .factory('focaModalTarjetasService', ['$http', 'API_ENDPOINT', function ($http, API_ENDPOINT) { + return { getBotonera: function () { return [ { @@ -16,12 +45,12 @@ angular.module('focaModalFormaPago') label: 'tarjeta', image: 'mastercard.svg', active: false, - }, + }, { label: 'tarjeta', image: 'maestro.svg', active: false, - }, + }, { label: 'tarjeta', image: 'americanExpress.svg', @@ -31,27 +60,27 @@ angular.module('focaModalFormaPago') label: 'tarjeta', image: 'naranja.png', active: false, - }, + }, { label: 'tarjeta', image: 'cabal.svg', active: false, - }, + }, { label: 'tarjeta', image: 'argencard.svg', active: false, - }, + }, { label: 'tarjeta', image: 'nativa.png', active: false, - }, + }, { label: 'tarjeta', image: 'cencosud.png', active: false, - }, + }, ]; } }; diff --git a/src/views/modal-forma-pago.html b/src/views/modal-forma-pago.html index 06c8267..b343d5e 100644 --- a/src/views/modal-forma-pago.html +++ b/src/views/modal-forma-pago.html @@ -1,42 +1,24 @@