diff --git a/db/changes/10100-AllSaints/01-userPhone.sql b/db/changes/10100-AllSaints/01-userPhone.sql index e82b48000..99690b0b6 100644 --- a/db/changes/10100-AllSaints/01-userPhone.sql +++ b/db/changes/10100-AllSaints/01-userPhone.sql @@ -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') \ No newline at end of file diff --git a/e2e/helpers/extensions.js b/e2e/helpers/extensions.js index c00a224b8..e6250a8a2 100644 --- a/e2e/helpers/extensions.js +++ b/e2e/helpers/extensions.js @@ -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) { diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 8abeaae95..f03e57962 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -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', diff --git a/e2e/paths/02-client-module/03_edit_fiscal_data.spec.js b/e2e/paths/02-client-module/03_edit_fiscal_data.spec.js index cbe3722de..836ce8976 100644 --- a/e2e/paths/02-client-module/03_edit_fiscal_data.spec.js +++ b/e2e/paths/02-client-module/03_edit_fiscal_data.spec.js @@ -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(); diff --git a/e2e/paths/02-client-module/06_add_address_notes.spec.js b/e2e/paths/02-client-module/06_add_address_notes.spec.js index cb4398366..a37fef529 100644 --- a/e2e/paths/02-client-module/06_add_address_notes.spec.js +++ b/e2e/paths/02-client-module/06_add_address_notes.spec.js @@ -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() => { diff --git a/e2e/paths/04-item-module/05_niche.spec.js b/e2e/paths/04-item-module/05_niche.spec.js index fcb3c69ef..042b28638 100644 --- a/e2e/paths/04-item-module/05_niche.spec.js +++ b/e2e/paths/04-item-module/05_niche.spec.js @@ -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') diff --git a/e2e/paths/04-item-module/09_regularize.spec.js b/e2e/paths/04-item-module/09_regularize.spec.js index 242414372..a83b9ef7f 100644 --- a/e2e/paths/04-item-module/09_regularize.spec.js +++ b/e2e/paths/04-item-module/09_regularize.spec.js @@ -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') diff --git a/e2e/paths/04-item-module/10_item_index.spec.js b/e2e/paths/04-item-module/10_item_index.spec.js index b83b37c59..32a6effda 100644 --- a/e2e/paths/04-item-module/10_item_index.spec.js +++ b/e2e/paths/04-item-module/10_item_index.spec.js @@ -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(); }); diff --git a/e2e/paths/05-ticket-module/01-sale/01_list_sales.spec.js b/e2e/paths/05-ticket-module/01-sale/01_list_sales.spec.js index 1f768c272..a5f7aa423 100644 --- a/e2e/paths/05-ticket-module/01-sale/01_list_sales.spec.js +++ b/e2e/paths/05-ticket-module/01-sale/01_list_sales.spec.js @@ -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') diff --git a/e2e/paths/05-ticket-module/12_descriptor.spec.js b/e2e/paths/05-ticket-module/12_descriptor.spec.js index b9c6c7c87..9442f1be0 100644 --- a/e2e/paths/05-ticket-module/12_descriptor.spec.js +++ b/e2e/paths/05-ticket-module/12_descriptor.spec.js @@ -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(); diff --git a/e2e/paths/05-ticket-module/13_services.spec.js b/e2e/paths/05-ticket-module/13_services.spec.js index d2b24de11..01da91f1b 100644 --- a/e2e/paths/05-ticket-module/13_services.spec.js +++ b/e2e/paths/05-ticket-module/13_services.spec.js @@ -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) diff --git a/e2e/paths/06-claim-module/05_summary.spec.js b/e2e/paths/06-claim-module/05_summary.spec.js index dde444ea3..b6d16cb6b 100644 --- a/e2e/paths/06-claim-module/05_summary.spec.js +++ b/e2e/paths/06-claim-module/05_summary.spec.js @@ -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 -'); diff --git a/e2e/paths/09-invoice-out-module/01_descriptor.spec.js b/e2e/paths/09-invoice-out-module/01_descriptor.spec.js index f170b87b0..9701d2238 100644 --- a/e2e/paths/09-invoice-out-module/01_descriptor.spec.js +++ b/e2e/paths/09-invoice-out-module/01_descriptor.spec.js @@ -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'); diff --git a/front/core/components/popup/index.js b/front/core/components/popup/index.js index e2cd7092f..994f4a0e7 100644 --- a/front/core/components/popup/index.js +++ b/front/core/components/popup/index.js @@ -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'); } diff --git a/gulpfile.js b/gulpfile.js index 56325ae8b..06c65e451 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -181,9 +181,9 @@ function e2eOnly() { }) .on('jasmineDone', function() { const nightmare = createNightmare(); - nightmare.end(() => {}); - })); + }) + ); } e2eOnly.description = `Runs the e2e tests only`; diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 862dd999e..301395559 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -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", diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 381814039..276e4aa0c 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -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", diff --git a/modules/agency/back/models/zone.json b/modules/agency/back/models/zone.json index 02e3cadda..853f1f4d2 100644 --- a/modules/agency/back/models/zone.json +++ b/modules/agency/back/models/zone.json @@ -56,10 +56,10 @@ "model": "ZoneExclusion", "foreignKey": "zoneFk" }, - "warehouses": { - "type": "hasMany", - "model": "ZoneWarehouse", - "foreignKey": "zoneFk" + "warehouses": { + "type": "hasMany", + "model": "ZoneWarehouse", + "foreignKey": "zoneFk" } } } \ No newline at end of file diff --git a/modules/claim/front/dms/index/index.js b/modules/claim/front/dms/index/index.js index 022c7c3ab..20eba62a3 100644 --- a/modules/claim/front/dms/index/index.js +++ b/modules/claim/front/dms/index/index.js @@ -37,7 +37,6 @@ class Controller { } onDrop($event) { - console.log($event); const files = $event.dataTransfer.files; this.setDefaultParams().then(() => { this.dms.files = files; diff --git a/modules/client/back/models/address-observation.js b/modules/client/back/models/address-observation.js index d148b967e..1c0a8aef7 100644 --- a/modules/client/back/models/address-observation.js +++ b/modules/client/back/models/address-observation.js @@ -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' }); diff --git a/modules/client/back/models/address-observation.json b/modules/client/back/models/address-observation.json index c338d972b..3096c8e5d 100644 --- a/modules/client/back/models/address-observation.json +++ b/modules/client/back/models/address-observation.json @@ -15,6 +15,9 @@ "description": { "type": "string", "required": true + }, + "observationTypeFk": { + "required": true } }, "relations": { diff --git a/modules/client/front/address/edit/index.html b/modules/client/front/address/edit/index.html index 3e5daaf0d..ed3758e33 100644 --- a/modules/client/front/address/edit/index.html +++ b/modules/client/front/address/edit/index.html @@ -140,7 +140,8 @@ data="types" ng-model="observation.observationTypeFk" show-field="description" - label="Observation type"> + label="Observation type" + rule="AddressObservation"> this.$.model.save(true)) .then(() => { - this.$.watcher.setPristine(); this.$.watcher.notifySaved(); this.card.reload(); this.goToIndex(); diff --git a/modules/client/front/fiscal-data/index.js b/modules/client/front/fiscal-data/index.js index f32002ebf..8a2d85109 100644 --- a/modules/client/front/fiscal-data/index.js +++ b/modules/client/front/fiscal-data/index.js @@ -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')) ); } } diff --git a/modules/ticket/front/basic-data/step-one/index.js b/modules/ticket/front/basic-data/step-one/index.js index 3cca80d57..568284198 100644 --- a/modules/ticket/front/basic-data/step-one/index.js +++ b/modules/ticket/front/basic-data/step-one/index.js @@ -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 { diff --git a/modules/ticket/front/basic-data/step-one/index.spec.js b/modules/ticket/front/basic-data/step-one/index.spec.js index 326d9ac15..77d20bda5 100644 --- a/modules/ticket/front/basic-data/step-one/index.spec.js +++ b/modules/ticket/front/basic-data/step-one/index.spec.js @@ -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); }); }); diff --git a/modules/ticket/front/descriptor/index.js b/modules/ticket/front/descriptor/index.js index 4d8df2d1f..beb95ee75 100644 --- a/modules/ticket/front/descriptor/index.js +++ b/modules/ticket/front/descriptor/index.js @@ -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'), diff --git a/modules/ticket/front/descriptor/index.spec.js b/modules/ticket/front/descriptor/index.spec.js index cca3045c3..f1ebd55b7 100644 --- a/modules/ticket/front/descriptor/index.spec.js +++ b/modules/ticket/front/descriptor/index.spec.js @@ -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(``)($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(); }); }); diff --git a/modules/ticket/front/sale/index.html b/modules/ticket/front/sale/index.html index 1bf27a2b5..bd9b390b5 100644 --- a/modules/ticket/front/sale/index.html +++ b/modules/ticket/front/sale/index.html @@ -152,7 +152,6 @@ diff --git a/modules/ticket/front/services/index.html b/modules/ticket/front/services/index.html index 6d42ba9d9..f7db96a5c 100644 --- a/modules/ticket/front/services/index.html +++ b/modules/ticket/front/services/index.html @@ -60,6 +60,7 @@