Ticket refactor
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Joan Sanchez 2020-03-18 08:35:59 +01:00
parent 3cb98eaf5f
commit f25c8bb644
61 changed files with 243 additions and 427 deletions

View File

@ -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'),

View File

@ -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: {

View File

@ -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,

View File

@ -13,7 +13,8 @@ describe('Ticket', () => {
$state = _$state_;
$httpBackend = _$httpBackend_;
$httpParamSerializer = _$httpParamSerializer_;
controller = $componentController('vnTicketBasicDataStepOne', {$state});
const $element = angular.element('<vn-ticket-basic-data-step-one></vn-ticket-basic-data-step-one>');
controller = $componentController('vnTicketBasicDataStepOne', {$element});
controller.ticket = {
addressFk: 121,
agencyModeFk: 7,

View File

@ -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,

View File

@ -7,7 +7,8 @@ describe('Ticket', () => {
beforeEach(ngModule('ticket'));
beforeEach(angular.mock.inject($componentController => {
controller = $componentController('vnTicketBasicDataStepTwo');
const $element = angular.element('<vn-ticket-basic-data-step-two><vn-ticket-basic-data-step-two>');
controller = $componentController('vnTicketBasicDataStepTwo', {$element});
}));
describe('getTotalPrice()', () => {

View File

@ -1,7 +1,7 @@
<vn-crud-model
vn-id="model"
url="Sales"
link="{ticketFk: $ctrl.$stateParams.id}"
link="{ticketFk: $ctrl.$params.id}"
filter="::$ctrl.filter"
data="components"
auto-load="true">

View File

@ -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,

View File

@ -75,7 +75,8 @@ describe('ticket', () => {
],
quantity: 5
}];
controller = $componentController('vnTicketComponents', {$scope});
const $element = angular.element('<vn-ticket-components></vn-ticket-components>');
controller = $componentController('vnTicketComponents', {$element, $scope});
}));
describe('base()', () => {

View File

@ -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,

View File

@ -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'),

View File

@ -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'),

View File

@ -1,5 +1,5 @@
<vn-crud-model vn-id="model"
url="Tickets/{{$ctrl.$stateParams.id}}/getPossibleStowaways"
url="Tickets/{{$ctrl.$params.id}}/getPossibleStowaways"
data="possibleStowaways">
</vn-crud-model>
<vn-dialog

View File

@ -1,15 +1,8 @@
import ngModule from '../module';
import Component from 'core/lib/component';
import './style.scss';
class Controller {
constructor($stateParams, $, $http, vnApp, $translate) {
this.vnApp = vnApp;
this.$translate = $translate;
this.$ = $;
this.$stateParams = $stateParams;
this.$http = $http;
}
class Controller extends Component {
addStowaway(stowaway) {
let params = {id: stowaway.id, shipFk: this.ticket.id};
this.$http.post(`Stowaways/`, params)
@ -29,8 +22,6 @@ class Controller {
}
}
Controller.$inject = ['$stateParams', '$scope', '$http', 'vnApp', '$translate'];
ngModule.component('vnAddStowaway', {
template: require('./addStowaway.html'),
controller: Controller,

View File

@ -235,8 +235,7 @@ class Controller extends Component {
clientId: this.ticket.client.id,
ticketId: this.ticket.id
};
const serializedParams = this.$httpParamSerializer(params);
this.$http.get(`email/delivery-note?${serializedParams}`).then(
this.$http.get(`email/delivery-note`, {params}).then(
() => this.vnApp.showMessage(this.$translate.instant('Notification sent!'))
);
}

View File

@ -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,

View File

@ -13,7 +13,8 @@ describe('Ticket', () => {
$scope = $rootScope.$new();
$httpBackend = _$httpBackend_;
$httpParamSerializer = _$httpParamSerializer_;
controller = $componentController('vnTicketDmsCreate', {$scope});
const $element = angular.element('<vn-ticket-dms-create></vn-ticket-dms-create>');
controller = $componentController('vnTicketDmsCreate', {$element});
controller._ticket = {
id: 15,
client: {id: 101, name: 'Bruce wayne'},

View File

@ -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,

View File

@ -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('<vn-ticket-dms-edit></vn-ticket-dms-edit>');
controller = $componentController('vnTicketDmsEdit', {$element});
controller._ticket = {id: 1, ticketFk: 16};
controller.$params = {dmsId: 1};
}));
describe('ticket() setter', () => {

View File

@ -54,7 +54,7 @@
<vn-td shrink>
<a target="_blank"
title="{{'Download file' | translate}}"
href="api/dms/{{::document.dmsFk}}/downloadFile?access_token={{::$ctrl.accessToken}}">
href="api/dms/{{::document.dmsFk}}/downloadFile?access_token={{::$ctrl.vnToken.token}}">
{{::document.dms.file}}
</a>
</vn-td>
@ -68,7 +68,7 @@
</vn-td>
<vn-td shrink>
<a target="_blank"
href="api/dms/{{::document.dmsFk}}/downloadFile?access_token={{::$ctrl.accessToken}}">
href="api/dms/{{::document.dmsFk}}/downloadFile?access_token={{::$ctrl.vnToken.token}}">
<vn-icon-button
icon="cloud_download"
title="{{'Download file' | translate}}">

View File

@ -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,

View File

@ -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('<vn-ticket-dms-index></vn-ticket-dms-index>');
controller = $componentController('vnTicketDmsIndex', {$element});
controller.$.model = crudModel;
}));

View File

@ -1,7 +1,7 @@
<vn-crud-model
vn-id="model"
url="Expeditions/filter"
link="{ticketFk: $ctrl.$stateParams.id}"
link="{ticketFk: $ctrl.$params.id}"
limit="20"
data="expeditions"
order="created DESC"

View File

@ -1,12 +1,7 @@
import ngModule from '../module';
import Section from 'salix/components/section';
class Controller {
constructor($scope, $stateParams, $http) {
this.$ = $scope;
this.$stateParams = $stateParams;
this.$http = $http;
}
class Controller extends Section {
deleteExpedition(expedition) {
this.expeditionId = expedition.id;
this.$.deleteExpedition.show();
@ -51,8 +46,6 @@ class Controller {
}
}
Controller.$inject = ['$scope', '$stateParams', '$http'];
ngModule.component('vnTicketExpedition', {
template: require('./index.html'),
controller: Controller,

View File

@ -4,19 +4,18 @@ describe('Ticket', () => {
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('<vn-ticket-expedition></vn-ticket-expedition>');
controller = $componentController('vnTicketExpedition', {$element, $scope});
}));
describe('returnDialog()', () => {

View File

@ -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

View File

@ -23,7 +23,8 @@ describe('Component vnTicketIndex', () => {
beforeEach(inject(($componentController, _$window_) => {
$window = _$window_;
controller = $componentController('vnTicketIndex');
const $element = angular.element('<vn-ticket-index></vn-ticket-index>');
controller = $componentController('vnTicketIndex', {$element});
}));
describe('compareDate()', () => {

View File

@ -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,
});

View File

@ -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">
</vn-crud-model>

View File

@ -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,

View File

@ -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">
</vn-crud-model>

View File

@ -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

View File

@ -1,7 +1,7 @@
<vn-crud-model
vn-id="model"
url="sales"
link="{ticketFk: $ctrl.$stateParams.id}"
link="{ticketFk: $ctrl.$params.id}"
filter="::$ctrl.filter"
limit="20"
data="sales"

View File

@ -1,10 +1,9 @@
import ngModule from '../module';
import Section from 'salix/components/section';
class Controller {
constructor($scope, $stateParams, $http) {
this.$scope = $scope;
this.$stateParams = $stateParams;
this.$http = $http;
class Controller extends Section {
constructor($element, $) {
super($element, $);
this.filter = {
include: {
relation: 'item',
@ -16,18 +15,16 @@ class Controller {
}
showDescriptor(event, itemFk) {
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', '$http'];
ngModule.component('vnTicketPicture', {
template: require('./index.html'),
controller: Controller

View File

@ -1,24 +1,22 @@
import ngModule from '../../module';
import Section from 'salix/components/section';
import './style.scss';
class Controller {
constructor($state, $scope) {
this.$ = $scope;
this.$state = $state;
class Controller extends Section {
constructor($element, $) {
super($element, $);
this.ticketRequest = {
ticketFk: $state.params.id
ticketFk: this.$params.id
};
}
onSubmit() {
this.$.watcher.submit().then(
json => 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

View File

@ -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">

View File

@ -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

View File

@ -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('<vn-ticket-request-index></vn-ticket-request-index>');
controller = $componentController('vnTicketRequestIndex', {$element});
}));
describe('getRequestState()', () => {

View File

@ -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"

View File

@ -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,

View File

@ -1,7 +1,7 @@
<vn-crud-model
vn-id="model"
url="SaleTrackings/listSaleTracking"
link="{ticketFk: $ctrl.$stateParams.id}"
link="{ticketFk: $ctrl.$params.id}"
limit="20"
data="sales"
order="itemFk DESC"

View File

@ -1,11 +1,7 @@
import ngModule from '../module';
import Section from 'salix/components/section';
class Controller {
constructor($scope, $stateParams) {
this.$ = $scope;
this.$stateParams = $stateParams;
}
class Controller extends Section {
showItemDescriptor(event, itemFk) {
this.quicklinks = {
btnThree: {
@ -36,8 +32,6 @@ class Controller {
}
}
Controller.$inject = ['$scope', '$stateParams'];
ngModule.component('vnTicketSaleTracking', {
template: require('./index.html'),
controller: Controller,

View File

@ -1,14 +1,7 @@
import ngModule from '../module';
import Component from 'core/lib/component';
class Controller {
constructor($scope, $http, $state, vnApp, $translate) {
this.$scope = $scope;
this.$http = $http;
this.$state = $state;
this.vnApp = vnApp;
this.$translate = $translate;
}
class Controller extends Component {
set edit(value) {
this._edit = value;
this.clearDiscount();
@ -59,7 +52,7 @@ class Controller {
if (modified) {
const params = {salesIds: salesIds, newDiscount: this.newDiscount};
const query = `Tickets/${this.$state.params.id}/updateDiscount`;
const query = `Tickets/${this.$params.id}/updateDiscount`;
this.$http.post(query, params).then(() => {
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,

View File

@ -1,6 +1,6 @@
<vn-crud-model auto-load="false"
vn-id="model"
url="Tickets/{{$ctrl.$stateParams.id}}/getSales"
url="Tickets/{{$ctrl.$params.id}}/getSales"
data="$ctrl.sales">
</vn-crud-model>
<vn-watcher

View File

@ -1,14 +1,10 @@
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.$state = $state;
this.$stateParams = $state.params;
this.$http = $http;
class Controller extends Section {
constructor($element, $) {
super($element, $);
this.edit = {};
this.moreOptions = [
{
@ -73,8 +69,8 @@ class Controller {
}
loadSubTotal() {
if (!this.$stateParams.id || !this.sales) return;
this.$http.get(`Tickets/${this.$stateParams.id}/subtotal`).then(res => {
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,

View File

@ -19,7 +19,8 @@ describe('Ticket', () => {
}};
$state = _$state_;
$state.params.id = 11;
controller = $componentController('vnTicketSaleEditDiscount', {$scope, $state});
const $element = angular.element('<vn-ticket-sale-edit-discount></vn-ticket-sale-edit-discount>');
controller = $componentController('vnTicketSaleEditDiscount', {$element, $scope});
controller._edit = [{id: 3}];
controller.onHide = () => {};
}));

View File

@ -53,7 +53,8 @@ describe('Ticket', () => {
writable: false
}
});
controller = $componentController('vnTicketSale', {$scope, $state});
const $element = angular.element('<vn-ticket-sale></vn-ticket-sale>');
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();
});
});

View File

@ -1,7 +1,7 @@
<vn-crud-model
vn-id="model"
url="TicketServices"
link="{ticketFk: $ctrl.$stateParams.id}"
link="{ticketFk: $ctrl.$params.id}"
data="$ctrl.services"
auto-load="true">
</vn-crud-model>

View File

@ -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

View File

@ -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,

View File

@ -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('<vn-dialog></vn-dialog>');
const $element = angular.element('<vn-dialog></vn-dialog>');
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€'
}

View File

@ -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,

View File

@ -9,7 +9,8 @@ describe('Ticket', () => {
beforeEach(angular.mock.inject(($componentController, _$httpBackend_) => {
$httpBackend = _$httpBackend_;
controller = $componentController('vnTicketSummary');
const $element = angular.element('<vn-ticket-summary></vn-ticket-summary>');
controller = $componentController('vnTicketSummary', {$element});
controller.ticket = {id: 1};
}));

View File

@ -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'),

View File

@ -9,7 +9,8 @@ describe('Ticket', () => {
beforeEach(angular.mock.inject(($componentController, _$httpBackend_, $translate, vnApp) => {
$httpBackend = _$httpBackend_;
controller = $componentController('vnTicketTrackingEdit');
const $element = angular.element('<vn-ticket-tracking-edit></vn-ticket-tracking-edit>');
controller = $componentController('vnTicketTrackingEdit', {$element});
controller.ticket = {id: 1};
controller.$ = {watcher: {updateOriginalData: () => {}}};
controller.card = {reload: () => {}};

View File

@ -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"

View File

@ -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

View File

@ -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">
</vn-crud-model>
<vn-crud-model auto-load="true"
url="tickets/{{$ctrl.$stateParams.id}}/getVolume"
url="tickets/{{$ctrl.$params.id}}/getVolume"
data="$ctrl.volumes">
</vn-crud-model>
<mg-ajax path="tickets/{{$ctrl.$stateParams.id}}/getTotalVolume" options="mgEdit"></mg-ajax>
<mg-ajax path="tickets/{{$ctrl.$params.id}}/getTotalVolume" options="mgEdit"></mg-ajax>
<vn-vertical>
<vn-card class="vn-pa-lg">
<vn-horizontal>

View File

@ -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,

View File

@ -19,7 +19,8 @@ describe('ticket', () => {
}};
$state = _$state_;
$state.params.id = 101;
controller = $componentController('vnTicketVolume', {$scope, $httpBackend, $state});
const $element = angular.element('<vn-ticket-volume></vn-ticket-volume>');
controller = $componentController('vnTicketVolume', {$element, $scope});
}));
describe('sales() setter', () => {

View File

@ -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