diff --git a/back/methods/user-config-view/save.js b/back/methods/user-config-view/save.js index da8a27083..b2144c01e 100644 --- a/back/methods/user-config-view/save.js +++ b/back/methods/user-config-view/save.js @@ -7,8 +7,7 @@ module.exports = function(Self) { required: true, description: `Code of the table you ask its configuration`, http: {source: 'body'} - } - ], + }], returns: { type: 'object', root: true @@ -29,6 +28,6 @@ module.exports = function(Self) { config.userFk = ctx.req.accessToken.userId; - return await Self.app.models.UserConfigView.create(config); + return Self.app.models.UserConfigView.create(config); }; }; diff --git a/back/model-config.json b/back/model-config.json index 18bf4cf98..8ad15a16a 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -29,6 +29,9 @@ "ChatConfig": { "dataSource": "vn" }, + "DefaultViewConfig": { + "dataSource": "vn" + }, "Delivery": { "dataSource": "vn" }, diff --git a/back/models/default-view-config.json b/back/models/default-view-config.json new file mode 100644 index 000000000..88164692d --- /dev/null +++ b/back/models/default-view-config.json @@ -0,0 +1,25 @@ +{ + "name": "DefaultViewConfig", + "base": "VnModel", + "options": { + "mysql": { + "table": "salix.defaultViewConfig" + } + }, + "properties": { + "tableCode": { + "id": true, + "type": "string", + "required": true + }, + "columns": { + "type": "object" + } + }, + "acls": [{ + "accessType": "READ", + "principalType": "ROLE", + "principalId": "$everyone", + "permission": "ALLOW" + }] +} diff --git a/db/changes/10380-allsaints/00-defaultViewConfig.sql b/db/changes/10380-allsaints/00-defaultViewConfig.sql new file mode 100644 index 000000000..e4b2f6c3d --- /dev/null +++ b/db/changes/10380-allsaints/00-defaultViewConfig.sql @@ -0,0 +1,14 @@ +CREATE TABLE `salix`.`defaultViewConfig` +( + tableCode VARCHAR(25) not null, + columns JSON not null +) +comment 'The default configuration of columns for views'; + +INSERT INTO `salix`.`defaultViewConfig` (tableCode, columns) + VALUES + ('itemsIndex', '{"intrastat":false,"stemMultiplier":false,"landed":false}'), + ('latestBuys', '{"intrastat":false,"description":false,"density":false,"isActive":false,"freightValue":false,"packageValue":false,"isIgnored":false,"price2":false,"minPrice":true,"ektFk":false,"weight":false,"id":true,"packing":true,"grouping":true,"quantity":true,"size":false,"name":true,"code":true,"origin":true,"family":true,"entryFk":true,"buyingValue":true,"comissionValue":false,"price3":true,"packageFk":true,"packingOut":true}'), + ('ticketsMonitor', '{"id":false}'); + + \ No newline at end of file diff --git a/e2e/helpers/extensions.js b/e2e/helpers/extensions.js index 1539aca85..789c800b5 100644 --- a/e2e/helpers/extensions.js +++ b/e2e/helpers/extensions.js @@ -341,48 +341,32 @@ let actions = { }, waitForTextInElement: async function(selector, text) { - const expectedText = text.toLowerCase(); - return new Promise((resolve, reject) => { - let attempts = 0; - const interval = setInterval(async() => { - const currentText = await this.evaluate(selector => { - return document.querySelector(selector).innerText.toLowerCase(); - }, selector); - - if (currentText === expectedText || attempts === 40) { - clearInterval(interval); - resolve(currentText); - } - attempts += 1; - }, 100); - }).then(result => { - return expect(result).toContain(expectedText); - }); + await this.waitForFunction((selector, text) => { + if (document.querySelector(selector)) { + const innerText = document.querySelector(selector).innerText.toLowerCase(); + const expectedText = text.toLowerCase(); + if (innerText.includes(expectedText)) + return innerText; + } + }, {}, selector, text); }, waitForTextInField: async function(selector, text) { - let builtSelector = await this.selectorFormater(selector); - await this.waitForSelector(builtSelector); - const expectedText = text.toLowerCase(); - return new Promise((resolve, reject) => { - let attempts = 0; - const interval = setInterval(async() => { - const currentText = await this.evaluate(selector => { - return document.querySelector(selector).value.toLowerCase(); - }, builtSelector); + const builtSelector = await this.selectorFormater(selector); + const expectedValue = text.toLowerCase(); - if (currentText === expectedText || attempts === 40) { - clearInterval(interval); - resolve(currentText); + try { + await this.waitForFunction((selector, text) => { + const element = document.querySelector(selector); + if (element) { + const value = element.value.toLowerCase(); + if (value.includes(text)) + return true; } - attempts += 1; - }, 100); - }).then(result => { - if (result === '') - return expect(result).toEqual(expectedText); - - return expect(result).toContain(expectedText); - }); + }, {}, builtSelector, expectedValue); + } catch (error) { + throw new Error(`${text} wasn't the value of ${builtSelector}, ${error}`); + } }, selectorFormater: function(selector) { diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index d3e4da99a..d8ebaa069 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -313,27 +313,26 @@ export default { }, itemsIndex: { createItemButton: `vn-float-button`, - firstSearchResult: 'vn-item-index a:nth-child(1)', - searchResult: 'vn-item-index a.vn-tr', - firstResultPreviewButton: 'vn-item-index vn-tbody > :nth-child(1) .buttons > [icon="preview"]', + firstSearchResult: 'vn-item-index tbody tr:nth-child(1)', + searchResult: 'vn-item-index tbody tr:not(.empty-rows)', + firstResultPreviewButton: 'vn-item-index tbody > :nth-child(1) .buttons > [icon="preview"]', searchResultCloneButton: 'vn-item-index .buttons > [icon="icon-clone"]', acceptClonationAlertButton: '.vn-confirm.shown [response="accept"]', closeItemSummaryPreview: '.vn-popup.shown', - fieldsToShowButton: 'vn-item-index vn-table > div > div > vn-icon-button[icon="more_vert"]', - fieldsToShowForm: '.vn-popover.shown .content', - 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-popover.shown vn-horizontal:nth-child(1) > vn-check', - stemsCheckbox: '.vn-popover.shown vn-horizontal:nth-child(2) > vn-check', - sizeCheckbox: '.vn-popover.shown vn-horizontal:nth-child(3) > vn-check', - typeCheckbox: '.vn-popover.shown vn-horizontal:nth-child(5) > vn-check', - categoryCheckbox: '.vn-popover.shown vn-horizontal:nth-child(6) > vn-check', - intrastadCheckbox: '.vn-popover.shown vn-horizontal:nth-child(7) > vn-check', - originCheckbox: '.vn-popover.shown vn-horizontal:nth-child(8) > vn-check', - buyerCheckbox: '.vn-popover.shown vn-horizontal:nth-child(9) > vn-check', - destinyCheckbox: '.vn-popover.shown vn-horizontal:nth-child(10) > vn-check', - taxClassCheckbox: '.vn-popover.shown vn-horizontal:nth-child(11) > vn-check', + shownColumns: 'vn-item-index vn-button[id="shownColumns"]', + shownColumnsList: '.vn-popover.shown .content', + firstItemImage: 'vn-item-index tbody > tr:nth-child(1) > td:nth-child(1) > img', + firstItemImageTd: 'vn-item-index smart-table tr:nth-child(1) td:nth-child(1)', + firstItemId: 'vn-item-index tbody > tr:nth-child(1) > td:nth-child(2)', + idCheckbox: '.vn-popover.shown vn-horizontal:nth-child(3) > vn-check[label="Identifier"]', + stemsCheckbox: '.vn-popover.shown vn-horizontal:nth-child(3) > vn-check[label="Stems"]', + sizeCheckbox: '.vn-popover.shown vn-horizontal:nth-child(3) > vn-check[label="Size"]', + typeCheckbox: '.vn-popover.shown vn-horizontal:nth-child(3) > vn-check[label="Type"]', + categoryCheckbox: '.vn-popover.shown vn-horizontal:nth-child(3) > vn-check[label="Category"]', + intrastadCheckbox: '.vn-popover.shown vn-horizontal:nth-child(3) > vn-check[label="Intrastat"]', + originCheckbox: '.vn-popover.shown vn-horizontal:nth-child(3) > vn-check[label="Origin"]', + buyerCheckbox: '.vn-popover.shown vn-horizontal:nth-child(3) > vn-check[label="Buyer"]', + densityCheckbox: '.vn-popover.shown vn-horizontal:nth-child(3) > vn-check[label="Density"]', saveFieldsButton: '.vn-popover.shown vn-button[label="Save"] > button' }, itemFixedPrice: { @@ -1087,7 +1086,7 @@ export default { allBuyCheckbox: 'vn-entry-buy-index thead vn-check', firstBuyCheckbox: 'vn-entry-buy-index tbody:nth-child(2) vn-check', deleteBuysButton: 'vn-entry-buy-index vn-button[icon="delete"]', - addBuyButton: 'vn-entry-buy-index vn-icon[icon="add_circle"]', + addBuyButton: 'vn-entry-buy-index vn-icon[icon="add"]', secondBuyPackingPrice: 'vn-entry-buy-index tbody:nth-child(3) > tr:nth-child(1) vn-input-number[ng-model="buy.price3"]', secondBuyGroupingPrice: 'vn-entry-buy-index tbody:nth-child(3) > tr:nth-child(1) vn-input-number[ng-model="buy.price2"]', secondBuyPrice: 'vn-entry-buy-index tbody:nth-child(3) > tr:nth-child(1) vn-input-number[ng-model="buy.buyingValue"]', @@ -1109,9 +1108,9 @@ export default { importBuysButton: 'vn-entry-buy-import button[type="submit"]' }, entryLatestBuys: { - firstBuy: 'vn-entry-latest-buys vn-tbody > a:nth-child(1)', - allBuysCheckBox: 'vn-entry-latest-buys vn-thead vn-check', - secondBuyCheckBox: 'vn-entry-latest-buys a:nth-child(2) vn-check[ng-model="buy.checked"]', + firstBuy: 'vn-entry-latest-buys tbody > tr:nth-child(1)', + allBuysCheckBox: 'vn-entry-latest-buys thead vn-check', + secondBuyCheckBox: 'vn-entry-latest-buys tbody tr:nth-child(2) vn-check[ng-model="buy.$checked"]', editBuysButton: 'vn-entry-latest-buys vn-button[icon="edit"]', fieldAutocomplete: 'vn-autocomplete[ng-model="$ctrl.editedColumn.field"]', newValueInput: 'vn-textfield[ng-model="$ctrl.editedColumn.newValue"]', diff --git a/e2e/paths/01-salix/01_login.spec.js b/e2e/paths/01-salix/01_login.spec.js index 7414856da..9dba61379 100644 --- a/e2e/paths/01-salix/01_login.spec.js +++ b/e2e/paths/01-salix/01_login.spec.js @@ -19,7 +19,9 @@ describe('Login path', async() => { const message = await page.waitForSnackbar(); const state = await page.getState(); - expect(message.text).toContain('Invalid login, remember that distinction is made between uppercase and lowercase'); + const errorMessage = 'Invalid login, remember that distinction is made between uppercase and lowercase'; + + expect(message.text).toContain(errorMessage); expect(state).toBe('login'); }); @@ -28,7 +30,9 @@ describe('Login path', async() => { const message = await page.waitForSnackbar(); const state = await page.getState(); - expect(message.text).toContain('Invalid login, remember that distinction is made between uppercase and lowercase'); + const errorMessage = 'Invalid login, remember that distinction is made between uppercase and lowercase'; + + expect(message.text).toContain(errorMessage); expect(state).toBe('login'); }); diff --git a/e2e/paths/02-client/03_edit_fiscal_data.spec.js b/e2e/paths/02-client/03_edit_fiscal_data.spec.js index ab0a61ddc..4ae1d4eca 100644 --- a/e2e/paths/02-client/03_edit_fiscal_data.spec.js +++ b/e2e/paths/02-client/03_edit_fiscal_data.spec.js @@ -112,7 +112,7 @@ describe('Client Edit fiscalData path', () => { expect(message.text).toContain('Cannot check Equalization Tax in this NIF/CIF'); }); - it('should finally edit the fixcal data correctly as VIES isnt checked and fiscal id is valid for EQtax', async() => { + it('should edit the fiscal data correctly as VIES isnt checked and fiscal id is valid for EQtax', async() => { await page.clearInput(selectors.clientFiscalData.fiscalId); await page.write(selectors.clientFiscalData.fiscalId, '94980061C'); await page.waitToClick(selectors.clientFiscalData.saveButton); diff --git a/e2e/paths/02-client/04_edit_billing_data.spec.js b/e2e/paths/02-client/04_edit_billing_data.spec.js index 6bc48093e..de3270f93 100644 --- a/e2e/paths/02-client/04_edit_billing_data.spec.js +++ b/e2e/paths/02-client/04_edit_billing_data.spec.js @@ -38,10 +38,13 @@ describe('Client Edit billing data path', () => { await page.autocompleteSearch(selectors.clientBillingData.newBankEntityCountry, 'España'); await page.write(selectors.clientBillingData.newBankEntityCode, '9999'); await page.waitToClick(selectors.clientBillingData.acceptBankEntityButton); + const message = await page.waitForSnackbar(); await page.waitForTextInField(selectors.clientBillingData.swiftBic, 'Gotham City Bank'); const newcode = await page.waitToGetProperty(selectors.clientBillingData.swiftBic, 'value'); expect(newcode).toEqual('GTHMCT Gotham City Bank'); + + expect(message.text).toContain('Data saved!'); }); it(`should confirm the IBAN pay method was sucessfully saved`, async() => { diff --git a/e2e/paths/04-item/01_summary.spec.js b/e2e/paths/04-item/01_summary.spec.js index a7526accb..e24fa6a9f 100644 --- a/e2e/paths/04-item/01_summary.spec.js +++ b/e2e/paths/04-item/01_summary.spec.js @@ -16,13 +16,13 @@ describe('Item summary path', () => { it('should search for an item', async() => { await page.doSearch('Ranged weapon'); - const nResults = await page.countElement(selectors.itemsIndex.searchResult); + const resultsCount = await page.countElement(selectors.itemsIndex.searchResult); await page.waitForTextInElement(selectors.itemsIndex.searchResult, 'Ranged weapon'); await page.waitToClick(selectors.itemsIndex.firstResultPreviewButton); const isVisible = await page.isVisible(selectors.itemSummary.basicData); - expect(nResults).toBe(3); + expect(resultsCount).toBe(3); expect(isVisible).toBeTruthy(); }); @@ -61,12 +61,12 @@ describe('Item summary path', () => { it('should search for other item', async() => { await page.doSearch('Melee Reinforced'); - const nResults = await page.countElement(selectors.itemsIndex.searchResult); + const resultsCount = await page.countElement(selectors.itemsIndex.searchResult); await page.waitToClick(selectors.itemsIndex.firstResultPreviewButton); await page.waitForSelector(selectors.itemSummary.basicData, {visible: true}); - expect(nResults).toBe(2); + expect(resultsCount).toBe(2); }); it(`should now check the item summary preview shows fields from basic data`, async() => { diff --git a/e2e/paths/04-item/07_create.spec.js b/e2e/paths/04-item/07_create.spec.js new file mode 100644 index 000000000..0820f2db7 --- /dev/null +++ b/e2e/paths/04-item/07_create.spec.js @@ -0,0 +1,71 @@ +import selectors from '../../helpers/selectors.js'; +import getBrowser from '../../helpers/puppeteer'; + +describe('Item Create', () => { + let browser; + let page; + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + await page.loginAndModule('buyer', 'item'); + }); + + afterAll(async() => { + await browser.close(); + }); + + it(`should search for the item Infinity Gauntlet to confirm it isn't created yet`, async() => { + await page.doSearch('Infinity Gauntlet'); + const resultsCount = await page.countElement(selectors.itemsIndex.searchResult); + + expect(resultsCount).toEqual(0); + }); + + it('should access to the create item view by clicking the create floating button', async() => { + await page.waitToClick(selectors.itemsIndex.createItemButton); + await page.waitForState('item.create'); + }); + + it('should return to the item index by clickig the cancel button', async() => { + await page.waitToClick(selectors.itemCreateView.cancelButton); + await page.waitForState('item.index'); + }); + + it('should now access to the create item view by clicking the create floating button', async() => { + await page.waitToClick(selectors.itemsIndex.createItemButton); + await page.waitForState('item.create'); + }); + + it('should create the Infinity Gauntlet item', async() => { + await page.write(selectors.itemCreateView.temporalName, 'Infinity Gauntlet'); + await page.autocompleteSearch(selectors.itemCreateView.type, 'Crisantemo'); + await page.autocompleteSearch(selectors.itemCreateView.intrastat, 'Coral y materiales similares'); + await page.autocompleteSearch(selectors.itemCreateView.origin, 'Holand'); + await page.waitToClick(selectors.itemCreateView.createButton); + const message = await page.waitForSnackbar(); + + expect(message.text).toContain('Data saved!'); + }); + + it('should confirm Infinity Gauntlet item was created', async() => { + let result = await page + .waitToGetProperty(selectors.itemBasicData.name, 'value'); + + expect(result).toEqual('Infinity Gauntlet'); + + result = await page + .waitToGetProperty(selectors.itemBasicData.type, 'value'); + + expect(result).toEqual('Crisantemo'); + + result = await page + .waitToGetProperty(selectors.itemBasicData.intrastat, 'value'); + + expect(result).toEqual('5080000 Coral y materiales similares'); + + result = await page + .waitToGetProperty(selectors.itemBasicData.origin, 'value'); + + expect(result).toEqual('Holand'); + }); +}); diff --git a/e2e/paths/04-item/07_create_and_clone.spec.js b/e2e/paths/04-item/07_create_and_clone.spec.js deleted file mode 100644 index 938f15e3f..000000000 --- a/e2e/paths/04-item/07_create_and_clone.spec.js +++ /dev/null @@ -1,105 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Item Create/Clone path', () => { - let browser; - let page; - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('buyer', 'item'); - }); - - afterAll(async() => { - await browser.close(); - }); - - describe('create', () => { - it(`should search for the item Infinity Gauntlet to confirm it isn't created yet`, async() => { - await page.doSearch('Infinity Gauntlet'); - const nResults = await page.countElement(selectors.itemsIndex.searchResult); - - expect(nResults).toEqual(0); - }); - - it('should access to the create item view by clicking the create floating button', async() => { - await page.waitToClick(selectors.itemsIndex.createItemButton); - await page.waitForState('item.create'); - }); - - it('should return to the item index by clickig the cancel button', async() => { - await page.waitToClick(selectors.itemCreateView.cancelButton); - await page.waitForState('item.index'); - }); - - it('should now access to the create item view by clicking the create floating button', async() => { - await page.waitToClick(selectors.itemsIndex.createItemButton); - await page.waitForState('item.create'); - }); - - it('should create the Infinity Gauntlet item', async() => { - await page.write(selectors.itemCreateView.temporalName, 'Infinity Gauntlet'); - await page.autocompleteSearch(selectors.itemCreateView.type, 'Crisantemo'); - await page.autocompleteSearch(selectors.itemCreateView.intrastat, 'Coral y materiales similares'); - await page.autocompleteSearch(selectors.itemCreateView.origin, 'Holand'); - await page.waitToClick(selectors.itemCreateView.createButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should confirm Infinity Gauntlet item was created', async() => { - let result = await page - .waitToGetProperty(selectors.itemBasicData.name, 'value'); - - expect(result).toEqual('Infinity Gauntlet'); - - result = await page - .waitToGetProperty(selectors.itemBasicData.type, 'value'); - - expect(result).toEqual('Crisantemo'); - - result = await page - .waitToGetProperty(selectors.itemBasicData.intrastat, 'value'); - - expect(result).toEqual('5080000 Coral y materiales similares'); - - result = await page - .waitToGetProperty(selectors.itemBasicData.origin, 'value'); - - expect(result).toEqual('Holand'); - }); - }); - - // Issue #2201 - // When there is just one result you're redirected automatically to it, so - // it's not possible to use the clone option. - xdescribe('clone', () => { - it('should return to the items index by clicking the return to items button', async() => { - await page.waitToClick(selectors.itemBasicData.goToItemIndexButton); - await page.waitForSelector(selectors.itemsIndex.createItemButton); - await page.waitForState('item.index'); - }); - - it(`should search for the item Infinity Gauntlet`, async() => { - await page.doSearch('Infinity Gauntlet'); - const nResults = await page.countElement(selectors.itemsIndex.searchResult); - - expect(nResults).toEqual(1); - }); - - it(`should clone the Infinity Gauntlet`, async() => { - await page.waitForTextInElement(selectors.itemsIndex.searchResult, 'Infinity Gauntlet'); - await page.waitToClick(selectors.itemsIndex.searchResultCloneButton); - await page.waitToClick(selectors.itemsIndex.acceptClonationAlertButton); - await page.waitForState('item.tags'); - }); - - it('should search for the item Infinity Gauntlet and find two', async() => { - await page.doSearch('Infinity Gauntlet'); - const nResults = await page.countElement(selectors.itemsIndex.searchResult); - - expect(nResults).toEqual(2); - }); - }); -}); diff --git a/e2e/paths/04-item/09_index.spec.js b/e2e/paths/04-item/09_index.spec.js index 262627e99..f9262863d 100644 --- a/e2e/paths/04-item/09_index.spec.js +++ b/e2e/paths/04-item/09_index.spec.js @@ -16,8 +16,8 @@ describe('Item index path', () => { }); it('should click on the fields to show button to open the list of columns to show', async() => { - await page.waitToClick(selectors.itemsIndex.fieldsToShowButton); - const visible = await page.isVisible(selectors.itemsIndex.fieldsToShowForm); + await page.waitToClick(selectors.itemsIndex.shownColumns); + const visible = await page.isVisible(selectors.itemsIndex.shownColumnsList); expect(visible).toBeTruthy(); }); @@ -31,7 +31,7 @@ describe('Item index path', () => { await page.waitToClick(selectors.itemsIndex.intrastadCheckbox); await page.waitToClick(selectors.itemsIndex.originCheckbox); await page.waitToClick(selectors.itemsIndex.buyerCheckbox); - await page.waitToClick(selectors.itemsIndex.destinyCheckbox); + await page.waitToClick(selectors.itemsIndex.densityCheckbox); await page.waitToClick(selectors.itemsIndex.saveFieldsButton); const message = await page.waitForSnackbar(); @@ -39,6 +39,7 @@ describe('Item index path', () => { }); it('should navigate forth and back to see the images column is still visible', async() => { + await page.closePopup(); await page.waitToClick(selectors.itemsIndex.firstSearchResult); await page.waitToClick(selectors.itemDescriptor.goBackToModuleIndexButton); await page.waitToClick(selectors.globalItems.searchButton); @@ -54,7 +55,7 @@ describe('Item index path', () => { }); it('should mark all unchecked boxes to leave the index as it was', async() => { - await page.waitToClick(selectors.itemsIndex.fieldsToShowButton); + await page.waitToClick(selectors.itemsIndex.shownColumns); await page.waitToClick(selectors.itemsIndex.idCheckbox); await page.waitToClick(selectors.itemsIndex.stemsCheckbox); await page.waitToClick(selectors.itemsIndex.sizeCheckbox); @@ -63,7 +64,7 @@ describe('Item index path', () => { await page.waitToClick(selectors.itemsIndex.intrastadCheckbox); await page.waitToClick(selectors.itemsIndex.originCheckbox); await page.waitToClick(selectors.itemsIndex.buyerCheckbox); - await page.waitToClick(selectors.itemsIndex.destinyCheckbox); + await page.waitToClick(selectors.itemsIndex.densityCheckbox); await page.waitToClick(selectors.itemsIndex.saveFieldsButton); const message = await page.waitForSnackbar(); @@ -71,6 +72,7 @@ describe('Item index path', () => { }); it('should now navigate forth and back to see the ids column is now visible', async() => { + await page.closePopup(); await page.waitToClick(selectors.itemsIndex.firstSearchResult); await page.waitToClick(selectors.itemDescriptor.goBackToModuleIndexButton); await page.waitToClick(selectors.globalItems.searchButton); diff --git a/e2e/paths/05-ticket/04_packages.spec.js b/e2e/paths/05-ticket/04_packages.spec.js index 06720ed7a..f874307a8 100644 --- a/e2e/paths/05-ticket/04_packages.spec.js +++ b/e2e/paths/05-ticket/04_packages.spec.js @@ -62,7 +62,7 @@ describe('Ticket Create packages path', () => { expect(result).toEqual('7 : Container medical box 1m'); }); - it(`should confirm the first quantity is just a number and the string part was ignored by the imput number`, async() => { + it(`should confirm quantity is just a number and the string part was ignored by the imput number`, async() => { await page.waitForTextInField(selectors.ticketPackages.firstQuantity, '-99'); const result = await page.waitToGetProperty(selectors.ticketPackages.firstQuantity, 'value'); diff --git a/e2e/paths/12-entry/03_latestBuys.spec.js b/e2e/paths/12-entry/03_latestBuys.spec.js index f7dc07ca9..553d41b95 100644 --- a/e2e/paths/12-entry/03_latestBuys.spec.js +++ b/e2e/paths/12-entry/03_latestBuys.spec.js @@ -31,7 +31,7 @@ describe('Entry lastest buys path', () => { await page.waitForSelector(selectors.entryLatestBuys.fieldAutocomplete, {visible: true}); }); - it('should search for the "Description" field and type a new description for the items in each selected buy', async() => { + it('should search for the "Description" and type a new one for the items in each selected buy', async() => { await page.autocompleteSearch(selectors.entryLatestBuys.fieldAutocomplete, 'Description'); await page.write(selectors.entryLatestBuys.newValueInput, 'Crafted item'); await page.waitToClick(selectors.entryLatestBuys.acceptEditBuysDialog); diff --git a/e2e/paths/12-entry/07_buys.spec.js b/e2e/paths/12-entry/07_buys.spec.js index 4042c99b6..a39e88ce6 100644 --- a/e2e/paths/12-entry/07_buys.spec.js +++ b/e2e/paths/12-entry/07_buys.spec.js @@ -28,7 +28,7 @@ describe('Entry import, create and edit buys path', () => { await page.waitForState('entry.card.buy.import'); }); - it('should fill the form, import the designated JSON file and select items for each import and confirm import', async() => { + it('should fill the form, import the a JSON file and select items for each import and confirm import', async() => { let currentDir = process.cwd(); let filePath = `${currentDir}/e2e/assets/07_import_buys.json`; @@ -42,7 +42,8 @@ describe('Entry import, create and edit buys path', () => { await page.waitForTextInField(selectors.entryBuys.observation, '729-6340 2846'); await page.autocompleteSearch(selectors.entryBuys.firstImportedItem, 'Ranged Reinforced weapon pistol 9mm'); - await page.autocompleteSearch(selectors.entryBuys.secondImportedItem, 'Melee Reinforced weapon heavy shield 1x0.5m'); + const itemName = 'Melee Reinforced weapon heavy shield 1x0.5m'; + await page.autocompleteSearch(selectors.entryBuys.secondImportedItem, itemName); await page.autocompleteSearch(selectors.entryBuys.thirdImportedItem, 'Container medical box 1m'); await page.autocompleteSearch(selectors.entryBuys.fourthImportedItem, 'Container ammo box 1m'); @@ -88,37 +89,37 @@ describe('Entry import, create and edit buys path', () => { it('should edit the newest buy', async() => { await page.clearInput(selectors.entryBuys.secondBuyPackingPrice); - await page.waitForTextInField(selectors.entryBuys.secondBuyPackingPrice, ''); + await page.waitForTimeout(250); await page.write(selectors.entryBuys.secondBuyPackingPrice, '100'); await page.waitForSnackbar(); await page.clearInput(selectors.entryBuys.secondBuyGroupingPrice); - await page.waitForTextInField(selectors.entryBuys.secondBuyGroupingPrice, ''); + await page.waitForTimeout(250); await page.write(selectors.entryBuys.secondBuyGroupingPrice, '200'); await page.waitForSnackbar(); await page.clearInput(selectors.entryBuys.secondBuyPrice); - await page.waitForTextInField(selectors.entryBuys.secondBuyPrice, ''); + await page.waitForTimeout(250); await page.write(selectors.entryBuys.secondBuyPrice, '300'); await page.waitForSnackbar(); await page.clearInput(selectors.entryBuys.secondBuyGrouping); - await page.waitForTextInField(selectors.entryBuys.secondBuyGrouping, ''); + await page.waitForTimeout(250); await page.write(selectors.entryBuys.secondBuyGrouping, '400'); await page.waitForSnackbar(); await page.clearInput(selectors.entryBuys.secondBuyPacking); - await page.waitForTextInField(selectors.entryBuys.secondBuyPacking, ''); + await page.waitForTimeout(250); await page.write(selectors.entryBuys.secondBuyPacking, '500'); await page.waitForSnackbar(); await page.clearInput(selectors.entryBuys.secondBuyWeight); - await page.waitForTextInField(selectors.entryBuys.secondBuyWeight, ''); + await page.waitForTimeout(250); await page.write(selectors.entryBuys.secondBuyWeight, '600'); await page.waitForSnackbar(); await page.clearInput(selectors.entryBuys.secondBuyStickers); - await page.waitForTextInField(selectors.entryBuys.secondBuyStickers, ''); + await page.waitForTimeout(250); await page.write(selectors.entryBuys.secondBuyStickers, '700'); await page.waitForSnackbar(); @@ -126,7 +127,7 @@ describe('Entry import, create and edit buys path', () => { await page.waitForSnackbar(); await page.clearInput(selectors.entryBuys.secondBuyQuantity); - await page.waitForTextInField(selectors.entryBuys.secondBuyQuantity, ''); + await page.waitForTimeout(250); await page.write(selectors.entryBuys.secondBuyQuantity, '800'); }); diff --git a/front/core/components/contextmenu/index.js b/front/core/components/contextmenu/index.js index 646df1a0a..fa1db6887 100755 --- a/front/core/components/contextmenu/index.js +++ b/front/core/components/contextmenu/index.js @@ -49,7 +49,7 @@ export default class Contextmenu { get rowIndex() { if (!this.row) return null; - const table = this.row.closest('vn-table, .vn-table'); + const table = this.row.closest('table, vn-table, .vn-table'); const rows = table.querySelectorAll('[ng-repeat]'); return Array.from(rows).findIndex( @@ -67,13 +67,13 @@ export default class Contextmenu { get cell() { if (!this.target) return null; - return this.target.closest('vn-td, .vn-td, vn-td-editable'); + return this.target.closest('td, vn-td, .vn-td, vn-td-editable'); } get cellIndex() { if (!this.row) return null; - const cells = this.row.querySelectorAll('vn-td, .vn-td, vn-td-editable'); + const cells = this.row.querySelectorAll('td, vn-td, .vn-td, vn-td-editable'); return Array.from(cells).findIndex( cellItem => cellItem == this.cell ); @@ -82,8 +82,8 @@ export default class Contextmenu { get rowHeader() { if (!this.row) return null; - const table = this.row.closest('vn-table, .vn-table'); - const headerCells = table && table.querySelectorAll('vn-thead vn-th'); + const table = this.row.closest('table, vn-table, .vn-table'); + const headerCells = table && table.querySelectorAll('thead th, vn-thead vn-th'); const headerCell = headerCells && headerCells[this.cellIndex]; return headerCell; @@ -147,7 +147,7 @@ export default class Contextmenu { */ isActionAllowed() { if (!this.target) return false; - const isTableCell = this.target.closest('vn-td, .vn-td'); + const isTableCell = this.target.closest('td, vn-td, .vn-td'); return isTableCell && this.fieldName; } @@ -172,9 +172,28 @@ export default class Contextmenu { excludeSelection() { let where = {[this.fieldName]: {neq: this.fieldValue}}; if (this.exprBuilder) { - where = buildFilter(where, (param, value) => - this.exprBuilder({param, value}) - ); + where = {[this.fieldName]: this.fieldValue}; + where = buildFilter(where, (param, value) => { + const expr = this.exprBuilder({param, value}); + const props = Object.keys(expr); + let newExpr = {}; + for (let prop of props) { + if (expr[prop].like) { + const operator = expr[prop].like; + newExpr[prop] = {nlike: operator}; + } else if (expr[prop].between) { + const operator = expr[prop].between; + newExpr = { + or: [ + {[prop]: {lt: operator[0]}}, + {[prop]: {gt: operator[1]}}, + ] + }; + } else + newExpr[prop] = {neq: this.fieldValue}; + } + return newExpr; + }); } this.model.addFilter({where}); @@ -208,15 +227,22 @@ export default class Contextmenu { if (prop == findProp) delete instance[prop]; - if (prop === 'and') { - for (let [index, param] of instance[prop].entries()) { + if (prop === 'and' || prop === 'or') { + const instanceCopy = instance[prop].slice(); + for (let param of instanceCopy) { const [key] = Object.keys(param); + const index = instance[prop].findIndex(param => { + return Object.keys(param)[0] == key; + }); if (key == findProp) instance[prop].splice(index, 1); if (param[key] instanceof Array) removeProp(param, filterKey, key); } + + if (instance[prop].length == 0) + delete instance[prop]; } } diff --git a/front/core/components/index.js b/front/core/components/index.js index 3ccc64b89..86ab89212 100644 --- a/front/core/components/index.js +++ b/front/core/components/index.js @@ -52,3 +52,4 @@ import './wday-picker'; import './datalist'; import './contextmenu'; import './rating'; +import './smart-table'; diff --git a/front/core/components/multi-check/multi-check.js b/front/core/components/multi-check/multi-check.js index d8fda6404..afa1bc3c4 100644 --- a/front/core/components/multi-check/multi-check.js +++ b/front/core/components/multi-check/multi-check.js @@ -145,9 +145,8 @@ export default class MultiCheck extends FormInput { toggle() { const data = this.model.data; if (!data) return; - data.forEach(el => { + for (let el of data) el[this.checkField] = this.checkAll; - }); } } @@ -156,8 +155,9 @@ ngModule.vnComponent('vnMultiCheck', { controller: MultiCheck, bindings: { model: '<', - checkField: '', + checkField: '@?', checkAll: '=?', + checked: '=?', disabled: '' } }); diff --git a/front/core/components/smart-table/index.html b/front/core/components/smart-table/index.html new file mode 100644 index 000000000..c2af9b41e --- /dev/null +++ b/front/core/components/smart-table/index.html @@ -0,0 +1,102 @@ +
+ |
+ Picture | ++ Identifier + | ++ Packing + | ++ Grouping + | ++ Quantity + | ++ Description + | ++ Size + | ++ Tags + | ++ Type + | ++ Intrastat + | ++ Origin + | ++ Density + | ++ Active + | ++ Family + | ++ Entry + | ++ Buying value + | ++ Freight value + | ++ Commission value + | ++ Package value + | ++ Is ignored + | ++ Grouping + | ++ Packing + | ++ Min + | ++ Ekt + | ++ Weight + | ++ Package + | ++ Package out + | +
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
+ |
+ + + | ++ + {{::buy.itemFk}} + + | +
+ |
+
+ |
+ {{::buy.quantity}} | ++ {{::buy.description | dashIfEmpty}} + | +{{::buy.size}} | +
+
+
+ {{::buy.subName}}+ |
+ + {{::buy.code}} + | ++ {{::buy.intrastat}} + | +{{::buy.origin}} | +{{::buy.density}} | +
+ |
+ {{::buy.family}} | ++ + {{::buy.entryFk}} + + | +{{::buy.buyingValue | currency: 'EUR':2}} | +{{::buy.freightValue | currency: 'EUR':2}} | +{{::buy.comissionValue | currency: 'EUR':2}} | +{{::buy.packageValue | currency: 'EUR':2}} | +
+ |
+ {{::buy.price2 | currency: 'EUR':2}} | +{{::buy.price3 | currency: 'EUR':2}} | +{{::buy.minPrice | currency: 'EUR':2}} | +{{::buy.ektFk | dashIfEmpty}} | +{{::buy.weight}} | +{{::buy.packageFk}} | +{{::buy.packingOut}} | +
+ | + Identifier + | ++ Grouping + | ++ Packing + | ++ Description + | ++ Stems + | ++ Size + | ++ Type + | ++ Category + | ++ Intrastat + | ++ Origin + | ++ Buyer + | ++ Density + | ++ Multiplier + | ++ Active + | ++ Landed + | ++ |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
+ + | ++ + {{::item.id}} + + | +{{::item.grouping | dashIfEmpty}} | +{{::item.packing | dashIfEmpty}} | +
+
+
+ {{::item.subName}}+ |
+ {{::item.stems}} | +{{::item.size}} | ++ {{::item.typeName}} + | ++ {{::item.category}} + | ++ {{::item.intrastat}} + | +{{::item.origin}} | ++ + {{::item.userName}} + + | +{{::item.density}} | +{{::item.stemMultiplier}} | +
+ |
+ {{::item.landed | date:'dd/MM/yyyy'}} | +
+ |
+
+ Problems + | ++ Identifier + | ++ Client + | ++ Salesperson + | ++ Date + | ++ Theoretical + | ++ Practical + | ++ Preparation + | ++ Province + | ++ State + | ++ Zone + | ++ Total + | ++ |
---|---|---|---|---|---|---|---|---|---|---|---|---|
+ |
+ + + {{::ticket.id}} + + | ++ + {{::ticket.nickname}} + + | ++ + {{::ticket.userName | dashIfEmpty}} + + | ++ + {{::ticket.shipped | date: 'dd/MM/yyyy'}} + + | +{{::ticket.zoneLanding | date: 'HH:mm'}} | +{{::ticket.practicalHour | date: 'HH:mm'}} | +{{::ticket.shipped | date: 'HH:mm'}} | +{{::ticket.province}} | ++ + {{::ticket.refFk}} + + + {{::ticket.state}} + + | ++ + {{::ticket.zoneName | dashIfEmpty}} + + | ++ + {{::(ticket.totalWithVat ? ticket.totalWithVat : 0) | currency: 'EUR': 2}} + + | +
+ |
+