From 5b38889a7274f9c3e588889af91aa9248c2e434e Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Mon, 30 Sep 2019 14:49:04 +0200 Subject: [PATCH] #1739 claim.detail dialog add cambiar campos --- modules/claim/front/detail/index.html | 12 ++++++---- modules/claim/front/detail/index.js | 4 ++-- modules/claim/front/detail/index.spec.js | 28 ++++++++++++++++++++++-- 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/modules/claim/front/detail/index.html b/modules/claim/front/detail/index.html index 5fc032e33..f4aea3247 100644 --- a/modules/claim/front/detail/index.html +++ b/modules/claim/front/detail/index.html @@ -45,7 +45,7 @@ + ng-click="$ctrl.showItemDescriptor($event, saleClaimed.sale.itemFk)"> {{::saleClaimed.sale.concept}} @@ -87,7 +87,6 @@ - Id Landed Quantity Description @@ -98,10 +97,15 @@ - {{sale.saleFk}} {{sale.landed | dateTime: 'dd/MM/yyyy'}} {{sale.quantity}} - {{sale.concept}} + + + {{sale.concept}} + + {{sale.price | currency: 'EUR':2}} {{sale.discount}} % diff --git a/modules/claim/front/detail/index.js b/modules/claim/front/detail/index.js index 137ad4d70..1c2cb9e97 100644 --- a/modules/claim/front/detail/index.js +++ b/modules/claim/front/detail/index.js @@ -111,8 +111,8 @@ class Controller { return total; } - // Item Descriptor - showDescriptor(event, itemFk) { + showItemDescriptor(event, itemFk) { + event.stopImmediatePropagation(); this.$.descriptor.itemFk = itemFk; this.$.descriptor.parent = event.target; this.$.descriptor.show(); diff --git a/modules/claim/front/detail/index.spec.js b/modules/claim/front/detail/index.spec.js index c25d6fe43..bb3866b4c 100644 --- a/modules/claim/front/detail/index.spec.js +++ b/modules/claim/front/detail/index.spec.js @@ -3,6 +3,7 @@ import crudModel from 'core/mocks/crud-model'; describe('claim', () => { describe('Component vnClaimDetail', () => { + let $scope; let controller; let $httpBackend; let $state; @@ -12,12 +13,16 @@ describe('claim', () => { $translateProvider.translations('en', {}); })); - beforeEach(angular.mock.inject(($componentController, _$state_, _$httpBackend_) => { + beforeEach(angular.mock.inject(($componentController, _$state_, _$httpBackend_, $rootScope) => { + $scope = $rootScope.$new(); + $scope.descriptor = { + show: () => {} + }; $httpBackend = _$httpBackend_; $httpBackend.when('GET', 'claim/api/Claims/ClaimBeginnings').respond({}); $state = _$state_; aclService = {hasAny: () => true}; - controller = $componentController('vnClaimDetail', {$state, aclService}); + controller = $componentController('vnClaimDetail', {$state, aclService, $scope}); controller.salesToClaim = [{saleFk: 1}, {saleFk: 2}]; controller.salesClaimed = [{id: 1, sale: {}}]; controller.claim = {ticketFk: 1}; @@ -119,5 +124,24 @@ describe('claim', () => { expect(controller.$.model.refresh).toHaveBeenCalledWith(); }); }); + + describe('showItemDescriptor()', () => { + it('should configure the descriptor then show it', () => { + const itemId = 500; + const event = { + stopImmediatePropagation: () => {}, + target: 'the target element' + }; + spyOn(event, 'stopImmediatePropagation'); + spyOn(controller.$.descriptor, 'show'); + + controller.showItemDescriptor(event, itemId); + + expect(event.stopImmediatePropagation).toHaveBeenCalledWith(); + expect(controller.$.descriptor.itemFk).toEqual(itemId); + expect(controller.$.descriptor.parent).toEqual(event.target); + expect(controller.$.descriptor.show).toHaveBeenCalledWith(); + }); + }); }); });