diff --git a/client/agency/src/zone/index/index.html b/client/agency/src/zone/index/index.html index cae870c3f..a0e479c66 100644 --- a/client/agency/src/zone/index/index.html +++ b/client/agency/src/zone/index/index.html @@ -40,7 +40,7 @@ {{::zone.price | currency:'€':2}} diff --git a/client/claim/src/index/index.html b/client/claim/src/index/index.html index 586328b16..329199b0c 100644 --- a/client/claim/src/index/index.html +++ b/client/claim/src/index/index.html @@ -42,7 +42,7 @@ {{::claim.claimState.description}} diff --git a/client/client/src/billing-data/index.html b/client/client/src/billing-data/index.html index 154cc9abb..7da67c550 100644 --- a/client/client/src/billing-data/index.html +++ b/client/client/src/billing-data/index.html @@ -10,7 +10,7 @@ Pay method - + + + + + + - - - - - - + @@ -79,4 +85,39 @@ - \ No newline at end of file + + + + + +
New bank entity
+ + + + + + + + + + + + +
+ + + + +
\ No newline at end of file diff --git a/client/client/src/billing-data/index.js b/client/client/src/billing-data/index.js index 03a433179..02d4e11da 100644 --- a/client/client/src/billing-data/index.js +++ b/client/client/src/billing-data/index.js @@ -5,7 +5,21 @@ export default class Controller { this.$scope = $scope; this.$http = $http; this.vnApp = vnApp; - this.translate = $translate; + this.$translate = $translate; + } + + get client() { + return this._client; + } + + set client(value) { + this._client = value; + + if (!value) return; + + this.newBankEntity = { + countryFk: Number.parseInt(value.countryFk) + }; } onSubmit() { @@ -22,7 +36,7 @@ export default class Controller { notifyChanges() { this.$http.get(`/mailer/notification/payment-update/${this.client.id}`).then( - () => this.vnApp.showMessage(this.translate.instant('Notification sent!')) + () => this.vnApp.showMessage(this.$translate.instant('Notification sent!')) ); } @@ -35,6 +49,32 @@ export default class Controller { return payMethod || iban || dueDay; } + + onBankEntityOpen() { + this.newBankEntity.name = ''; + this.newBankEntity.bic = ''; + this.$scope.$apply(); + } + + onBankEntityResponse(response) { + if (response == 'ACCEPT') + try { + if (!this.newBankEntity.name) + throw new Error(`Name can't be empty`); + if (!this.newBankEntity.bic) + throw new Error(`Swift / BIC can't be empty`); + + this.$http.post(`/client/api/BankEntities`, this.newBankEntity).then(response => { + if (response.data) + this.client.bankEntityFk = response.data.id; + }); + } catch (e) { + this.vnApp.showError(this.$translate.instant(e.message)); + return false; + } + + return true; + } } Controller.$inject = ['$scope', '$http', 'vnApp', '$translate']; diff --git a/client/client/src/billing-data/index.spec.js b/client/client/src/billing-data/index.spec.js index 0158a325d..f875eb0a0 100644 --- a/client/client/src/billing-data/index.spec.js +++ b/client/client/src/billing-data/index.spec.js @@ -7,17 +7,20 @@ describe('Client', () => { let $httpBackend; let $scope; let controller; + let vnApp; beforeEach(() => { angular.mock.module('client'); }); - beforeEach(angular.mock.inject((_$componentController_, $rootScope, _$httpBackend_) => { + beforeEach(angular.mock.inject((_$componentController_, $rootScope, _$httpBackend_, _vnApp_) => { $componentController = _$componentController_; $httpBackend = _$httpBackend_; $httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({}); $scope = $rootScope.$new(); $scope.watcher = watcher; + vnApp = _vnApp_; + spyOn(vnApp, 'showError'); controller = $componentController('vnClientBillingData', {$scope: $scope}); controller.client = {id: 101, name: 'Client name', payMethodFk: 4}; $scope.watcher.orgData = {id: 101, name: 'Client name', payMethodFk: 4}; @@ -55,5 +58,53 @@ describe('Client', () => { expect(controller.hasPaymethodChanges()).toBeFalsy(); }); }); + + describe('onBankEntityOpen()', () => { + it('should set reset the new bank entity properties', () => { + controller.newBankEntity.name = 'My new bank entity'; + controller.newBankEntity.bic = 'ES123'; + controller.onBankEntityOpen(); + + expect(controller.newBankEntity.name).toBe(''); + expect(controller.newBankEntity.bic).toBe(''); + }); + }); + + describe('onBankEntityResponse()', () => { + it(`should throw an error if name property is empty`, () => { + controller.newBankEntity = { + name: '', + bic: 'ES123', + countryFk: 1 + }; + controller.onBankEntityResponse('ACCEPT'); + + expect(vnApp.showError).toHaveBeenCalledWith(`Name can't be empty`); + }); + + it(`should throw an error if bic property is empty`, () => { + controller.newBankEntity = { + name: 'My new bank entity', + bic: '', + countryFk: 1 + }; + controller.onBankEntityResponse('ACCEPT'); + + expect(vnApp.showError).toHaveBeenCalledWith(`Swift / BIC can't be empty`); + }); + + it('should request to create a new bank entity', () => { + let newBankEntity = { + name: 'My new bank entity', + bic: 'ES123', + countryFk: 1 + }; + controller.newBankEntity = newBankEntity; + $httpBackend.when('POST', '/client/api/BankEntities').respond('done'); + $httpBackend.expectPOST('/client/api/BankEntities', newBankEntity); + controller.onBankEntityResponse('ACCEPT'); + $httpBackend.flush(); + }); + }); }); }); diff --git a/client/client/src/billing-data/locale/es.yml b/client/client/src/billing-data/locale/es.yml index b0334d0df..78d970f5c 100644 --- a/client/client/src/billing-data/locale/es.yml +++ b/client/client/src/billing-data/locale/es.yml @@ -12,4 +12,7 @@ Due day: Vencimiento Received LCR: Recibido LCR Received core VNL: Recibido core VNL Received B2B VNL: Recibido B2B VNL -Save: Guardar \ No newline at end of file +Save: Guardar +New bank entity: Nueva entidad bancaria +Name can't be empty: El nombre no puede quedar vacío +Swift / BIC can't be empty: El Swift / BIC no puede quedar vacío \ No newline at end of file diff --git a/client/client/src/recovery/index/index.html b/client/client/src/recovery/index/index.html index 86f7fdf9c..5cc874dcf 100644 --- a/client/client/src/recovery/index/index.html +++ b/client/client/src/recovery/index/index.html @@ -29,7 +29,7 @@ vn-acl-action="remove" vn-tooltip="Finish that recovery period" ng-if="!recovery.finished" - on-click="$ctrl.setFinished(recovery)"> + ng-click="$ctrl.setFinished(recovery)">
{{::recovery.started | date:'dd/MM/yyyy' }} diff --git a/client/client/src/web-access/index.js b/client/client/src/web-access/index.js index 8116e6c33..ef1ccd16c 100644 --- a/client/client/src/web-access/index.js +++ b/client/client/src/web-access/index.js @@ -1,10 +1,11 @@ import ngModule from '../module'; export default class Controller { - constructor($scope, $http, vnApp) { + constructor($scope, $http, vnApp, $translate) { this.$ = $scope; this.$http = $http; this.vnApp = vnApp; + this.$translate = $translate; this.canChangePassword = false; this.canEnableCheckBox = true; } @@ -52,14 +53,14 @@ export default class Controller { this.$http.patch(`/client/api/Accounts/${this.client.id}`, account); } catch (e) { - this.vnApp.showError(e.message); + this.vnApp.showError(this.$translate.instant(e.message)); return false; } return true; } } -Controller.$inject = ['$scope', '$http', 'vnApp']; +Controller.$inject = ['$scope', '$http', 'vnApp', '$translate']; ngModule.component('vnClientWebAccess', { template: require('./index.html'), diff --git a/client/client/src/web-payment/index.html b/client/client/src/web-payment/index.html index 5311122c5..0c4e52c47 100644 --- a/client/client/src/web-payment/index.html +++ b/client/client/src/web-payment/index.html @@ -29,7 +29,7 @@ vn-acl="administrative" vn-tooltip="Confirm transaction" ng-show="::!transaction.isConfirmed" - on-click="$ctrl.confirm(transaction)"> + ng-click="$ctrl.confirm(transaction)">
{{::transaction.id}} diff --git a/client/core/src/components/icon-button/icon-button.html b/client/core/src/components/icon-button/icon-button.html index d319b4808..53bb1378e 100644 --- a/client/core/src/components/icon-button/icon-button.html +++ b/client/core/src/components/icon-button/icon-button.html @@ -1,3 +1,3 @@ - \ No newline at end of file diff --git a/client/core/src/components/icon-button/icon-button.js b/client/core/src/components/icon-button/icon-button.js index a35c1afbc..100c76179 100644 --- a/client/core/src/components/icon-button/icon-button.js +++ b/client/core/src/components/icon-button/icon-button.js @@ -5,7 +5,13 @@ export default class IconButton { constructor($element) { if ($element[0].getAttribute('tabindex') == null) $element[0].tabIndex = 0; + $element.on("keyup", event => this.onKeyDown(event, $element)); + let button = $element[0].querySelector('button'); + $element[0].addEventListener('click', event => { + if (this.disabled || button.disabled) + event.stopImmediatePropagation(); + }); } onKeyDown(event, $element) { @@ -23,8 +29,6 @@ ngModule.component('vnIconButton', { template: require('./icon-button.html'), bindings: { icon: '@', - onClick: '&?', - enabled: ' - - - \ No newline at end of file +
\ No newline at end of file diff --git a/client/item/src/search-panel/index.html b/client/item/src/search-panel/index.html index 392efb51e..e14444805 100644 --- a/client/item/src/search-panel/index.html +++ b/client/item/src/search-panel/index.html @@ -56,16 +56,14 @@ show-field="name" value-field="name"> - - - - + +