diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 37f7308a5..0ad9ad7f4 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -1014,9 +1014,9 @@ export default { save: 'vn-travel-create vn-submit > button' }, travelExtraCommunity: { - anySearchResult: 'vn-travel-extra-community > vn-data-viewer div > vn-tbody > vn-tr', - firstTravelReference: 'vn-travel-extra-community vn-tbody:nth-child(2) vn-td-editable[name="reference"]', - firstTravelLockedKg: 'vn-travel-extra-community vn-tbody:nth-child(2) vn-td-editable[name="lockedKg"]', + anySearchResult: 'vn-travel-extra-community > vn-card div > tbody > tr[ng-attr-id="{{::travel.id}}"]', + firstTravelReference: 'vn-travel-extra-community tbody:nth-child(2) vn-textfield[ng-model="travel.ref"]', + firstTravelLockedKg: 'vn-travel-extra-community tbody:nth-child(2) vn-input-number[ng-model="travel.kg"]', removeContinentFilter: 'vn-searchbar > form > vn-textfield > div.container > div.prepend > prepend > div > span:nth-child(3) > vn-icon > i' }, travelBasicData: { diff --git a/e2e/paths/10-travel/04_extra_community.spec.js b/e2e/paths/10-travel/04_extra_community.spec.js index e4a859192..a1cad6a7d 100644 --- a/e2e/paths/10-travel/04_extra_community.spec.js +++ b/e2e/paths/10-travel/04_extra_community.spec.js @@ -19,18 +19,22 @@ describe('Travel extra community path', () => { it('should edit the travel reference and the locked kilograms', async() => { await page.waitToClick(selectors.travelExtraCommunity.removeContinentFilter); await page.waitForSpinnerLoad(); - await page.writeOnEditableTD(selectors.travelExtraCommunity.firstTravelReference, 'edited reference'); - await page.waitForSpinnerLoad(); - await page.writeOnEditableTD(selectors.travelExtraCommunity.firstTravelLockedKg, '1500'); + await page.clearInput(selectors.travelExtraCommunity.firstTravelReference); + await page.write(selectors.travelExtraCommunity.firstTravelReference, 'edited reference'); + await page.clearInput(selectors.travelExtraCommunity.firstTravelLockedKg); + await page.write(selectors.travelExtraCommunity.firstTravelLockedKg, '1500'); + const message = await page.waitForSnackbar(); + + expect(message.text).toContain('Data saved!'); }); it('should reload the index and confirm the reference and locked kg were edited', async() => { await page.accessToSection('travel.index'); await page.accessToSection('travel.extraCommunity'); await page.waitToClick(selectors.travelExtraCommunity.removeContinentFilter); - await page.waitForTextInElement(selectors.travelExtraCommunity.firstTravelReference, 'edited reference'); - const reference = await page.getProperty(selectors.travelExtraCommunity.firstTravelReference, 'innerText'); - const lockedKg = await page.getProperty(selectors.travelExtraCommunity.firstTravelLockedKg, 'innerText'); + + const reference = await page.waitToGetProperty(selectors.travelExtraCommunity.firstTravelReference, 'value'); + const lockedKg = await page.waitToGetProperty(selectors.travelExtraCommunity.firstTravelLockedKg, 'value'); expect(reference).toContain('edited reference'); expect(lockedKg).toContain(1500); diff --git a/modules/travel/back/methods/travel/extraCommunityFilter.js b/modules/travel/back/methods/travel/extraCommunityFilter.js index 7769b7f21..feb16d052 100644 --- a/modules/travel/back/methods/travel/extraCommunityFilter.js +++ b/modules/travel/back/methods/travel/extraCommunityFilter.js @@ -128,7 +128,7 @@ module.exports = Self => { w.name AS warehouseInFk, w.name AS warehouseInName, SUM(b.stickers) AS stickers, - s.id AS supplierFk, + s.id AS cargoSupplierFk, s.nickname AS cargoSupplierNickname, CAST(SUM(i.density * b.stickers * IF(pkg.volume, pkg.volume, pkg.width * pkg.depth * pkg.height) / 1000000 ) as DECIMAL(10,0)) as loadedKg, CAST(SUM(167.5 * b.stickers * IF(pkg.volume, pkg.volume, pkg.width * pkg.depth * pkg.height) / 1000000 ) as DECIMAL(10,0)) as volumeKg @@ -160,13 +160,14 @@ module.exports = Self => { e.travelFk, e.ref, e.loadPriority, + s.id AS supplierFk, s.name AS supplierName, SUM(b.stickers) AS stickers, e.evaNotes, e.notes, CAST(SUM(i.density * b.stickers * IF(pkg.volume, pkg.volume, pkg.width * pkg.depth * pkg.height) / 1000000 ) as DECIMAL(10,0)) as loadedkg, CAST(SUM(167.5 * b.stickers * IF(pkg.volume, pkg.volume, pkg.width * pkg.depth * pkg.height) / 1000000 ) as DECIMAL(10,0)) as volumeKg - FROM tmp.travel tr + FROM tmp.travel tr JOIN entry e ON e.travelFk = tr.id JOIN buy b ON b.entryFk = e.id JOIN packaging pkg ON pkg.id = b.packageFk diff --git a/modules/travel/front/extra-community-search-panel/index.html b/modules/travel/front/extra-community-search-panel/index.html index ab1e88891..09fbb8949 100644 --- a/modules/travel/front/extra-community-search-panel/index.html +++ b/modules/travel/front/extra-community-search-panel/index.html @@ -50,15 +50,15 @@ @@ -84,4 +84,4 @@ - \ No newline at end of file + diff --git a/modules/travel/front/extra-community/index.html b/modules/travel/front/extra-community/index.html index 0b94c6c1e..f19ab592e 100644 --- a/modules/travel/front/extra-community/index.html +++ b/modules/travel/front/extra-community/index.html @@ -1,6 +1,7 @@ - - -
- - - - - - - - Id - Supplier - Freighter - Reference - Packages - Bl. KG - Phy. KG - Vol. KG - - Wh. Out - - W. Shipped - - Wh. In - - W. Landed - - - - - - + + +
+ + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + +
+ Id + + Supplier + + Agency + + Reference + + Packages + + Bl. KG + + Phy. KG + + Vol. KG + + Wh. Out + + W. Shipped + + Wh. In + + W. Landed +
+ {{::travel.id}} - - {{::travel.agencyModeName}} - {{::travel.cargoSupplierNickname}} - - {{travel.ref}} - - - - - - {{::travel.stickers}} - - {{travel.kg}} - - - - - - {{::travel.loadedKg}} - {{::travel.volumeKg}} - {{::travel.warehouseOutName}} - {{::travel.shipped | date: 'dd/MM/yyyy'}} - {{::travel.warehouseInName}} - {{::travel.landed | date: 'dd/MM/yyyy'}} - - + + + {{::travel.cargoSupplierNickname}} + + {{::travel.agencyModeName}} + + + + {{::travel.stickers}} + + + {{::travel.loadedKg}}{{::travel.volumeKg}}{{::travel.warehouseOutName}}{{::travel.shipped | date: 'dd/MM/yyyy'}}{{::travel.warehouseInName}}{{::travel.landed | date: 'dd/MM/yyyy'}}
{{::entry.id}} - - {{::entry.supplierName}} - - {{::entry.ref}} - {{::entry.stickers}} - - {{::entry.loadedkg}} - {{::entry.volumeKg}} - + + + {{::entry.supplierName}} + + {{::entry.ref}}{{::entry.stickers}}{{::entry.loadedkg}}{{::entry.volumeKg}} {{::entry.notes}} - - + {{::entry.evaNotes}} - - - - - - - - - +
+
+
+ - + + diff --git a/modules/travel/front/extra-community/index.js b/modules/travel/front/extra-community/index.js index a380c1ed8..461712e9c 100644 --- a/modules/travel/front/extra-community/index.js +++ b/modules/travel/front/extra-community/index.js @@ -14,8 +14,15 @@ class Controller extends Section { draggable.addEventListener('dragend', event => this.dragEnd(event)); - this.draggableElement = 'a[draggable]'; - this.droppableElement = 'vn-tbody[vn-droppable]'; + draggable.addEventListener('dragover', + event => this.dragOver(event)); + draggable.addEventListener('dragenter', + event => this.dragEnter(event)); + draggable.addEventListener('dragleave', + event => this.dragLeave(event)); + + this.draggableElement = 'tr[draggable]'; + this.droppableElement = 'tbody[vn-droppable]'; const twoDays = 2; const shippedFrom = new Date(); @@ -32,6 +39,8 @@ class Controller extends Section { landedTo: landedTo, continent: 'AM' }; + + this.smartTableOptions = {}; } get hasDateRange() { @@ -44,6 +53,15 @@ class Controller extends Section { return hasLanded || hasShipped || hasContinent || hasWarehouseOut; } + onDragInterval() { + if (this.dragClientY > 0 && this.dragClientY < 75) + this.$window.scrollTo(0, this.$window.scrollY - 10); + + const maxHeight = window.screen.availHeight - (window.outerHeight - window.innerHeight); + if (this.dragClientY > maxHeight - 75 && this.dragClientY < maxHeight) + this.$window.scrollTo(0, this.$window.scrollY + 10); + } + findDraggable($event) { const target = $event.target; const draggable = target.closest(this.draggableElement); @@ -65,6 +83,7 @@ class Controller extends Section { const id = parseInt(draggable.id); this.entryId = id; this.entry = draggable; + this.interval = setInterval(() => this.onDragInterval(), 50); } dragEnd($event) { @@ -72,6 +91,8 @@ class Controller extends Section { draggable.classList.remove('dragging'); this.entryId = null; this.entry = null; + + clearInterval(this.interval); } onDrop($event) { @@ -91,6 +112,37 @@ class Controller extends Section { } } + undrop() { + if (!this.dropping) return; + this.dropping.classList.remove('dropping'); + this.dropping = null; + } + + dragOver($event) { + this.dragClientY = $event.clientY; + $event.preventDefault(); + } + + dragEnter($event) { + let element = this.findDroppable($event); + if (element) this.dropCount++; + + if (element != this.dropping) { + this.undrop(); + if (element) element.classList.add('dropping'); + this.dropping = element; + } + } + + dragLeave($event) { + let element = this.findDroppable($event); + + if (element) { + this.dropCount--; + if (this.dropCount == 0) this.undrop(); + } + } + save(id, data) { const endpoint = `Travels/${id}`; this.$http.patch(endpoint, data) diff --git a/modules/travel/front/extra-community/index.spec.js b/modules/travel/front/extra-community/index.spec.js index 59688a46c..ae48b9ca1 100644 --- a/modules/travel/front/extra-community/index.spec.js +++ b/modules/travel/front/extra-community/index.spec.js @@ -27,7 +27,7 @@ describe('Travel Component vnTravelExtraCommunity', () => { describe('findDraggable()', () => { it('should find the draggable element', () => { - const draggable = document.createElement('a'); + const draggable = document.createElement('tr'); draggable.setAttribute('draggable', true); const $event = new Event('dragstart'); @@ -43,7 +43,7 @@ describe('Travel Component vnTravelExtraCommunity', () => { describe('findDroppable()', () => { it('should find the droppable element', () => { - const droppable = document.createElement('vn-tbody'); + const droppable = document.createElement('tbody'); droppable.setAttribute('vn-droppable', true); const $event = new Event('drop'); @@ -58,9 +58,9 @@ describe('Travel Component vnTravelExtraCommunity', () => { }); describe('dragStart()', () => { - it(`should add the class "dragging" to the draggable element + it(`should add the class "dragging" to the draggable element and then set the entryId controller property`, () => { - const draggable = document.createElement('a'); + const draggable = document.createElement('tr'); draggable.setAttribute('draggable', true); draggable.setAttribute('id', 3); @@ -78,9 +78,9 @@ describe('Travel Component vnTravelExtraCommunity', () => { }); describe('dragEnd()', () => { - it(`should remove the class "dragging" from the draggable element + it(`should remove the class "dragging" from the draggable element and then set the entryId controller property to null`, () => { - const draggable = document.createElement('a'); + const draggable = document.createElement('tr'); draggable.setAttribute('draggable', true); draggable.setAttribute('id', 3); draggable.classList.add('dragging'); @@ -100,13 +100,13 @@ describe('Travel Component vnTravelExtraCommunity', () => { describe('onDrop()', () => { it('should make an HTTP patch query', () => { - const droppable = document.createElement('vn-tbody'); + const droppable = document.createElement('tbody'); droppable.setAttribute('vn-droppable', true); droppable.setAttribute('id', 1); jest.spyOn(controller, 'findDroppable').mockReturnValue(droppable); - const oldDroppable = document.createElement('vn-tbody'); + const oldDroppable = document.createElement('tbody'); oldDroppable.setAttribute('vn-droppable', true); const entry = document.createElement('div'); oldDroppable.appendChild(entry); diff --git a/modules/travel/front/extra-community/style.scss b/modules/travel/front/extra-community/style.scss index f903f94ea..532a3056a 100644 --- a/modules/travel/front/extra-community/style.scss +++ b/modules/travel/front/extra-community/style.scss @@ -15,41 +15,44 @@ vn-travel-extra-community { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; + cursor: pointer; } - vn-td-editable text { - background-color: transparent; - padding: 0; - border: 0; - border-bottom: 1px dashed $color-active; - border-radius: 0; - color: $color-active - } - - vn-td-editable:hover text:after { - font-family: 'Material Icons'; - content: 'edit'; - position: absolute; - right: -15px; - color: $color-spacer - } - - vn-table[vn-droppable] { + table[vn-droppable] { border-radius: 0; } - a[draggable] { + tr[draggable] { transition: all .5s; cursor: move; + overflow: auto; outline: 0; + height: 65px; + pointer-events: fill; + user-select:all; } - a[draggable]:hover { - background-color: $color-hover-cd + tr[draggable] *::selection{ + background-color: transparent; } - a[draggable].dragging { - background-color: $color-success-light; - font-weight:bold + tr[draggable]:hover { + background-color: $color-hover-cd; } -} \ No newline at end of file + + tr[draggable].dragging { + background-color: $color-primary-light; + color: $color-font-light; + font-weight:bold; + } + + .td-editable{ + input{ + font-size: 1.25rem!important; + } + } + + .number *{ + text-align: right; + } +}