diff --git a/modules/claim/front/action/index.js b/modules/claim/front/action/index.js
index dc22cb4be6..d4b3541e04 100644
--- a/modules/claim/front/action/index.js
+++ b/modules/claim/front/action/index.js
@@ -1,16 +1,12 @@
import ngModule from '../module';
+import Section from 'salix/components/section';
import './style.scss';
-class Controller {
- constructor($stateParams, $scope, $http, $translate, vnApp, $httpParamSerializer) {
- this.$stateParams = $stateParams;
- this.$ = $scope;
- this.$http = $http;
- this.$translate = $translate;
- this.vnApp = vnApp;
- this.$httpParamSerializer = $httpParamSerializer;
+export default class Controller extends Section {
+ constructor($element, $) {
+ super($element, $);
this.filter = {
- where: {claimFk: $stateParams.id},
+ where: {claimFk: this.$params.id},
include: [
{relation: 'sale',
scope: {
@@ -34,9 +30,7 @@ class Controller {
}
getClaimedSales() {
- let json = encodeURIComponent(JSON.stringify(this.claim.id));
-
- let query = `ClaimBeginnings/${json}`;
+ let query = `ClaimBeginnings/${this.claim.id}`;
this.$http.get(query).then(res => {
if (res.data)
this.claimedSales = res.data;
@@ -54,8 +48,7 @@ class Controller {
}
deleteClaimedSale(id) {
- let json = encodeURIComponent(JSON.stringify(id));
- let query = `ClaimEnds/${json}`;
+ let query = `ClaimEnds/${id}`;
this.$http.delete(query).then(() => {
this.$.model.refresh();
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
@@ -63,7 +56,7 @@ class Controller {
}
importToNewRefundTicket() {
- let query = `ClaimBeginnings/${this.$stateParams.id}/importToNewRefundTicket`;
+ let query = `ClaimBeginnings/${this.$params.id}/importToNewRefundTicket`;
return this.$http.post(query).then(() => {
this.$.model.refresh();
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
@@ -112,7 +105,7 @@ class Controller {
}
importTicketLines(ticketFk) {
- let data = {claimFk: this.$stateParams.id, ticketFk: ticketFk};
+ let data = {claimFk: this.$params.id, ticketFk: ticketFk};
let query = `ClaimEnds/importTicketSales`;
this.$http.post(query, data).then(() => {
@@ -123,7 +116,7 @@ class Controller {
}
regularize() {
- let data = {claimFk: this.$stateParams.id};
+ let data = {claimFk: this.$params.id};
let query = `Claims/regularizeClaim`;
return this.$http.post(query, data).then(() => {
if (this.claim.responsibility >= Math.ceil(this.maxResponsibility) / 2)
@@ -137,9 +130,8 @@ class Controller {
getGreugeTypeId() {
const params = {filter: {where: {code: 'freightPickUp'}}};
- const serializedParams = this.$httpParamSerializer(params);
- const query = `GreugeTypes/findOne?${serializedParams}`;
- return this.$http.get(query).then(res => {
+ const query = `GreugeTypes/findOne`;
+ return this.$http.get(query, {params}).then(res => {
this.greugeTypeFreightId = res.data.id;
return res;
@@ -188,7 +180,7 @@ class Controller {
}
saveResponsibility(value) {
- let query = `Claims/${this.$stateParams.id}/updateClaimAction`;
+ let query = `Claims/${this.$params.id}/updateClaimAction`;
this.$http.post(query, {responsibility: value}).then(() => {
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
@@ -196,7 +188,7 @@ class Controller {
}
saveMana(value) {
- let query = `Claims/${this.$stateParams.id}/updateClaimAction`;
+ let query = `Claims/${this.$params.id}/updateClaimAction`;
this.$http.post(query, {isChargedToMana: value}).then(() => {
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
@@ -208,7 +200,7 @@ class Controller {
}
}
-Controller.$inject = ['$stateParams', '$scope', '$http', '$translate', 'vnApp', '$httpParamSerializer'];
+Controller.$inject = ['$element', '$scope'];
ngModule.component('vnClaimAction', {
template: require('./index.html'),
diff --git a/modules/claim/front/action/index.spec.js b/modules/claim/front/action/index.spec.js
index c0bcea452a..639e908271 100644
--- a/modules/claim/front/action/index.spec.js
+++ b/modules/claim/front/action/index.spec.js
@@ -18,7 +18,8 @@ describe('claim', () => {
$state = _$state_;
$state.params.id = 1;
- controller = $componentController('vnClaimAction', {$state, $scope});
+ const $element = angular.element('');
+ controller = $componentController('vnClaimAction', {$element, $scope});
controller.claim = {ticketFk: 1};
controller.$.model = {refresh: () => {}};
controller.$.addSales = {
diff --git a/modules/claim/front/basic-data/index.html b/modules/claim/front/basic-data/index.html
index 9be04cb57f..948ac6b18d 100644
--- a/modules/claim/front/basic-data/index.html
+++ b/modules/claim/front/basic-data/index.html
@@ -2,7 +2,7 @@
vn-id="watcher"
data="$ctrl.claim"
form="form"
- url="Claims/{{$ctrl.$stateParams.id}}/updateClaim"
+ url="Claims/{{$ctrl.$params.id}}/updateClaim"
save="post">
diff --git a/modules/claim/front/basic-data/index.js b/modules/claim/front/basic-data/index.js
index bc616dd5c7..c3eac92ff3 100644
--- a/modules/claim/front/basic-data/index.js
+++ b/modules/claim/front/basic-data/index.js
@@ -1,24 +1,16 @@
import ngModule from '../module';
+import Section from 'salix/components/section';
import './style.scss';
-class Controller {
- constructor($scope, $state, aclService) {
- this.$scope = $scope;
- this.$state = $state;
- this.$stateParams = $state.params;
- this.aclService = aclService;
- }
-
+class Controller extends Section {
onSubmit() {
- this.$scope.watcher.submit().then(() => {
+ this.$.watcher.submit().then(() => {
if (this.aclService.hasAny(['salesAssistant']))
this.$state.go('claim.card.detail');
});
}
}
-Controller.$inject = ['$scope', '$state', 'aclService'];
-
ngModule.component('vnClaimBasicData', {
template: require('./index.html'),
controller: Controller,
diff --git a/modules/claim/front/basic-data/index.spec.js b/modules/claim/front/basic-data/index.spec.js
index 54b6e025d7..65e934cb81 100644
--- a/modules/claim/front/basic-data/index.spec.js
+++ b/modules/claim/front/basic-data/index.spec.js
@@ -11,12 +11,13 @@ describe('Claim', () => {
beforeEach(angular.mock.inject(($componentController, $rootScope) => {
$scope = $rootScope.$new();
$scope.watcher = watcher;
- let aclService = {hasAny: () => true};
- controller = $componentController('vnClaimBasicData', {$scope, aclService});
+ const $element = angular.element('');
+ controller = $componentController('vnClaimBasicData', {$element, $scope});
}));
describe('onSubmit()', () => {
it(`should redirect to 'claim.card.detail' state`, () => {
+ jest.spyOn(controller.aclService, 'hasAny').mockReturnValue(true);
jest.spyOn(controller.$state, 'go');
controller.onSubmit();
diff --git a/modules/claim/front/detail/index.js b/modules/claim/front/detail/index.js
index 74033b565e..33b348513a 100644
--- a/modules/claim/front/detail/index.js
+++ b/modules/claim/front/detail/index.js
@@ -1,17 +1,13 @@
import ngModule from '../module';
+import Section from 'salix/components/section';
import './style.scss';
-class Controller {
- constructor($state, $, $http, $translate, vnApp, aclService) {
- this.$state = $state;
- this.$ = $;
- this.$http = $http;
- this.$translate = $translate;
- this.vnApp = vnApp;
- this.aclService = aclService;
+class Controller extends Section {
+ constructor($element, $) {
+ super($element, $);
this.edit = {};
this.filter = {
- where: {claimFk: $state.params.id},
+ where: {claimFk: this.$params.id},
include: [
{
relation: 'sale',
@@ -173,7 +169,7 @@ class Controller {
}
}
-Controller.$inject = ['$state', '$scope', '$http', '$translate', 'vnApp', 'aclService'];
+Controller.$inject = ['$element', '$scope'];
ngModule.component('vnClaimDetail', {
template: require('./index.html'),
diff --git a/modules/claim/front/detail/index.spec.js b/modules/claim/front/detail/index.spec.js
index a4d7878c58..922076b9f5 100644
--- a/modules/claim/front/detail/index.spec.js
+++ b/modules/claim/front/detail/index.spec.js
@@ -6,12 +6,10 @@ describe('claim', () => {
let $scope;
let controller;
let $httpBackend;
- let $state;
- let aclService;
beforeEach(ngModule('claim'));
- beforeEach(angular.mock.inject(($componentController, _$state_, _$httpBackend_, $rootScope) => {
+ beforeEach(angular.mock.inject(($componentController, _$httpBackend_, $rootScope) => {
$scope = $rootScope.$new();
$scope.descriptor = {
show: () => {}
@@ -19,9 +17,8 @@ describe('claim', () => {
$httpBackend = _$httpBackend_;
$httpBackend.whenGET('Claims/ClaimBeginnings').respond({});
$httpBackend.whenGET(`Tickets/1/isEditable`).respond(true);
- $state = _$state_;
- aclService = {hasAny: () => true};
- controller = $componentController('vnClaimDetail', {$state, aclService, $scope});
+ const $element = angular.element('');
+ controller = $componentController('vnClaimDetail', {$element, $scope});
controller.claim = {ticketFk: 1};
controller.salesToClaim = [{saleFk: 1}, {saleFk: 2}];
controller.salesClaimed = [{id: 1, sale: {}}];
@@ -33,6 +30,7 @@ describe('claim', () => {
controller.$.editPopover = {
hide: () => {}
};
+ jest.spyOn(controller.aclService, 'hasAny').mockReturnValue(true);
}));
describe('openAddSalesDialog()', () => {
@@ -111,7 +109,6 @@ describe('claim', () => {
quantity: 10}};
controller.newDiscount = 10;
-
jest.spyOn(controller.vnApp, 'showSuccess');
jest.spyOn(controller, 'calculateTotals');
jest.spyOn(controller, 'clearDiscount');
diff --git a/modules/claim/front/development/index.html b/modules/claim/front/development/index.html
index 38082847a4..2b504be11c 100644
--- a/modules/claim/front/development/index.html
+++ b/modules/claim/front/development/index.html
@@ -2,7 +2,7 @@
vn-id="model"
url="ClaimDevelopments"
fields="['id', 'claimFk', 'claimReasonFk', 'claimResultFk', 'claimResponsibleFk', 'workerFk', 'claimRedeliveryFk']"
- link="{claimFk: $ctrl.$state.params.id}"
+ link="{claimFk: $ctrl.$params.id}"
filter="$ctrl.filter"
data="claimDevelopments"
auto-load="true">
diff --git a/modules/claim/front/development/index.js b/modules/claim/front/development/index.js
index d6220fbca2..cc86d54525 100644
--- a/modules/claim/front/development/index.js
+++ b/modules/claim/front/development/index.js
@@ -1,18 +1,13 @@
import ngModule from '../module';
+import Section from 'salix/components/section';
import './style.scss';
-class Controller {
- constructor($state, $scope, aclService) {
- this.$state = $state;
- this.$scope = $scope;
- this.aclService = aclService;
- }
-
+class Controller extends Section {
onSubmit() {
- this.$scope.watcher.check();
- this.$scope.model.save().then(() => {
- this.$scope.watcher.notifySaved();
- this.$scope.watcher.updateOriginalData();
+ this.$.watcher.check();
+ this.$.model.save().then(() => {
+ this.$.watcher.notifySaved();
+ this.$.watcher.updateOriginalData();
if (this.aclService.hasAny(['salesAssistant']))
this.$state.go('claim.card.action');
@@ -20,8 +15,6 @@ class Controller {
}
}
-Controller.$inject = ['$state', '$scope', 'aclService'];
-
ngModule.component('vnClaimDevelopment', {
template: require('./index.html'),
controller: Controller,
diff --git a/modules/claim/front/development/index.spec.js b/modules/claim/front/development/index.spec.js
index 4d9ebdc7ee..5708f82f27 100644
--- a/modules/claim/front/development/index.spec.js
+++ b/modules/claim/front/development/index.spec.js
@@ -6,7 +6,6 @@ describe('Claim', () => {
describe('Component vnClaimDevelopment', () => {
let controller;
let $scope;
- let aclService;
beforeEach(ngModule('claim'));
@@ -14,13 +13,15 @@ describe('Claim', () => {
$scope = $rootScope.$new();
$scope.watcher = watcher;
$scope.model = crudModel;
- aclService = {hasAny: () => true};
- controller = $componentController('vnClaimDevelopment', {$scope, aclService});
+ const $element = angular.element('');
+ controller = $componentController('vnClaimDevelopment', {$element, $scope});
}));
describe('onSubmit()', () => {
it(`should redirect to 'claim.card.action' state`, () => {
+ jest.spyOn(controller.aclService, 'hasAny').mockReturnValue(true);
jest.spyOn(controller.$state, 'go');
+
controller.onSubmit();
expect(controller.$state.go).toHaveBeenCalledWith('claim.card.action');
diff --git a/modules/claim/front/dms/style.scss b/modules/claim/front/dms/style.scss
deleted file mode 100644
index 28f9db6fca..0000000000
--- a/modules/claim/front/dms/style.scss
+++ /dev/null
@@ -1,31 +0,0 @@
-@import "./variables";
-
-vn-claim-dms-index {
- .drop-zone {
- color: $color-font-secondary;
- box-sizing: border-box;
- border-radius: 0.5em;
- text-align: center;
- min-height: 100%;
-
- .empty-rows {
- padding: 5em $spacing-md;
- font-size: 1.4em
- }
-
- vn-icon {
- font-size: 3em
- }
- }
-
- .photo-list {
-
- padding: $spacing-md;
- min-height: 100%;
-
- .photo {
- width: 32em;
- height: 18em;
- }
- }
-}
\ No newline at end of file
diff --git a/modules/claim/front/index/index.js b/modules/claim/front/index/index.js
index 21464fea9d..51a0c7042a 100644
--- a/modules/claim/front/index/index.js
+++ b/modules/claim/front/index/index.js
@@ -1,11 +1,7 @@
import ngModule from '../module';
+import Section from 'salix/components/section';
-export default class Controller {
- constructor($scope) {
- this.$ = $scope;
- this.ticketSelected = null;
- }
-
+export default class Controller extends Section {
stateColor(claim) {
switch (claim.description) {
case 'Pendiente':
@@ -52,8 +48,6 @@ export default class Controller {
}
}
-Controller.$inject = ['$scope'];
-
ngModule.component('vnClaimIndex', {
template: require('./index.html'),
controller: Controller
diff --git a/modules/claim/front/photos/index.html b/modules/claim/front/photos/index.html
index 447538bd1f..4a6e3e7b24 100644
--- a/modules/claim/front/photos/index.html
+++ b/modules/claim/front/photos/index.html
@@ -1,10 +1,9 @@
-
+ ng-style="{'background': 'url(/api/dms/' + photo.dmsFk + '/downloadFile?access_token=' + $ctrl.vnToken.token + ')'}"
+ zoom-image="/api/dms/{{::photo.dmsFk}}/downloadFile?access_token={{::$ctrl.vnToken.token}}">
{
$httpParamSerializer = _$httpParamSerializer_;
$httpBackend = _$httpBackend_;
$scope = $rootScope.$new();
- controller = $componentController('vnClaimPhotos', {$: $scope});
+ const $element = angular.element('');
+ controller = $componentController('vnClaimPhotos', {$element, $scope});
controller.$.model = crudModel;
controller.claim = {
id: 1,
diff --git a/modules/claim/front/summary/index.html b/modules/claim/front/summary/index.html
index 20dca702bb..6f639c709e 100644
--- a/modules/claim/front/summary/index.html
+++ b/modules/claim/front/summary/index.html
@@ -86,8 +86,8 @@
+ ng-style="{'background': 'url(/api/dms/' + photo.dmsFk + '/downloadFile?access_token=' + $ctrl.vnToken.token + ')'}"
+ zoom-image="/api/dms/{{::photo.dmsFk}}/downloadFile?access_token={{::$ctrl.vnToken.token}}">
diff --git a/modules/claim/front/summary/index.js b/modules/claim/front/summary/index.js
index 448ce9b387..06dedfbce8 100644
--- a/modules/claim/front/summary/index.js
+++ b/modules/claim/front/summary/index.js
@@ -1,34 +1,8 @@
import ngModule from '../module';
+import Section from 'salix/components/section';
import './style.scss';
-class Controller {
- constructor($scope, $http, $stateParams, vnToken) {
- this.$http = $http;
- this.$ = $scope;
- this.$stateParams = $stateParams;
- this.accessToken = vnToken.token;
- }
-
- get claim() {
- return this._claim;
- }
-
-
- set claim(value) {
- this._claim = value;
-
- // Get DMS on summary load
- if (value)
- this.$.$applyAsync(() => this.loadDms());
- }
-
- loadDms() {
- this.$.model.where = {
- claimFk: this.claim.id
- };
- this.$.model.refresh();
- }
-
+class Controller extends Section {
getSummary() {
this.$http.get(`Claims/${this.claim.id}/getSummary`).then(response => {
this.summary = response.data;
@@ -36,8 +10,13 @@ class Controller {
}
$onChanges() {
- if (this.claim && this.claim.id)
+ if (this.claim && this.claim.id) {
this.getSummary();
+ this.$.model.where = {
+ claimFk: this.claim.id
+ };
+ this.$.model.refresh();
+ }
}
showItemDescriptor(event, itemFk) {
@@ -59,8 +38,6 @@ class Controller {
}
}
-Controller.$inject = ['$scope', '$http', '$stateParams', 'vnToken'];
-
ngModule.component('vnClaimSummary', {
template: require('./index.html'),
controller: Controller,
diff --git a/modules/claim/front/summary/index.spec.js b/modules/claim/front/summary/index.spec.js
index f1897a3e09..8b83695163 100644
--- a/modules/claim/front/summary/index.spec.js
+++ b/modules/claim/front/summary/index.spec.js
@@ -5,13 +5,16 @@ describe('Claim', () => {
describe('Component summary', () => {
let controller;
let $httpBackend;
+ let $scope;
beforeEach(ngModule('claim'));
- beforeEach(angular.mock.inject(($componentController, _$httpBackend_) => {
+ beforeEach(angular.mock.inject(($componentController, _$httpBackend_, $rootScope) => {
+ $scope = $rootScope.$new();
$httpBackend = _$httpBackend_;
- controller = $componentController('vnClaimSummary');
- controller.claim = {id: 1};
+ const $element = angular.element('');
+ controller = $componentController('vnClaimSummary', {$element, $scope});
+ controller._claim = {id: 1};
controller.$.model = crudModel;
}));
@@ -29,6 +32,7 @@ describe('Claim', () => {
describe('$onChanges()', () => {
it('should call getSummary when item.id is defined', () => {
jest.spyOn(controller, 'getSummary');
+
controller.$onChanges();
expect(controller.getSummary).toHaveBeenCalledWith();