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

View File

@ -191,7 +191,8 @@ export default {
closeItemSummaryPreview: '.vn-popup.shown', closeItemSummaryPreview: '.vn-popup.shown',
fieldsToShowButton: 'vn-item-index vn-table > div > div > vn-icon-button[icon="menu"]', fieldsToShowButton: 'vn-item-index vn-table > div > div > vn-icon-button[icon="menu"]',
fieldsToShowForm: '.vn-dialog.shown form', 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)', 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', idCheckbox: '.vn-dialog.shown form vn-horizontal:nth-child(2) > vn-check',
stemsCheckbox: '.vn-dialog.shown form vn-horizontal:nth-child(3) > 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"]', shipButton: 'vn-ticket-descriptor vn-icon[icon="icon-stowaway"]',
thursdayButton: '.vn-popup.shown vn-tool-bar > vn-button:nth-child(4)', thursdayButton: '.vn-popup.shown vn-tool-bar > vn-button:nth-child(4)',
saturdayButton: '.vn-popup.shown vn-tool-bar > vn-button:nth-child(6)', 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"]', acceptDeleteButton: '.vn-dialog.shown button[response="accept"]',
acceptChangeHourButton: '.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', 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', 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', 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', 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', 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', 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', 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() => { it(`should click on the 1st edit icon to confirm EQtax is checked`, async() => {
const result = await nightmare const result = await nightmare
.waitToClick(selectors.clientAddresses.firstEditAddress) .waitToClick(selectors.clientAddresses.firstEditAddress)
.waitForSpinnerLoad()
.checkboxState(selectors.clientAddresses.equalizationTaxCheckbox); .checkboxState(selectors.clientAddresses.equalizationTaxCheckbox);
expect(result).toBe('checked'); expect(result).toBe('checked');
@ -148,6 +149,7 @@ describe('Client Edit fiscalData path', () => {
const result = await nightmare const result = await nightmare
.waitToClick(selectors.clientAddresses.addressesButton) .waitToClick(selectors.clientAddresses.addressesButton)
.waitToClick(selectors.clientAddresses.secondEditAddress) .waitToClick(selectors.clientAddresses.secondEditAddress)
.waitForSpinnerLoad()
.checkboxState(selectors.clientAddresses.equalizationTaxCheckbox); .checkboxState(selectors.clientAddresses.equalizationTaxCheckbox);
expect(result).toBe('checked'); 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() => { it(`should click on the 1st edit icon to access the address details and uncheck EQtax checkbox`, async() => {
const result = await nightmare const result = await nightmare
.waitToClick(selectors.clientAddresses.firstEditAddress) .waitToClick(selectors.clientAddresses.firstEditAddress)
.waitForTextInInput(selectors.clientAddresses.cityInput, 'Silla')
.waitToClick(selectors.clientAddresses.equalizationTaxCheckbox) .waitToClick(selectors.clientAddresses.equalizationTaxCheckbox)
.waitToClick(selectors.clientAddresses.saveButton) .waitToClick(selectors.clientAddresses.saveButton)
.waitForLastSnackbar(); .waitForLastSnackbar();

View File

@ -28,7 +28,7 @@ describe('Client add address notes path', () => {
.waitToClick(selectors.clientAddresses.saveButton) .waitToClick(selectors.clientAddresses.saveButton)
.waitForLastSnackbar(); .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() => { 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() => { it(`should click create a new niche and delete a former one`, async() => {
const result = await nightmare const result = await nightmare
.waitForTextInInput(`${selectors.itemNiches.firstWarehouseAutocomplete} input`, 'Warehouse One')
.waitToClick(selectors.itemNiches.addNicheButton) .waitToClick(selectors.itemNiches.addNicheButton)
.waitToClick(selectors.itemNiches.secondNicheRemoveButton) .waitToClick(selectors.itemNiches.secondNicheRemoveButton)
.autocompleteSearch(selectors.itemNiches.thirdWarehouseAutocomplete, 'Warehouse Two') .autocompleteSearch(selectors.itemNiches.thirdWarehouseAutocomplete, 'Warehouse Two')

View File

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

View File

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

View File

@ -57,8 +57,8 @@ describe('Ticket List sale path', () => {
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
}); });
// #1865
it('should update the description of the new sale', async() => { xit('should update the description of the new sale', async() => {
const result = await nightmare const result = await nightmare
.focusElement(selectors.ticketSales.secondSaleConceptCell) .focusElement(selectors.ticketSales.secondSaleConceptCell)
.write(selectors.ticketSales.secondSaleConceptInput, 'Aegis of Valor\u000d') .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() => { it('should open the add stowaway dialog', async() => {
const isVisible = await nightmare 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.moreMenu)
.waitToClick(selectors.ticketDescriptor.moreMenuAddStowaway) .waitToClick(selectors.ticketDescriptor.moreMenuAddStowaway)
.wait(selectors.ticketDescriptor.addStowawayDialogFirstTicket) .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() => { it(`should navigate back to the added ticket using the descriptors ship button`, async() => {
const url = await nightmare const url = await nightmare
.waitToClick(selectors.ticketDescriptor.closeStowawayDialog)
.waitToClick(selectors.ticketDescriptor.shipButton) .waitToClick(selectors.ticketDescriptor.shipButton)
.waitForURL('#!/ticket/17/summary') .waitForURL('#!/ticket/17/summary')
.parsedUrl(); .parsedUrl();

View File

@ -15,6 +15,7 @@ describe('Ticket services path', () => {
it('should find the add descripton button disabled for this user role', async() => { it('should find the add descripton button disabled for this user role', async() => {
const result = await nightmare const result = await nightmare
.waitForClassPresent(selectors.ticketService.firstAddDescriptionButton, 'disabled')
.waitToClick(selectors.ticketService.addServiceButton) .waitToClick(selectors.ticketService.addServiceButton)
.wait(selectors.ticketService.firstAddDescriptionButton) .wait(selectors.ticketService.firstAddDescriptionButton)
.isDisabled(selectors.ticketService.firstAddDescriptionButton); .isDisabled(selectors.ticketService.firstAddDescriptionButton);
@ -129,7 +130,7 @@ describe('Ticket services path', () => {
expect(result).toEqual('Data saved!'); 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 const result = await nightmare
.reloadSection('ticket.card.service') .reloadSection('ticket.card.service')
.waitForNumberOfElements(selectors.ticketService.serviceLine, 0) .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() => { it(`should display details from the claim and it's client on the top of the header`, async() => {
let result = await nightmare let result = await nightmare
.waitForSpinnerLoad() .waitForTextInElement(selectors.claimSummary.header, 'Tony Stark')
.waitToGetProperty(selectors.claimSummary.header, 'innerText'); .waitToGetProperty(selectors.claimSummary.header, 'innerText');
expect(result).toContain('4 -'); 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() => { it(`should check the invoiceOut booked in the summary data`, async() => {
let today = new Date(); 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 const result = await nightmare
.waitToGetProperty(selectors.invoiceOutSummary.bookedLabel, 'innerText'); .waitToGetProperty(selectors.invoiceOutSummary.bookedLabel, 'innerText');

View File

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

View File

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

View File

@ -1,7 +1,6 @@
{ {
"State cannot be blank": "State cannot be blank", "State cannot be blank": "State cannot be blank",
"Cannot be blank": "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 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", "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", "Invalid email": "Invalid email",

View File

@ -21,7 +21,6 @@
"Worker cannot be blank": "El trabajador no puede estar en blanco", "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", "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", "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", "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 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", "The grade must be similar to the last one": "El grade debe ser similar al último",

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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