This commit is contained in:
Juan Ferrer 2019-11-12 09:24:01 +01:00
commit f6050a6c65
31 changed files with 122 additions and 167 deletions

View File

@ -21,43 +21,3 @@ ADD CONSTRAINT `fgnUserFk`
ON DELETE CASCADE
ON UPDATE CASCADE;
insert into vn.userPhone(userFk,typeFk,phone)
select id,'personalPhone', phone
from vn.client
where phone is not null;
insert into vn.userPhone(userFk,typeFk,phone)
select id,'businessPhone', phone
from vn.worker
where phone is not null AND phone > '';
insert into vn.userPhone(userFk,typeFk,phone)
SELECT
`w`.`userFk`,
'businessPhone',
`m`.`value` AS `mediaValue`
FROM
(((((`postgresql`.`person` `p`
JOIN `postgresql`.`profile` `po` ON ((`po`.`person_id` = `p`.`person_id`)))
JOIN `postgresql`.`profile_media` `pom` ON ((`pom`.`profile_id` = `po`.`profile_id`)))
JOIN `postgresql`.`media` `m` ON ((`m`.`media_id` = `pom`.`media_id`)))
JOIN `postgresql`.`media_type` `mt` ON ((`mt`.`media_type_id` = `m`.`media_type_id`)))
JOIN `vn`.`worker` `w` ON ((`w`.`id` = `p`.`id_trabajador`)))
WHERE
(`mt`.`name` = 'movil empresa');
insert into vn.userPhone(userFk,typeFk,phone)
SELECT
`w`.`userFk`,
'personalPhone',
`m`.`value` AS `mediaValue`
FROM
(((((`postgresql`.`person` `p`
JOIN `postgresql`.`profile` `po` ON ((`po`.`person_id` = `p`.`person_id`)))
JOIN `postgresql`.`profile_media` `pom` ON ((`pom`.`profile_id` = `po`.`profile_id`)))
JOIN `postgresql`.`media` `m` ON ((`m`.`media_id` = `pom`.`media_id`)))
JOIN `postgresql`.`media_type` `mt` ON ((`mt`.`media_type_id` = `m`.`media_type_id`)))
JOIN `vn`.`worker` `w` ON ((`w`.`id` = `p`.`id_trabajador`)))
WHERE
(`mt`.`name` = 'movil personal')

View File

