From 0c8fe855acf8c10369900371bea3e4d9529848be Mon Sep 17 00:00:00 2001 From: alexandre Date: Mon, 27 Mar 2023 09:11:29 +0200 Subject: [PATCH 01/10] refs #5418 lateral search panel added, missing e2e --- front/core/styles/variables.scss | 1 + front/salix/components/layout/style.scss | 6 +- .../front/fixed-price-search-panel/index.html | 351 +++++++++++------- .../front/fixed-price-search-panel/index.js | 53 ++- .../fixed-price-search-panel/index.spec.js | 56 +++ .../front/fixed-price-search-panel/style.scss | 71 ++++ modules/item/front/fixed-price/index.html | 10 +- 7 files changed, 396 insertions(+), 152 deletions(-) create mode 100644 modules/item/front/fixed-price-search-panel/index.spec.js create mode 100644 modules/item/front/fixed-price-search-panel/style.scss diff --git a/front/core/styles/variables.scss b/front/core/styles/variables.scss index bcc9fab667..0a00e2e1fa 100644 --- a/front/core/styles/variables.scss +++ b/front/core/styles/variables.scss @@ -2,6 +2,7 @@ $font-size: 11pt; $menu-width: 256px; +$right-menu-width: 315px; $topbar-height: 56px; $mobile-width: 800px; $float-spacing: 20px; diff --git a/front/salix/components/layout/style.scss b/front/salix/components/layout/style.scss index 6123662280..6697bb1b01 100644 --- a/front/salix/components/layout/style.scss +++ b/front/salix/components/layout/style.scss @@ -88,13 +88,13 @@ vn-layout { } &.right-menu { & > vn-topbar > .end { - width: 80px + $menu-width; + width: 80px + $right-menu-width; } & > .main-view { - padding-right: $menu-width; + padding-right: $right-menu-width; } [fixed-bottom-right] { - right: $menu-width; + right: $right-menu-width; } } & > .main-view { diff --git a/modules/item/front/fixed-price-search-panel/index.html b/modules/item/front/fixed-price-search-panel/index.html index 5c8a58674e..ebe2102772 100644 --- a/modules/item/front/fixed-price-search-panel/index.html +++ b/modules/item/front/fixed-price-search-panel/index.html @@ -1,136 +1,215 @@ - - -
-
- - - - - - - - - -
{{name}}
-
- {{category.name}} -
-
-
-
- - - - - - - - - - - - - - - - - - - - - Tags - - - - - - - - - - - - - - - - - -
-
+ + + + + + + + + + + + + + + + + + +
{{name}}
+
+ {{category.name}} +
+
+
+
+ + + + + + + + + + + + + + + + + + + + Tags + + + + + + + + + + + + + +
+ + Id/{{$ctrl.$t('Name')}}: {{$ctrl.filter.search}} + + + {{$ctrl.$t('Category')}}: {{category.selection.name}} + + + {{$ctrl.$t('Type')}}: {{type.selection.name}} + + + {{$ctrl.$t('Buyer')}}: {{buyer.selection.nickname}} + + + {{$ctrl.$t('Warehouse')}}: {{warehouse.selection.name}} + + + {{$ctrl.$t('Started')}}: {{$ctrl.filter.started | date:'dd/MM/yyyy'}} + + + {{$ctrl.$t('Ended')}}: {{$ctrl.filter.ended | date:'dd/MM/yyyy'}} + + + {{$ctrl.$t('For me')}}: {{$ctrl.filter.mine ? '✓' : '✗'}} + + + {{$ctrl.$t('Minimum price')}}: {{$ctrl.filter.hasMinPrice ? '✓' : '✗'}} + + + {{$ctrl.showTagInfo(chipTag)}} + +
+
diff --git a/modules/item/front/fixed-price-search-panel/index.js b/modules/item/front/fixed-price-search-panel/index.js index ec13765fde..0882eb5ac4 100644 --- a/modules/item/front/fixed-price-search-panel/index.js +++ b/modules/item/front/fixed-price-search-panel/index.js @@ -1,19 +1,60 @@ import ngModule from '../module'; import SearchPanel from 'core/components/searchbar/search-panel'; +import './style.scss'; class Controller extends SearchPanel { - get filter() { - return this.$.filter; + constructor($element, $) { + super($element, $); } - set filter(value = {}) { - if (!value.tags) value.tags = [{}]; + $onInit() { + this.filter = { + tags: [] + }; + } - this.$.filter = value; + changeCategory(id) { + if (this.filter.categoryFk != id) { + this.filter.categoryFk = id; + this.addFilters(); + } + } + + removeItemFilter(param) { + this.filter[param] = null; + if (param == 'categoryFk') this.filter['typeFk'] = null; + this.addFilters(); + } + + removeTag(tag) { + const index = this.filter.tags.indexOf(tag); + if (index > -1) this.filter.tags.splice(index, 1); + this.addFilters(); + } + + onKeyPress($event) { + if ($event.key === 'Enter') + this.addFilters(); + } + + addFilters() { + for (let i = 0; i < this.filter.tags.length; i++) { + if (!this.filter.tags[i].value) + this.filter.tags.splice(i, 1); + } + return this.model.addFilter({}, this.filter); + } + + showTagInfo(itemTag) { + if (!itemTag.tagFk) return itemTag.value; + return `${this.tags.find(tag => tag.id == itemTag.tagFk).name}: ${itemTag.value}`; } } ngModule.vnComponent('vnFixedPriceSearchPanel', { template: require('./index.html'), - controller: Controller + controller: Controller, + bindings: { + model: '<' + } }); diff --git a/modules/item/front/fixed-price-search-panel/index.spec.js b/modules/item/front/fixed-price-search-panel/index.spec.js new file mode 100644 index 0000000000..597bc108e8 --- /dev/null +++ b/modules/item/front/fixed-price-search-panel/index.spec.js @@ -0,0 +1,56 @@ +import './index.js'; + +describe('Item', () => { + describe('Component vnFixedPriceSearchPanel', () => { + let $element; + let controller; + + beforeEach(ngModule('item')); + + beforeEach(angular.mock.inject($componentController => { + $element = angular.element(``); + controller = $componentController('vnFixedPriceSearchPanel', {$element}); + controller.model = {addFilter: () => {}}; + })); + + describe('removeItemFilter()', () => { + it(`should remove param from filter`, () => { + controller.filter = {tags: [], categoryFk: 1, typeFk: 1}; + const expectFilter = {tags: [], categoryFk: null, typeFk: null}; + + controller.removeItemFilter('categoryFk'); + + expect(controller.filter).toEqual(expectFilter); + }); + }); + + describe('removeTag()', () => { + it(`should remove tag from filter`, () => { + const tag = {tagFk: 1, value: 'Value'}; + controller.filter = {tags: [tag]}; + const expectFilter = {tags: []}; + + controller.removeTag(tag); + + expect(controller.filter).toEqual(expectFilter); + }); + }); + + describe('showTagInfo()', () => { + it(`should show tag value`, () => { + const tag = {value: 'Value'}; + const result = controller.showTagInfo(tag); + + expect(result).toEqual('Value'); + }); + + it(`should show tag name and value`, () => { + const tag = {tagFk: 1, value: 'Value'}; + controller.tags = [{id: 1, name: 'tagName'}]; + const result = controller.showTagInfo(tag); + + expect(result).toEqual('tagName: Value'); + }); + }); + }); +}); diff --git a/modules/item/front/fixed-price-search-panel/style.scss b/modules/item/front/fixed-price-search-panel/style.scss new file mode 100644 index 0000000000..a63f84f3b3 --- /dev/null +++ b/modules/item/front/fixed-price-search-panel/style.scss @@ -0,0 +1,71 @@ +@import "variables"; + +vn-fixed-price-search-panel vn-side-menu { + .menu { + min-width: $right-menu-width; + } + & > div { + .input { + padding-left: $spacing-md; + padding-right: $spacing-md; + border-color: $color-spacer; + border-bottom: $border-thin; + } + .horizontal { + padding-left: $spacing-md; + padding-right: $spacing-md; + grid-auto-flow: column; + grid-column-gap: $spacing-sm; + align-items: center; + } + .tags { + padding: $spacing-md; + padding-bottom: 0%; + padding-top: 0%; + align-items: center; + } + .chips { + display: flex; + flex-wrap: wrap; + padding: $spacing-md; + overflow: hidden; + max-width: 100%; + border-color: $color-spacer; + border-top: $border-thin; + } + .item-category { + padding: $spacing-sm; + justify-content: flex-start; + align-items: flex-start; + flex-wrap: wrap; + + vn-autocomplete[vn-id="category"] { + display: none; + } + + & > vn-one { + padding: $spacing-sm; + min-width: 33.33%; + text-align: center; + box-sizing: border-box; + + & > vn-icon { + padding: $spacing-sm; + background-color: $color-font-secondary; + border-radius: 50%; + cursor: pointer; + + &.active { + background-color: $color-main; + color: #fff; + } + & > i:before { + font-size: 2.6rem; + width: 16px; + height: 16px; + } + } + } + } + } +} diff --git a/modules/item/front/fixed-price/index.html b/modules/item/front/fixed-price/index.html index ce7cefe7a3..be5acf3689 100644 --- a/modules/item/front/fixed-price/index.html +++ b/modules/item/front/fixed-price/index.html @@ -13,14 +13,10 @@ order="name">
- - + +
Date: Mon, 27 Mar 2023 12:12:42 +0200 Subject: [PATCH 02/10] refs #5418 e2e implemented and fixed --- e2e/helpers/selectors.js | 15 ++++- ..._smartTable_searchBar_integrations.spec.js | 9 +-- e2e/paths/04-item/13_fixedPrice.spec.js | 58 +++++++++++++++++-- 3 files changed, 67 insertions(+), 15 deletions(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index f4c67f0025..2cbbd31c01 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -414,7 +414,7 @@ export default { saveFieldsButton: '.vn-popover.shown vn-button[label="Save"] > button' }, itemFixedPrice: { - add: 'vn-fixed-price vn-icon-button[icon="add_circle"]', + add: 'vn-fixed-price vn-icon-button[vn-tooltip="Add fixed price"]', firstItemID: 'vn-fixed-price tr:nth-child(2) vn-autocomplete[ng-model="price.itemFk"]', fourthFixedPrice: 'vn-fixed-price tr:nth-child(5)', fourthItemID: 'vn-fixed-price tr:nth-child(5) vn-autocomplete[ng-model="price.itemFk"]', @@ -426,7 +426,18 @@ export default { fourthStarted: 'vn-fixed-price tr:nth-child(5) vn-date-picker[ng-model="price.started"]', fourthEnded: 'vn-fixed-price tr:nth-child(5) vn-date-picker[ng-model="price.ended"]', fourthDeleteIcon: 'vn-fixed-price tr:nth-child(5) > td:nth-child(9) > vn-icon-button[icon="delete"]', - orderColumnId: 'vn-fixed-price th[field="itemFk"]' + orderColumnId: 'vn-fixed-price th[field="itemFk"]', + generalSearchFilter: 'vn-fixed-price-search-panel vn-textfield[ng-model="$ctrl.filter.search"]', + reignFilter: 'vn-fixed-price-search-panel vn-horizontal.item-category vn-one', + typeFilter: 'vn-fixed-price-search-panel vn-autocomplete[ng-model="$ctrl.filter.typeFk"]', + buyerFilter: 'vn-fixed-price-search-panel vn-autocomplete[ng-model="$ctrl.filter.buyerFk"]', + warehouseFilter: 'vn-fixed-price-search-panel vn-autocomplete[ng-model="$ctrl.filter.warehouseFk"]', + mineFilter: 'vn-fixed-price-search-panel vn-check[ng-model="$ctrl.filter.mine"]', + hasMinPriceFilter: 'vn-fixed-price-search-panel vn-check[ng-model="$ctrl.filter.hasMinPrice"]', + addTag: 'vn-fixed-price-search-panel vn-icon-button[icon="add_circle"]', + tagFilter: 'vn-fixed-price-search-panel vn-autocomplete[ng-model="itemTag.tagFk"]', + tagValueFilter: 'vn-fixed-price-search-panel vn-autocomplete[ng-model="itemTag.value"]', + chip: 'vn-fixed-price-search-panel vn-chip > vn-icon', }, itemCreateView: { temporalName: 'vn-item-create vn-textfield[ng-model="$ctrl.item.provisionalName"]', diff --git a/e2e/paths/01-salix/03_smartTable_searchBar_integrations.spec.js b/e2e/paths/01-salix/03_smartTable_searchBar_integrations.spec.js index ad558ace2e..1c8fe0840b 100644 --- a/e2e/paths/01-salix/03_smartTable_searchBar_integrations.spec.js +++ b/e2e/paths/01-salix/03_smartTable_searchBar_integrations.spec.js @@ -79,21 +79,14 @@ describe('SmartTable SearchBar integration', () => { it('should order by first id', async() => { await page.loginAndModule('developer', 'item'); await page.accessToSection('item.fixedPrice'); - await page.doSearch(); const result = await page.waitToGetProperty(selectors.itemFixedPrice.firstItemID, 'value'); expect(result).toEqual('1'); }); - it('should order by last id', async() => { + it('should order by last id, reload page and have same order', async() => { await page.waitToClick(selectors.itemFixedPrice.orderColumnId); - const result = await page.waitToGetProperty(selectors.itemFixedPrice.firstItemID, 'value'); - - expect(result).toEqual('13'); - }); - - it('should reload page and have same order', async() => { await page.reload({ waitUntil: 'networkidle2' }); diff --git a/e2e/paths/04-item/13_fixedPrice.spec.js b/e2e/paths/04-item/13_fixedPrice.spec.js index 1b0f82d83e..df3b4f7a39 100644 --- a/e2e/paths/04-item/13_fixedPrice.spec.js +++ b/e2e/paths/04-item/13_fixedPrice.spec.js @@ -4,19 +4,69 @@ import getBrowser from '../../helpers/puppeteer'; describe('Item fixed prices path', () => { let browser; let page; + let httpRequest; + beforeAll(async() => { browser = await getBrowser(); page = browser.page; await page.loginAndModule('buyer', 'item'); await page.accessToSection('item.fixedPrice'); + page.on('request', req => { + if (req.url().includes(`FixedPrices/filter`)) + httpRequest = req.url(); + }); }); afterAll(async() => { await browser.close(); }); - it('should click on the add new foxed price button', async() => { - await page.doSearch(); + it('should filter using all the fields', async() => { + await page.write(selectors.itemFixedPrice.generalSearchFilter, 'item'); + await page.keyboard.press('Enter'); + + expect(httpRequest).toContain('search=item'); + + await page.click(selectors.itemFixedPrice.chip); + await page.click(selectors.itemFixedPrice.reignFilter); + + expect(httpRequest).toContain('categoryFk'); + + await page.autocompleteSearch(selectors.itemFixedPrice.typeFilter, 'Alstroemeria'); + + expect(httpRequest).toContain('typeFk'); + + await page.click(selectors.itemFixedPrice.chip); + await page.autocompleteSearch(selectors.itemFixedPrice.buyerFilter, 'buyerNick'); + + expect(httpRequest).toContain('buyerFk'); + + await page.click(selectors.itemFixedPrice.chip); + await page.autocompleteSearch(selectors.itemFixedPrice.warehouseFilter, 'Algemesi'); + + expect(httpRequest).toContain('warehouseFk'); + + await page.click(selectors.itemFixedPrice.chip); + await page.click(selectors.itemFixedPrice.mineFilter); + + expect(httpRequest).toContain('mine=true'); + + await page.click(selectors.itemFixedPrice.chip); + await page.click(selectors.itemFixedPrice.hasMinPriceFilter); + + expect(httpRequest).toContain('hasMinPrice=true'); + + await page.click(selectors.itemFixedPrice.chip); + await page.click(selectors.itemFixedPrice.addTag); + await page.autocompleteSearch(selectors.itemFixedPrice.tagFilter, 'Color'); + await page.autocompleteSearch(selectors.itemFixedPrice.tagValueFilter, 'Brown'); + + expect(httpRequest).toContain('tags'); + + await page.click(selectors.itemFixedPrice.chip); + }); + + it('should click on the add new fixed price button', async() => { await page.waitToClick(selectors.itemFixedPrice.add); await page.waitForSelector(selectors.itemFixedPrice.fourthFixedPrice); }); @@ -35,9 +85,7 @@ describe('Item fixed prices path', () => { }); it('should reload the section and check the created price has the expected ID', async() => { - await page.accessToSection('item.index'); - await page.accessToSection('item.fixedPrice'); - await page.doSearch(); + await page.goto(`http://localhost:5000/#!/item/fixed-price`); const result = await page.waitToGetProperty(selectors.itemFixedPrice.fourthItemID, 'value'); From ecbfdad1025af31ed536fde8f69e6b284fe2fbcf Mon Sep 17 00:00:00 2001 From: alexandre Date: Tue, 4 Apr 2023 09:51:07 +0200 Subject: [PATCH 03/10] refs #5418 changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c5ee05fe49..dc16a87d62 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - (Facturas recibidas -> Bases negativas) Nueva sección ### Changed -- +- (Artículo -> Precio fijado) Modificado el buscador superior por uno lateral ### Fixed - From abaeeddc21c4ede37b2c0fb431effd9350e3185e Mon Sep 17 00:00:00 2001 From: alexandre Date: Tue, 11 Apr 2023 10:54:58 +0200 Subject: [PATCH 04/10] refs #5418 fix e2e --- e2e/paths/01-salix/03_smartTable_searchBar_integrations.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/paths/01-salix/03_smartTable_searchBar_integrations.spec.js b/e2e/paths/01-salix/03_smartTable_searchBar_integrations.spec.js index 70fa121fd3..1c8fe0840b 100644 --- a/e2e/paths/01-salix/03_smartTable_searchBar_integrations.spec.js +++ b/e2e/paths/01-salix/03_smartTable_searchBar_integrations.spec.js @@ -92,7 +92,7 @@ describe('SmartTable SearchBar integration', () => { }); const result = await page.waitToGetProperty(selectors.itemFixedPrice.firstItemID, 'value'); - expect(result).toEqual('3'); + expect(result).toEqual('13'); }); }); }); From 41f9ec63ff95d28a99fdfa5a009667b6798bc400 Mon Sep 17 00:00:00 2001 From: alexandre Date: Thu, 13 Apr 2023 13:35:11 +0200 Subject: [PATCH 05/10] refs #5418 changelog --- CHANGELOG.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 222f547e46..bf7887b9ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2316.01] - 2023-05-04 + +### Added +- + +### Changed +- (Artículo -> Precio fijado) Modificado el buscador superior por uno lateral + +### Fixed +- + + ## [2314.01] - 2023-04-20 ### Added @@ -13,7 +25,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - (Facturas recibidas -> Bases negativas) Nueva sección ### Changed -- (Artículo -> Precio fijado) Modificado el buscador superior por uno lateral ### Fixed - (Clientes -> Morosos) Ahora se mantienen los elementos seleccionados al hacer sroll. From 05ceba65d6257a929572d65132653c61f90a4a93 Mon Sep 17 00:00:00 2001 From: alexandre Date: Thu, 13 Apr 2023 13:35:54 +0200 Subject: [PATCH 06/10] refs #5418 changelog --- CHANGELOG.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bf7887b9ad..e89f394b07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,8 +24,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - (Monitor tickets) Muestra un icono al lado de la zona, si el ticket es frágil y se envía por agencia - (Facturas recibidas -> Bases negativas) Nueva sección -### Changed - ### Fixed - (Clientes -> Morosos) Ahora se mantienen los elementos seleccionados al hacer sroll. From ac4772e44ee6a27e019dcff3e2d40b2022a0b688 Mon Sep 17 00:00:00 2001 From: alexandre Date: Thu, 13 Apr 2023 13:46:29 +0200 Subject: [PATCH 07/10] refs #5418 mistake doing git pull origin dev --- .../231401/00-claimBeginningAfterInsert.sql | 1 + db/dump/fixtures.sql | 10 +++++----- loopback/locale/es.json | 3 ++- loopback/server/connectors/vn-mysql.js | 20 ++++++++++--------- .../claim/specs/createFromSales.spec.js | 4 ++-- modules/claim/back/models/claim-beginning.js | 12 +++++++++-- .../fixed-price/specs/editFixedPrice.spec.js | 2 +- modules/item/back/models/item-shelving.json | 3 +++ package.json | 2 +- .../expedition-pallet-label/sql/labelData.sql | 4 ++-- 10 files changed, 38 insertions(+), 23 deletions(-) create mode 100644 db/changes/231401/00-claimBeginningAfterInsert.sql diff --git a/db/changes/231401/00-claimBeginningAfterInsert.sql b/db/changes/231401/00-claimBeginningAfterInsert.sql new file mode 100644 index 0000000000..230b6defb9 --- /dev/null +++ b/db/changes/231401/00-claimBeginningAfterInsert.sql @@ -0,0 +1 @@ +DROP TRIGGER IF EXISTS `vn`.`claimBeginning_afterInsert`; diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 9006c66761..59d0a5eaab 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -1774,12 +1774,12 @@ INSERT INTO `vn`.`claimState`(`id`, `code`, `description`, `roleFk`, `priority`, ( 6, 'mana', 'Mana', 72, 4, 0), ( 7, 'lack', 'Faltas', 72, 2, 0); -INSERT INTO `vn`.`claim`(`id`, `ticketCreated`, `claimStateFk`, `clientFk`, `workerFk`, `responsibility`, `isChargedToMana`, `created`, `packages`, `rma`) +INSERT INTO `vn`.`claim`(`id`, `ticketCreated`, `claimStateFk`, `clientFk`, `workerFk`, `responsibility`, `isChargedToMana`, `created`, `packages`, `rma`, `ticketFk`) VALUES - (1, util.VN_CURDATE(), 1, 1101, 18, 3, 0, util.VN_CURDATE(), 0, '02676A049183'), - (2, util.VN_CURDATE(), 2, 1101, 18, 3, 0, util.VN_CURDATE(), 1, NULL), - (3, util.VN_CURDATE(), 3, 1101, 18, 1, 1, util.VN_CURDATE(), 5, NULL), - (4, util.VN_CURDATE(), 3, 1104, 18, 5, 0, util.VN_CURDATE(), 10, NULL); + (1, util.VN_CURDATE(), 1, 1101, 18, 3, 0, util.VN_CURDATE(), 0, '02676A049183', 11), + (2, util.VN_CURDATE(), 2, 1101, 18, 3, 0, util.VN_CURDATE(), 1, NULL, 16), + (3, util.VN_CURDATE(), 3, 1101, 18, 1, 1, util.VN_CURDATE(), 5, NULL, 7), + (4, util.VN_CURDATE(), 3, 1104, 18, 5, 0, util.VN_CURDATE(), 10, NULL, 8); INSERT INTO `vn`.`claimObservation` (`claimFk`, `workerFk`, `text`, `created`) VALUES diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 42276efe7e..33741d395a 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -274,5 +274,6 @@ "This ticket cannot be signed because it has not been boxed": "Este ticket no puede firmarse porque no ha sido encajado", "Insert a date range": "Inserte un rango de fechas", "Added observation": "{{user}} añadió esta observacion: {{text}}", - "Comment added to client": "Observación añadida al cliente {{clientFk}}" + "Comment added to client": "Observación añadida al cliente {{clientFk}}", + "Cannot create a new claimBeginning from a different ticket": "No se puede crear una línea de reclamación de un ticket diferente al origen" } diff --git a/loopback/server/connectors/vn-mysql.js b/loopback/server/connectors/vn-mysql.js index 728454d862..a6fd3351a1 100644 --- a/loopback/server/connectors/vn-mysql.js +++ b/loopback/server/connectors/vn-mysql.js @@ -311,7 +311,7 @@ class VnMySQL extends MySQL { return super[method].apply(this, args); this.invokeMethodP(method, [...args], model, ctx, opts) - .then(res => cb(...res), cb); + .then(res => cb(...[null].concat(res)), cb); } async invokeMethodP(method, args, model, ctx, opts) { @@ -331,8 +331,7 @@ class VnMySQL extends MySQL { const userId = opts.httpCtx && opts.httpCtx.active.accessToken.userId; const user = await Model.app.models.Account.findById(userId, { fields: ['name'] }, opts); await this.executeP(`CALL account.myUser_loginWithName(?)`, [user.name], opts); - } - else { + } else { where = ctx.where; id = ctx.id; data = ctx.data; @@ -358,9 +357,12 @@ class VnMySQL extends MySQL { } } - const res = await new Promise(resolve => { + const res = await new Promise((resolve, reject) => { const fnArgs = args.slice(0, -2); - fnArgs.push(opts, (...args) => resolve(args)); + fnArgs.push(opts, (err, ...args) => { + if (err) return reject(err); + resolve(args); + }); super[method].apply(this, fnArgs); }); @@ -375,11 +377,11 @@ class VnMySQL extends MySQL { case 'update': { switch (method) { case 'createAll': - for (const row of res[1]) + for (const row of res[0]) ids.push(row[idName]); break; case 'create': - ids.push(res[1]); + ids.push(res[0]); break; case 'update': if (data[idName] != null) @@ -387,7 +389,7 @@ class VnMySQL extends MySQL { break; } - const newWhere = ids.length ? { [idName]: ids } : where; + const newWhere = ids.length ? {[idName]: {inq: ids}} : where; const stmt = this.buildSelectStmt(op, data, idName, model, newWhere, limit); newInstances = await this.executeStmt(stmt, opts); @@ -671,4 +673,4 @@ SQLConnector.prototype.all = function find(model, filter, options, cb) { cb(error, []) } }); -}; \ No newline at end of file +}; diff --git a/modules/claim/back/methods/claim/specs/createFromSales.spec.js b/modules/claim/back/methods/claim/specs/createFromSales.spec.js index 7cf663caf9..fe009c1c3e 100644 --- a/modules/claim/back/methods/claim/specs/createFromSales.spec.js +++ b/modules/claim/back/methods/claim/specs/createFromSales.spec.js @@ -2,9 +2,9 @@ const models = require('vn-loopback/server/server').models; const LoopBackContext = require('loopback-context'); describe('Claim createFromSales()', () => { - const ticketId = 16; + const ticketId = 23; const newSale = [{ - id: 3, + id: 31, instance: 0, quantity: 10 }]; diff --git a/modules/claim/back/models/claim-beginning.js b/modules/claim/back/models/claim-beginning.js index 4c4b59737a..4b870e5ea4 100644 --- a/modules/claim/back/models/claim-beginning.js +++ b/modules/claim/back/models/claim-beginning.js @@ -10,8 +10,16 @@ module.exports = Self => { }); Self.observe('before save', async ctx => { - if (ctx.isNewInstance) return; - //await claimIsEditable(ctx); + if (ctx.isNewInstance) { + const models = Self.app.models; + const options = ctx.options; + const instance = ctx.instance; + const ticket = await models.Sale.findById(instance.saleFk, {fields: ['ticketFk']}, options); + const claim = await models.Claim.findById(instance.claimFk, {fields: ['ticketFk']}, options); + if (ticket.ticketFk != claim.ticketFk) + throw new UserError(`Cannot create a new claimBeginning from a different ticket`); + } + // await claimIsEditable(ctx); }); Self.observe('before delete', async ctx => { diff --git a/modules/item/back/methods/fixed-price/specs/editFixedPrice.spec.js b/modules/item/back/methods/fixed-price/specs/editFixedPrice.spec.js index a5e6cd35ae..9c265f28ab 100644 --- a/modules/item/back/methods/fixed-price/specs/editFixedPrice.spec.js +++ b/modules/item/back/methods/fixed-price/specs/editFixedPrice.spec.js @@ -50,7 +50,7 @@ describe('Item editFixedPrice()', () => { await models.FixedPrice.editFixedPrice(ctx, field, newValue, null, filter, options); - const [result] = await models.FixedPrice.filter(ctx, null, options); + const [result] = await models.FixedPrice.filter(ctx, filter, options); expect(result[field]).toEqual(newValue); diff --git a/modules/item/back/models/item-shelving.json b/modules/item/back/models/item-shelving.json index 0890350dac..b24edfc53d 100644 --- a/modules/item/back/models/item-shelving.json +++ b/modules/item/back/models/item-shelving.json @@ -20,6 +20,9 @@ }, "created": { "type": "date" + }, + "isChecked": { + "type": "boolean" } }, "relations": { diff --git a/package.json b/package.json index 8fa1776460..607367e7b6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-back", - "version": "23.14.01", + "version": "23.16.01", "author": "Verdnatura Levante SL", "description": "Salix backend", "license": "GPL-3.0", diff --git a/print/templates/reports/expedition-pallet-label/sql/labelData.sql b/print/templates/reports/expedition-pallet-label/sql/labelData.sql index 0661dbe0fb..b2a805251e 100644 --- a/print/templates/reports/expedition-pallet-label/sql/labelData.sql +++ b/print/templates/reports/expedition-pallet-label/sql/labelData.sql @@ -12,8 +12,8 @@ SELECT ep.id palletFk, JOIN vn.expedition e ON e.id = es.expeditionFk JOIN vn.ticket t ON t.id = e.ticketFk JOIN vn.route r ON r.id = t.routeFk - LEFT JOIN vn2008.Rutas_monitor rm ON rm.Id_Ruta = r.id + LEFT JOIN vn.routesMonitor rm ON rm.routeFk = r.id LEFT JOIN vn.expeditionTruck et2 ON et2.id = rm.expeditionTruckFk WHERE ep.id = ? GROUP BY ep.id, t.routeFk - ORDER BY t.routeFk \ No newline at end of file + ORDER BY t.routeFk From 025c158b279d246b432f8b5f32a2537af095d963 Mon Sep 17 00:00:00 2001 From: alexandre Date: Thu, 13 Apr 2023 13:52:11 +0200 Subject: [PATCH 08/10] refs #5418 minor fixes --- .../03_smartTable_searchBar_integrations.spec.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/e2e/paths/01-salix/03_smartTable_searchBar_integrations.spec.js b/e2e/paths/01-salix/03_smartTable_searchBar_integrations.spec.js index 1c8fe0840b..a3d747f1cb 100644 --- a/e2e/paths/01-salix/03_smartTable_searchBar_integrations.spec.js +++ b/e2e/paths/01-salix/03_smartTable_searchBar_integrations.spec.js @@ -79,20 +79,27 @@ describe('SmartTable SearchBar integration', () => { it('should order by first id', async() => { await page.loginAndModule('developer', 'item'); await page.accessToSection('item.fixedPrice'); + await page.doSearch(); const result = await page.waitToGetProperty(selectors.itemFixedPrice.firstItemID, 'value'); expect(result).toEqual('1'); }); - it('should order by last id, reload page and have same order', async() => { + it('should order by last id', async() => { await page.waitToClick(selectors.itemFixedPrice.orderColumnId); + const result = await page.waitToGetProperty(selectors.itemFixedPrice.firstItemID, 'value'); + + expect(result).toEqual('3'); + }); + + it('should reload page and have same order', async() => { await page.reload({ waitUntil: 'networkidle2' }); const result = await page.waitToGetProperty(selectors.itemFixedPrice.firstItemID, 'value'); - expect(result).toEqual('13'); + expect(result).toEqual('3'); }); }); }); From ad3836552e3647640544091ecc7345d8becdaad7 Mon Sep 17 00:00:00 2001 From: alexandre Date: Fri, 14 Apr 2023 14:16:29 +0200 Subject: [PATCH 09/10] refs #5518 sections added --- back/model-config.json | 3 ++ back/models/role-log.json | 58 +++++++++++++++++++++++ back/models/user-log.json | 6 +-- db/changes/231601/00-userRoleLog.sql | 44 +++++++++++++++++ modules/account/front/index.js | 2 + modules/account/front/locale/es.yml | 3 +- modules/account/front/role-log/index.html | 1 + modules/account/front/role-log/index.js | 7 +++ modules/account/front/routes.json | 18 ++++++- modules/account/front/user-log/index.html | 1 + modules/account/front/user-log/index.js | 7 +++ 11 files changed, 144 insertions(+), 6 deletions(-) create mode 100644 back/models/role-log.json create mode 100644 db/changes/231601/00-userRoleLog.sql create mode 100644 modules/account/front/role-log/index.html create mode 100644 modules/account/front/role-log/index.js create mode 100644 modules/account/front/user-log/index.html create mode 100644 modules/account/front/user-log/index.js diff --git a/back/model-config.json b/back/model-config.json index 29676e979e..0410d45a7e 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -128,6 +128,9 @@ "UserLog": { "dataSource": "vn" }, + "RoleLog": { + "dataSource": "vn" + }, "Warehouse": { "dataSource": "vn" }, diff --git a/back/models/role-log.json b/back/models/role-log.json new file mode 100644 index 0000000000..b4fc3daf99 --- /dev/null +++ b/back/models/role-log.json @@ -0,0 +1,58 @@ +{ + "name": "RoleLog", + "base": "VnModel", + "options": { + "mysql": { + "table": "account.roleLog" + } + }, + "properties": { + "id": { + "id": true, + "type": "number", + "forceId": false + }, + "originFk": { + "type": "number", + "required": true + }, + "userFk": { + "type": "number" + }, + "action": { + "type": "string", + "required": true + }, + "changedModel": { + "type": "string" + }, + "oldInstance": { + "type": "object" + }, + "newInstance": { + "type": "object" + }, + "creationDate": { + "type": "date" + }, + "changedModelId": { + "type": "number" + }, + "changedModelValue": { + "type": "string" + }, + "description": { + "type": "string" + } + }, + "relations": { + "user": { + "type": "belongsTo", + "model": "Account", + "foreignKey": "userFk" + } + }, + "scope": { + "order": ["creationDate DESC", "id DESC"] + } +} diff --git a/back/models/user-log.json b/back/models/user-log.json index 43ccbfa438..5169d99b05 100644 --- a/back/models/user-log.json +++ b/back/models/user-log.json @@ -3,7 +3,7 @@ "base": "VnModel", "options": { "mysql": { - "table": "userLog" + "table": "account.userLog" } }, "properties": { @@ -16,7 +16,7 @@ "type": "number", "required": true }, - "userFk": { + "userFk": { "type": "number" }, "action": { @@ -50,7 +50,7 @@ "type": "belongsTo", "model": "Account", "foreignKey": "userFk" - } + } }, "scope": { "order": ["creationDate DESC", "id DESC"] diff --git a/db/changes/231601/00-userRoleLog.sql b/db/changes/231601/00-userRoleLog.sql new file mode 100644 index 0000000000..12000993ab --- /dev/null +++ b/db/changes/231601/00-userRoleLog.sql @@ -0,0 +1,44 @@ +DROP TABLE IF EXISTS `vn`.`userLog`; + +CREATE TABLE `account`.`userLog` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `originFk` int(10) unsigned DEFAULT NULL, + `userFk` int(10) unsigned DEFAULT NULL, + `action` set('insert','update','delete') COLLATE utf8mb4_unicode_ci NOT NULL, + `creationDate` timestamp NULL DEFAULT current_timestamp(), + `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `changedModel` varchar(45) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `oldInstance` text COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `newInstance` text COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `changedModelId` int(11) DEFAULT NULL, + `changedModelValue` varchar(45) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `originFk` (`originFk`), + KEY `userFk` (`userFk`), + CONSTRAINT `userLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `userLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + +CREATE TABLE `account`.`roleLog` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `originFk` int(10) unsigned DEFAULT NULL, + `userFk` int(10) unsigned DEFAULT NULL, + `action` set('insert','update','delete') COLLATE utf8mb3_unicode_ci NOT NULL, + `creationDate` timestamp NULL DEFAULT current_timestamp(), + `description` text CHARACTER SET utf8mb3 DEFAULT NULL, + `changedModel` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `oldInstance` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `newInstance` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `changedModelId` int(11) DEFAULT NULL, + `changedModelValue` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `originFk` (`originFk`), + KEY `userFk` (`userFk`), + CONSTRAINT `roleLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `roleLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `role` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; + +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) + VALUES + ('UserLog', '*', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('RoleLog', '*', 'READ', 'ALLOW', 'ROLE', 'employee'); diff --git a/modules/account/front/index.js b/modules/account/front/index.js index 0cd0c49555..695f369677 100644 --- a/modules/account/front/index.js +++ b/modules/account/front/index.js @@ -19,3 +19,5 @@ import './ldap'; import './samba'; import './accounts'; import './privileges'; +import './user-log'; +import './role-log'; diff --git a/modules/account/front/locale/es.yml b/modules/account/front/locale/es.yml index 18e2c06a18..7988cbda6d 100644 --- a/modules/account/front/locale/es.yml +++ b/modules/account/front/locale/es.yml @@ -8,4 +8,5 @@ Role: Rol Mail aliases: Alias de correo Account not enabled: Cuenta no habilitada Inherited roles: Roles heredados -Go to the user: Ir al usuario \ No newline at end of file +Go to the user: Ir al usuario +Log: Histórico diff --git a/modules/account/front/role-log/index.html b/modules/account/front/role-log/index.html new file mode 100644 index 0000000000..9e2b151b54 --- /dev/null +++ b/modules/account/front/role-log/index.html @@ -0,0 +1 @@ + diff --git a/modules/account/front/role-log/index.js b/modules/account/front/role-log/index.js new file mode 100644 index 0000000000..02448ccaa5 --- /dev/null +++ b/modules/account/front/role-log/index.js @@ -0,0 +1,7 @@ +import ngModule from '../module'; +import Section from 'salix/components/section'; + +ngModule.vnComponent('vnRoleLog', { + template: require('./index.html'), + controller: Section, +}); diff --git a/modules/account/front/routes.json b/modules/account/front/routes.json index a6f2f5d3f5..cc66df103c 100644 --- a/modules/account/front/routes.json +++ b/modules/account/front/routes.json @@ -20,12 +20,14 @@ {"state": "account.card.roles", "icon": "group"}, {"state": "account.card.mailForwarding", "icon": "forward"}, {"state": "account.card.aliases", "icon": "email"}, - {"state": "account.card.privileges", "icon": "badge"} + {"state": "account.card.privileges", "icon": "badge"}, + {"state": "account.card.log", "icon": "history"} ], "role": [ {"state": "account.role.card.basicData", "icon": "settings"}, {"state": "account.role.card.subroles", "icon": "groups"}, - {"state": "account.role.card.inherited", "icon": "account_tree"} + {"state": "account.role.card.inherited", "icon": "account_tree"}, + {"state": "account.role.card.log", "icon": "history"} ], "alias": [ {"state": "account.alias.card.basicData", "icon": "settings"}, @@ -80,6 +82,18 @@ "description": "Basic data", "acl": ["hr"] }, + { + "url" : "/log", + "state": "account.card.log", + "component": "vn-user-log", + "description": "Log" + }, + { + "url" : "/log", + "state": "account.role.card.log", + "component": "vn-role-log", + "description": "Log" + }, { "url": "/roles", "state": "account.card.roles", diff --git a/modules/account/front/user-log/index.html b/modules/account/front/user-log/index.html new file mode 100644 index 0000000000..5a77ed7b9f --- /dev/null +++ b/modules/account/front/user-log/index.html @@ -0,0 +1 @@ + diff --git a/modules/account/front/user-log/index.js b/modules/account/front/user-log/index.js new file mode 100644 index 0000000000..7cd0bb378d --- /dev/null +++ b/modules/account/front/user-log/index.js @@ -0,0 +1,7 @@ +import ngModule from '../module'; +import Section from 'salix/components/section'; + +ngModule.vnComponent('vnUserLog', { + template: require('./index.html'), + controller: Section, +}); From 2675c02d13cef9cfbafc8a5b40650fcca8489545 Mon Sep 17 00:00:00 2001 From: alexandre Date: Mon, 17 Apr 2023 11:52:52 +0200 Subject: [PATCH 10/10] refs #5518 moved models to account --- back/model-config.json | 6 --- db/changes/231601/00-userRoleLog.sql | 40 ------------------- modules/account/back/model-config.json | 8 +++- .../account/back}/models/role-log.json | 0 .../account/back}/models/user-log.json | 0 5 files changed, 7 insertions(+), 47 deletions(-) rename {back => modules/account/back}/models/role-log.json (100%) rename {back => modules/account/back}/models/user-log.json (100%) diff --git a/back/model-config.json b/back/model-config.json index 0410d45a7e..5a5c6d3aca 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -125,12 +125,6 @@ "UserConfigView": { "dataSource": "vn" }, - "UserLog": { - "dataSource": "vn" - }, - "RoleLog": { - "dataSource": "vn" - }, "Warehouse": { "dataSource": "vn" }, diff --git a/db/changes/231601/00-userRoleLog.sql b/db/changes/231601/00-userRoleLog.sql index 12000993ab..ae5da13cb3 100644 --- a/db/changes/231601/00-userRoleLog.sql +++ b/db/changes/231601/00-userRoleLog.sql @@ -1,43 +1,3 @@ -DROP TABLE IF EXISTS `vn`.`userLog`; - -CREATE TABLE `account`.`userLog` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `originFk` int(10) unsigned DEFAULT NULL, - `userFk` int(10) unsigned DEFAULT NULL, - `action` set('insert','update','delete') COLLATE utf8mb4_unicode_ci NOT NULL, - `creationDate` timestamp NULL DEFAULT current_timestamp(), - `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, - `changedModel` varchar(45) COLLATE utf8mb4_unicode_ci DEFAULT NULL, - `oldInstance` text COLLATE utf8mb4_unicode_ci DEFAULT NULL, - `newInstance` text COLLATE utf8mb4_unicode_ci DEFAULT NULL, - `changedModelId` int(11) DEFAULT NULL, - `changedModelValue` varchar(45) COLLATE utf8mb4_unicode_ci DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `originFk` (`originFk`), - KEY `userFk` (`userFk`), - CONSTRAINT `userLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `userLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; - -CREATE TABLE `account`.`roleLog` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `originFk` int(10) unsigned DEFAULT NULL, - `userFk` int(10) unsigned DEFAULT NULL, - `action` set('insert','update','delete') COLLATE utf8mb3_unicode_ci NOT NULL, - `creationDate` timestamp NULL DEFAULT current_timestamp(), - `description` text CHARACTER SET utf8mb3 DEFAULT NULL, - `changedModel` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, - `oldInstance` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, - `newInstance` text COLLATE utf8mb3_unicode_ci DEFAULT NULL, - `changedModelId` int(11) DEFAULT NULL, - `changedModelValue` varchar(45) COLLATE utf8mb3_unicode_ci DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `originFk` (`originFk`), - KEY `userFk` (`userFk`), - CONSTRAINT `roleLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `roleLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `role` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; - INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('UserLog', '*', 'READ', 'ALLOW', 'ROLE', 'employee'), diff --git a/modules/account/back/model-config.json b/modules/account/back/model-config.json index c697bd3b9f..057a487dd4 100644 --- a/modules/account/back/model-config.json +++ b/modules/account/back/model-config.json @@ -23,6 +23,9 @@ "RoleConfig": { "dataSource": "vn" }, + "RoleLog": { + "dataSource": "vn" + }, "RoleInherit": { "dataSource": "vn" }, @@ -41,10 +44,13 @@ "UserAccount": { "dataSource": "vn" }, + "UserLog": { + "dataSource": "vn" + }, "UserPassword": { "dataSource": "vn" }, "UserSync": { "dataSource": "vn" } -} \ No newline at end of file +} diff --git a/back/models/role-log.json b/modules/account/back/models/role-log.json similarity index 100% rename from back/models/role-log.json rename to modules/account/back/models/role-log.json diff --git a/back/models/user-log.json b/modules/account/back/models/user-log.json similarity index 100% rename from back/models/user-log.json rename to modules/account/back/models/user-log.json