From f25c8bb644fb26482b7621b05399aa3b8390f811 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Wed, 18 Mar 2020 08:35:59 +0100 Subject: [PATCH] Ticket refactor --- modules/client/front/balance/create/index.js | 9 +- modules/ticket/front/basic-data/index.js | 10 +-- .../ticket/front/basic-data/step-one/index.js | 12 +-- .../front/basic-data/step-one/index.spec.js | 3 +- .../ticket/front/basic-data/step-two/index.js | 14 +-- .../front/basic-data/step-two/index.spec.js | 3 +- modules/ticket/front/component/index.html | 2 +- modules/ticket/front/component/index.js | 20 ++--- modules/ticket/front/component/index.spec.js | 3 +- modules/ticket/front/create/card.js | 20 ++--- modules/ticket/front/create/index.js | 10 +-- .../ticket/front/descriptor-popover/index.js | 6 +- .../ticket/front/descriptor/addStowaway.html | 2 +- .../ticket/front/descriptor/addStowaway.js | 13 +-- modules/ticket/front/descriptor/index.js | 3 +- modules/ticket/front/dms/create/index.js | 14 +-- modules/ticket/front/dms/create/index.spec.js | 3 +- modules/ticket/front/dms/edit/index.js | 18 +--- modules/ticket/front/dms/edit/index.spec.js | 6 +- modules/ticket/front/dms/index/index.html | 4 +- modules/ticket/front/dms/index/index.js | 14 +-- modules/ticket/front/dms/index/index.spec.js | 7 +- modules/ticket/front/expedition/index.html | 2 +- modules/ticket/front/expedition/index.js | 11 +-- modules/ticket/front/expedition/index.spec.js | 7 +- modules/ticket/front/index/index.js | 14 +-- modules/ticket/front/index/index.spec.js | 3 +- modules/ticket/front/log/index.js | 12 +-- modules/ticket/front/note/index.html | 2 +- modules/ticket/front/note/index.js | 19 ++-- modules/ticket/front/package/index.html | 2 +- modules/ticket/front/package/index.js | 21 ++--- modules/ticket/front/picture/index.html | 2 +- modules/ticket/front/picture/index.js | 19 ++-- modules/ticket/front/request/create/index.js | 16 ++-- modules/ticket/front/request/index/index.html | 2 +- modules/ticket/front/request/index/index.js | 12 ++- .../ticket/front/request/index/index.spec.js | 8 +- modules/ticket/front/sale-checked/index.html | 2 +- modules/ticket/front/sale-checked/index.js | 18 ++-- modules/ticket/front/sale-tracking/index.html | 2 +- modules/ticket/front/sale-tracking/index.js | 10 +-- modules/ticket/front/sale/editDiscount.js | 15 +--- modules/ticket/front/sale/index.html | 2 +- modules/ticket/front/sale/index.js | 86 +++++++++---------- .../front/sale/specs/editDiscount.spec.js | 3 +- modules/ticket/front/sale/specs/index.spec.js | 19 ++-- modules/ticket/front/services/index.html | 2 +- modules/ticket/front/services/index.js | 30 +++---- modules/ticket/front/sms/index.js | 15 +--- modules/ticket/front/sms/index.spec.js | 7 +- modules/ticket/front/summary/index.js | 33 +++---- modules/ticket/front/summary/index.spec.js | 3 +- modules/ticket/front/tracking/edit/index.js | 16 ++-- .../ticket/front/tracking/edit/index.spec.js | 3 +- .../ticket/front/tracking/index/index.html | 2 +- modules/ticket/front/tracking/index/index.js | 10 +-- modules/ticket/front/volume/index.html | 6 +- modules/ticket/front/volume/index.js | 20 ++--- modules/ticket/front/volume/index.spec.js | 3 +- modules/ticket/front/weekly/index.js | 15 +--- 61 files changed, 243 insertions(+), 427 deletions(-) diff --git a/modules/client/front/balance/create/index.js b/modules/client/front/balance/create/index.js index f4c103bb4..1a7d8b97b 100644 --- a/modules/client/front/balance/create/index.js +++ b/modules/client/front/balance/create/index.js @@ -7,9 +7,9 @@ class Controller extends Section { super($element, $); this.receipt = { payed: new Date(), - clientFk: this.$state.params.id, - companyFk: vnConfig.companyFk, - bankFk: vnConfig.bankFk + clientFk: this.$params.id, + companyFk: this.vnConfig.companyFk, + bankFk: this.vnConfig.bankFk }; } @@ -53,7 +53,7 @@ class Controller extends Section { getAmountPaid() { let filter = { where: { - clientFk: this.$state.params.id, + clientFk: this.$params.id, companyFk: this.receipt.companyFk } }; @@ -82,7 +82,6 @@ class Controller extends Section { }); } } -Controller.$inject = ['$element', '$scope']; ngModule.component('vnClientBalanceCreate', { template: require('./index.html'), diff --git a/modules/ticket/front/basic-data/index.js b/modules/ticket/front/basic-data/index.js index 4965ee61e..4deebff17 100644 --- a/modules/ticket/front/basic-data/index.js +++ b/modules/ticket/front/basic-data/index.js @@ -1,11 +1,7 @@ import ngModule from '../module'; +import Section from 'salix/components/section'; -class Controller { - constructor($scope, $state) { - this.$scope = $scope; - this.$state = $state; - } - +class Controller extends Section { set ticket(data) { if (!data) return; @@ -25,8 +21,6 @@ class Controller { } } -Controller.$inject = ['$scope', '$state']; - ngModule.component('vnTicketBasicData', { template: require('./index.html'), bindings: { diff --git a/modules/ticket/front/basic-data/step-one/index.js b/modules/ticket/front/basic-data/step-one/index.js index b8fffd2c1..f6655a221 100644 --- a/modules/ticket/front/basic-data/step-one/index.js +++ b/modules/ticket/front/basic-data/step-one/index.js @@ -1,14 +1,8 @@ import ngModule from '../../module'; +import Component from 'core/lib/component'; import './style.scss'; -class Controller { - constructor($scope, $http, $translate, vnApp) { - this.$scope = $scope; - this.$http = $http; - this.$translate = $translate; - this.vnApp = vnApp; - } - +class Controller extends Component { $onInit() { this.basicData.registerChild(this); } @@ -247,8 +241,6 @@ class Controller { } } -Controller.$inject = ['$scope', '$http', '$translate', 'vnApp']; - ngModule.component('vnTicketBasicDataStepOne', { template: require('./index.html'), controller: Controller, diff --git a/modules/ticket/front/basic-data/step-one/index.spec.js b/modules/ticket/front/basic-data/step-one/index.spec.js index b1931d0bb..a0673cbbe 100644 --- a/modules/ticket/front/basic-data/step-one/index.spec.js +++ b/modules/ticket/front/basic-data/step-one/index.spec.js @@ -13,7 +13,8 @@ describe('Ticket', () => { $state = _$state_; $httpBackend = _$httpBackend_; $httpParamSerializer = _$httpParamSerializer_; - controller = $componentController('vnTicketBasicDataStepOne', {$state}); + const $element = angular.element(''); + controller = $componentController('vnTicketBasicDataStepOne', {$element}); controller.ticket = { addressFk: 121, agencyModeFk: 7, diff --git a/modules/ticket/front/basic-data/step-two/index.js b/modules/ticket/front/basic-data/step-two/index.js index f766f5726..00556350b 100644 --- a/modules/ticket/front/basic-data/step-two/index.js +++ b/modules/ticket/front/basic-data/step-two/index.js @@ -1,13 +1,7 @@ import ngModule from '../../module'; +import Component from 'core/lib/component'; -class Controller { - constructor($http, $state, $translate, vnApp) { - this.$http = $http; - this.$state = $state; - this.$translate = $translate; - this.vnApp = vnApp; - } - +class Controller extends Component { $onInit() { this.data.registerChild(this); } @@ -92,13 +86,11 @@ class Controller { this.$translate.instant(`The ticket has been unrouted`) ); this.card.reload(); - this.$state.go('ticket.card.summary', {id: this.$state.params.id}); + this.$state.go('ticket.card.summary', {id: this.$params.id}); }); } } -Controller.$inject = ['$http', '$state', '$translate', 'vnApp']; - ngModule.component('vnTicketBasicDataStepTwo', { template: require('./index.html'), controller: Controller, diff --git a/modules/ticket/front/basic-data/step-two/index.spec.js b/modules/ticket/front/basic-data/step-two/index.spec.js index 1ca89fd90..e67389f9d 100644 --- a/modules/ticket/front/basic-data/step-two/index.spec.js +++ b/modules/ticket/front/basic-data/step-two/index.spec.js @@ -7,7 +7,8 @@ describe('Ticket', () => { beforeEach(ngModule('ticket')); beforeEach(angular.mock.inject($componentController => { - controller = $componentController('vnTicketBasicDataStepTwo'); + const $element = angular.element(''); + controller = $componentController('vnTicketBasicDataStepTwo', {$element}); })); describe('getTotalPrice()', () => { diff --git a/modules/ticket/front/component/index.html b/modules/ticket/front/component/index.html index 16db43a2e..e555eb8d7 100644 --- a/modules/ticket/front/component/index.html +++ b/modules/ticket/front/component/index.html @@ -1,7 +1,7 @@ diff --git a/modules/ticket/front/component/index.js b/modules/ticket/front/component/index.js index 027fdad77..d0b6ed880 100644 --- a/modules/ticket/front/component/index.js +++ b/modules/ticket/front/component/index.js @@ -1,10 +1,10 @@ import ngModule from '../module'; +import Section from 'salix/components/section'; import './style.scss'; -class Controller { - constructor($scope, $stateParams) { - this.$stateParams = $stateParams; - this.$scope = $scope; +class Controller extends Section { + constructor($element, $) { + super($element, $); this.filter = { order: 'concept ASC', include: [{ @@ -32,7 +32,7 @@ class Controller { } base() { - let sales = this.$scope.model.data; + let sales = this.$.model.data; let sum = 0; if (!sales) return; @@ -59,18 +59,16 @@ class Controller { tooltip: 'Item diary' } }; - this.$scope.descriptor.itemFk = itemFk; - this.$scope.descriptor.parent = event.target; - this.$scope.descriptor.show(); + this.$.descriptor.itemFk = itemFk; + this.$.descriptor.parent = event.target; + this.$.descriptor.show(); } onDescriptorLoad() { - this.$scope.popover.relocate(); + this.$.popover.relocate(); } } -Controller.$inject = ['$scope', '$stateParams']; - ngModule.component('vnTicketComponents', { template: require('./index.html'), controller: Controller, diff --git a/modules/ticket/front/component/index.spec.js b/modules/ticket/front/component/index.spec.js index 4dd361b27..3547a4905 100644 --- a/modules/ticket/front/component/index.spec.js +++ b/modules/ticket/front/component/index.spec.js @@ -75,7 +75,8 @@ describe('ticket', () => { ], quantity: 5 }]; - controller = $componentController('vnTicketComponents', {$scope}); + const $element = angular.element(''); + controller = $componentController('vnTicketComponents', {$element, $scope}); })); describe('base()', () => { diff --git a/modules/ticket/front/create/card.js b/modules/ticket/front/create/card.js index 54cc56c68..ef1dfb771 100644 --- a/modules/ticket/front/create/card.js +++ b/modules/ticket/front/create/card.js @@ -1,20 +1,16 @@ import ngModule from '../module'; +import Component from 'core/lib/component'; -class Controller { - constructor($http, vnApp, $translate, $state, $stateParams, vnConfig) { - this.$stateParams = $stateParams; - this.$http = $http; - this.translate = $translate; - this.vnApp = vnApp; - this.vnConfig = vnConfig; +class Controller extends Component { + constructor($element, $) { + super($element, $); this.ticket = {}; - this.$state = $state; - this.clientFk = $stateParams.clientFk; + this.clientFk = this.$params.clientFk; } $onInit() { - if (this.$stateParams && this.$stateParams.clientFk) - this.clientId = parseInt(this.$stateParams.clientFk); + if (this.$params && this.$params.clientFk) + this.clientId = parseInt(this.$params.clientFk); this.warehouseId = this.vnConfig.warehouseFk; } @@ -130,8 +126,6 @@ class Controller { } } -Controller.$inject = ['$http', 'vnApp', '$translate', '$state', '$stateParams', 'vnConfig']; - ngModule.component('vnTicketCreateCard', { template: require('./card.html'), controller: Controller, diff --git a/modules/ticket/front/create/index.js b/modules/ticket/front/create/index.js index bb9b4c76e..c93051d7a 100644 --- a/modules/ticket/front/create/index.js +++ b/modules/ticket/front/create/index.js @@ -1,18 +1,12 @@ import ngModule from '../module'; +import Section from 'salix/components/section'; -class Controller { - constructor($scope, $http, $state) { - this.$ = $scope; - this.$http = $http; - this.$state = $state; - } - +class Controller extends Section { async onSubmit() { let newTicketID = await this.$.card.createTicket(); this.$state.go('ticket.card.summary', {id: newTicketID}); } } -Controller.$inject = ['$scope', '$http', '$state']; ngModule.component('vnTicketCreate', { template: require('./index.html'), diff --git a/modules/ticket/front/descriptor-popover/index.js b/modules/ticket/front/descriptor-popover/index.js index 5b94f3c14..622222e21 100644 --- a/modules/ticket/front/descriptor-popover/index.js +++ b/modules/ticket/front/descriptor-popover/index.js @@ -3,11 +3,8 @@ import Component from 'core/lib/component'; import './style.scss'; class Controller extends Component { - constructor($element, $scope, $http, $timeout, $q) { + constructor($element, $scope) { super($element, $scope); - this.$timeout = $timeout; - this.$http = $http; - this.$q = $q; this.ticket = null; this._quicklinks = {}; } @@ -106,7 +103,6 @@ class Controller extends Component { ); } } -Controller.$inject = ['$element', '$scope', '$http', '$timeout', '$q']; ngModule.component('vnTicketDescriptorPopover', { template: require('./index.html'), diff --git a/modules/ticket/front/descriptor/addStowaway.html b/modules/ticket/front/descriptor/addStowaway.html index ec7005e79..d15d7185d 100644 --- a/modules/ticket/front/descriptor/addStowaway.html +++ b/modules/ticket/front/descriptor/addStowaway.html @@ -1,5 +1,5 @@ this.vnApp.showMessage(this.$translate.instant('Notification sent!')) ); } diff --git a/modules/ticket/front/dms/create/index.js b/modules/ticket/front/dms/create/index.js index f1b59f6c0..e745d98b8 100644 --- a/modules/ticket/front/dms/create/index.js +++ b/modules/ticket/front/dms/create/index.js @@ -1,13 +1,9 @@ import ngModule from '../../module'; +import Section from 'salix/components/section'; -class Controller { - constructor($scope, $http, $state, $translate, vnApp, vnConfig) { - this.$ = $scope; - this.$http = $http; - this.$state = $state; - this.$translate = $translate; - this.vnApp = vnApp; - this.vnConfig = vnConfig; +class Controller extends Section { + constructor($element, $) { + super($element, $); this.dms = { files: [], hasFile: false, @@ -103,8 +99,6 @@ class Controller { } } -Controller.$inject = ['$scope', '$http', '$state', '$translate', 'vnApp', 'vnConfig']; - ngModule.component('vnTicketDmsCreate', { template: require('./index.html'), controller: Controller, diff --git a/modules/ticket/front/dms/create/index.spec.js b/modules/ticket/front/dms/create/index.spec.js index f0d7ad7c5..c6cb1da5a 100644 --- a/modules/ticket/front/dms/create/index.spec.js +++ b/modules/ticket/front/dms/create/index.spec.js @@ -13,7 +13,8 @@ describe('Ticket', () => { $scope = $rootScope.$new(); $httpBackend = _$httpBackend_; $httpParamSerializer = _$httpParamSerializer_; - controller = $componentController('vnTicketDmsCreate', {$scope}); + const $element = angular.element(''); + controller = $componentController('vnTicketDmsCreate', {$element}); controller._ticket = { id: 15, client: {id: 101, name: 'Bruce wayne'}, diff --git a/modules/ticket/front/dms/edit/index.js b/modules/ticket/front/dms/edit/index.js index 9ff967816..44e3890f8 100644 --- a/modules/ticket/front/dms/edit/index.js +++ b/modules/ticket/front/dms/edit/index.js @@ -1,15 +1,7 @@ import ngModule from '../../module'; +import Section from 'salix/components/section'; -class Controller { - constructor($scope, $http, $state, $translate, vnApp) { - this.$ = $scope; - this.$http = $http; - this.$state = $state; - this.$stateParams = $state.params; - this.$translate = $translate; - this.vnApp = vnApp; - } - +class Controller extends Section { get ticket() { return this._ticket; } @@ -37,7 +29,7 @@ class Controller { } setDefaultParams() { - const path = `Dms/${this.$stateParams.dmsId}`; + const path = `Dms/${this.$params.dmsId}`; this.$http.get(path).then(res => { const dms = res.data && res.data; this.dms = { @@ -54,7 +46,7 @@ class Controller { } onSubmit() { - const query = `dms/${this.$stateParams.dmsId}/updateFile`; + const query = `dms/${this.$params.dmsId}/updateFile`; const options = { method: 'POST', url: query, @@ -92,8 +84,6 @@ class Controller { } } -Controller.$inject = ['$scope', '$http', '$state', '$translate', 'vnApp']; - ngModule.component('vnTicketDmsEdit', { template: require('./index.html'), controller: Controller, diff --git a/modules/ticket/front/dms/edit/index.spec.js b/modules/ticket/front/dms/edit/index.spec.js index 757ca24ef..20224a4b9 100644 --- a/modules/ticket/front/dms/edit/index.spec.js +++ b/modules/ticket/front/dms/edit/index.spec.js @@ -5,16 +5,16 @@ describe('Ticket', () => { let controller; let $scope; let $httpBackend; - let $state; beforeEach(ngModule('ticket')); beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_) => { $scope = $rootScope.$new(); $httpBackend = _$httpBackend_; - $state = {params: {dmsId: 1}}; - controller = $componentController('vnTicketDmsEdit', {$scope, $state}); + const $element = angular.element(''); + controller = $componentController('vnTicketDmsEdit', {$element}); controller._ticket = {id: 1, ticketFk: 16}; + controller.$params = {dmsId: 1}; })); describe('ticket() setter', () => { diff --git a/modules/ticket/front/dms/index/index.html b/modules/ticket/front/dms/index/index.html index 4e4834510..090d5298a 100644 --- a/modules/ticket/front/dms/index/index.html +++ b/modules/ticket/front/dms/index/index.html @@ -54,7 +54,7 @@ + href="api/dms/{{::document.dmsFk}}/downloadFile?access_token={{::$ctrl.vnToken.token}}"> {{::document.dms.file}} @@ -68,7 +68,7 @@ + href="api/dms/{{::document.dmsFk}}/downloadFile?access_token={{::$ctrl.vnToken.token}}"> diff --git a/modules/ticket/front/dms/index/index.js b/modules/ticket/front/dms/index/index.js index c6ceb6b0d..a37d15426 100644 --- a/modules/ticket/front/dms/index/index.js +++ b/modules/ticket/front/dms/index/index.js @@ -1,14 +1,10 @@ import ngModule from '../../module'; +import Section from 'salix/components/section'; import './style.scss'; -class Controller { - constructor($stateParams, $scope, $http, $translate, vnToken, vnApp) { - this.$stateParams = $stateParams; - this.$ = $scope; - this.$http = $http; - this.$translate = $translate; - this.accessToken = vnToken.token; - this.vnApp = vnApp; +class Controller extends Section { + constructor($element, $) { + super($element, $); this.filter = { include: { relation: 'dms', @@ -71,8 +67,6 @@ class Controller { } } -Controller.$inject = ['$stateParams', '$scope', '$http', '$translate', 'vnToken', 'vnApp']; - ngModule.component('vnTicketDmsIndex', { template: require('./index.html'), controller: Controller, diff --git a/modules/ticket/front/dms/index/index.spec.js b/modules/ticket/front/dms/index/index.spec.js index 8916a5c63..1cb231965 100644 --- a/modules/ticket/front/dms/index/index.spec.js +++ b/modules/ticket/front/dms/index/index.spec.js @@ -4,17 +4,16 @@ import crudModel from 'core/mocks/crud-model'; describe('Ticket', () => { describe('Component vnTicketDmsIndex', () => { let $componentController; - let $scope; let $httpBackend; let controller; beforeEach(ngModule('ticket')); - beforeEach(angular.mock.inject((_$componentController_, $rootScope, _$httpBackend_) => { + beforeEach(angular.mock.inject((_$componentController_, _$httpBackend_) => { $componentController = _$componentController_; $httpBackend = _$httpBackend_; - $scope = $rootScope.$new(); - controller = $componentController('vnTicketDmsIndex', {$: $scope}); + const $element = angular.element(''); + controller = $componentController('vnTicketDmsIndex', {$element}); controller.$.model = crudModel; })); diff --git a/modules/ticket/front/expedition/index.html b/modules/ticket/front/expedition/index.html index b2e859970..a90d48670 100644 --- a/modules/ticket/front/expedition/index.html +++ b/modules/ticket/front/expedition/index.html @@ -1,7 +1,7 @@ { describe('Component vnTicketExpedition', () => { let controller; let $scope; - let $state; let $httpBackend; beforeEach(ngModule('ticket')); - beforeEach(angular.mock.inject(($componentController, $rootScope, _$state_, _$httpBackend_) => { - $state = _$state_; + beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_) => { $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); $scope.model = { refresh: () => {} }; - controller = $componentController('vnTicketExpedition', {$state, $scope}); + const $element = angular.element(''); + controller = $componentController('vnTicketExpedition', {$element, $scope}); })); describe('returnDialog()', () => { diff --git a/modules/ticket/front/index/index.js b/modules/ticket/front/index/index.js index 563265ab3..deb9a9aea 100644 --- a/modules/ticket/front/index/index.js +++ b/modules/ticket/front/index/index.js @@ -1,17 +1,9 @@ import ngModule from '../module'; +import Section from 'salix/components/section'; import UserError from 'core/lib/user-error'; import './style.scss'; -export default class Controller { - constructor($scope, $state, $stateParams, $translate, $http) { - this.$ = $scope; - this.$http = $http; - this.$translate = $translate; - this.$stateParams = $stateParams; - this.$state = $state; - this.selectedTicket = null; - } - +export default class Controller extends Section { openBalanceDialog() { const checkedTickets = this.checked; const description = []; @@ -147,8 +139,6 @@ export default class Controller { } } -Controller.$inject = ['$scope', '$state', '$stateParams', '$translate', '$http']; - ngModule.component('vnTicketIndex', { template: require('./index.html'), controller: Controller diff --git a/modules/ticket/front/index/index.spec.js b/modules/ticket/front/index/index.spec.js index 6b0b42ffd..1cb57926b 100644 --- a/modules/ticket/front/index/index.spec.js +++ b/modules/ticket/front/index/index.spec.js @@ -23,7 +23,8 @@ describe('Component vnTicketIndex', () => { beforeEach(inject(($componentController, _$window_) => { $window = _$window_; - controller = $componentController('vnTicketIndex'); + const $element = angular.element(''); + controller = $componentController('vnTicketIndex', {$element}); })); describe('compareDate()', () => { diff --git a/modules/ticket/front/log/index.js b/modules/ticket/front/log/index.js index 6a486d3d0..df2584481 100644 --- a/modules/ticket/front/log/index.js +++ b/modules/ticket/front/log/index.js @@ -1,15 +1,7 @@ import ngModule from '../module'; - -class Controller { - constructor($scope, $stateParams) { - this.$scope = $scope; - this.$stateParams = $stateParams; - } -} - -Controller.$inject = ['$scope', '$stateParams']; +import Section from 'salix/components/section'; ngModule.component('vnTicketLog', { template: require('./index.html'), - controller: Controller, + controller: Section, }); diff --git a/modules/ticket/front/note/index.html b/modules/ticket/front/note/index.html index 617cf2f7d..32d93c630 100644 --- a/modules/ticket/front/note/index.html +++ b/modules/ticket/front/note/index.html @@ -2,7 +2,7 @@ vn-id="model" url="TicketObservations" fields="['id', 'ticketFk', 'observationTypeFk', 'description']" - link="{ticketFk: $ctrl.$stateParams.id}" + link="{ticketFk: $ctrl.$params.id}" data="observations" auto-load="true"> diff --git a/modules/ticket/front/note/index.js b/modules/ticket/front/note/index.js index 4a74b3b98..399284abd 100644 --- a/modules/ticket/front/note/index.js +++ b/modules/ticket/front/note/index.js @@ -1,22 +1,15 @@ import ngModule from '../module'; +import Section from 'salix/components/section'; -class Controller { - constructor($stateParams, $scope) { - this.$stateParams = $stateParams; - this.$scope = $scope; - } - +class Controller extends Section { onSubmit() { - this.$scope.watcher.check(); - this.$scope.model.save().then(() => { - this.$scope.watcher.notifySaved(); - this.$scope.model.refresh(); - }); + this.$.watcher.check(); + this.$.model.save().then(() => + this.$.watcher.notifySaved() + ); } } -Controller.$inject = ['$stateParams', '$scope']; - ngModule.component('vnTicketObservation', { template: require('./index.html'), controller: Controller, diff --git a/modules/ticket/front/package/index.html b/modules/ticket/front/package/index.html index 12ac13862..84d79fce3 100644 --- a/modules/ticket/front/package/index.html +++ b/modules/ticket/front/package/index.html @@ -2,7 +2,7 @@ vn-id="model" url="TicketPackagings" fields="['id', 'ticketFk', 'packagingFk', 'quantity', 'created']" - link="{ticketFk: $ctrl.$stateParams.id}" + link="{ticketFk: $ctrl.$params.id}" data="packages" auto-load="true"> diff --git a/modules/ticket/front/package/index.js b/modules/ticket/front/package/index.js index d73c000c7..3ad64202e 100644 --- a/modules/ticket/front/package/index.js +++ b/modules/ticket/front/package/index.js @@ -1,13 +1,9 @@ import ngModule from '../module'; +import Section from 'salix/components/section'; -class Controller { - constructor($scope, $stateParams) { - this.$scope = $scope; - this.$stateParams = $stateParams; - } - +class Controller extends Section { add() { - this.$scope.model.insert({ + this.$.model.insert({ packagingFk: null, quantity: null, created: new Date(), @@ -16,16 +12,13 @@ class Controller { } onSubmit() { - this.$scope.watcher.check(); - this.$scope.model.save().then(() => { - this.$scope.watcher.notifySaved(); - this.$scope.model.refresh(); - }); + this.$.watcher.check(); + this.$.model.save().then(() => + this.$.watcher.notifySaved() + ); } } -Controller.$inject = ['$scope', '$stateParams']; - ngModule.component('vnTicketPackage', { template: require('./index.html'), controller: Controller diff --git a/modules/ticket/front/picture/index.html b/modules/ticket/front/picture/index.html index 67ce5464e..58e13a451 100644 --- a/modules/ticket/front/picture/index.html +++ b/modules/ticket/front/picture/index.html @@ -1,7 +1,7 @@ this.$state.go('ticket.card.request.index', {id: this.$state.params.id}) + this.$.watcher.submit().then(() => + this.$state.go('ticket.card.request.index', {id: this.$params.id}) ); } } -Controller.$inject = ['$state', '$scope']; - ngModule.component('vnTicketRequestCreate', { template: require('./index.html'), controller: Controller diff --git a/modules/ticket/front/request/index/index.html b/modules/ticket/front/request/index/index.html index 395338116..0acb661e3 100644 --- a/modules/ticket/front/request/index/index.html +++ b/modules/ticket/front/request/index/index.html @@ -3,7 +3,7 @@ url="TicketRequests" fields="['id', 'description', 'created', 'requesterFk', 'attenderFk', 'quantity', 'price', 'saleFk', 'isOk']" order="created ASC" - link="{ticketFk: $ctrl.$stateParams.id}" + link="{ticketFk: $ctrl.$params.id}" filter="::$ctrl.filter" data="purchaseRequests" auto-load="true"> diff --git a/modules/ticket/front/request/index/index.js b/modules/ticket/front/request/index/index.js index e8cb54f22..c2e6dc123 100644 --- a/modules/ticket/front/request/index/index.js +++ b/modules/ticket/front/request/index/index.js @@ -1,9 +1,9 @@ import ngModule from '../../module'; +import Section from 'salix/components/section'; -class Controller { - constructor($scope, $stateParams) { - this.$stateParams = $stateParams; - this.$ = $scope; +class Controller extends Section { + constructor($element, $) { + super($element, $); this.filter = { include: [ { @@ -50,7 +50,7 @@ class Controller { icon: 'icon-transaction', state: `item.card.diary({ id: ${itemFk}, - ticketFk: ${this.$stateParams.id} + ticketFk: ${this.$params.id} })`, tooltip: 'Item diary' } @@ -94,8 +94,6 @@ class Controller { } } -Controller.$inject = ['$scope', '$stateParams']; - ngModule.component('vnTicketRequestIndex', { template: require('./index.html'), controller: Controller diff --git a/modules/ticket/front/request/index/index.spec.js b/modules/ticket/front/request/index/index.spec.js index 90d71f062..17f085010 100644 --- a/modules/ticket/front/request/index/index.spec.js +++ b/modules/ticket/front/request/index/index.spec.js @@ -3,14 +3,12 @@ import './index'; describe('Ticket', () => { describe('Component vnTicketRequestIndex', () => { let controller; - let $scope; beforeEach(ngModule('ticket')); - beforeEach(angular.mock.inject(($componentController, $rootScope) => { - $scope = $rootScope.$new(); - - controller = $componentController('vnTicketRequestIndex', {$scope}); + beforeEach(angular.mock.inject($componentController => { + const $element = angular.element(''); + controller = $componentController('vnTicketRequestIndex', {$element}); })); describe('getRequestState()', () => { diff --git a/modules/ticket/front/sale-checked/index.html b/modules/ticket/front/sale-checked/index.html index c7e060e4e..a2afd3b8f 100644 --- a/modules/ticket/front/sale-checked/index.html +++ b/modules/ticket/front/sale-checked/index.html @@ -2,7 +2,7 @@ vn-id="model" url="sales" filter="::$ctrl.filter" - link="{ticketFk: $ctrl.$stateParams.id}" + link="{ticketFk: $ctrl.$params.id}" limit="20" data="sales" order="concept ASC" diff --git a/modules/ticket/front/sale-checked/index.js b/modules/ticket/front/sale-checked/index.js index 08157bc9d..1fd9b662b 100644 --- a/modules/ticket/front/sale-checked/index.js +++ b/modules/ticket/front/sale-checked/index.js @@ -1,9 +1,9 @@ import ngModule from '../module'; +import Section from 'salix/components/section'; -class Controller { - constructor($scope, $stateParams) { - this.$scope = $scope; - this.$stateParams = $stateParams; +class Controller extends Section { + constructor($element, $) { + super($element, $); this.filter = { include: [{ relation: 'item' @@ -29,18 +29,16 @@ class Controller { tooltip: 'Item diary' } }; - this.$scope.descriptor.itemFk = itemFk; - this.$scope.descriptor.parent = event.target; - this.$scope.descriptor.show(); + this.$.descriptor.itemFk = itemFk; + this.$.descriptor.parent = event.target; + this.$.descriptor.show(); } onDescriptorLoad() { - this.$scope.popover.relocate(); + this.$.popover.relocate(); } } -Controller.$inject = ['$scope', '$stateParams']; - ngModule.component('vnTicketSaleChecked', { template: require('./index.html'), controller: Controller, diff --git a/modules/ticket/front/sale-tracking/index.html b/modules/ticket/front/sale-tracking/index.html index 0186fb935..b365ef1ca 100644 --- a/modules/ticket/front/sale-tracking/index.html +++ b/modules/ticket/front/sale-tracking/index.html @@ -1,7 +1,7 @@ { this.vnApp.showSuccess(this.$translate.instant('Data saved!')); this.clearDiscount(); @@ -79,8 +72,6 @@ class Controller { } } -Controller.$inject = ['$scope', '$http', '$state', 'vnApp', '$translate']; - ngModule.component('vnTicketSaleEditDiscount', { template: require('./editDiscount.html'), controller: Controller, diff --git a/modules/ticket/front/sale/index.html b/modules/ticket/front/sale/index.html index b050d3579..e120ad942 100644 --- a/modules/ticket/front/sale/index.html +++ b/modules/ticket/front/sale/index.html @@ -1,6 +1,6 @@ { + if (!this.$params.id || !this.sales) return; + this.$http.get(`Tickets/${this.$params.id}/subtotal`).then(res => { this.subtotal = res.data || 0.0; }); } @@ -88,8 +84,8 @@ class Controller { loadVAT() { this.VAT = 0.0; - if (!this.$stateParams.id || !this.sales) return; - this.$http.get(`Tickets/${this.$stateParams.id}/getVAT`).then(res => { + if (!this.$params.id || !this.sales) return; + this.$http.get(`Tickets/${this.$params.id}/getVAT`).then(res => { this.VAT = res.data || 0.0; }); } @@ -106,7 +102,7 @@ class Controller { return (shouldShow && (option.always || this.isChecked)); }); - this.$scope.moreButton.data = options; + this.$.moreButton.data = options; } onMoreChange(callback) { @@ -191,7 +187,7 @@ class Controller { }); if (this.newInstances().length === 0) - this.$scope.watcher.updateOriginalData(); + this.$.watcher.updateOriginalData(); this.refreshTotal(); } @@ -211,7 +207,7 @@ class Controller { this.vnApp.showSuccess(this.$translate.instant('Data saved!')); }).finally(() => { if (this.newInstances().length === 0) - this.$scope.watcher.updateOriginalData(); + this.$.watcher.updateOriginalData(); }); } @@ -234,13 +230,13 @@ class Controller { } showRemoveLinesDialog() { - this.$scope.deleteLines.show(); + this.$.deleteLines.show(); } showTransferPopover(event) { this.setTransferParams(); - this.$scope.transfer.parent = event.target; - this.$scope.transfer.show(); + this.$.transfer.parent = event.target; + this.$.transfer.show(); } setTransferParams() { @@ -264,7 +260,7 @@ class Controller { sales: this.transfer.sales }; - this.$scope.watcher.updateOriginalData(); + this.$.watcher.updateOriginalData(); const query = `tickets/${this.ticket.id}/transferSales`; this.$http.post(query, params).then(res => { @@ -281,7 +277,7 @@ class Controller { const sales = this.checkedLines(); if (this.newInstances().length === 0) - this.$scope.watcher.updateOriginalData(); + this.$.watcher.updateOriginalData(); this.$http.post(`Claims/createFromSales`, {claim: claim, sales: sales}).then(res => { this.$state.go('claim.card.basicData', {id: res.data.id}); @@ -312,13 +308,13 @@ class Controller { tooltip: 'Item diary' } }; - this.$scope.descriptor.itemFk = itemFk; - this.$scope.descriptor.parent = event.target; - this.$scope.descriptor.show(); + this.$.descriptor.itemFk = itemFk; + this.$.descriptor.parent = event.target; + this.$.descriptor.show(); } onDescriptorLoad() { - this.$scope.popover.relocate(); + this.$.popover.relocate(); } showEditPricePopover(event, sale) { @@ -330,8 +326,8 @@ class Controller { id: sale.id, quantity: sale.quantity }; - this.$scope.editPricePopover.parent = event.target; - this.$scope.editPricePopover.show(); + this.$.editPricePopover.parent = event.target; + this.$.editPricePopover.show(); } updatePrice() { @@ -342,11 +338,11 @@ class Controller { this.vnApp.showSuccess(this.$translate.instant('Data saved!')); }).finally(() => { if (this.newInstances().length === 0) - this.$scope.watcher.updateOriginalData(); + this.$.watcher.updateOriginalData(); }); } - this.$scope.editPricePopover.hide(); + this.$.editPricePopover.hide(); } updateNewPrice() { @@ -364,23 +360,23 @@ class Controller { price: sale.price, discount: sale.discount }]; - this.$scope.editPopover.parent = event.target; - this.$scope.editPopover.show(); + this.$.editPopover.parent = event.target; + this.$.editPopover.show(); } showEditDialog() { this.edit = this.checkedLines(); - this.$scope.editDialog.show(); + this.$.editDialog.show(); } hideEditDialog() { - this.$scope.model.refresh(); - this.$scope.editDialog.hide(); + this.$.model.refresh(); + this.$.editDialog.hide(); } hideEditPopover() { - this.$scope.model.refresh(); - this.$scope.editPopover.hide(); + this.$.model.refresh(); + this.$.editPopover.hide(); } /* @@ -416,7 +412,7 @@ class Controller { }); }).finally(() => { if (this.newInstances().length === 0) - this.$scope.watcher.updateOriginalData(); + this.$.watcher.updateOriginalData(); }); } @@ -449,14 +445,14 @@ class Controller { destination: phone, message: this.$translate.instant('Product not available', params) }; - this.$scope.sms.open(); + this.$.sms.open(); } /** * Inserts a new instance */ add() { - this.$scope.model.insert({}); + this.$.model.insert({}); } /* @@ -481,11 +477,11 @@ class Controller { this.$http.post(query, data).then(() => { this.vnApp.showSuccess(this.$translate.instant('Data saved!')); }).catch(e => { - this.$scope.model.refresh(); + this.$.model.refresh(); throw e; }).finally(() => { if (this.newInstances().length === 0) - this.$scope.watcher.updateOriginalData(); + this.$.watcher.updateOriginalData(); }); } @@ -498,11 +494,11 @@ class Controller { this.$http.post(query, data).then(() => { this.vnApp.showSuccess(this.$translate.instant('Data saved!')); }).catch(e => { - this.$scope.model.refresh(); + this.$.model.refresh(); throw e; }).finally(() => { if (this.newInstances().length === 0) - this.$scope.watcher.updateOriginalData(); + this.$.watcher.updateOriginalData(); }); } @@ -532,7 +528,7 @@ class Controller { this.vnApp.showSuccess(this.$translate.instant('Data saved!')); }).finally(() => { if (this.newInstances().length === 0) - this.$scope.watcher.updateOriginalData(); + this.$.watcher.updateOriginalData(); }); } @@ -559,7 +555,7 @@ class Controller { const query = `Sales/${sale.id}/recalculatePrice`; this.$http.post(query).then(res => { this.vnApp.showSuccess(this.$translate.instant('Data saved!')); - this.$scope.model.refresh(); + this.$.model.refresh(); }); } @@ -570,8 +566,6 @@ class Controller { } } -Controller.$inject = ['$scope', '$state', '$http', 'vnApp', '$translate']; - ngModule.component('vnTicketSale', { template: require('./index.html'), controller: Controller, diff --git a/modules/ticket/front/sale/specs/editDiscount.spec.js b/modules/ticket/front/sale/specs/editDiscount.spec.js index 8937d25c6..8eccfe74f 100644 --- a/modules/ticket/front/sale/specs/editDiscount.spec.js +++ b/modules/ticket/front/sale/specs/editDiscount.spec.js @@ -19,7 +19,8 @@ describe('Ticket', () => { }}; $state = _$state_; $state.params.id = 11; - controller = $componentController('vnTicketSaleEditDiscount', {$scope, $state}); + const $element = angular.element(''); + controller = $componentController('vnTicketSaleEditDiscount', {$element, $scope}); controller._edit = [{id: 3}]; controller.onHide = () => {}; })); diff --git a/modules/ticket/front/sale/specs/index.spec.js b/modules/ticket/front/sale/specs/index.spec.js index 3b0f04a82..1c8fbda53 100644 --- a/modules/ticket/front/sale/specs/index.spec.js +++ b/modules/ticket/front/sale/specs/index.spec.js @@ -53,7 +53,8 @@ describe('Ticket', () => { writable: false } }); - controller = $componentController('vnTicketSale', {$scope, $state}); + const $element = angular.element(''); + controller = $componentController('vnTicketSale', {$element, $scope}); controller.card = {reload: () => {}}; controller.ticket = ticket; controller.sales = sales; @@ -196,12 +197,12 @@ describe('Ticket', () => { describe('showSMSDialog()', () => { it('should open an SMS dialog with specified data', () => { - jest.spyOn(controller.$scope.sms, 'open'); + jest.spyOn(controller.$.sms, 'open'); controller.sales[0].checked = true; controller.showSMSDialog(); - expect(controller.$scope.sms.open).toHaveBeenCalledWith(); + expect(controller.$.sms.open).toHaveBeenCalledWith(); expect(controller.newSMS.destination).toEqual(111111111); expect(controller.newSMS.message).not.toEqual(''); }); @@ -242,7 +243,7 @@ describe('Ticket', () => { describe('updateQuantity()', () => { it('should make a POST query saving sale quantity', () => { - jest.spyOn(controller.$scope.watcher, 'updateOriginalData'); + jest.spyOn(controller.$.watcher, 'updateOriginalData'); const data = {quantity: 10}; const sale = sales[0]; sale.quantity = 10; @@ -256,13 +257,13 @@ describe('Ticket', () => { controller.updateQuantity(sale); $httpBackend.flush(); - expect(controller.$scope.watcher.updateOriginalData).toHaveBeenCalledWith(); + expect(controller.$.watcher.updateOriginalData).toHaveBeenCalledWith(); }); }); describe('updateConcept()', () => { it('should make a POST query saving sale concept', () => { - jest.spyOn(controller.$scope.watcher, 'updateOriginalData'); + jest.spyOn(controller.$.watcher, 'updateOriginalData'); const data = {newConcept: 'My new weapon'}; const sale = sales[0]; sale.concept = 'My new weapon'; @@ -276,13 +277,13 @@ describe('Ticket', () => { controller.updateConcept(sale); $httpBackend.flush(); - expect(controller.$scope.watcher.updateOriginalData).toHaveBeenCalledWith(); + expect(controller.$.watcher.updateOriginalData).toHaveBeenCalledWith(); }); }); describe('addSale()', () => { it('should make a POST query adding a new sale', () => { - jest.spyOn(controller.$scope.watcher, 'updateOriginalData'); + jest.spyOn(controller.$.watcher, 'updateOriginalData'); const newSale = {itemFk: 4, quantity: 10}; const params = {itemId: 4, quantity: 10}; @@ -307,7 +308,7 @@ describe('Ticket', () => { controller.addSale(newSale); $httpBackend.flush(); - expect(controller.$scope.watcher.updateOriginalData).toHaveBeenCalledWith(); + expect(controller.$.watcher.updateOriginalData).toHaveBeenCalledWith(); }); }); diff --git a/modules/ticket/front/services/index.html b/modules/ticket/front/services/index.html index 0cbcbe5df..419110eac 100644 --- a/modules/ticket/front/services/index.html +++ b/modules/ticket/front/services/index.html @@ -1,7 +1,7 @@ diff --git a/modules/ticket/front/services/index.js b/modules/ticket/front/services/index.js index fca4cd070..8627360c6 100644 --- a/modules/ticket/front/services/index.js +++ b/modules/ticket/front/services/index.js @@ -1,18 +1,10 @@ import ngModule from '../module'; +import Section from 'salix/components/section'; import UserError from 'core/lib/user-error'; -class Controller { - constructor($http, $scope, $stateParams, vnApp, $translate, $element) { - this.$http = $http; - this.$scope = $scope; - this.$stateParams = $stateParams; - this.vnApp = vnApp; - this.$translate = $translate; - this.$element = $element; - this.services = []; - } - +class Controller extends Section { $onInit() { + this.services = []; this.getDefaultTaxClass(); } @@ -26,10 +18,10 @@ class Controller { add() { if (this.defaultTaxClass) { - this.$scope.model.insert({ + this.$.model.insert({ taxClassFk: this.defaultTaxClass.id, quantity: 1, - ticketFk: this.$stateParams.id + ticketFk: this.$params.id }); } } @@ -40,7 +32,7 @@ class Controller { newServiceTypeDialog(elementIndex, event) { event.preventDefault(); - this.$scope.createServiceTypeDialog.show(); + this.$.createServiceTypeDialog.show(); this.currentServiceIndex = elementIndex; } @@ -56,17 +48,15 @@ class Controller { } onSubmit() { - this.$scope.watcher.check(); + this.$.watcher.check(); - this.$scope.model.save().then(() => { - this.$scope.watcher.notifySaved(); - this.$scope.model.refresh(); + this.$.model.save().then(() => { + this.$.watcher.notifySaved(); + this.$.model.refresh(); }); } } -Controller.$inject = ['$http', '$scope', '$stateParams', 'vnApp', '$translate', '$element']; - ngModule.component('vnTicketService', { template: require('./index.html'), controller: Controller diff --git a/modules/ticket/front/sms/index.js b/modules/ticket/front/sms/index.js index ac1131513..56959e3ee 100644 --- a/modules/ticket/front/sms/index.js +++ b/modules/ticket/front/sms/index.js @@ -3,21 +3,12 @@ import Component from 'core/lib/component'; import './style.scss'; class Controller extends Component { - constructor($element, $scope, $http, $translate, vnApp) { - super($element, $scope); - - this.$scope = $scope; - this.$http = $http; - this.$translate = $translate; - this.vnApp = vnApp; - } - open() { - this.$scope.SMSDialog.show(); + this.$.SMSDialog.show(); } charactersRemaining() { - const element = this.$scope.message; + const element = this.$.message; const value = element.input.value; const maxLength = 160; @@ -49,8 +40,6 @@ class Controller extends Component { } } -Controller.$inject = ['$element', '$scope', '$http', '$translate', 'vnApp']; - ngModule.component('vnTicketSms', { template: require('./index.html'), controller: Controller, diff --git a/modules/ticket/front/sms/index.spec.js b/modules/ticket/front/sms/index.spec.js index cd397b9fa..45e7765d1 100644 --- a/modules/ticket/front/sms/index.spec.js +++ b/modules/ticket/front/sms/index.spec.js @@ -4,17 +4,16 @@ describe('Ticket', () => { describe('Component vnTicketSms', () => { let controller; let $httpBackend; - let $element; beforeEach(ngModule('ticket')); beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_) => { $httpBackend = _$httpBackend_; let $scope = $rootScope.$new(); - $element = angular.element(''); + const $element = angular.element(''); controller = $componentController('vnTicketSms', {$element, $scope}); controller.$params = {id: 11}; - controller.$scope.message = { + controller.$.message = { input: { value: 'My SMS' } @@ -58,7 +57,7 @@ describe('Ticket', () => { describe('charactersRemaining()', () => { it('should return the characters remaining in a element', () => { - controller.$scope.message = { + controller.$.message = { input: { value: 'My message 0€' } diff --git a/modules/ticket/front/summary/index.js b/modules/ticket/front/summary/index.js index 010110340..7e892b265 100644 --- a/modules/ticket/front/summary/index.js +++ b/modules/ticket/front/summary/index.js @@ -1,15 +1,8 @@ import ngModule from '../module'; +import Section from 'salix/components/section'; import './style.scss'; -class Controller { - constructor($scope, $state, $http, vnApp, $translate) { - this.$scope = $scope; - this.vnApp = vnApp; - this.$translate = $translate; - this.$http = $http; - this.$state = $state; - } - +class Controller extends Section { get ticket() { return this._ticket; } @@ -46,9 +39,9 @@ class Controller { tooltip: 'Route summary' } }; - this.$scope.routeDescriptor.routeFk = this.summary.routeFk; - this.$scope.routeDescriptor.parent = event.target; - this.$scope.routeDescriptor.show(); + this.$.routeDescriptor.routeFk = this.summary.routeFk; + this.$.routeDescriptor.parent = event.target; + this.$.routeDescriptor.show(); } showDescriptor(event, itemFk) { @@ -63,13 +56,13 @@ class Controller { tooltip: 'Item diary' } }; - this.$scope.descriptor.itemFk = itemFk; - this.$scope.descriptor.parent = event.target; - this.$scope.descriptor.show(); + this.$.descriptor.itemFk = itemFk; + this.$.descriptor.parent = event.target; + this.$.descriptor.show(); } onDescriptorLoad() { - this.$scope.popover.relocate(); + this.$.popover.relocate(); } get isEditable() { @@ -83,10 +76,10 @@ class Controller { setOkState() { let params = {}; - if (this.$state.params.id) - params = {ticketFk: this.$state.params.id}; + if (this.$params.id) + params = {ticketFk: this.$params.id}; - if (!this.$state.params.id) + if (!this.$params.id) params = {ticketFk: this.ticket.id}; params.code = 'OK'; @@ -112,8 +105,6 @@ class Controller { } } -Controller.$inject = ['$scope', '$state', '$http', 'vnApp', '$translate']; - ngModule.component('vnTicketSummary', { template: require('./index.html'), controller: Controller, diff --git a/modules/ticket/front/summary/index.spec.js b/modules/ticket/front/summary/index.spec.js index 08557e36e..e1f0e8836 100644 --- a/modules/ticket/front/summary/index.spec.js +++ b/modules/ticket/front/summary/index.spec.js @@ -9,7 +9,8 @@ describe('Ticket', () => { beforeEach(angular.mock.inject(($componentController, _$httpBackend_) => { $httpBackend = _$httpBackend_; - controller = $componentController('vnTicketSummary'); + const $element = angular.element(''); + controller = $componentController('vnTicketSummary', {$element}); controller.ticket = {id: 1}; })); diff --git a/modules/ticket/front/tracking/edit/index.js b/modules/ticket/front/tracking/edit/index.js index 03c5c6c0f..f2de08389 100644 --- a/modules/ticket/front/tracking/edit/index.js +++ b/modules/ticket/front/tracking/edit/index.js @@ -1,16 +1,13 @@ import ngModule from '../../module'; +import Section from 'salix/components/section'; -class Controller { - constructor($scope, $state, vnApp, $translate, $http) { - this.$http = $http; - this.$ = $scope; - this.$state = $state; - this.vnApp = vnApp; - this.$translate = $translate; +class Controller extends Section { + constructor($element, $) { + super($element, $); this.ticket = { - ticketFk: $state.params.id + ticketFk: this.$params.id }; - this.params = {ticketFk: $state.params.id}; + this.params = {ticketFk: this.$params.id}; } $onInit() { @@ -64,7 +61,6 @@ class Controller { }); } } -Controller.$inject = ['$scope', '$state', 'vnApp', '$translate', '$http']; ngModule.component('vnTicketTrackingEdit', { template: require('./index.html'), diff --git a/modules/ticket/front/tracking/edit/index.spec.js b/modules/ticket/front/tracking/edit/index.spec.js index 313a25b73..cf8036814 100644 --- a/modules/ticket/front/tracking/edit/index.spec.js +++ b/modules/ticket/front/tracking/edit/index.spec.js @@ -9,7 +9,8 @@ describe('Ticket', () => { beforeEach(angular.mock.inject(($componentController, _$httpBackend_, $translate, vnApp) => { $httpBackend = _$httpBackend_; - controller = $componentController('vnTicketTrackingEdit'); + const $element = angular.element(''); + controller = $componentController('vnTicketTrackingEdit', {$element}); controller.ticket = {id: 1}; controller.$ = {watcher: {updateOriginalData: () => {}}}; controller.card = {reload: () => {}}; diff --git a/modules/ticket/front/tracking/index/index.html b/modules/ticket/front/tracking/index/index.html index 8398a0602..f66c62449 100644 --- a/modules/ticket/front/tracking/index/index.html +++ b/modules/ticket/front/tracking/index/index.html @@ -2,7 +2,7 @@ vn-id="model" url="TicketTrackings" filter="::$ctrl.filter" - link="{ticketFk: $ctrl.$stateParams.id}" + link="{ticketFk: $ctrl.$params.id}" limit="20" data="trackings" order="created DESC" diff --git a/modules/ticket/front/tracking/index/index.js b/modules/ticket/front/tracking/index/index.js index adc1ac5a2..e58dc4300 100644 --- a/modules/ticket/front/tracking/index/index.js +++ b/modules/ticket/front/tracking/index/index.js @@ -1,9 +1,9 @@ import ngModule from '../../module'; +import Section from 'salix/components/section'; -class Controller { - constructor($scope, $stateParams) { - this.$ = $scope; - this.$stateParams = $stateParams; +class Controller extends Section { + constructor($element, $) { + super($element, $); this.filter = { include: [ { @@ -37,8 +37,6 @@ class Controller { } } -Controller.$inject = ['$scope', '$stateParams']; - ngModule.component('vnTicketTrackingIndex', { template: require('./index.html'), controller: Controller diff --git a/modules/ticket/front/volume/index.html b/modules/ticket/front/volume/index.html index 0006b8854..977f76513 100644 --- a/modules/ticket/front/volume/index.html +++ b/modules/ticket/front/volume/index.html @@ -2,15 +2,15 @@ vn-id="model" url="sales" filter="::$ctrl.filter" - link="{ticketFk: $ctrl.$stateParams.id}" + link="{ticketFk: $ctrl.$params.id}" data="$ctrl.sales" limit="20"> - + diff --git a/modules/ticket/front/volume/index.js b/modules/ticket/front/volume/index.js index 914c9819d..bf616cb24 100644 --- a/modules/ticket/front/volume/index.js +++ b/modules/ticket/front/volume/index.js @@ -1,10 +1,9 @@ import ngModule from '../module'; +import Section from 'salix/components/section'; -class Controller { - constructor($scope, $http, $stateParams) { - this.$scope = $scope; - this.$http = $http; - this.$stateParams = $stateParams; +class Controller extends Section { + constructor($element, $) { + super($element, $); this.filter = { include: [{ relation: 'item' @@ -34,7 +33,6 @@ class Controller { if (value) this.applyVolumes(); } - applyVolumes() { if (!this.sales || !this.volumes) return; @@ -58,18 +56,16 @@ class Controller { tooltip: 'Item diary' } }; - this.$scope.descriptor.itemFk = itemFk; - this.$scope.descriptor.parent = event.target; - this.$scope.descriptor.show(); + this.$.descriptor.itemFk = itemFk; + this.$.descriptor.parent = event.target; + this.$.descriptor.show(); } onDescriptorLoad() { - this.$scope.popover.relocate(); + this.$.popover.relocate(); } } -Controller.$inject = ['$scope', '$http', '$stateParams']; - ngModule.component('vnTicketVolume', { template: require('./index.html'), controller: Controller, diff --git a/modules/ticket/front/volume/index.spec.js b/modules/ticket/front/volume/index.spec.js index 6c2a808eb..2f6efee21 100644 --- a/modules/ticket/front/volume/index.spec.js +++ b/modules/ticket/front/volume/index.spec.js @@ -19,7 +19,8 @@ describe('ticket', () => { }}; $state = _$state_; $state.params.id = 101; - controller = $componentController('vnTicketVolume', {$scope, $httpBackend, $state}); + const $element = angular.element(''); + controller = $componentController('vnTicketVolume', {$element, $scope}); })); describe('sales() setter', () => { diff --git a/modules/ticket/front/weekly/index.js b/modules/ticket/front/weekly/index.js index 7668264f6..fd889cf65 100644 --- a/modules/ticket/front/weekly/index.js +++ b/modules/ticket/front/weekly/index.js @@ -1,14 +1,11 @@ import ngModule from '../module'; +import Section from 'salix/components/section'; -export default class Controller { - constructor($scope, vnApp, $translate, $http) { - this.$ = $scope; - this.vnApp = vnApp; - this.$translate = $translate; - this.$http = $http; +export default class Controller extends Section { + constructor($element, $) { + super($element, $); this.ticketSelected = null; - this.weekdays = [ {id: 0, name: 'Monday'}, {id: 1, name: 'Tuesday'}, @@ -40,7 +37,6 @@ export default class Controller { this.$.model.clear(); } - showClientDescriptor(event, clientFk) { this.$.clientDescriptor.clientFk = clientFk; this.$.clientDescriptor.parent = event.target; @@ -85,9 +81,6 @@ export default class Controller { } } - -Controller.$inject = ['$scope', 'vnApp', '$translate', '$http']; - ngModule.component('vnTicketWeeklyIndex', { template: require('./index.html'), controller: Controller