@ -181,26 +181,27 @@ let actions = {
isVisible: function(selector) {
return this.wait(selector)
.evaluate(elementSelector => {
const selectorMatches = document.querySelectorAll(elementSelector);
const element = selectorMatches[0];
let selectorMatches = document.querySelectorAll(elementSelector);
let element = selectorMatches[0];
if (selectorMatches.length > 1)
throw new Error(`multiple matches of ${elementSelector} found`);
let isVisible = false;
if (element) {
const eventHandler = event => {
let eventHandler = event => {
event.preventDefault();
isVisible = true;
};
element.addEventListener('mouseover', eventHandler);
const rect = element.getBoundingClientRect();
const x = rect.left + rect.width / 2;
const y = rect.top + rect.height / 2;
const elementInCenter = document.elementFromPoint(x, y);
const elementInTopLeft = document.elementFromPoint(rect.left, rect.top);
const elementInBottomRight = document.elementFromPoint(rect.right, rect.bottom);
const e = new MouseEvent('mouseover', {
let rect = element.getBoundingClientRect();
let x = rect.left + rect.width / 2;
let y = rect.top + rect.height / 2;
let elementInCenter = document.elementFromPoint(x, y);
let elementInTopLeft = document.elementFromPoint(rect.left, rect.top);
let elementInBottomRight = document.elementFromPoint(rect.right, rect.bottom);
let e = new MouseEvent('mouseover', {
view: window,
bubbles: true,
cancelable: true,
@ -417,9 +418,16 @@ let actions = {
}, selector);
},
waitForStylePresent: function(selector, property, value) {
return this.wait((selector, property, value) => {
const element = document.querySelector(selector);
return element.style[property] == value;
}, selector, property, value);
},
waitForSpinnerLoad: function() {
return this.waitUntilNotPresent('vn-topbar vn-spinner');
},
}
};
for (let name in actions) {

View File

@ -191,7 +191,8 @@ export default {
closeItemSummaryPreview: '.vn-popup.shown',
fieldsToShowButton: 'vn-item-index vn-table > div > div > vn-icon-button[icon="menu"]',
fieldsToShowForm: '.vn-dialog.shown form',
firstItemImage: 'vn-item-index vn-tbody > a:nth-child(1) > vn-td:nth-child(1)',
firstItemImage: 'vn-item-index vn-tbody > a:nth-child(1) > vn-td:nth-child(1) > img',
firstItemImageTd: 'vn-item-index vn-table a:nth-child(1) vn-td:nth-child(1)',
firstItemId: 'vn-item-index vn-tbody > a:nth-child(1) > vn-td:nth-child(2)',
idCheckbox: '.vn-dialog.shown form vn-horizontal:nth-child(2) > vn-check',
stemsCheckbox: '.vn-dialog.shown form vn-horizontal:nth-child(3) > vn-check',
@ -367,7 +368,6 @@ export default {
shipButton: 'vn-ticket-descriptor vn-icon[icon="icon-stowaway"]',
thursdayButton: '.vn-popup.shown vn-tool-bar > vn-button:nth-child(4)',
saturdayButton: '.vn-popup.shown vn-tool-bar > vn-button:nth-child(6)',
closeStowawayDialog: '.vn-dialog.shown button[class="close"]',
acceptDeleteButton: '.vn-dialog.shown button[response="accept"]',
acceptChangeHourButton: '.vn-dialog.shown button[response="accept"]',
descriptorDeliveryDate: 'vn-ticket-descriptor > div > div.body > div.attributes > vn-label-value:nth-child(6) > section > span',
@ -441,7 +441,7 @@ export default {
secondSaleIdInput: 'vn-ticket-sale vn-table vn-tbody > vn-tr:nth-child(2) > vn-td:nth-child(4) > vn-autocomplete input',
secondSaleIdAutocomplete: 'vn-ticket-sale vn-table vn-tbody > vn-tr:nth-child(2) > vn-td:nth-child(4) > vn-autocomplete',
secondSaleQuantity: 'vn-ticket-sale vn-table vn-tr:nth-child(2) vn-input-number input',
secondSaleConceptCell: 'vn-ticket-sale vn-table vn-tbody > vn-tr:nth-child(2) > vn-td-editable:nth-child(6)',
secondSaleConceptCell: 'vn-ticket-sale vn-table vn-tbody > vn-tr:nth-child(2) > vn-td-editable:nth-child(6) > div',
secondSaleConceptInput: 'vn-ticket-sale vn-table vn-tr:nth-child(2) > vn-td-editable.ng-isolate-scope.selected vn-textfield input',
totalImport: 'vn-ticket-sale > vn-vertical > vn-card > vn-vertical > vn-horizontal > vn-one > p:nth-child(3) > strong',
selectAllSalesCheckbox: 'vn-ticket-sale vn-thead vn-check',

View File

@ -138,6 +138,7 @@ describe('Client Edit fiscalData path', () => {
it(`should click on the 1st edit icon to confirm EQtax is checked`, async() => {
const result = await nightmare
.waitToClick(selectors.clientAddresses.firstEditAddress)
.waitForSpinnerLoad()
.checkboxState(selectors.clientAddresses.equalizationTaxCheckbox);
expect(result).toBe('checked');
@ -148,6 +149,7 @@ describe('Client Edit fiscalData path', () => {
const result = await nightmare
.waitToClick(selectors.clientAddresses.addressesButton)
.waitToClick(selectors.clientAddresses.secondEditAddress)
.waitForSpinnerLoad()
.checkboxState(selectors.clientAddresses.equalizationTaxCheckbox);
expect(result).toBe('checked');
@ -293,6 +295,7 @@ describe('Client Edit fiscalData path', () => {
it(`should click on the 1st edit icon to access the address details and uncheck EQtax checkbox`, async() => {
const result = await nightmare
.waitToClick(selectors.clientAddresses.firstEditAddress)
.waitForTextInInput(selectors.clientAddresses.cityInput, 'Silla')
.waitToClick(selectors.clientAddresses.equalizationTaxCheckbox)
.waitToClick(selectors.clientAddresses.saveButton)
.waitForLastSnackbar();

View File

@ -28,7 +28,7 @@ describe('Client add address notes path', () => {
.waitToClick(selectors.clientAddresses.saveButton)
.waitForLastSnackbar();
expect(result).toEqual('Observation type cannot be blank');
expect(result).toEqual('Some fields are invalid');
});
it('should not save an observation type without description', async() => {

View File

@ -13,6 +13,7 @@ describe('Item create niche path', () => {
it(`should click create a new niche and delete a former one`, async() => {
const result = await nightmare
.waitForTextInInput(`${selectors.itemNiches.firstWarehouseAutocomplete} input`, 'Warehouse One')
.waitToClick(selectors.itemNiches.addNicheButton)
.waitToClick(selectors.itemNiches.secondNicheRemoveButton)
.autocompleteSearch(selectors.itemNiches.thirdWarehouseAutocomplete, 'Warehouse Two')

View File

@ -27,7 +27,7 @@ describe('Item regularize path', () => {
expect(userLocalWarehouse).toContain('Warehouse Four');
});
it('should search for the item', async() => {
it('should search for an item', async() => {
const resultCount = await nightmare
.clearInput(selectors.itemsIndex.searchItemInput)
.write(selectors.itemsIndex.searchItemInput, 'Ranged weapon pistol 9mm')

View File

@ -42,7 +42,8 @@ describe('Item index path', () => {
.waitToClick(selectors.itemDescriptor.goBackToModuleIndexButton)
.waitToClick(selectors.itemsIndex.searchIcon)
.wait(selectors.itemsIndex.searchResult)
.isVisible(selectors.itemsIndex.firstItemImage);
.waitImgLoad(selectors.itemsIndex.firstItemImage)
.isVisible(selectors.itemsIndex.firstItemImageTd);
expect(imageVisible).toBeTruthy();
});

View File

@ -57,8 +57,8 @@ describe('Ticket List sale path', () => {
expect(result).toEqual('Data saved!');
});
it('should update the description of the new sale', async() => {
// #1865
xit('should update the description of the new sale', async() => {
const result = await nightmare
.focusElement(selectors.ticketSales.secondSaleConceptCell)
.write(selectors.ticketSales.secondSaleConceptInput, 'Aegis of Valor\u000d')

View File

@ -101,7 +101,10 @@ describe('Ticket descriptor path', () => {
it('should open the add stowaway dialog', async() => {
const isVisible = await nightmare
.waitForSpinnerLoad()
.wait(() => {
let element = document.querySelector('vn-ticket-descriptor');
return element.$ctrl.canShowStowaway === true;
})
.waitToClick(selectors.ticketDescriptor.moreMenu)
.waitToClick(selectors.ticketDescriptor.moreMenuAddStowaway)
.wait(selectors.ticketDescriptor.addStowawayDialogFirstTicket)
@ -127,7 +130,6 @@ describe('Ticket descriptor path', () => {
it(`should navigate back to the added ticket using the descriptors ship button`, async() => {
const url = await nightmare
.waitToClick(selectors.ticketDescriptor.closeStowawayDialog)
.waitToClick(selectors.ticketDescriptor.shipButton)
.waitForURL('#!/ticket/17/summary')
.parsedUrl();

View File

@ -15,6 +15,7 @@ describe('Ticket services path', () => {
it('should find the add descripton button disabled for this user role', async() => {
const result = await nightmare
.waitForClassPresent(selectors.ticketService.firstAddDescriptionButton, 'disabled')
.waitToClick(selectors.ticketService.addServiceButton)
.wait(selectors.ticketService.firstAddDescriptionButton)
.isDisabled(selectors.ticketService.firstAddDescriptionButton);
@ -129,7 +130,7 @@ describe('Ticket services path', () => {
expect(result).toEqual('Data saved!');
});
it(`should confirm the service wasn't sucessfully removed`, async() => {
it(`should confirm the service was removed`, async() => {
const result = await nightmare
.reloadSection('ticket.card.service')
.waitForNumberOfElements(selectors.ticketService.serviceLine, 0)

View File

@ -17,7 +17,7 @@ describe('claim Summary path', () => {
it(`should display details from the claim and it's client on the top of the header`, async() => {
let result = await nightmare
.waitForSpinnerLoad()
.waitForTextInElement(selectors.claimSummary.header, 'Tony Stark')
.waitToGetProperty(selectors.claimSummary.header, 'innerText');
expect(result).toContain('4 -');

View File

@ -140,7 +140,14 @@ describe('InvoiceOut descriptor path', () => {
it(`should check the invoiceOut booked in the summary data`, async() => {
let today = new Date();
let expectedDate = `${today.getDate()}/${(today.getMonth() + 1)}/${today.getFullYear()}`;
let day = today.getDate();
if (day < 10) day = `0${day}`;
let month = (today.getMonth() + 1);
if (month < 10) month = `0${month}`;
let expectedDate = `${day}/${month}/${today.getFullYear()}`;
const result = await nightmare
.waitToGetProperty(selectors.invoiceOutSummary.bookedLabel, 'innerText');

View File

@ -56,8 +56,7 @@ export default class Popup extends Component {
classList.add(this.displayMode);
classList.add(...this.constructor.$classNames);
if (!this.transitionTimeout)
this.document.body.appendChild(this.popup);
this.document.body.appendChild(this.popup);
this.keyDownHandler = e => this.onkeyDown(e);
this.document.addEventListener('keydown', this.keyDownHandler);
@ -79,6 +78,7 @@ export default class Popup extends Component {
*/
hide() {
if (!this.shown) return;
this._shown = false;
this.document.removeEventListener('keydown', this.keyDownHandler);
this.keyDownHandler = null;
@ -88,12 +88,10 @@ export default class Popup extends Component {
this.popup.classList.remove('shown');
this.$timeout.cancel(this.closeTimeout);
this.closeTimeout = this.$timeout(
() => this.onClose(), 200);
this.lastEvent = null;
this._shown = false;
this.emit('closeStart');
}
@ -102,6 +100,7 @@ export default class Popup extends Component {
this.popup.remove();
this.popup = null;
this.$contentScope.$destroy();
this.$contentScope = null;
this.windowEl = null;
this.emit('close');
}

View File

@ -181,9 +181,9 @@ function e2eOnly() {
})
.on('jasmineDone', function() {
const nightmare = createNightmare();
nightmare.end(() => {});
}));
})
);
}
e2eOnly.description = `Runs the e2e tests only`;

View File

@ -1,7 +1,6 @@
{
"State cannot be blank": "State cannot be blank",
"Cannot be blank": "Cannot be blank",
"Observation type cannot be blank": "Observation type cannot be blank",
"The credit must be an integer greater than or equal to zero": "The credit must be an integer greater than or equal to zero",
"The grade must be an integer greater than or equal to zero": "The grade must be an integer greater than or equal to zero",
"Invalid email": "Invalid email",

View File

@ -21,7 +21,6 @@
"Worker cannot be blank": "El trabajador no puede estar en blanco",
"Cannot change the payment method if no salesperson": "No se puede cambiar la forma de pago si no hay comercial asignado",
"can't be blank": "El campo no puede estar vacío",
"Observation type cannot be blank": "El tipo de observación no puede estar en blanco",
"Observation type must be unique": "El tipo de observación no puede repetirse",
"The credit must be an integer greater than or equal to zero": "The credit must be an integer greater than or equal to zero",
"The grade must be similar to the last one": "El grade debe ser similar al último",

View File

@ -56,10 +56,10 @@
"model": "ZoneExclusion",
"foreignKey": "zoneFk"
},
"warehouses": {
"type": "hasMany",
"model": "ZoneWarehouse",
"foreignKey": "zoneFk"
"warehouses": {
"type": "hasMany",
"model": "ZoneWarehouse",
"foreignKey": "zoneFk"
}
}
}

View File

@ -37,7 +37,6 @@ class Controller {
}
onDrop($event) {
console.log($event);
const files = $event.dataTransfer.files;
this.setDefaultParams().then(() => {
this.dms.files = files;

View File

@ -1,8 +1,4 @@
module.exports = function(Self) {
Self.validatesPresenceOf('observationTypeFk', {
message: 'Observation type cannot be blank'
});
Self.validateAsync('typeUnique', typeIsUnique, {
message: 'Observation type must be unique'
});

View File

@ -15,6 +15,9 @@
"description": {
"type": "string",
"required": true
},
"observationTypeFk": {
"required": true
}
},
"relations": {

View File

@ -140,7 +140,8 @@
data="types"
ng-model="observation.observationTypeFk"
show-field="description"
label="Observation type">
label="Observation type"
rule="AddressObservation">
</vn-autocomplete>
<vn-textfield
vn-two

View File

@ -29,7 +29,6 @@ export default class Controller {
this.$.watcher.realSubmit()
.then(() => this.$.model.save(true))
.then(() => {
this.$.watcher.setPristine();
this.$.watcher.notifySaved();
this.card.reload();
this.goToIndex();

View File

@ -49,10 +49,7 @@ export default class Controller {
returnDialogEt(response) {
if (response === 'accept') {
this.$http.patch(`Clients/${this.client.id}/addressesPropagateRe`, {isEqualizated: this.client.isEqualizated}).then(
res => {
if (res.data)
this.vnApp.showMessage(this.translate.instant('Equivalent tax spreaded'));
}
() => this.vnApp.showMessage(this.translate.instant('Equivalent tax spreaded'))
);
}
}

View File

@ -46,8 +46,7 @@ class Controller {
this.getShipped({
landed: this.ticket.landed,
addressFk: value,
agencyModeFk: this.ticket.agencyModeFk,
warehouseFk: this.ticket.warehouseFk
agencyModeFk: this.ticket.agencyModeFk
});
}
}
@ -78,8 +77,7 @@ class Controller {
this.getLanded({
shipped: value,
addressFk: this.ticket.addressFk,
agencyModeFk: this.ticket.agencyModeFk,
warehouseFk: this.ticket.warehouseFk
agencyModeFk: this.ticket.agencyModeFk
});
}
@ -92,8 +90,7 @@ class Controller {
this.getShipped({
landed: value,
addressFk: this.ticket.addressFk,
agencyModeFk: this.ticket.agencyModeFk,
warehouseFk: this.ticket.warehouseFk
agencyModeFk: this.ticket.agencyModeFk
});
}
@ -107,8 +104,7 @@ class Controller {
this.getLanded({
shipped: this.ticket.shipped,
addressFk: this.ticket.addressFk,
agencyModeFk: value,
warehouseFk: this.ticket.warehouseFk
agencyModeFk: value
});
}
}
@ -160,10 +156,7 @@ class Controller {
this.ticket.agencyModeFk = null;
const query = `Zones/${zoneId}`;
this.$http.get(query).then(res => {
if (res.data) {
this.ticket.agencyModeFk = res.data.agencyModeFk;
this.ticket.warehouseFk = res.data.warehouseFk;
}
this.ticket.agencyModeFk = res.data.agencyModeFk;
});
}
@ -205,7 +198,6 @@ class Controller {
if (res.data) {
this.ticket.zoneFk = res.data.zoneFk;
this.ticket.agencyModeFk = res.data.agencyModeFk;
this.ticket.warehouseFk = res.data.warehouseFk;
this.ticket.landed = res.data.landed;
this.ticket.shipped = params.shipped;
} else {
@ -226,7 +218,6 @@ class Controller {
if (res.data) {
this.ticket.zoneFk = res.data.zoneFk;
this.ticket.agencyModeFk = res.data.agencyModeFk;
this.ticket.warehouseFk = res.data.warehouseFk;
this.ticket.landed = params.landed;
this.ticket.shipped = res.data.shipped;
} else {

View File

@ -72,8 +72,7 @@ describe('Ticket', () => {
const spectedResult = {
landed: landed,
addressFk: 100,
agencyModeFk: 7,
warehouseFk: 1
agencyModeFk: 7
};
controller.landed = landed;
@ -99,8 +98,7 @@ describe('Ticket', () => {
const spectedResult = {
landed: landed,
addressFk: 121,
agencyModeFk: 7,
warehouseFk: 2
agencyModeFk: 7
};
controller.landed = landed;
@ -125,8 +123,7 @@ describe('Ticket', () => {
const spectedResult = {
shipped: shipped,
addressFk: 121,
agencyModeFk: 7,
warehouseFk: 1
agencyModeFk: 7
};
controller.shipped = shipped;
@ -150,8 +147,7 @@ describe('Ticket', () => {
const spectedResult = {
landed: landed,
addressFk: 121,
agencyModeFk: 7,
warehouseFk: 1
agencyModeFk: 7
};
controller.landed = landed;
@ -176,8 +172,7 @@ describe('Ticket', () => {
const spectedResult = {
shipped: shipped,
addressFk: 121,
agencyModeFk: agencyModeId,
warehouseFk: 1
agencyModeFk: agencyModeId
};
controller.ticket.shipped = shipped;
controller.agencyModeId = 8;
@ -192,8 +187,7 @@ describe('Ticket', () => {
const spectedResult = {
landed: landed,
addressFk: 121,
agencyModeFk: agencyModeId,
warehouseFk: 1
agencyModeFk: agencyModeId
};
controller.ticket.landed = landed;
controller.agencyModeId = 7;
@ -261,18 +255,13 @@ describe('Ticket', () => {
describe('onChangeZone()', () => {
it('should return an available zone', async() => {
const zoneId = 5;
const landed = new Date();
controller._ticket = {
id: 1,
landed: landed,
addressFk: 121,
warehouseFk: 1
};
$httpBackend.when('GET', `Zones/${zoneId}`).respond(200);
const agencyModeFk = 8;
$httpBackend.when('GET', `Zones/${zoneId}`).respond(200, {agencyModeFk});
$httpBackend.expect('GET', `Zones/${zoneId}`);
controller.onChangeZone(zoneId);
$httpBackend.flush();
expect(controller.ticket.agencyModeFk).toEqual(agencyModeFk);
});
});

View File

@ -1,12 +1,9 @@
import ngModule from '../module';
import Component from 'core/lib/component';
class Controller {
constructor($state, $scope, $http, vnApp, $translate, aclService) {
this.$scope = $scope;
this.$state = $state;
this.$http = $http;
this.vnApp = vnApp;
this.$translate = $translate;
class Controller extends Component {
constructor($element, $, aclService) {
super($element, $);
this.aclService = aclService;
this.moreOptions = [
{name: 'Add turn', callback: this.showAddTurnDialog},
@ -46,7 +43,7 @@ class Controller {
return;
}
this.newShipped = this.ticket.shipped;
this.$scope.changeShippedDialog.show();
this.$.changeShippedDialog.show();
}
changeShipped(response) {
@ -104,7 +101,7 @@ class Controller {
return (!hasShowProperty || option.show === true ||
typeof option.show === 'function' && option.show()) && hasAcl;
});
this.$scope.moreButton.data = options;
this.$.moreButton.data = options;
}
get isEditable() {
@ -116,13 +113,13 @@ class Controller {
}
showAddTurnDialog() {
this.$scope.addTurn.show();
this.$.addTurn.show();
}
addTurn(day) {
let params = {ticketFk: this.ticket.id, weekDay: day};
this.$http.patch(`TicketWeeklies`, params).then(() => {
this.$scope.addTurn.hide();
this.$.addTurn.hide();
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
});
}
@ -133,7 +130,7 @@ class Controller {
return;
}
this.$scope.deleteConfirmation.show();
this.$.deleteConfirmation.show();
}
deleteTicket(response) {
@ -147,11 +144,11 @@ class Controller {
}
showAddStowaway() {
this.$scope.addStowaway.show();
this.$.addStowaway.show();
}
showRemoveStowaway() {
this.$scope.removeStowaway.show();
this.$.removeStowaway.show();
}
get ticket() {
@ -160,11 +157,11 @@ class Controller {
set ticket(value) {
this._ticket = value;
if (value)
this.canStowaway();
if (!value) return;
this.canStowaway();
let links = {
btnOne: {
icon: 'person',
@ -212,14 +209,14 @@ class Controller {
destination: address.mobile || null,
message: this.$translate.instant('SMSPayment')
};
this.$scope.sms.open();
this.$.sms.open();
}
/**
* Shows an invoice confirmation
*/
showMakeInvoiceDialog() {
this.$scope.makeInvoiceConfirmation.show();
this.$.makeInvoiceConfirmation.show();
}
/**
@ -242,7 +239,7 @@ class Controller {
* Shows an invoice confirmation
*/
showRegenerateInvoiceDialog() {
this.$scope.regenerateInvoiceConfirmation.show();
this.$.regenerateInvoiceConfirmation.show();
}
/**
@ -273,7 +270,7 @@ class Controller {
}
confirmDeliveryNote() {
this.$scope.confirmDeliveryNote.show();
this.$.confirmDeliveryNote.show();
}
sendDeliveryNote(response) {
@ -285,7 +282,7 @@ class Controller {
}
}
Controller.$inject = ['$state', '$scope', '$http', 'vnApp', '$translate', 'aclService'];
Controller.$inject = ['$element', '$scope', 'aclService'];
ngModule.component('vnTicketDescriptor', {
template: require('./index.html'),

View File

@ -7,7 +7,8 @@ describe('Ticket Component vnTicketDescriptor', () => {
beforeEach(ngModule('ticket'));
beforeEach(angular.mock.inject(($componentController, _$state_, _$httpBackend_) => {
beforeEach(angular.mock.inject(($componentController, _$httpBackend_, $rootScope, $compile, _$state_) => {
let $element = $compile(`<vn-autocomplete></vn-autocomplete>`)($rootScope);
$state = _$state_;
$state.getCurrentPath = () => {
return [
@ -16,7 +17,7 @@ describe('Ticket Component vnTicketDescriptor', () => {
];
};
$httpBackend = _$httpBackend_;
controller = $componentController('vnTicketDescriptor', {$state});
controller = $componentController('vnTicketDescriptor', {$element});
controller._ticket = {id: 2, invoiceOut: {id: 1}};
controller.cardReload = ()=> {
return true;
@ -24,25 +25,25 @@ describe('Ticket Component vnTicketDescriptor', () => {
}));
describe('showAddTurnDialog()', () => {
it('should call contrtoller.$scope.addTurn.show()', () => {
controller.$scope.addTurn = {show: () => {}};
spyOn(controller.$scope.addTurn, 'show');
it('should call controller.$.addTurn.show()', () => {
controller.$.addTurn = {show: () => {}};
spyOn(controller.$.addTurn, 'show');
controller.showAddTurnDialog();
expect(controller.$scope.addTurn.show).toHaveBeenCalledWith();
expect(controller.$.addTurn.show).toHaveBeenCalledWith();
});
});
describe('addTurn()', () => {
it('should make a query and call $.addTurn.hide() and vnApp.showSuccess()', () => {
controller.$scope.addTurn = {hide: () => {}};
spyOn(controller.$scope.addTurn, 'hide');
controller.$.addTurn = {hide: () => {}};
spyOn(controller.$.addTurn, 'hide');
$httpBackend.expectPATCH(`TicketWeeklies`).respond();
controller.addTurn(1);
$httpBackend.flush();
expect(controller.$scope.addTurn.hide).toHaveBeenCalledWith();
expect(controller.$.addTurn.hide).toHaveBeenCalledWith();
});
});
@ -57,11 +58,11 @@ describe('Ticket Component vnTicketDescriptor', () => {
it('should call deleteConfirmation.show() if the ticket is editable', () => {
controller.ticket.tracking = {state: {alertLevel: 0}};
controller.$scope.deleteConfirmation = {show: () => {}};
spyOn(controller.$scope.deleteConfirmation, 'show');
controller.$.deleteConfirmation = {show: () => {}};
spyOn(controller.$.deleteConfirmation, 'show');
controller.showDeleteTicketDialog();
expect(controller.$scope.deleteConfirmation.show).toHaveBeenCalledWith();
expect(controller.$.deleteConfirmation.show).toHaveBeenCalledWith();
});
});
@ -136,21 +137,21 @@ describe('Ticket Component vnTicketDescriptor', () => {
describe('showAddStowaway()', () => {
it('should show a dialog with a list of tickets available for an stowaway', () => {
controller.$scope.addStowaway = {};
controller.$scope.addStowaway.show = jasmine.createSpy('show');
controller.$.addStowaway = {};
controller.$.addStowaway.show = jasmine.createSpy('show');
controller.showAddStowaway();
expect(controller.$scope.addStowaway.show).toHaveBeenCalledWith();
expect(controller.$.addStowaway.show).toHaveBeenCalledWith();
});
});
describe('showRemoveStowaway()', () => {
it('should show a dialog for an stowaway removal', () => {
controller.$scope.removeStowaway = {};
controller.$scope.removeStowaway.show = jasmine.createSpy('show');
controller.$.removeStowaway = {};
controller.$.removeStowaway.show = jasmine.createSpy('show');
controller.showRemoveStowaway();
expect(controller.$scope.removeStowaway.show).toHaveBeenCalledWith();
expect(controller.$.removeStowaway.show).toHaveBeenCalledWith();
});
});

View File

@ -152,7 +152,6 @@
<field>
<vn-textfield
vn-id="concept"
vn-focus
ng-model="sale.concept"
on-change="$ctrl.updateConcept(sale)">
</vn-textfield>

View File

@ -60,6 +60,7 @@
</vn-auto>
</vn-horizontal>
<vn-icon-button
ng-if=$ctrl.defaultTaxClass
vn-tooltip="Add service"
vn-bind="+"
icon="add_circle"

View File

@ -25,11 +25,13 @@ class Controller {
}
add() {
this.$scope.model.insert({
taxClassFk: this.defaultTaxClass.id,
quantity: 1,
ticketFk: this.$stateParams.id
});
if (this.defaultTaxClass) {
this.$scope.model.insert({
taxClassFk: this.defaultTaxClass.id,
quantity: 1,
ticketFk: this.$stateParams.id
});
}
}
onNewServiceTypeOpen() {