From bce66899c54dfeb1631242c356747a67950b7124 Mon Sep 17 00:00:00 2001 From: carlosjr Date: Tue, 1 Feb 2022 12:24:11 +0100 Subject: [PATCH 1/5] corrected a typo --- .../entry/back/methods/entry/specs/latestBuysFilter.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/entry/back/methods/entry/specs/latestBuysFilter.spec.js b/modules/entry/back/methods/entry/specs/latestBuysFilter.spec.js index aa8f23a85..7c813ea89 100644 --- a/modules/entry/back/methods/entry/specs/latestBuysFilter.spec.js +++ b/modules/entry/back/methods/entry/specs/latestBuysFilter.spec.js @@ -1,6 +1,6 @@ const models = require('vn-loopback/server/server').models; -describe('Buy latests buys filter()', () => { +describe('Entry latests buys filter()', () => { it('should return the entry matching "search"', async() => { const tx = await models.Buy.beginTransaction({}); const options = {transaction: tx}; @@ -12,7 +12,7 @@ describe('Buy latests buys filter()', () => { } }; - const results = await models.Buy.latestBuysFilter(ctx); + const results = await models.Buy.latestBuysFilter(ctx, options); const firstBuy = results[0]; expect(results.length).toEqual(1); From cb21d4db01ad86d9d3beb7ac81f1996149bc8267 Mon Sep 17 00:00:00 2001 From: carlosjr Date: Mon, 7 Feb 2022 17:59:40 +0100 Subject: [PATCH 2/5] removed a typo --- modules/claim/front/search-panel/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/claim/front/search-panel/index.html b/modules/claim/front/search-panel/index.html index 6efd6603b..dbbc3a46b 100644 --- a/modules/claim/front/search-panel/index.html +++ b/modules/claim/front/search-panel/index.html @@ -12,7 +12,7 @@ Date: Mon, 7 Feb 2022 18:00:23 +0100 Subject: [PATCH 3/5] added groupingMode to getBuys --- modules/entry/back/methods/entry/getBuys.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/entry/back/methods/entry/getBuys.js b/modules/entry/back/methods/entry/getBuys.js index 6da9ec53e..ebb271df1 100644 --- a/modules/entry/back/methods/entry/getBuys.js +++ b/modules/entry/back/methods/entry/getBuys.js @@ -18,7 +18,7 @@ module.exports = Self => { } ], returns: { - type: ['Object'], + type: ['object'], root: true }, http: { @@ -42,6 +42,7 @@ module.exports = Self => { 'stickers', 'packing', 'grouping', + 'groupingMode', 'quantity', 'packageFk', 'weight', From 00f89466751e362c4f276adeabd761d750b313bf Mon Sep 17 00:00:00 2001 From: carlosjr Date: Mon, 7 Feb 2022 18:01:45 +0100 Subject: [PATCH 4/5] feat(entry.buys): each buy groupingMode can now changed --- modules/entry/front/buy/index/index.html | 33 +++++++++++++-- modules/entry/front/buy/index/index.js | 17 ++++++++ modules/entry/front/buy/index/index.spec.js | 47 +++++++++++++++++++++ 3 files changed, 94 insertions(+), 3 deletions(-) diff --git a/modules/entry/front/buy/index/index.html b/modules/entry/front/buy/index/index.html index bb33b98b3..eaa37c92e 100644 --- a/modules/entry/front/buy/index/index.html +++ b/modules/entry/front/buy/index/index.html @@ -111,17 +111,45 @@ - + + + + + + - + + + + + + @@ -213,7 +241,6 @@ vn-id="item-descriptor" warehouse-fk="$ctrl.vnConfig.warehouseFk"> - { + buy.groupingMode = newGroupingMode; + this.vnApp.showSuccess(this.$t('Data saved!')); + }); + } } ngModule.vnComponent('vnEntryBuyIndex', { diff --git a/modules/entry/front/buy/index/index.spec.js b/modules/entry/front/buy/index/index.spec.js index ee249c3b6..b9884acb1 100644 --- a/modules/entry/front/buy/index/index.spec.js +++ b/modules/entry/front/buy/index/index.spec.js @@ -1,3 +1,4 @@ +/* eslint max-len: ["error", { "code": 150 }]*/ import './index.js'; describe('Entry buy', () => { @@ -64,4 +65,50 @@ describe('Entry buy', () => { expect(controller.buys.length).toEqual(1); }); }); + + describe('toggleGroupingMode()', () => { + it(`should toggle grouping mode from grouping to packing`, () => { + const groupingFk = 1; + const packingFk = 2; + const buy = {id: 999, groupingMode: groupingFk}; + + const query = `Buys/${buy.id}`; + $httpBackend.expectPATCH(query, {groupingMode: packingFk}).respond(200); + controller.toggleGroupingMode(buy, 'packing'); + $httpBackend.flush(); + }); + + it(`should toggle grouping mode from packing to grouping`, () => { + const groupingFk = 1; + const packingFk = 2; + const buy = {id: 999, groupingMode: packingFk}; + + const query = `Buys/${buy.id}`; + $httpBackend.expectPATCH(query, {groupingMode: groupingFk}).respond(200); + controller.toggleGroupingMode(buy, 'grouping'); + $httpBackend.flush(); + }); + + it(`should toggle off the grouping mode if it was packing to packing`, () => { + const noGroupingFk = 0; + const packingFk = 2; + const buy = {id: 999, groupingMode: packingFk}; + + const query = `Buys/${buy.id}`; + $httpBackend.expectPATCH(query, {groupingMode: noGroupingFk}).respond(200); + controller.toggleGroupingMode(buy, 'packing'); + $httpBackend.flush(); + }); + + it(`should toggle off the grouping mode if it was grouping to grouping`, () => { + const noGroupingFk = 0; + const groupingFk = 1; + const buy = {id: 999, groupingMode: groupingFk}; + + const query = `Buys/${buy.id}`; + $httpBackend.expectPATCH(query, {groupingMode: noGroupingFk}).respond(200); + controller.toggleGroupingMode(buy, 'grouping'); + $httpBackend.flush(); + }); + }); }); From 4f1d34069b1a65ee2ef315dcce2a32003358222c Mon Sep 17 00:00:00 2001 From: carlosjr Date: Tue, 8 Feb 2022 09:27:39 +0100 Subject: [PATCH 5/5] corrected some typos --- modules/entry/front/buy/index/index.js | 8 +++--- modules/entry/front/buy/index/index.spec.js | 32 ++++++++++----------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/modules/entry/front/buy/index/index.js b/modules/entry/front/buy/index/index.js index 2f2588cde..6d9ee5760 100644 --- a/modules/entry/front/buy/index/index.js +++ b/modules/entry/front/buy/index/index.js @@ -58,11 +58,11 @@ export default class Controller extends Section { } toggleGroupingMode(buy, mode) { - const groupingFk = 1; - const packingFk = 2; - const grouingMode = mode === 'grouping' ? groupingFk : packingFk; + const grouping = 1; + const packing = 2; + const groupingMode = mode === 'grouping' ? grouping : packing; - const newGroupingMode = buy.groupingMode === grouingMode ? 0 : grouingMode; + const newGroupingMode = buy.groupingMode === groupingMode ? 0 : groupingMode; const params = { groupingMode: newGroupingMode diff --git a/modules/entry/front/buy/index/index.spec.js b/modules/entry/front/buy/index/index.spec.js index b9884acb1..aff52bc80 100644 --- a/modules/entry/front/buy/index/index.spec.js +++ b/modules/entry/front/buy/index/index.spec.js @@ -68,45 +68,45 @@ describe('Entry buy', () => { describe('toggleGroupingMode()', () => { it(`should toggle grouping mode from grouping to packing`, () => { - const groupingFk = 1; - const packingFk = 2; - const buy = {id: 999, groupingMode: groupingFk}; + const grouping = 1; + const packing = 2; + const buy = {id: 999, groupingMode: grouping}; const query = `Buys/${buy.id}`; - $httpBackend.expectPATCH(query, {groupingMode: packingFk}).respond(200); + $httpBackend.expectPATCH(query, {groupingMode: packing}).respond(200); controller.toggleGroupingMode(buy, 'packing'); $httpBackend.flush(); }); it(`should toggle grouping mode from packing to grouping`, () => { - const groupingFk = 1; - const packingFk = 2; - const buy = {id: 999, groupingMode: packingFk}; + const grouping = 1; + const packing = 2; + const buy = {id: 999, groupingMode: packing}; const query = `Buys/${buy.id}`; - $httpBackend.expectPATCH(query, {groupingMode: groupingFk}).respond(200); + $httpBackend.expectPATCH(query, {groupingMode: grouping}).respond(200); controller.toggleGroupingMode(buy, 'grouping'); $httpBackend.flush(); }); it(`should toggle off the grouping mode if it was packing to packing`, () => { - const noGroupingFk = 0; - const packingFk = 2; - const buy = {id: 999, groupingMode: packingFk}; + const noGrouping = 0; + const packing = 2; + const buy = {id: 999, groupingMode: packing}; const query = `Buys/${buy.id}`; - $httpBackend.expectPATCH(query, {groupingMode: noGroupingFk}).respond(200); + $httpBackend.expectPATCH(query, {groupingMode: noGrouping}).respond(200); controller.toggleGroupingMode(buy, 'packing'); $httpBackend.flush(); }); it(`should toggle off the grouping mode if it was grouping to grouping`, () => { - const noGroupingFk = 0; - const groupingFk = 1; - const buy = {id: 999, groupingMode: groupingFk}; + const noGrouping = 0; + const grouping = 1; + const buy = {id: 999, groupingMode: grouping}; const query = `Buys/${buy.id}`; - $httpBackend.expectPATCH(query, {groupingMode: noGroupingFk}).respond(200); + $httpBackend.expectPATCH(query, {groupingMode: noGrouping}).respond(200); controller.toggleGroupingMode(buy, 'grouping'); $httpBackend.flush(); });