From e6304d026c6c1892903bc8fa67bd85d055a5aa3c Mon Sep 17 00:00:00 2001 From: joan Date: Fri, 22 Oct 2021 15:01:54 +0200 Subject: [PATCH 01/43] feat(smart-table): added smart-table and smart-table-menu components --- front/core/components/index.js | 1 + .../components/smart-table-menu/index.html | 45 ++++ .../core/components/smart-table-menu/index.js | 48 +++++ .../components/smart-table-menu/style.scss | 24 +++ front/core/directives/index.js | 2 + front/core/directives/smart-table2.js | 54 +++++ modules/ticket/front/index/index.html | 200 ++---------------- 7 files changed, 196 insertions(+), 178 deletions(-) create mode 100644 front/core/components/smart-table-menu/index.html create mode 100644 front/core/components/smart-table-menu/index.js create mode 100644 front/core/components/smart-table-menu/style.scss create mode 100644 front/core/directives/smart-table2.js diff --git a/front/core/components/index.js b/front/core/components/index.js index 3ccc64b89..150fc2158 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-menu'; diff --git a/front/core/components/smart-table-menu/index.html b/front/core/components/smart-table-menu/index.html new file mode 100644 index 000000000..14b94cf48 --- /dev/null +++ b/front/core/components/smart-table-menu/index.html @@ -0,0 +1,45 @@ +
+
+ +
+ + +
+
+ + +
+ + a + + + + + +
+ +
+ + + + +
+
+
+ +
+
\ No newline at end of file diff --git a/front/core/components/smart-table-menu/index.js b/front/core/components/smart-table-menu/index.js new file mode 100644 index 000000000..9d2b378cc --- /dev/null +++ b/front/core/components/smart-table-menu/index.js @@ -0,0 +1,48 @@ +import ngModule from '../../module'; +import Component from '../../lib/component'; +import './style.scss'; + +export default class SmartTableMenu extends Component { + constructor($element, $, $transclude) { + super($element, $); + this.$transclude = $transclude; + // stuff + } + + $onDestroy() { + if (this.$contentScope) + this.$contentScope.$destroy(); + } + + get model() { + return this._model; + } + + set model(value) { + this._model = value; + if (value) + this.transclude(); + } + + transclude() { + const body = this.element.querySelector('.body'); + this.$transclude(($clone, $scope) => { + this.$contentScope = $scope; + $scope.model = this.model; + body.appendChild($clone[0]); + }, null, 'body'); + } +} + +SmartTableMenu.$inject = ['$element', '$scope', '$transclude']; + +ngModule.vnComponent('smartTableMenu', { + template: require('./index.html'), + controller: SmartTableMenu, + transclude: { + body: '?slotBody' + }, + bindings: { + model: ' vn-button { + box-shadow: 0 0 0 0 + } + } + } +} diff --git a/front/core/directives/index.js b/front/core/directives/index.js index e0f42aef5..dfc79d1aa 100644 --- a/front/core/directives/index.js +++ b/front/core/directives/index.js @@ -16,3 +16,5 @@ import './droppable'; import './http-click'; import './http-submit'; import './anchor'; +import './smart-table2'; + diff --git a/front/core/directives/smart-table2.js b/front/core/directives/smart-table2.js new file mode 100644 index 000000000..187f77569 --- /dev/null +++ b/front/core/directives/smart-table2.js @@ -0,0 +1,54 @@ +import ngModule from '../module'; +import Component from '../lib/component'; +import './smart-table.scss'; + +class Controller extends Component { + constructor($element, $, $attrs) { + super($element, $); + // this.element = $element[0]; + + this.$attrs = $attrs; + + this.registerColumns(); + this.registerEvents(); + } + + registerColumns() { + const header = this.element.querySelector('thead > tr'); + if (!header) return; + const columns = header.querySelectorAll('th'); + + // TODO: Add arrow icon and so on.. + // Click handler + for (let column of columns) + column.addEventListener('click', () => this.orderHandler(column)); + } + + registerEvents() { + this.$.$on('addRow', () => this.addRow()); + this.$.$on('displaySearch', () => this.displaySearch()); + } + + orderHandler(element) { + const field = element.getAttribute('field'); + console.log(`You clicked to ` + field); + } + + displaySearch() { + console.log('Display the search!'); + } + + addRow() { + console.log('Add new row element'); + this.$.model.insert({}); + } +} +Controller.$inject = ['$element', '$scope', '$attrs']; + +ngModule.directive('smartTable', () => { + return { + controller: Controller, + bindings: { + } + }; +}); diff --git a/modules/ticket/front/index/index.html b/modules/ticket/front/index/index.html index 63b0b049d..f3ac18c52 100644 --- a/modules/ticket/front/index/index.html +++ b/modules/ticket/front/index/index.html @@ -1,155 +1,28 @@ - - - - - - - - - - - Id - Salesperson - Date - Hour - Closure - Alias - Province - State - Zone - Warehouse - Total - - - - - - - - - - - - - - - - - - - - - - - - {{::ticket.id}} - - - {{::ticket.userName | dashIfEmpty}} - - - - - {{::ticket.shipped | date: 'dd/MM/yyyy'}} - - - {{::ticket.shipped | date: 'HH:mm'}} - {{::ticket.zoneLanding | date: 'HH:mm'}} - - - {{::ticket.nickname}} - - - {{::ticket.province}} - - - {{::ticket.refFk}} - - - {{ticket.state}} - - - - - {{::ticket.zoneName | dashIfEmpty}} - - - {{::ticket.warehouse}} - - - {{::(ticket.totalWithVat ? ticket.totalWithVat : 0) | currency: 'EUR': 2}} - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + +
Column 1Column 2
{{::ticket.id}}{{::ticket.userName}}
+
+
+ +
- - - - Filter by selection - - - Exclude selection - - - Remove filter - - - Remove all filters - - - Copy value - - - Date: Fri, 22 Oct 2021 15:41:44 +0200 Subject: [PATCH 02/43] Added save function --- front/core/components/smart-table-menu/index.html | 3 +-- front/core/components/smart-table-menu/index.js | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/front/core/components/smart-table-menu/index.html b/front/core/components/smart-table-menu/index.html index 14b94cf48..6cd90efe8 100644 --- a/front/core/components/smart-table-menu/index.html +++ b/front/core/components/smart-table-menu/index.html @@ -16,14 +16,13 @@ - a
diff --git a/front/core/components/smart-table-menu/index.js b/front/core/components/smart-table-menu/index.js index 9d2b378cc..9f0d27852 100644 --- a/front/core/components/smart-table-menu/index.js +++ b/front/core/components/smart-table-menu/index.js @@ -32,6 +32,11 @@ export default class SmartTableMenu extends Component { body.appendChild($clone[0]); }, null, 'body'); } + + save() { + this.model.save() + .then(() => this.vnApp.showSuccess(this.$t('Data saved!'))); + } } SmartTableMenu.$inject = ['$element', '$scope', '$transclude']; From d5264486c7f3a1fba3da44d2834f9f3121de8c6c Mon Sep 17 00:00:00 2001 From: joan Date: Sat, 23 Oct 2021 14:26:42 +0200 Subject: [PATCH 03/43] Simplified to one component --- front/core/components/index.js | 2 +- .../core/components/smart-table-menu/index.js | 53 --------- .../index.html | 19 ++-- front/core/components/smart-table/index.js | 102 ++++++++++++++++++ .../style.scss | 14 ++- front/core/directives/smart-table2.js | 2 +- modules/ticket/front/index/index.html | 47 +++++--- 7 files changed, 163 insertions(+), 76 deletions(-) delete mode 100644 front/core/components/smart-table-menu/index.js rename front/core/components/{smart-table-menu => smart-table}/index.html (69%) create mode 100644 front/core/components/smart-table/index.js rename front/core/components/{smart-table-menu => smart-table}/style.scss (63%) diff --git a/front/core/components/index.js b/front/core/components/index.js index 150fc2158..86ab89212 100644 --- a/front/core/components/index.js +++ b/front/core/components/index.js @@ -52,4 +52,4 @@ import './wday-picker'; import './datalist'; import './contextmenu'; import './rating'; -import './smart-table-menu'; +import './smart-table'; diff --git a/front/core/components/smart-table-menu/index.js b/front/core/components/smart-table-menu/index.js deleted file mode 100644 index 9f0d27852..000000000 --- a/front/core/components/smart-table-menu/index.js +++ /dev/null @@ -1,53 +0,0 @@ -import ngModule from '../../module'; -import Component from '../../lib/component'; -import './style.scss'; - -export default class SmartTableMenu extends Component { - constructor($element, $, $transclude) { - super($element, $); - this.$transclude = $transclude; - // stuff - } - - $onDestroy() { - if (this.$contentScope) - this.$contentScope.$destroy(); - } - - get model() { - return this._model; - } - - set model(value) { - this._model = value; - if (value) - this.transclude(); - } - - transclude() { - const body = this.element.querySelector('.body'); - this.$transclude(($clone, $scope) => { - this.$contentScope = $scope; - $scope.model = this.model; - body.appendChild($clone[0]); - }, null, 'body'); - } - - save() { - this.model.save() - .then(() => this.vnApp.showSuccess(this.$t('Data saved!'))); - } -} - -SmartTableMenu.$inject = ['$element', '$scope', '$transclude']; - -ngModule.vnComponent('smartTableMenu', { - template: require('./index.html'), - controller: SmartTableMenu, - transclude: { - body: '?slotBody' - }, - bindings: { - model: ' -
+ +
+ +
@@ -40,5 +45,5 @@
-
+
\ No newline at end of file diff --git a/front/core/components/smart-table/index.js b/front/core/components/smart-table/index.js new file mode 100644 index 000000000..fd22ac9a4 --- /dev/null +++ b/front/core/components/smart-table/index.js @@ -0,0 +1,102 @@ +import ngModule from '../../module'; +import Component from '../../lib/component'; +import './style.scss'; + +export default class SmartTable extends Component { + constructor($element, $, $transclude) { + super($element, $); + this.$transclude = $transclude; + // stuff + } + + /* $onDestroy() { + if (this.$contentScope) + this.$contentScope.$destroy(); + } + */ + get model() { + return this._model; + } + + set model(value) { + this._model = value; + if (value) { + this.$.model = value; + this.transclude(); + } + } + + registerColumns() { + const header = this.element.querySelector('thead > tr'); + if (!header) return; + const columns = header.querySelectorAll('th'); + + // TODO: Add arrow icon and so on.. + // Click handler + for (let column of columns) { + const field = column.getAttribute('field'); + if (field) + column.addEventListener('click', () => this.orderHandler(column)); + } + } + + // Creo que se puede hacer directamente desde ng-transclude + transclude() { + const slotTable = this.element.querySelector('#table'); + this.$transclude(($clone, $scope) => { + const table = $clone[0]; + $scope.hasChanges = this.hasChanges; + slotTable.appendChild(table); + this.registerColumns(); + }, null, 'table'); + } + + orderHandler(element) { + const field = element.getAttribute('field'); + console.log(`You clicked to ` + field); + } + + createRow() { + this.model.insert({ + nickname: 'New row' + }); + } + + deleteAll() { + const data = this.model.data; + const checkedRows = data.filter(row => row.checked); + for (let row of checkedRows) + this.model.remove(row); + + if (this.autoSave) + this.save(); + } + + saveAll() { + const model = this.model; + if (!model.isChanged) + return this.vnApp.showError(this.$t('No changes to save')); + + this.model.save() + .then(() => this.vnApp.showSuccess(this.$t('Data saved!'))); + } + + hasChanges() { + return true; + } +} + +SmartTable.$inject = ['$element', '$scope', '$transclude']; + +ngModule.vnComponent('smartTable', { + template: require('./index.html'), + controller: SmartTable, + transclude: { + table: '?slotTable', + actions: '?slotActions' + }, + bindings: { + model: ' { +ngModule.directive('smartTable2', () => { return { controller: Controller, bindings: { diff --git a/modules/ticket/front/index/index.html b/modules/ticket/front/index/index.html index f3ac18c52..af59eac7d 100644 --- a/modules/ticket/front/index/index.html +++ b/modules/ticket/front/index/index.html @@ -1,27 +1,48 @@ - - + --> + + - - - + + + Mas iconos.. + + +
- - + + + - - + + + - + +
Column 1Column 2 + + + IDNickname
+ + + {{::ticket.id}}{{::ticket.userName}}{{::ticket.nickname}}
-
-
- + +
From 301d303cc1b1023b0f4c036d32a1c5f7098c6dbf Mon Sep 17 00:00:00 2001 From: carlosjr Date: Sun, 24 Oct 2021 13:35:37 +0200 Subject: [PATCH 04/43] polished deletions --- front/core/components/smart-table/index.html | 2 +- front/core/components/smart-table/index.js | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/front/core/components/smart-table/index.html b/front/core/components/smart-table/index.html index 53d015dd4..ccac52b9f 100644 --- a/front/core/components/smart-table/index.html +++ b/front/core/components/smart-table/index.html @@ -23,7 +23,7 @@ vn-tooltip="Undo"> row.checked); - for (let row of checkedRows) - this.model.remove(row); + + for (let row of checkedRows) { + if (row.id) + this.model.remove(row); + else { + const index = this.model.data.indexOf(row); + this.model.data.splice(index, 1); + } + } if (this.autoSave) - this.save(); + this.saveAll(); } saveAll() { From 7ce58c5f33c74ca7e90a4f2fc8d24a361b3d9486 Mon Sep 17 00:00:00 2001 From: carlosjr Date: Mon, 25 Oct 2021 14:20:17 +0200 Subject: [PATCH 05/43] sorting arrows for multiple columns --- front/core/components/smart-table/index.js | 37 +++++++++++++- front/core/components/smart-table/style.scss | 32 ++++++++++++ front/core/directives/index.js | 1 - front/core/directives/smart-table2.js | 54 -------------------- modules/ticket/front/index/index.html | 8 ++- 5 files changed, 73 insertions(+), 59 deletions(-) delete mode 100644 front/core/directives/smart-table2.js diff --git a/front/core/components/smart-table/index.js b/front/core/components/smart-table/index.js index 1ba29b215..2bf032195 100644 --- a/front/core/components/smart-table/index.js +++ b/front/core/components/smart-table/index.js @@ -6,7 +6,7 @@ export default class SmartTable extends Component { constructor($element, $, $transclude) { super($element, $); this.$transclude = $transclude; - // stuff + this.sortCriteria = []; } /* $onDestroy() { @@ -53,7 +53,40 @@ export default class SmartTable extends Component { orderHandler(element) { const field = element.getAttribute('field'); - console.log(`You clicked to ` + field); + const existingCriteria = this.sortCriteria.find(criteria => { + return criteria.field == field; + }); + + if (!existingCriteria) { + this.sortCriteria.push({field: field, sortType: 'ASC'}); + element.classList.remove('desc'); + element.classList.add('asc'); + } + + if (existingCriteria && existingCriteria.sortType == 'DESC') { + this.sortCriteria.splice(this.sortCriteria.findIndex(criteria => { + return criteria.field == field; + }), 1); + element.classList.remove('desc'); + element.classList.remove('asc'); + } + if (existingCriteria && existingCriteria.sortType == 'ASC') { + existingCriteria.sortType = 'DESC'; + element.classList.remove('asc'); + element.classList.add('desc'); + } + + this.applySort(); + } + + applySort() { + let order = this.sortCriteria.map(criteria => `${criteria.field} ${criteria.sortType}`); + order = order.join(', '); + + if (order) + this.model.order = order; + + this.model.refresh(); } createRow() { diff --git a/front/core/components/smart-table/style.scss b/front/core/components/smart-table/style.scss index 15a47d3ec..a9a5c4bb0 100644 --- a/front/core/components/smart-table/style.scss +++ b/front/core/components/smart-table/style.scss @@ -2,6 +2,38 @@ @import "variables"; smart-table { + th[field] { + overflow: visible; + cursor: pointer; + + &.asc > :after, &.desc > :after { + color: $color-font; + opacity: 1; + } + + &.asc > :after { + content: 'arrow_drop_up'; + } + + &.desc > :after { + content: 'arrow_drop_down'; + } + + & > :after { + font-family: 'Material Icons'; + content: 'arrow_drop_down'; + position: absolute; + color: $color-spacer; + font-size: 1.5em; + margin-top: -2px; + opacity: 0 + + } + &:hover > :after { + opacity: 1; + } + } + .actions-left { display: flex; justify-content: flex-start; diff --git a/front/core/directives/index.js b/front/core/directives/index.js index dfc79d1aa..e77917285 100644 --- a/front/core/directives/index.js +++ b/front/core/directives/index.js @@ -16,5 +16,4 @@ import './droppable'; import './http-click'; import './http-submit'; import './anchor'; -import './smart-table2'; diff --git a/front/core/directives/smart-table2.js b/front/core/directives/smart-table2.js deleted file mode 100644 index 916ff130f..000000000 --- a/front/core/directives/smart-table2.js +++ /dev/null @@ -1,54 +0,0 @@ -import ngModule from '../module'; -import Component from '../lib/component'; -import './smart-table.scss'; - -class Controller extends Component { - constructor($element, $, $attrs) { - super($element, $); - // this.element = $element[0]; - - this.$attrs = $attrs; - - this.registerColumns(); - this.registerEvents(); - } - - registerColumns() { - const header = this.element.querySelector('thead > tr'); - if (!header) return; - const columns = header.querySelectorAll('th'); - - // TODO: Add arrow icon and so on.. - // Click handler - for (let column of columns) - column.addEventListener('click', () => this.orderHandler(column)); - } - - registerEvents() { - this.$.$on('addRow', () => this.addRow()); - this.$.$on('displaySearch', () => this.displaySearch()); - } - - orderHandler(element) { - const field = element.getAttribute('field'); - console.log(`You clicked to ` + field); - } - - displaySearch() { - console.log('Display the search!'); - } - - addRow() { - console.log('Add new row element'); - this.$.model.insert({}); - } -} -Controller.$inject = ['$element', '$scope', '$attrs']; - -ngModule.directive('smartTable2', () => { - return { - controller: Controller, - bindings: { - } - }; -}); diff --git a/modules/ticket/front/index/index.html b/modules/ticket/front/index/index.html index af59eac7d..017a25a6c 100644 --- a/modules/ticket/front/index/index.html +++ b/modules/ticket/front/index/index.html @@ -22,8 +22,12 @@ model="model"> - ID - Nickname + + #ID + + + Nickname + From bf386929d3de9678c9df6b38e4a9c2bdc6f9ae1e Mon Sep 17 00:00:00 2001 From: joan Date: Mon, 25 Oct 2021 17:18:57 +0200 Subject: [PATCH 06/43] Deletion ammends and selection fixed --- .../components/multi-check/multi-check.js | 2 +- front/core/components/smart-table/index.html | 20 ++++++++++-- front/core/components/smart-table/index.js | 30 ++++++++--------- .../core/components/smart-table/locale/es.yml | 5 +++ front/core/components/smart-table/style.scss | 32 +++++++++++++++---- modules/ticket/front/index/index.html | 27 +++++++++++++--- 6 files changed, 85 insertions(+), 31 deletions(-) create mode 100644 front/core/components/smart-table/locale/es.yml diff --git a/front/core/components/multi-check/multi-check.js b/front/core/components/multi-check/multi-check.js index d8fda6404..97b86f03d 100644 --- a/front/core/components/multi-check/multi-check.js +++ b/front/core/components/multi-check/multi-check.js @@ -156,7 +156,7 @@ ngModule.vnComponent('vnMultiCheck', { controller: MultiCheck, bindings: { model: '<', - checkField: '
-
+
@@ -23,7 +23,8 @@ vn-tooltip="Undo">
-
\ No newline at end of file + + + +
+ + + \ No newline at end of file diff --git a/front/core/components/smart-table/index.js b/front/core/components/smart-table/index.js index 2bf032195..81c8572e6 100644 --- a/front/core/components/smart-table/index.js +++ b/front/core/components/smart-table/index.js @@ -7,13 +7,9 @@ export default class SmartTable extends Component { super($element, $); this.$transclude = $transclude; this.sortCriteria = []; + this.autoSave = false; } - /* $onDestroy() { - if (this.$contentScope) - this.$contentScope.$destroy(); - } - */ get model() { return this._model; } @@ -26,12 +22,19 @@ export default class SmartTable extends Component { } } + get checkedRows() { + const model = this.model; + if (model && model.data) + return model.data.filter(row => row.$checked); + + return null; + } + registerColumns() { const header = this.element.querySelector('thead > tr'); if (!header) return; const columns = header.querySelectorAll('th'); - // TODO: Add arrow icon and so on.. // Click handler for (let column of columns) { const field = column.getAttribute('field'); @@ -96,17 +99,9 @@ export default class SmartTable extends Component { } deleteAll() { - const data = this.model.data; - const checkedRows = data.filter(row => row.checked); - - for (let row of checkedRows) { - if (row.id) - this.model.remove(row); - else { - const index = this.model.data.indexOf(row); - this.model.data.splice(index, 1); - } - } + const rowsChecked = this.checkedRows(); + for (let row of rowsChecked) + this.model.removeRow(row); if (this.autoSave) this.saveAll(); @@ -114,6 +109,7 @@ export default class SmartTable extends Component { saveAll() { const model = this.model; + if (!model.isChanged) return this.vnApp.showError(this.$t('No changes to save')); diff --git a/front/core/components/smart-table/locale/es.yml b/front/core/components/smart-table/locale/es.yml new file mode 100644 index 000000000..1cf39daa1 --- /dev/null +++ b/front/core/components/smart-table/locale/es.yml @@ -0,0 +1,5 @@ +Remove selected rows: Eliminar líneas seleccionadas +Add new row: Añadir nueva fila +Undo: Deshacer +Save data: Guardar datos +Shown columns: Columnas visibles \ No newline at end of file diff --git a/front/core/components/smart-table/style.scss b/front/core/components/smart-table/style.scss index a9a5c4bb0..5d5244fcf 100644 --- a/front/core/components/smart-table/style.scss +++ b/front/core/components/smart-table/style.scss @@ -34,19 +34,17 @@ smart-table { } } - .actions-left { - display: flex; - justify-content: flex-start; + tr[vn-anchor] { + @extend %clickable; } - .actions { + .actions-left, + .actions-right { display: flex; - justify-content: flex-end; .button-group { display: flex; box-shadow: 0 2px 2px 0 rgba(0, 0, 0, .3); - margin-left: 10px; & > vn-button { box-shadow: 0 0 0 0 @@ -54,6 +52,28 @@ smart-table { } } + .actions-left { + justify-content: flex-start; + + slot-actions > vn-button, + & > vn-button, + .button-group { + margin-right: 10px + } + + slot-actions { + display: flex + } + } + + .actions-right { + justify-content: flex-end; + & > vn-button, + .button-group { + margin-left: 10px + } + } + vn-tbody a[ng-repeat].vn-tr:focus { background-color: $color-primary-light } diff --git a/modules/ticket/front/index/index.html b/modules/ticket/front/index/index.html index 017a25a6c..25f437011 100644 --- a/modules/ticket/front/index/index.html +++ b/modules/ticket/front/index/index.html @@ -11,7 +11,21 @@ - Mas iconos.. + + + +
+ + + + +
@@ -19,7 +33,8 @@ + ng-class="{'new-row': ticket.$isNew, 'changed-row': ticket.$oldData}" + vn-anchor="::{ + state: 'ticket.card.summary', + params: {id: ticket.id} + }"> From e4fe125627dad78df857febcd81a2b50302c5156 Mon Sep 17 00:00:00 2001 From: carlosjr Date: Tue, 26 Oct 2021 09:18:31 +0200 Subject: [PATCH 07/43] deleteAll uses checkedRows getter now --- front/core/components/smart-table/index.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/front/core/components/smart-table/index.js b/front/core/components/smart-table/index.js index 81c8572e6..fa40443dc 100644 --- a/front/core/components/smart-table/index.js +++ b/front/core/components/smart-table/index.js @@ -60,20 +60,23 @@ export default class SmartTable extends Component { return criteria.field == field; }); + const isASC = existingCriteria && existingCriteria.sortType == 'ASC'; + const isDESC = existingCriteria && existingCriteria.sortType == 'DESC'; + if (!existingCriteria) { this.sortCriteria.push({field: field, sortType: 'ASC'}); element.classList.remove('desc'); element.classList.add('asc'); } - if (existingCriteria && existingCriteria.sortType == 'DESC') { + if (isDESC) { this.sortCriteria.splice(this.sortCriteria.findIndex(criteria => { return criteria.field == field; }), 1); element.classList.remove('desc'); element.classList.remove('asc'); } - if (existingCriteria && existingCriteria.sortType == 'ASC') { + if (isASC) { existingCriteria.sortType = 'DESC'; element.classList.remove('asc'); element.classList.add('desc'); @@ -99,8 +102,8 @@ export default class SmartTable extends Component { } deleteAll() { - const rowsChecked = this.checkedRows(); - for (let row of rowsChecked) + const checkedRows = this.checkedRows; + for (let row of checkedRows) this.model.removeRow(row); if (this.autoSave) From c976f1ed07a04375da58dc30bf5c822b23c3a59a Mon Sep 17 00:00:00 2001 From: carlosjr Date: Tue, 26 Oct 2021 17:16:01 +0200 Subject: [PATCH 08/43] multiple search by column feature --- front/core/components/smart-table/index.js | 115 ++++++++++++++++++++- modules/ticket/front/index/index.html | 11 +- modules/ticket/front/index/index.js | 45 ++++---- modules/ticket/front/index/style.scss | 12 +-- 4 files changed, 154 insertions(+), 29 deletions(-) diff --git a/front/core/components/smart-table/index.js b/front/core/components/smart-table/index.js index fa40443dc..628f25e47 100644 --- a/front/core/components/smart-table/index.js +++ b/front/core/components/smart-table/index.js @@ -1,5 +1,6 @@ import ngModule from '../../module'; import Component from '../../lib/component'; +import {buildFilter} from 'vn-loopback/util/filter'; import './style.scss'; export default class SmartTable extends Component { @@ -76,6 +77,7 @@ export default class SmartTable extends Component { element.classList.remove('desc'); element.classList.remove('asc'); } + if (isASC) { existingCriteria.sortType = 'DESC'; element.classList.remove('asc'); @@ -85,6 +87,65 @@ export default class SmartTable extends Component { this.applySort(); } + displaySearch() { + const header = this.element.querySelector('thead > tr'); + if (!header) return; + + const tbody = this.element.querySelector('tbody'); + const columns = header.querySelectorAll('th'); + + const hasSearchRow = tbody.querySelector('tr#searchRow'); + if (hasSearchRow) return hasSearchRow.remove(); + + const searchRow = document.createElement('tr'); + searchRow.setAttribute('id', 'searchRow'); + for (let column of columns) { + const field = column.getAttribute('field'); + const cell = document.createElement('td'); + if (field) { + const input = this.$compile(` + `)(this.$); + cell.appendChild(input[0]); + } + searchRow.appendChild(cell); + } + + tbody.prepend(searchRow); + } + + searchByColumn($event, scope, field) { + if ($event.key != 'Enter') return; + + const searchCriteria = scope.searchProps[field]; + const emptySearch = searchCriteria == '' || null; + + const filters = this.filterSanitizer(field); + + if (filters && filters.userFilter) + this.model.userFilter = filters.userFilter; + + if (!emptySearch) + this.addFilter(field, scope.searchProps[field]); + else this.model.refresh(); + } + + addFilter(field, value) { + let where = {[field]: value}; + + if (this.exprBuilder) { + where = buildFilter(where, (param, value) => + this.exprBuilder({param, value}) + ); + } + + this.model.addFilter({where}); + } + applySort() { let order = this.sortCriteria.map(criteria => `${criteria.field} ${criteria.sortType}`); order = order.join(', '); @@ -95,6 +156,54 @@ export default class SmartTable extends Component { this.model.refresh(); } + filterSanitizer(field) { + // tenemos que eliminar ands vacios al ir borrando filtros + const userFilter = this.model.userFilter; + const userParams = this.model.userParams; + const where = userFilter && userFilter.where; + + if (this.exprBuilder) { + const param = this.exprBuilder({ + param: field, + value: null + }); + if (param) [field] = Object.keys(param); + } + + if (!where) return; + + const whereKeys = Object.keys(where); + for (let key of whereKeys) { + removeProp(where, field, key); + + if (!Object.keys(where)) + delete userFilter.where; + } + + function removeProp(instance, findProp, prop) { + if (prop == findProp) + delete instance[prop]; + + if (prop === 'and') { + for (let [index, param] of instance[prop].entries()) { + const [key] = Object.keys(param); + if (key == findProp) + instance[prop].splice(index, 1); + + if (param[key] instanceof Array) + removeProp(param, field, key); + } + } + } + + return {userFilter, userParams}; + } + + removeFilter(field) { + // + this.model.applyFilter(userFilter, userParams); + } + createRow() { this.model.insert({ nickname: 'New row' @@ -102,8 +211,7 @@ export default class SmartTable extends Component { } deleteAll() { - const checkedRows = this.checkedRows; - for (let row of checkedRows) + for (let row of this.checkedRows) this.model.removeRow(row); if (this.autoSave) @@ -136,6 +244,7 @@ ngModule.vnComponent('smartTable', { }, bindings: { model: ' - + Nickname + @@ -60,7 +67,7 @@ - +
+ model="model" + check-field="$checked"> @@ -32,10 +47,14 @@
+ Pepinillos +
{{::ticket.id}} {{::ticket.nickname}}
diff --git a/modules/ticket/front/index/index.js b/modules/ticket/front/index/index.js index 2df4de0a5..59d297b3c 100644 --- a/modules/ticket/front/index/index.js +++ b/modules/ticket/front/index/index.js @@ -130,28 +130,37 @@ export default class Controller extends Section { exprBuilder(param, value) { switch (param) { - case 'stateFk': - return {'ts.stateFk': value}; - case 'salesPersonFk': - return {'c.salesPersonFk': value}; - case 'provinceFk': - return {'a.provinceFk': value}; - case 'hour': - return {'z.hour': value}; - case 'shipped': - return {'t.shipped': { - between: this.dateRange(value)} - }; - case 'id': - case 'refFk': - case 'zoneFk': case 'nickname': - case 'agencyModeFk': - case 'warehouseFk': - return {[`t.${param}`]: value}; + return {'nickname': {like: `%${value}%`}}; + case 'id': + return {[param]: value}; } } + // exprBuilder(param, value) { + // switch (param) { + // case 'stateFk': + // return {'ts.stateFk': value}; + // case 'salesPersonFk': + // return {'c.salesPersonFk': value}; + // case 'provinceFk': + // return {'a.provinceFk': value}; + // case 'hour': + // return {'z.hour': value}; + // case 'shipped': + // return {'t.shipped': { + // between: this.dateRange(value)} + // }; + // case 'id': + // case 'refFk': + // case 'zoneFk': + // case 'nickname': + // case 'agencyModeFk': + // case 'warehouseFk': + // return {[`t.${param}`]: value}; + // } + // } + dateRange(value) { const minHour = new Date(value); minHour.setHours(0, 0, 0, 0); diff --git a/modules/ticket/front/index/style.scss b/modules/ticket/front/index/style.scss index 23c4b88b8..36409ab67 100644 --- a/modules/ticket/front/index/style.scss +++ b/modules/ticket/front/index/style.scss @@ -7,19 +7,19 @@ vn-ticket-index { } } - vn-th.icon-field, - vn-th.icon-field *, - vn-td.icon-field, - vn-td.icon-field * { + th.icon-field, + th.icon-field *, + td.icon-field, + td.icon-field * { padding: 0 } - vn-td.icon-field > vn-icon { + td.icon-field > vn-icon { margin-left: 3px; margin-right: 3px; } - vn-tbody a[ng-repeat].vn-tr:focus { + tbody a[ng-repeat].vn-tr:focus { background-color: $color-primary-light } } \ No newline at end of file From b27a44372941265ee95e8cb17b6a90b5caaf3a7a Mon Sep 17 00:00:00 2001 From: carlosjr Date: Wed, 27 Oct 2021 17:11:33 +0200 Subject: [PATCH 09/43] show/hide columns and load default view --- back/methods/user-config-view/save.js | 5 +- back/model-config.json | 3 + back/models/default-view-config.json | 25 ++++ .../10380-allsaints/00-defaultViewConfig.sql | 6 + front/core/components/smart-table/index.html | 32 ++++- front/core/components/smart-table/index.js | 117 ++++++++++++++++-- front/salix/components/log/index.html | 10 +- modules/ticket/front/index/index.html | 3 +- modules/ticket/front/index/index.js | 6 + 9 files changed, 188 insertions(+), 19 deletions(-) create mode 100644 back/models/default-view-config.json create mode 100644 db/changes/10380-allsaints/00-defaultViewConfig.sql 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..6f66bd6eb --- /dev/null +++ b/db/changes/10380-allsaints/00-defaultViewConfig.sql @@ -0,0 +1,6 @@ +CREATE TABLE `salix`.`defaultViewConfig` +( + tableCode VARCHAR(25) not null, + columns JSON not null +) +comment 'The default configuration of columns for views'; \ No newline at end of file diff --git a/front/core/components/smart-table/index.html b/front/core/components/smart-table/index.html index 2a7a45b18..68c29dcb5 100644 --- a/front/core/components/smart-table/index.html +++ b/front/core/components/smart-table/index.html @@ -2,10 +2,9 @@
-
@@ -32,7 +31,6 @@ vn-tooltip="Save data">
-
- \ No newline at end of file + + + + + + +
+ + + + + + + + +
+
+
\ No newline at end of file diff --git a/front/core/components/smart-table/index.js b/front/core/components/smart-table/index.js index 628f25e47..353cbb050 100644 --- a/front/core/components/smart-table/index.js +++ b/front/core/components/smart-table/index.js @@ -2,12 +2,15 @@ import ngModule from '../../module'; import Component from '../../lib/component'; import {buildFilter} from 'vn-loopback/util/filter'; import './style.scss'; +import angular from 'angular'; export default class SmartTable extends Component { constructor($element, $, $transclude) { super($element, $); + this.currentUserId = window.localStorage.currentUserWorkerId; this.$transclude = $transclude; this.sortCriteria = []; + this.columns = []; this.autoSave = false; } @@ -23,6 +26,52 @@ export default class SmartTable extends Component { } } + get viewConfigId() { + return this._viewConfigId; + } + + set viewConfigId(value) { + this._viewConfigId = value; + + if (value) { + this.defaultViewConfig = {}; + + const url = 'DefaultViewConfigs'; + this.$http.get(url, {where: {tableCode: value}}) + .then(res => { + if (res && res.data.length) { + const columns = res.data[0].columns; + this.defaultViewConfig = columns; + } + }); + } + } + + get viewConfig() { + return this._viewConfig; + } + + set viewConfig(value) { + this._viewConfig = value; + + if (!value) return; + + if (!value.length) { + const userViewModel = this.$.userViewModel; + + for (const column of this.columns) { + if (this.defaultViewConfig[column.field] == undefined) + this.defaultViewConfig[column.field] = true; + } + userViewModel.insert({ + userFk: this.currentUserId, + tableConfig: this.viewConfigId, + configuration: this.defaultViewConfig ? this.defaultViewConfig : {} + }); + } + this.applyViewConfig(); + } + get checkedRows() { const model = this.model; if (model && model.data) @@ -31,16 +80,63 @@ export default class SmartTable extends Component { return null; } + saveViewConfig() { + const userViewModel = this.$.userViewModel; + const [viewConfig] = userViewModel.data; + viewConfig.configuration = Object.assign({}, viewConfig.configuration); + userViewModel.save() + .then(() => this.vnApp.showSuccess(this.$t('Data saved!'))) + .then(() => this.applyViewConfig()); + } + + applyViewConfig() { + const userViewModel = this.$.userViewModel; + const [viewConfig] = userViewModel.data; + + const selectors = []; + for (const column of this.columns) { + if (viewConfig.configuration[column.field] == false) { + const baseSelector = `smart-table[view-config-id="${this.viewConfigId}"] table`; + selectors.push(`${baseSelector} thead > tr > th:nth-child(${column.index + 1})`); + selectors.push(`${baseSelector} tbody > tr > td:nth-child(${column.index + 1})`); + } + } + + const styleElement = document.querySelector('style[id="smart-table"]'); + + if (styleElement) + styleElement.parentNode.removeChild(styleElement); + + if (selectors.length) { + const rule = selectors.join(', ') + '{display: none}'; + this.$.css = document.createElement('style'); + this.$.css.setAttribute('id', 'smart-table'); + document.head.appendChild(this.$.css); + this.$.css.appendChild(document.createTextNode(rule)); + } + + this.$.$on('$destroy', () => { + if (this.$.css && styleElement) + styleElement.parentNode.removeChild(styleElement); + }); + } + registerColumns() { const header = this.element.querySelector('thead > tr'); if (!header) return; const columns = header.querySelectorAll('th'); // Click handler - for (let column of columns) { + for (const [index, column] of columns.entries()) { const field = column.getAttribute('field'); - if (field) + if (field) { + const columnElement = angular.element(column); + const caption = columnElement.text().trim(); + + this.columns.push({field, caption, index}); + column.addEventListener('click', () => this.orderHandler(column)); + } } } @@ -157,7 +253,6 @@ export default class SmartTable extends Component { } filterSanitizer(field) { - // tenemos que eliminar ands vacios al ir borrando filtros const userFilter = this.model.userFilter; const userParams = this.model.userParams; const where = userFilter && userFilter.where; @@ -199,15 +294,17 @@ export default class SmartTable extends Component { return {userFilter, userParams}; } - removeFilter(field) { - // + removeFilter() { this.model.applyFilter(userFilter, userParams); } createRow() { - this.model.insert({ - nickname: 'New row' - }); + let data = {}; + + if (this.defaultNewData) + data = this.defaultNewData(); + + this.model.insert(data); } deleteAll() { @@ -244,7 +341,9 @@ ngModule.vnComponent('smartTable', { }, bindings: { model: ' + diff --git a/modules/ticket/front/index/index.html b/modules/ticket/front/index/index.html index f5e3e1591..dc0f49369 100644 --- a/modules/ticket/front/index/index.html +++ b/modules/ticket/front/index/index.html @@ -11,9 +11,10 @@ + default-new-data="$ctrl.defaultNewData()"> Date: Thu, 28 Oct 2021 09:06:03 +0200 Subject: [PATCH 10/43] Restored ticket table and added table compatibility on contextmenu --- front/core/components/contextmenu/index.js | 12 +- modules/ticket/front/index/index.html | 180 +++++++++++++++++++-- modules/ticket/front/index/index.js | 45 +++--- 3 files changed, 194 insertions(+), 43 deletions(-) diff --git a/front/core/components/contextmenu/index.js b/front/core/components/contextmenu/index.js index 646df1a0a..76a25e701 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; } diff --git a/modules/ticket/front/index/index.html b/modules/ticket/front/index/index.html index dc0f49369..e0062fc1f 100644 --- a/modules/ticket/front/index/index.html +++ b/modules/ticket/front/index/index.html @@ -1,12 +1,12 @@ - - + + #ID - - Nickname + + Salesperson + + + Date - Pepinillos + Hour + + Closure + + + Alias + + + Province + + + State + + + Zone + + + Warehouse + + + Total + + @@ -66,9 +92,113 @@ vn-click-stop> - {{::ticket.id}} - {{::ticket.nickname}} - + + + + + + + + + + + + + + + {{::ticket.id}} + + + {{::ticket.userName | dashIfEmpty}} + + + + + {{::ticket.shipped | date: 'dd/MM/yyyy'}} + + + {{::ticket.shipped | date: 'HH:mm'}} + {{::ticket.zoneLanding | date: 'HH:mm'}} + + + {{::ticket.nickname}} + + + {{::ticket.province}} + + + {{::ticket.refFk}} + + + {{ticket.state}} + + + + + {{::ticket.zoneName | dashIfEmpty}} + + + {{::ticket.warehouse}} + + + {{::(ticket.totalWithVat ? ticket.totalWithVat : 0) | currency: 'EUR': 2}} + + + + + + + + @@ -131,6 +261,36 @@ vn-id="invoiceOutDescriptor"> + + + + Filter by selection + + + Exclude selection + + + Remove filter + + + Remove all filters + + + Copy value + + + + Date: Thu, 28 Oct 2021 09:09:52 +0200 Subject: [PATCH 11/43] Updated checked property --- modules/ticket/front/index/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/front/index/index.js b/modules/ticket/front/index/index.js index dd16d4bff..329d9785b 100644 --- a/modules/ticket/front/index/index.js +++ b/modules/ticket/front/index/index.js @@ -64,7 +64,7 @@ export default class Controller extends Section { const tickets = this.$.model.data || []; const checkedLines = []; for (let ticket of tickets) { - if (ticket.checked) + if (ticket.$checked) checkedLines.push(ticket); } From 5beeab36b10ddb17893e0f7da6ce595dcee54634 Mon Sep 17 00:00:00 2001 From: joan Date: Thu, 28 Oct 2021 09:25:46 +0200 Subject: [PATCH 12/43] Changed shown fields form to two columns --- front/core/components/smart-table/index.html | 9 +++++---- front/core/components/smart-table/style.scss | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/front/core/components/smart-table/index.html b/front/core/components/smart-table/index.html index 68c29dcb5..263d2a658 100644 --- a/front/core/components/smart-table/index.html +++ b/front/core/components/smart-table/index.html @@ -67,11 +67,12 @@ data="$ctrl.viewConfig" auto-load="true"> - + -
- - +
Check the columns you want to see
+ + diff --git a/front/core/components/smart-table/style.scss b/front/core/components/smart-table/style.scss index 5d5244fcf..0207ce080 100644 --- a/front/core/components/smart-table/style.scss +++ b/front/core/components/smart-table/style.scss @@ -86,3 +86,19 @@ smart-table { background-color: $color-primary-light } } + +.smart-table-columns { + h6 { + color: $color-font-secondary + } + + & > vn-horizontal { + align-items: flex-start; + flex-wrap: wrap; + } + + vn-check { + flex: initial; + width: 50% + } +} \ No newline at end of file From a1970c6fc8881be2f37afd4df7f40d0700023f70 Mon Sep 17 00:00:00 2001 From: carlosjr Date: Thu, 28 Oct 2021 15:22:26 +0200 Subject: [PATCH 13/43] translation for hide show columns --- front/core/components/smart-table/index.html | 2 +- front/core/components/smart-table/locale/es.yml | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/front/core/components/smart-table/index.html b/front/core/components/smart-table/index.html index 263d2a658..90d5d4dd3 100644 --- a/front/core/components/smart-table/index.html +++ b/front/core/components/smart-table/index.html @@ -70,7 +70,7 @@
-
Check the columns you want to see
+
Check the columns you want to see
Date: Fri, 29 Oct 2021 15:52:04 +0200 Subject: [PATCH 14/43] autocomplete options added to smart table --- front/core/components/smart-table/index.html | 1 + front/core/components/smart-table/index.js | 44 ++++++++++++++++---- modules/ticket/front/index/index.html | 2 +- modules/ticket/front/index/index.js | 38 +++++++++++++++++ 4 files changed, 77 insertions(+), 8 deletions(-) diff --git a/front/core/components/smart-table/index.html b/front/core/components/smart-table/index.html index 90d5d4dd3..291bff613 100644 --- a/front/core/components/smart-table/index.html +++ b/front/core/components/smart-table/index.html @@ -2,6 +2,7 @@
diff --git a/front/core/components/smart-table/index.js b/front/core/components/smart-table/index.js index 353cbb050..0498bc2e9 100644 --- a/front/core/components/smart-table/index.js +++ b/front/core/components/smart-table/index.js @@ -3,6 +3,7 @@ import Component from '../../lib/component'; import {buildFilter} from 'vn-loopback/util/filter'; import './style.scss'; import angular from 'angular'; +import {camelToKebab} from '../../lib/string'; export default class SmartTable extends Component { constructor($element, $, $transclude) { @@ -199,13 +200,37 @@ export default class SmartTable extends Component { const field = column.getAttribute('field'); const cell = document.createElement('td'); if (field) { - const input = this.$compile(` - column.field == field); + + if (options && options.autocomplete) { + let props = ``; + + const autocomplete = options.autocomplete; + for (const prop in autocomplete) + props += `${camelToKebab(prop)}="${autocomplete[prop]}"\n`; + + input = this.$compile(` + `)(this.$); + } else { + input = this.$compile(` + `)(this.$); + } cell.appendChild(input[0]); } searchRow.appendChild(cell); @@ -214,10 +239,14 @@ export default class SmartTable extends Component { tbody.prepend(searchRow); } - searchByColumn($event, scope, field) { + searchWithEvent($event, field) { if ($event.key != 'Enter') return; - const searchCriteria = scope.searchProps[field]; + this.searchByColumn(field); + } + + searchByColumn(field) { + const searchCriteria = this.$.searchProps[field]; const emptySearch = searchCriteria == '' || null; const filters = this.filterSanitizer(field); @@ -226,7 +255,7 @@ export default class SmartTable extends Component { this.model.userFilter = filters.userFilter; if (!emptySearch) - this.addFilter(field, scope.searchProps[field]); + this.addFilter(field, this.$.searchProps[field]); else this.model.refresh(); } @@ -344,6 +373,7 @@ ngModule.vnComponent('smartTable', { viewConfigId: '@?', autoSave: ' @@ -20,7 +21,6 @@ ng-click="$ctrl.test()" vn-tooltip="Info"> -
Date: Fri, 29 Oct 2021 16:55:19 +0200 Subject: [PATCH 15/43] vn table now receives show buttons options --- front/core/components/smart-table/index.html | 23 +++++++++----------- front/core/components/smart-table/index.js | 14 ++++++++++++ modules/ticket/front/index/index.html | 23 -------------------- modules/ticket/front/index/index.js | 5 +++++ 4 files changed, 29 insertions(+), 36 deletions(-) diff --git a/front/core/components/smart-table/index.html b/front/core/components/smart-table/index.html index 291bff613..e4b1df1ec 100644 --- a/front/core/components/smart-table/index.html +++ b/front/core/components/smart-table/index.html @@ -2,7 +2,7 @@
@@ -10,10 +10,12 @@
-
+
@@ -32,16 +34,10 @@ vn-tooltip="Save data">
-
- - - - -
+ +
@@ -61,7 +57,8 @@ message="Remove selected rows"> - - - - - - -
- - - - -
-
diff --git a/modules/ticket/front/index/index.js b/modules/ticket/front/index/index.js index cec47baeb..d076fec5a 100644 --- a/modules/ticket/front/index/index.js +++ b/modules/ticket/front/index/index.js @@ -8,6 +8,11 @@ export default class Controller extends Section { super($element, $); this.vnReport = vnReport; this.smartTableOptions = { + activeButtons: { + search: true, + crud: true, + shownColumns: true, + }, columns: [ { field: 'salesPersonFk', From fbf1c50f97323ff84a68a949ff109e096565f1f8 Mon Sep 17 00:00:00 2001 From: joan Date: Mon, 8 Nov 2021 14:13:28 +0100 Subject: [PATCH 16/43] Added total rows and a message for no results --- front/core/components/smart-table/index.html | 9 +++- front/core/components/smart-table/index.js | 42 +++++++++++++------ .../core/components/smart-table/locale/es.yml | 4 +- front/core/components/smart-table/style.scss | 5 +++ 4 files changed, 46 insertions(+), 14 deletions(-) diff --git a/front/core/components/smart-table/index.html b/front/core/components/smart-table/index.html index e4b1df1ec..a4c26459f 100644 --- a/front/core/components/smart-table/index.html +++ b/front/core/components/smart-table/index.html @@ -1,5 +1,5 @@
- +
+
+ < + Showing + {{model.data.length}} + rows + > +
{ + const table = $clone[0]; + slotTable.appendChild(table); + this.registerColumns(); + + const header = this.element.querySelector('thead > tr'); + const columns = header.querySelectorAll('th'); + const tbody = this.element.querySelector('tbody'); + if (tbody) { + const noSearch = this.$compile(` +
+ + + `)($scope); + tbody.appendChild(noSearch[0]); + + const noRows = this.$compile(` + + + + `)($scope); + tbody.appendChild(noRows[0]); + } + }, null, 'table'); + } + saveViewConfig() { const userViewModel = this.$.userViewModel; const [viewConfig] = userViewModel.data; @@ -155,17 +184,6 @@ export default class SmartTable extends Component { } } - // Creo que se puede hacer directamente desde ng-transclude - transclude() { - const slotTable = this.element.querySelector('#table'); - this.$transclude(($clone, $scope) => { - const table = $clone[0]; - $scope.hasChanges = this.hasChanges; - slotTable.appendChild(table); - this.registerColumns(); - }, null, 'table'); - } - orderHandler(element) { const field = element.getAttribute('field'); const existingCriteria = this.sortCriteria.find(criteria => { diff --git a/front/core/components/smart-table/locale/es.yml b/front/core/components/smart-table/locale/es.yml index a681d8be5..b5cc554ee 100644 --- a/front/core/components/smart-table/locale/es.yml +++ b/front/core/components/smart-table/locale/es.yml @@ -3,4 +3,6 @@ Add new row: Añadir nueva fila Undo: Deshacer Save data: Guardar datos Shown columns: Columnas visibles -Check the columns you want to see: Marca las columnas que quieres ver \ No newline at end of file +Check the columns you want to see: Marca las columnas que quieres ver +Showing: Mostrando +rows: filas \ No newline at end of file diff --git a/front/core/components/smart-table/style.scss b/front/core/components/smart-table/style.scss index 0207ce080..b1e93486e 100644 --- a/front/core/components/smart-table/style.scss +++ b/front/core/components/smart-table/style.scss @@ -38,9 +38,14 @@ smart-table { @extend %clickable; } + .totalRows { + color: $color-font-secondary; + } + .actions-left, .actions-right { display: flex; + align-items: center; .button-group { display: flex; From eb36f86b9d27df391347688d4c50d0955986083d Mon Sep 17 00:00:00 2001 From: joan Date: Mon, 8 Nov 2021 14:46:23 +0100 Subject: [PATCH 17/43] Added smart-table to item index --- modules/item/front/index/index.html | 253 ++++++++++++++++------------ modules/item/front/index/index.js | 23 ++- modules/item/front/index/style.scss | 2 +- 3 files changed, 166 insertions(+), 112 deletions(-) diff --git a/modules/item/front/index/index.html b/modules/item/front/index/index.html index 023295042..9fa03eabb 100644 --- a/modules/item/front/index/index.html +++ b/modules/item/front/index/index.html @@ -1,115 +1,148 @@ - - - - - - - Id - Grouping - Packing - Description - Stems - Size - Type - Category - Intrastat - Origin - Buyer - Density - Multiplier - Active - Landed - - - - - - - - - - - {{::item.id}} - - - {{::item.grouping | dashIfEmpty}} - {{::item.packing | dashIfEmpty}} - -
- {{::item.name}} - -

{{::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'}} - - - - - - - - -
-
-
-
-
+ + + +
Enter a new search
No data
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Id + + Grouping + + Packing + + Description + + Stems + + Size + + Type + + Category + + Intrastat + + Origin + + Buyer + + Density + + Multiplier + + Active + + Landed +
+ + + + {{::item.id}} + + {{::item.grouping | dashIfEmpty}}{{::item.packing | dashIfEmpty}} +
+ {{::item.name}} + +

{{::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'}} + + + + + + +
+
+
+
@@ -133,7 +166,7 @@ diff --git a/modules/item/front/index/index.js b/modules/item/front/index/index.js index 3235d684e..86e67f919 100644 --- a/modules/item/front/index/index.js +++ b/modules/item/front/index/index.js @@ -5,9 +5,30 @@ import './style.scss'; class Controller extends Section { constructor($element, $) { super($element, $); - this.showFields = { + /* this.showFields = { id: false, actions: false + }; */ + + this.smartTableOptions = { + activeButtons: { + search: true, + shownColumns: true, + }, + columns: [ + { + field: 'category', + autocomplete: { + url: 'ItemCategories', + } + }, + { + field: 'origin', + autocomplete: { + url: 'Origins', + } + }, + ] }; } diff --git a/modules/item/front/index/style.scss b/modules/item/front/index/style.scss index b0b94c19d..eaa1a16ed 100644 --- a/modules/item/front/index/style.scss +++ b/modules/item/front/index/style.scss @@ -23,7 +23,7 @@ vn-item-product { } } -vn-table { +table { img { border-radius: 50%; width: 50px; From 262e46d7c9e9d77927c3ec08948cdbac77a80ad2 Mon Sep 17 00:00:00 2001 From: carlosjr Date: Mon, 8 Nov 2021 17:46:40 +0100 Subject: [PATCH 18/43] added autocompletes to item index --- front/core/components/smart-table/index.html | 2 +- .../core/components/smart-table/locale/es.yml | 2 +- modules/item/back/methods/item/filter.js | 2 +- modules/item/back/models/intrastat.json | 4 +-- modules/item/back/models/origin.json | 6 ++-- modules/item/front/index/index.html | 2 +- modules/item/front/index/index.js | 33 ++++++++++++++++--- modules/item/front/search-panel/index.html | 2 +- 8 files changed, 38 insertions(+), 15 deletions(-) diff --git a/front/core/components/smart-table/index.html b/front/core/components/smart-table/index.html index a4c26459f..9cfcf7849 100644 --- a/front/core/components/smart-table/index.html +++ b/front/core/components/smart-table/index.html @@ -11,7 +11,7 @@ < Showing {{model.data.length}} - rows + results >
diff --git a/front/core/components/smart-table/locale/es.yml b/front/core/components/smart-table/locale/es.yml index b5cc554ee..f65df07b7 100644 --- a/front/core/components/smart-table/locale/es.yml +++ b/front/core/components/smart-table/locale/es.yml @@ -5,4 +5,4 @@ Save data: Guardar datos Shown columns: Columnas visibles Check the columns you want to see: Marca las columnas que quieres ver Showing: Mostrando -rows: filas \ No newline at end of file +results: resultados \ No newline at end of file diff --git a/modules/item/back/methods/item/filter.js b/modules/item/back/methods/item/filter.js index cff36a223..8cfefac9f 100644 --- a/modules/item/back/methods/item/filter.js +++ b/modules/item/back/methods/item/filter.js @@ -113,7 +113,7 @@ module.exports = Self => { return {'i.typeFk': value}; case 'categoryFk': return {'ic.id': value}; - case 'salesPersonFk': + case 'buyerFk': return {'it.workerFk': value}; case 'origin': return {'ori.code': value}; diff --git a/modules/item/back/models/intrastat.json b/modules/item/back/models/intrastat.json index e536e2581..18a964e7b 100644 --- a/modules/item/back/models/intrastat.json +++ b/modules/item/back/models/intrastat.json @@ -8,12 +8,12 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, "description": { - "type": "String" + "type": "string" } }, "relations": { diff --git a/modules/item/back/models/origin.json b/modules/item/back/models/origin.json index c381600bf..d2fe3fdf0 100644 --- a/modules/item/back/models/origin.json +++ b/modules/item/back/models/origin.json @@ -8,15 +8,15 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, "code": { - "type": "String" + "type": "string" }, "name": { - "type": "String" + "type": "string" } }, "acls": [ diff --git a/modules/item/front/index/index.html b/modules/item/front/index/index.html index 9fa03eabb..6fa3ae8c2 100644 --- a/modules/item/front/index/index.html +++ b/modules/item/front/index/index.html @@ -42,7 +42,7 @@ Origin - + Buyer diff --git a/modules/item/front/index/index.js b/modules/item/front/index/index.js index 86e67f919..3b2b71af8 100644 --- a/modules/item/front/index/index.js +++ b/modules/item/front/index/index.js @@ -5,10 +5,6 @@ import './style.scss'; class Controller extends Section { constructor($element, $) { super($element, $); - /* this.showFields = { - id: false, - actions: false - }; */ this.smartTableOptions = { activeButtons: { @@ -20,12 +16,39 @@ class Controller extends Section { field: 'category', autocomplete: { url: 'ItemCategories', + valueField: 'name', } }, { field: 'origin', autocomplete: { url: 'Origins', + showField: 'name', + valueField: 'code' + } + }, + { + field: 'typeFk', + autocomplete: { + url: 'ItemTypes', + } + }, + { + field: 'intrastat', + autocomplete: { + url: 'Intrastats', + showField: 'description', + valueField: 'description' + } + }, + { + field: 'buyerFk', + autocomplete: { + url: 'Workers/activeWithRole', + where: `{role: {inq: ['logistic', 'buyer']}}`, + searchFunction: '{firstName: $search}', + showField: 'nickname', + valueField: 'id', } }, ] @@ -36,7 +59,7 @@ class Controller extends Section { switch (param) { case 'category': return {'ic.name': value}; - case 'salesPersonFk': + case 'buyerFk': return {'it.workerFk': value}; case 'grouping': return {'b.grouping': value}; diff --git a/modules/item/front/search-panel/index.html b/modules/item/front/search-panel/index.html index 518062eba..94e4b6d07 100644 --- a/modules/item/front/search-panel/index.html +++ b/modules/item/front/search-panel/index.html @@ -41,7 +41,7 @@ Date: Tue, 9 Nov 2021 11:44:00 +0100 Subject: [PATCH 19/43] refactor(contextmenu): excludes now ensures negation --- front/core/components/contextmenu/index.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/front/core/components/contextmenu/index.js b/front/core/components/contextmenu/index.js index 76a25e701..9c1206865 100755 --- a/front/core/components/contextmenu/index.js +++ b/front/core/components/contextmenu/index.js @@ -172,9 +172,14 @@ 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 = buildFilter(where, (param, value) => { + const expr = this.exprBuilder({param, value}); + const props = Object.keys(expr); + const newExpr = {}; + for (let prop of props) + newExpr[prop] = {neq: this.fieldValue}; + return newExpr; + }); } this.model.addFilter({where}); From 469c544536d6b7ebea66e1227790a6622232c236 Mon Sep 17 00:00:00 2001 From: carlosjr Date: Tue, 9 Nov 2021 11:47:54 +0100 Subject: [PATCH 20/43] item.index default columns and filter with like --- .../10380-allsaints/00-defaultViewConfig.sql | 8 ++- front/core/components/smart-table/index.js | 8 ++- modules/item/front/index/index.html | 60 +++++++++---------- modules/item/front/index/index.js | 13 +++- 4 files changed, 54 insertions(+), 35 deletions(-) diff --git a/db/changes/10380-allsaints/00-defaultViewConfig.sql b/db/changes/10380-allsaints/00-defaultViewConfig.sql index 6f66bd6eb..2e1c55288 100644 --- a/db/changes/10380-allsaints/00-defaultViewConfig.sql +++ b/db/changes/10380-allsaints/00-defaultViewConfig.sql @@ -3,4 +3,10 @@ CREATE TABLE `salix`.`defaultViewConfig` tableCode VARCHAR(25) not null, columns JSON not null ) -comment 'The default configuration of columns for views'; \ No newline at end of file +comment 'The default configuration of columns for views'; + +INSERT INTO `salix`.`defaultViewConfig` (tableCode, columns) + VALUES ( + 'itemIndex', + '{"id":true,"grouping":true,"packing":true,"name":true,"stems":true,"size":true,"typeFk":true,"category":true,"intrastat":false,"origin":true,"buyerFk":true,"density":false,"stemMultiplier":false,"active":false,"landed":true}' + ); \ No newline at end of file diff --git a/front/core/components/smart-table/index.js b/front/core/components/smart-table/index.js index bfeab63ce..918bbca18 100644 --- a/front/core/components/smart-table/index.js +++ b/front/core/components/smart-table/index.js @@ -37,9 +37,8 @@ export default class SmartTable extends Component { set model(value) { this._model = value; - if (value) { + if (value) this.$.model = value; - } } get viewConfigId() { @@ -239,6 +238,11 @@ export default class SmartTable extends Component { if (columnOptions) options = columnOptions.find(column => column.field == field); + if (options && options.searchable == false) { + searchRow.appendChild(cell); + continue; + } + if (options && options.autocomplete) { let props = ``; diff --git a/modules/item/front/index/index.html b/modules/item/front/index/index.html index 6fa3ae8c2..75de5733c 100644 --- a/modules/item/front/index/index.html +++ b/modules/item/front/index/index.html @@ -12,49 +12,49 @@ - - Id + + Identifier - + Grouping - + Packing Description - + Stems - + Size - + Type - + Category - + Intrastat - + Origin - + Buyer - + Density - + Multiplier - + Active - + Landed @@ -66,22 +66,22 @@ state: 'item.card.summary', params: {id: item.id} }"> - + - + {{::item.id}} - {{::item.grouping | dashIfEmpty}} - {{::item.packing | dashIfEmpty}} + {{::item.grouping | dashIfEmpty}} + {{::item.packing | dashIfEmpty}}
{{::item.name}} @@ -95,35 +95,35 @@ tabindex="-1"> - {{::item.stems}} - {{::item.size}} - + {{::item.stems}} + {{::item.size}} + {{::item.typeName}} - + {{::item.category}} - + {{::item.intrastat}} - {{::item.origin}} - + {{::item.origin}} + {{::item.userName}} - {{::item.density}} - {{::item.stemMultiplier}} - + {{::item.density}} + {{::item.stemMultiplier}} + {{::item.landed | date:'dd/MM/yyyy'}} - + Date: Wed, 10 Nov 2021 17:07:16 +0100 Subject: [PATCH 21/43] refactor(entry.lastBuys): usage of smart table on latests buys --- .../10380-allsaints/00-defaultViewConfig.sql | 9 +- front/core/components/smart-table/index.js | 8 +- front/core/components/smart-table/style.scss | 4 + front/core/components/smart-table/table.scss | 102 ++++++ modules/entry/front/latest-buys/index.html | 334 ++++++++++-------- modules/entry/front/latest-buys/index.js | 99 +++++- modules/item/back/model-config.json | 3 + modules/item/back/models/item-category.json | 8 +- modules/item/back/models/item-family.json | 27 ++ modules/item/back/models/item-type.json | 10 +- modules/item/front/index/index.html | 2 +- modules/ticket/back/models/packaging.json | 16 +- 12 files changed, 454 insertions(+), 168 deletions(-) create mode 100644 front/core/components/smart-table/table.scss create mode 100644 modules/item/back/models/item-family.json diff --git a/db/changes/10380-allsaints/00-defaultViewConfig.sql b/db/changes/10380-allsaints/00-defaultViewConfig.sql index 2e1c55288..f7e29f45f 100644 --- a/db/changes/10380-allsaints/00-defaultViewConfig.sql +++ b/db/changes/10380-allsaints/00-defaultViewConfig.sql @@ -6,7 +6,8 @@ CREATE TABLE `salix`.`defaultViewConfig` comment 'The default configuration of columns for views'; INSERT INTO `salix`.`defaultViewConfig` (tableCode, columns) - VALUES ( - 'itemIndex', - '{"id":true,"grouping":true,"packing":true,"name":true,"stems":true,"size":true,"typeFk":true,"category":true,"intrastat":false,"origin":true,"buyerFk":true,"density":false,"stemMultiplier":false,"active":false,"landed":true}' - ); \ No newline at end of file + VALUES + ('itemIndex', '{"intrastat":false,"density":false,"stemMultiplier":false,"active":false}'), + ('latestBuys', '{"intrastat":false,"description":false,"density":false,"isActive":false,"freightValue":false,"packageValue":false,"isIgnored":false,"price2":false,"minPrice":false,"ektFk":false,"weight":false,"packageFk":false,"packingOut":false}'); + + \ No newline at end of file diff --git a/front/core/components/smart-table/index.js b/front/core/components/smart-table/index.js index 918bbca18..f8a35d491 100644 --- a/front/core/components/smart-table/index.js +++ b/front/core/components/smart-table/index.js @@ -1,9 +1,10 @@ import ngModule from '../../module'; import Component from '../../lib/component'; import {buildFilter} from 'vn-loopback/util/filter'; -import './style.scss'; import angular from 'angular'; import {camelToKebab} from '../../lib/string'; +import './style.scss'; +import './table.scss'; export default class SmartTable extends Component { constructor($element, $, $transclude) { @@ -52,7 +53,8 @@ export default class SmartTable extends Component { this.defaultViewConfig = {}; const url = 'DefaultViewConfigs'; - this.$http.get(url, {where: {tableCode: value}}) + const filter = {where: {tableCode: value}}; + this.$http.get(url, {filter}) .then(res => { if (res && res.data.length) { const columns = res.data[0].columns; @@ -252,6 +254,7 @@ export default class SmartTable extends Component { input = this.$compile(` thead { + border-bottom: 2px solid $color-spacer; + + & > * > th { + font-weight: normal; + } + } + & > tfoot { + border-top: 2px solid $color-spacer; + } + thead, tbody, tfoot { + & > * { + & > th { + color: $color-font-light; + } + & > th, + & > td { + overflow: hidden; + } + & > th, + & > td { + text-align: left; + padding: 9px 8px; + white-space: nowrap; + text-overflow: ellipsis; + + &[number] { + text-align: right; + width: 96px; + } + &[center] { + text-align: center; + } + &[shrink] { + width: 1px; + text-align: center; + } + &[shrink-date] { + width: 100px; + max-width: 100px; + } + &[shrink-datetime] { + width: 150px; + max-width: 150px; + } + &[expand] { + max-width: 400px; + min-width: 0; + } + vn-icon.bright, i.bright { + color: #f7931e; + } + } + } + } + tbody > * { + border-bottom: 1px solid $color-spacer-light; + + &:last-child { + border-bottom: none; + } + & > td { + .chip { + padding: 4px; + border-radius: 4px; + color: $color-font-bg; + + &.notice { + background-color: $color-notice-medium + } + &.success { + background-color: $color-success-medium; + } + &.warning { + background-color: $color-main-medium; + } + &.alert { + background-color: $color-alert-medium; + } + &.message { + color: $color-font-dark; + background-color: $color-bg-dark + } + } + } + } + .vn-check { + margin: 0; + } + .empty-rows { + color: $color-font-secondary; + font-size: 1.375rem; + text-align: center; + } +} \ No newline at end of file diff --git a/modules/entry/front/latest-buys/index.html b/modules/entry/front/latest-buys/index.html index 9281c1b79..ce1dcbaa0 100644 --- a/modules/entry/front/latest-buys/index.html +++ b/modules/entry/front/latest-buys/index.html @@ -16,146 +16,202 @@ auto-state="false"> - - - + - - - - - - - Picture - Id - Packing - Grouping - Quantity - Description - Size - Tags - Type - Intrastat - Origin - Density - Active - Family - Entry - Buying value - Freight value - Commission value - Package value - Is ignored - Grouping price - Packing price - Min price - Ekt - Weight - PackageName - PackingOut - - - - - - - - - - - - - - {{::buy.itemFk | zeroFill:6}} - - - - - {{::buy.packing | dashIfEmpty}} - - - - - {{::buy.grouping | dashIfEmpty}} - - - {{::buy.quantity}} - - {{::buy.description | dashIfEmpty}} - - {{::buy.size}} - -
- {{::buy.name}} - -

{{::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}} -
-
-
-
-
+ view-config-id="latestBuys" + options="$ctrl.smartTableOptions" + expr-builder="$ctrl.exprBuilder(param, value)"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + 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 price + + Packing price + + Min price + + Ekt + + Weight + + Package name + + Packing out +
+ + + + + + + {{::buy.itemFk | zeroFill:6}} + + + + {{::buy.packing | dashIfEmpty}} + + + + {{::buy.grouping | dashIfEmpty}} + + {{::buy.quantity}} + {{::buy.description | dashIfEmpty}} + {{::buy.size}} +
+ {{::buy.name}} + +

{{::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}}
+
+ +
- +
diff --git a/modules/ticket/back/models/packaging.json b/modules/ticket/back/models/packaging.json index 9d5c098df..0605ae06a 100644 --- a/modules/ticket/back/models/packaging.json +++ b/modules/ticket/back/models/packaging.json @@ -9,29 +9,29 @@ "properties": { "id": { "id": true, - "type": "String", + "type": "string", "description": "Identifier" }, "volume": { - "type": "Number" + "type": "number" }, "width": { - "type": "Date" + "type": "date" }, "height": { - "type": "Number" + "type": "number" }, "depth": { - "type": "Number" + "type": "number" }, "isPackageReturnable": { - "type": "Number" + "type": "boolean" }, "created": { - "type": "Date" + "type": "date" }, "price": { - "type": "Number" + "type": "number" } }, "relations": { From 8b31322fa196780376a149924679e0ec3d7a0651 Mon Sep 17 00:00:00 2001 From: joan Date: Thu, 11 Nov 2021 10:16:44 +0100 Subject: [PATCH 22/43] fix(contextmenu): exclusion by date range and removed empty or/and arrays --- front/core/components/contextmenu/index.js | 31 ++++++++++++++++++---- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/front/core/components/contextmenu/index.js b/front/core/components/contextmenu/index.js index 9c1206865..fa1db6887 100755 --- a/front/core/components/contextmenu/index.js +++ b/front/core/components/contextmenu/index.js @@ -172,12 +172,26 @@ export default class Contextmenu { excludeSelection() { let where = {[this.fieldName]: {neq: this.fieldValue}}; if (this.exprBuilder) { + where = {[this.fieldName]: this.fieldValue}; where = buildFilter(where, (param, value) => { const expr = this.exprBuilder({param, value}); const props = Object.keys(expr); - const newExpr = {}; - for (let prop of props) - newExpr[prop] = {neq: this.fieldValue}; + 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; }); } @@ -213,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]; } } From f99e0c56487bea48c867ec564d76286c33ae9435 Mon Sep 17 00:00:00 2001 From: joan Date: Thu, 11 Nov 2021 10:40:21 +0100 Subject: [PATCH 23/43] Updated default hidden columns --- db/changes/10380-allsaints/00-defaultViewConfig.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/changes/10380-allsaints/00-defaultViewConfig.sql b/db/changes/10380-allsaints/00-defaultViewConfig.sql index f7e29f45f..440bf9850 100644 --- a/db/changes/10380-allsaints/00-defaultViewConfig.sql +++ b/db/changes/10380-allsaints/00-defaultViewConfig.sql @@ -7,7 +7,7 @@ comment 'The default configuration of columns for views'; INSERT INTO `salix`.`defaultViewConfig` (tableCode, columns) VALUES - ('itemIndex', '{"intrastat":false,"density":false,"stemMultiplier":false,"active":false}'), - ('latestBuys', '{"intrastat":false,"description":false,"density":false,"isActive":false,"freightValue":false,"packageValue":false,"isIgnored":false,"price2":false,"minPrice":false,"ektFk":false,"weight":false,"packageFk":false,"packingOut":false}'); + ('itemsIndex', '{"intrastat":false,"stemMultiplier":false}'), + ('latestBuys', '{"intrastat":false,"description":false,"density":false,"isActive":false,"freightValue":false,"packageValue":false,"isIgnored":false,"price2":false,"minPrice":false,"ektFk":false,"weight":false}'); \ No newline at end of file From d2dc0bd14764b888e5b54c3812410cbcc9903c40 Mon Sep 17 00:00:00 2001 From: carlosjr Date: Thu, 11 Nov 2021 16:38:41 +0100 Subject: [PATCH 24/43] multi check now behaves properly --- db/changes/10380-allsaints/00-defaultViewConfig.sql | 2 +- front/core/components/multi-check/multi-check.js | 4 ++-- gulpfile.js | 3 ++- modules/entry/front/latest-buys/index.html | 3 ++- modules/entry/front/latest-buys/index.js | 7 ++----- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/db/changes/10380-allsaints/00-defaultViewConfig.sql b/db/changes/10380-allsaints/00-defaultViewConfig.sql index 440bf9850..6530fe226 100644 --- a/db/changes/10380-allsaints/00-defaultViewConfig.sql +++ b/db/changes/10380-allsaints/00-defaultViewConfig.sql @@ -8,6 +8,6 @@ comment 'The default configuration of columns for views'; INSERT INTO `salix`.`defaultViewConfig` (tableCode, columns) VALUES ('itemsIndex', '{"intrastat":false,"stemMultiplier":false}'), - ('latestBuys', '{"intrastat":false,"description":false,"density":false,"isActive":false,"freightValue":false,"packageValue":false,"isIgnored":false,"price2":false,"minPrice":false,"ektFk":false,"weight":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}'); \ No newline at end of file diff --git a/front/core/components/multi-check/multi-check.js b/front/core/components/multi-check/multi-check.js index 97b86f03d..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; - }); } } @@ -158,6 +157,7 @@ ngModule.vnComponent('vnMultiCheck', { model: '<', checkField: '@?', checkAll: '=?', + checked: '=?', disabled: ' - - - - - - - - - - @@ -139,21 +139,21 @@ {{::buy.itemFk | zeroFill:6}} - - - + - + - - - - + + + + - - - + + + diff --git a/modules/entry/front/latest-buys/locale/es.yml b/modules/entry/front/latest-buys/locale/es.yml index cb45724f8..21eae0307 100644 --- a/modules/entry/front/latest-buys/locale/es.yml +++ b/modules/entry/front/latest-buys/locale/es.yml @@ -14,4 +14,4 @@ Field to edit: Campo a editar PackageName: Cubo Edit: Editar buy(s): compra(s) -PackingOut: Packing envíos \ No newline at end of file +Package out: Embalaje envíos \ No newline at end of file diff --git a/modules/monitor/front/index/tickets/index.html b/modules/monitor/front/index/tickets/index.html index 04f7f339f..87fdd407a 100644 --- a/modules/monitor/front/index/tickets/index.html +++ b/modules/monitor/front/index/tickets/index.html @@ -34,141 +34,180 @@ - - - - Problems - Client - Salesperson - Date - Prep. - Theoretical - Practical - Province - State - Zone - Total - - - - - - - - - - - - - - - - - - - - - - {{::ticket.nickname}} - - - - - {{::ticket.userName | dashIfEmpty}} - - - - - {{::ticket.shipped | date: 'dd/MM/yyyy'}} - - - {{::ticket.shipped | date: 'HH:mm'}} - {{::ticket.zoneLanding | date: 'HH:mm'}} - {{::ticket.practicalHour | date: 'HH:mm'}} - {{::ticket.province}} - - - {{::ticket.refFk}} - - - {{::ticket.state}} - - - - - {{::ticket.zoneName | dashIfEmpty}} - - - - - {{::(ticket.totalWithVat ? ticket.totalWithVat : 0) | currency: 'EUR': 2}} - - - - + +
- diff --git a/modules/entry/front/latest-buys/index.js b/modules/entry/front/latest-buys/index.js index e15d4a16b..f59b12b5d 100644 --- a/modules/entry/front/latest-buys/index.js +++ b/modules/entry/front/latest-buys/index.js @@ -6,6 +6,7 @@ export default class Controller extends Section { constructor($element, $) { super($element, $); this.editedColumn; + this.$checkAll = false; this.smartTableOptions = { activeButtons: { @@ -130,11 +131,7 @@ export default class Controller extends Section { } uncheck() { - const lines = this.checked; - for (let line of lines) { - if (line.checked) - line.checked = false; - } + this.checkAll = false; } get totalChecked() { From 4fe7d4f566d3224f5e67661c0b197574125aa725 Mon Sep 17 00:00:00 2001 From: carlosjr Date: Thu, 11 Nov 2021 17:17:48 +0100 Subject: [PATCH 25/43] ticket index rollback --- modules/ticket/front/index/index.html | 333 ++++++++++++-------------- modules/ticket/front/index/index.js | 51 +--- modules/ticket/front/index/style.scss | 12 +- 3 files changed, 157 insertions(+), 239 deletions(-) diff --git a/modules/ticket/front/index/index.html b/modules/ticket/front/index/index.html index a1c34c43b..63b0b049d 100644 --- a/modules/ticket/front/index/index.html +++ b/modules/ticket/front/index/index.html @@ -1,187 +1,155 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - #ID - - Salesperson - - Date - - Hour - - Closure - - Alias - - Province - - State - - Zone - - Warehouse - - Total -
- - - - - - - - - - - - - - - - {{::ticket.id}} - - {{::ticket.userName | dashIfEmpty}} - - - - {{::ticket.shipped | date: 'dd/MM/yyyy'}} - - {{::ticket.shipped | date: 'HH:mm'}}{{::ticket.zoneLanding | date: 'HH:mm'}} - - {{::ticket.nickname}} - - {{::ticket.province}} - - {{::ticket.refFk}} - - - {{ticket.state}} - - - - {{::ticket.zoneName | dashIfEmpty}} - - {{::ticket.warehouse}} - - {{::(ticket.totalWithVat ? ticket.totalWithVat : 0) | currency: 'EUR': 2}} - - - - - - -
-
-
-
+ + + + + + + + + + + Id + Salesperson + Date + Hour + Closure + Alias + Province + State + Zone + Warehouse + Total + + + + + + + + + + + + + + + + + + + + + + + + {{::ticket.id}} + + + {{::ticket.userName | dashIfEmpty}} + + + + + {{::ticket.shipped | date: 'dd/MM/yyyy'}} + + + {{::ticket.shipped | date: 'HH:mm'}} + {{::ticket.zoneLanding | date: 'HH:mm'}} + + + {{::ticket.nickname}} + + + {{::ticket.province}} + + + {{::ticket.refFk}} + + + {{ticket.state}} + + + + + {{::ticket.zoneName | dashIfEmpty}} + + + {{::ticket.warehouse}} + + + {{::(ticket.totalWithVat ? ticket.totalWithVat : 0) | currency: 'EUR': 2}} + + + + + + + + + + + + +
- - vn-icon { + vn-td.icon-field > vn-icon { margin-left: 3px; margin-right: 3px; } - tbody a[ng-repeat].vn-tr:focus { + vn-tbody a[ng-repeat].vn-tr:focus { background-color: $color-primary-light } } \ No newline at end of file From acd2d2e51f12b5b4381f4ca5719268125867a252 Mon Sep 17 00:00:00 2001 From: carlosjr Date: Thu, 11 Nov 2021 17:18:19 +0100 Subject: [PATCH 26/43] front unit tests fix for lastests buys --- modules/entry/front/buy/import/index.spec.js | 74 ++++++++++++++++--- modules/entry/front/latest-buys/index.js | 2 +- modules/entry/front/latest-buys/index.spec.js | 42 ++--------- 3 files changed, 72 insertions(+), 46 deletions(-) diff --git a/modules/entry/front/buy/import/index.spec.js b/modules/entry/front/buy/import/index.spec.js index c948304c7..bf100dc83 100644 --- a/modules/entry/front/buy/import/index.spec.js +++ b/modules/entry/front/buy/import/index.spec.js @@ -63,8 +63,21 @@ describe('Entry', () => { } ]}`; const expectedBuys = [ - {'buyingValue': 5.77, 'description': 'Bow', 'grouping': 1, 'packing': 1, 'size': 1, 'volume': 1200}, - {'buyingValue': 2.16, 'description': 'Arrow', 'grouping': 1, 'packing': 1, 'size': 25, 'volume': 1125} + { + 'buyingValue': 5.77, + 'description': 'Bow', + 'grouping': 1, + 'packing': 1, + 'size': 1, + 'volume': 1200}, + + { + 'buyingValue': 2.16, + 'description': 'Arrow', + 'grouping': 1, + 'packing': 1, + 'size': 25, + 'volume': 1125} ]; controller.fillData(rawData); controller.$.$apply(); @@ -81,8 +94,21 @@ describe('Entry', () => { describe('fetchBuys()', () => { it(`should perform a query to fetch the buys data`, () => { const buys = [ - {'buyingValue': 5.77, 'description': 'Bow', 'grouping': 1, 'packing': 1, 'size': 1, 'volume': 1200}, - {'buyingValue': 2.16, 'description': 'Arrow', 'grouping': 1, 'packing': 1, 'size': 25, 'volume': 1125} + { + 'buyingValue': 5.77, + 'description': 'Bow', + 'grouping': 1, + 'packing': 1, + 'size': 1, + 'volume': 1200}, + + { + 'buyingValue': 2.16, + 'description': 'Arrow', + 'grouping': 1, + 'packing': 1, + 'size': 25, + 'volume': 1125} ]; const serializedParams = $httpParamSerializer({buys}); @@ -105,17 +131,31 @@ describe('Entry', () => { observation: '123456', ref: '1, 2', buys: [ - {'buyingValue': 5.77, 'description': 'Bow', 'grouping': 1, 'packing': 1, 'size': 1, 'volume': 1200}, - {'buyingValue': 2.16, 'description': 'Arrow', 'grouping': 1, 'packing': 1, 'size': 25, 'volume': 1125} + { + 'buyingValue': 5.77, + 'description': 'Bow', + 'grouping': 1, + 'packing': 1, + 'size': 1, + 'volume': 1200}, + { + 'buyingValue': 2.16, + 'description': 'Arrow', + 'grouping': 1, + 'packing': 1, + 'size': 25, + 'volume': 1125} ] }; controller.onSubmit(); - expect(controller.vnApp.showError).toHaveBeenCalledWith(`Some of the imported buys doesn't have an item`); + const message = `Some of the imported buys doesn't have an item`; + + expect(controller.vnApp.showError).toHaveBeenCalledWith(message); }); - it(`should perform a query to update columns`, () => { + it(`should now perform a query to update columns`, () => { jest.spyOn(controller.vnApp, 'showSuccess'); controller.$state.go = jest.fn(); @@ -123,8 +163,22 @@ describe('Entry', () => { observation: '123456', ref: '1, 2', buys: [ - {'itemFk': 10, 'buyingValue': 5.77, 'description': 'Bow', 'grouping': 1, 'packing': 1, 'size': 1, 'volume': 1200}, - {'itemFk': 11, 'buyingValue': 2.16, 'description': 'Arrow', 'grouping': 1, 'packing': 1, 'size': 25, 'volume': 1125} + { + 'itemFk': 10, + 'buyingValue': 5.77, + 'description': 'Bow', + 'grouping': 1, + 'packing': 1, + 'size': 1, + 'volume': 1200}, + { + 'itemFk': 11, + 'buyingValue': 2.16, + 'description': 'Arrow', + 'grouping': 1, + 'packing': 1, + 'size': 25, + 'volume': 1125} ] }; const params = controller.import; diff --git a/modules/entry/front/latest-buys/index.js b/modules/entry/front/latest-buys/index.js index f59b12b5d..e899c50fa 100644 --- a/modules/entry/front/latest-buys/index.js +++ b/modules/entry/front/latest-buys/index.js @@ -143,7 +143,7 @@ export default class Controller extends Section { for (let row of this.checked) rowsToEdit.push({id: row.id, itemFk: row.itemFk}); - let data = { + const data = { field: this.editedColumn.field, newValue: this.editedColumn.newValue, lines: rowsToEdit diff --git a/modules/entry/front/latest-buys/index.spec.js b/modules/entry/front/latest-buys/index.spec.js index 6f86650c9..e9392a797 100644 --- a/modules/entry/front/latest-buys/index.spec.js +++ b/modules/entry/front/latest-buys/index.spec.js @@ -7,9 +7,9 @@ describe('Entry', () => { beforeEach(ngModule('entry')); - beforeEach(angular.mock.inject(($componentController, $compile, $rootScope, _$httpBackend_) => { + beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_) => { $httpBackend = _$httpBackend_; - let $element = $compile(' {}}, @@ -31,10 +31,10 @@ describe('Entry', () => { describe('get checked', () => { it(`should return a set of checked lines`, () => { controller.$.model.data = [ - {checked: true, id: 1}, - {checked: true, id: 2}, - {checked: true, id: 3}, - {checked: false, id: 4}, + {$checked: true, id: 1}, + {$checked: true, id: 2}, + {$checked: true, id: 3}, + {$checked: false, id: 4}, ]; let result = controller.checked; @@ -43,38 +43,10 @@ describe('Entry', () => { }); }); - describe('uncheck()', () => { - it(`should clear the selection of lines on the controller`, () => { - controller.$.model.data = [ - {checked: true, id: 1}, - {checked: true, id: 2}, - {checked: true, id: 3}, - {checked: false, id: 4}, - ]; - - let result = controller.checked; - - expect(result.length).toEqual(3); - - controller.uncheck(); - - result = controller.checked; - - expect(result.length).toEqual(0); - }); - }); - describe('onEditAccept()', () => { it(`should perform a query to update columns`, () => { - $httpBackend.whenGET('UserConfigViews/getConfig?tableCode=latestBuys').respond([]); - $httpBackend.whenGET('Buys/latestBuysFilter?filter=%7B%22limit%22:20%7D').respond([ - {entryFk: 1}, - {entryFk: 2}, - {entryFk: 3}, - {entryFk: 4} - ]); controller.editedColumn = {field: 'my field', newValue: 'the new value'}; - let query = 'Buys/editLatestBuys'; + const query = 'Buys/editLatestBuys'; $httpBackend.expectPOST(query).respond(); controller.onEditAccept(); From 04da06d778cdef5fc27be2df0c40977c44573291 Mon Sep 17 00:00:00 2001 From: joan Date: Thu, 11 Nov 2021 17:18:44 +0100 Subject: [PATCH 27/43] refactor(smart-table): style changes and added smart-table to sales monitor --- front/core/components/smart-table/index.html | 28 +- front/core/components/smart-table/index.js | 13 + .../core/components/smart-table/locale/es.yml | 3 +- front/core/components/smart-table/style.scss | 62 +++- front/core/components/smart-table/table.scss | 9 +- modules/entry/front/latest-buys/index.html | 52 +-- modules/entry/front/latest-buys/locale/es.yml | 2 +- .../monitor/front/index/tickets/index.html | 307 ++++++++++-------- modules/monitor/front/index/tickets/index.js | 55 ++++ 9 files changed, 346 insertions(+), 185 deletions(-) diff --git a/front/core/components/smart-table/index.html b/front/core/components/smart-table/index.html index 9cfcf7849..8051502a7 100644 --- a/front/core/components/smart-table/index.html +++ b/front/core/components/smart-table/index.html @@ -7,15 +7,12 @@ vn-tooltip="Shown columns">
-
- < - Showing - {{model.data.length}} - results - > -
+
+ {{model.data.length}} + results +
-
-
Check the columns you want to see
+
+ +
Shown columns
+ +
+
+ + +
+ { diff --git a/front/core/components/smart-table/locale/es.yml b/front/core/components/smart-table/locale/es.yml index f65df07b7..422871fbf 100644 --- a/front/core/components/smart-table/locale/es.yml +++ b/front/core/components/smart-table/locale/es.yml @@ -5,4 +5,5 @@ Save data: Guardar datos Shown columns: Columnas visibles Check the columns you want to see: Marca las columnas que quieres ver Showing: Mostrando -results: resultados \ No newline at end of file +results: resultados +Tick all: Marcar todas \ No newline at end of file diff --git a/front/core/components/smart-table/style.scss b/front/core/components/smart-table/style.scss index ed6b6d41f..6b973c5b0 100644 --- a/front/core/components/smart-table/style.scss +++ b/front/core/components/smart-table/style.scss @@ -5,6 +5,51 @@ smart-table { th[field] { overflow: visible; cursor: pointer; + align-items: center; + + & > * { + display: flex + } + } + th[field][number] { + & > :before { + display: flex; + font-family: 'Material Icons'; + content: 'arrow_downward'; + color: $color-spacer; + margin: 2px 2px 0 0; + opacity: 0 + + } + + &.asc > :before, &.desc > :before { + color: $color-font; + opacity: 1; + } + + &.asc > :before { + content: 'arrow_upward'; + } + + &.desc > :before { + content: 'arrow_downward'; + } + + &:hover > :before { + opacity: 1; + } + } + + th[field]:not([number]) { + & > :after { + display: flex; + font-family: 'Material Icons'; + content: 'arrow_downward'; + color: $color-spacer; + margin: 2px 0 0 2px; + opacity: 0 + + } &.asc > :after, &.desc > :after { color: $color-font; @@ -12,23 +57,13 @@ smart-table { } &.asc > :after { - content: 'arrow_drop_up'; + content: 'arrow_upward'; } &.desc > :after { - content: 'arrow_drop_down'; + content: 'arrow_downward'; } - & > :after { - font-family: 'Material Icons'; - content: 'arrow_drop_down'; - position: absolute; - color: $color-spacer; - font-size: 1.5em; - margin-top: -2px; - opacity: 0 - - } &:hover > :after { opacity: 1; } @@ -81,6 +116,7 @@ smart-table { #table { overflow-x: auto; + margin-top: 15px } vn-tbody a[ng-repeat].vn-tr:focus { @@ -108,6 +144,6 @@ smart-table { vn-check { flex: initial; - width: 50% + width: 33% } } \ No newline at end of file diff --git a/front/core/components/smart-table/table.scss b/front/core/components/smart-table/table.scss index 377c3bf8e..d3b9fa990 100644 --- a/front/core/components/smart-table/table.scss +++ b/front/core/components/smart-table/table.scss @@ -35,7 +35,7 @@ smart-table table { text-align: right; width: 96px; } - &[center] { + &[centered] { text-align: center; } &[shrink] { @@ -54,6 +54,13 @@ smart-table table { max-width: 400px; min-width: 0; } + &[actions] { + width: 1px; + + & > * { + vertical-align: middle; + } + } vn-icon.bright, i.bright { color: #f7931e; } diff --git a/modules/entry/front/latest-buys/index.html b/modules/entry/front/latest-buys/index.html index ce1dcbaa0..61f4ce6fc 100644 --- a/modules/entry/front/latest-buys/index.html +++ b/modules/entry/front/latest-buys/index.html @@ -36,13 +36,13 @@
Identifier + Packing + Grouping + Quantity @@ -75,29 +75,29 @@ Entry + Buying value + Freight value + Commission value + Package value Is ignored - Grouping price + + Grouping - Packing price + + Packing - Min price + + Min Ekt @@ -106,10 +106,10 @@ Weight - Package name + Package - Packing out + Package out
+ {{::buy.packing | dashIfEmpty}} + {{::buy.grouping | dashIfEmpty}} {{::buy.quantity}}{{::buy.quantity}} {{::buy.description | dashIfEmpty}} {{::buy.size}}{{::buy.size}}
{{::buy.name}} @@ -189,19 +189,19 @@ {{::buy.entryFk}}
{{::buy.buyingValue | currency: 'EUR':2}}{{::buy.freightValue | currency: 'EUR':2}}{{::buy.comissionValue | currency: 'EUR':2}}{{::buy.packageValue | currency: 'EUR':2}}{{::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.price2 | currency: 'EUR':2}}{{::buy.price3 | currency: 'EUR':2}}{{::buy.minPrice | currency: 'EUR':2}} {{::buy.ektFk | dashIfEmpty}} {{::buy.weight}} {{::buy.packageFk}}
+ + + + + + + + + + + + + + + + + + + - - - - - - - - - + }"> + + + + + + + + + + + + + + + +
+ Problems + + Identifier + + Client + + Salesperson + + Date + + Preparation + + Theoretical + + Practical + + Province + + State + + Zone + + Total +
+ + + + + + + + + + + + + + + {{::ticket.id}} + + + + {{::ticket.nickname}} + + + + {{::ticket.userName | dashIfEmpty}} + + + + {{::ticket.shipped | date: 'dd/MM/yyyy'}} + + {{::ticket.shipped | date: 'HH:mm'}}{{::ticket.zoneLanding | date: 'HH:mm'}}{{::ticket.practicalHour | date: 'HH:mm'}}{{::ticket.province}} + + {{::ticket.refFk}} + + + {{::ticket.state}} + + + + {{::ticket.zoneName | dashIfEmpty}} + + + + {{::(ticket.totalWithVat ? ticket.totalWithVat : 0) | currency: 'EUR': 2}} + + + + + + +
+
+ @@ -185,7 +224,7 @@ model="model"> - Date: Fri, 12 Nov 2021 10:21:54 +0100 Subject: [PATCH 28/43] item summary e2e fix --- e2e/helpers/selectors.js | 4 ++-- e2e/paths/04-item/01_summary.spec.js | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index d4d5d33aa..3860ecc25 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -313,8 +313,8 @@ 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"]', + searchResult: 'vn-item-index tbody tr', + 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', 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() => { From 62e03f4752ca3dc55ef12138ff0d19175c8d871d Mon Sep 17 00:00:00 2001 From: carlosjr Date: Fri, 12 Nov 2021 11:03:23 +0100 Subject: [PATCH 29/43] item create e2e fix --- e2e/helpers/selectors.js | 2 +- e2e/paths/04-item/07_create.spec.js | 71 ++++++++++++ e2e/paths/04-item/07_create_and_clone.spec.js | 105 ------------------ front/core/components/smart-table/index.js | 3 +- modules/item/front/last-entries/index.html | 1 - 5 files changed, 74 insertions(+), 108 deletions(-) create mode 100644 e2e/paths/04-item/07_create.spec.js delete mode 100644 e2e/paths/04-item/07_create_and_clone.spec.js diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 3860ecc25..a97f20a00 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -313,7 +313,7 @@ export default { itemsIndex: { createItemButton: `vn-float-button`, firstSearchResult: 'vn-item-index a:nth-child(1)', - searchResult: 'vn-item-index tbody tr', + searchResult: 'vn-item-index tbody tr td: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"]', 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/front/core/components/smart-table/index.js b/front/core/components/smart-table/index.js index 89a50bb27..d93d704dd 100644 --- a/front/core/components/smart-table/index.js +++ b/front/core/components/smart-table/index.js @@ -160,7 +160,7 @@ export default class SmartTable extends Component { } } - const styleElement = document.querySelector('style[id="smart-table"]'); + let styleElement = document.querySelector('style[id="smart-table"]'); if (styleElement) styleElement.parentNode.removeChild(styleElement); @@ -174,6 +174,7 @@ export default class SmartTable extends Component { } this.$.$on('$destroy', () => { + styleElement = document.querySelector('style[id="smart-table"]'); if (this.$.css && styleElement) styleElement.parentNode.removeChild(styleElement); }); diff --git a/modules/item/front/last-entries/index.html b/modules/item/front/last-entries/index.html index af7bbd751..29047c613 100644 --- a/modules/item/front/last-entries/index.html +++ b/modules/item/front/last-entries/index.html @@ -23,7 +23,6 @@ - From 259c192c8b70c7f39f27f3d1c951d5e6fbabee35 Mon Sep 17 00:00:00 2001 From: carlosjr Date: Fri, 12 Nov 2021 11:33:34 +0100 Subject: [PATCH 30/43] empty rows class moved to the tr from td --- e2e/helpers/selectors.js | 4 ++-- front/core/components/smart-table/index.js | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index a97f20a00..9705df60a 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -312,8 +312,8 @@ export default { }, itemsIndex: { createItemButton: `vn-float-button`, - firstSearchResult: 'vn-item-index a:nth-child(1)', - searchResult: 'vn-item-index tbody tr td:not(.empty-rows)', + firstSearchResult: 'vn-item-index tr:nth-child(2)', + 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"]', diff --git a/front/core/components/smart-table/index.js b/front/core/components/smart-table/index.js index d93d704dd..32a66f9bc 100644 --- a/front/core/components/smart-table/index.js +++ b/front/core/components/smart-table/index.js @@ -122,15 +122,15 @@ export default class SmartTable extends Component { const tbody = this.element.querySelector('tbody'); if (tbody) { const noSearch = this.$compile(` - - Enter a new search + + Enter a new search `)($scope); tbody.appendChild(noSearch[0]); const noRows = this.$compile(` - - No data + + No data `)($scope); tbody.appendChild(noRows[0]); From 3a655d393bb81c1e51363ee67f205eafad6aa2c9 Mon Sep 17 00:00:00 2001 From: joan Date: Fri, 12 Nov 2021 12:13:50 +0100 Subject: [PATCH 31/43] Remove search inputs scope on element removal --- front/core/components/smart-table/index.js | 32 ++++++++++++---------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/front/core/components/smart-table/index.js b/front/core/components/smart-table/index.js index 89a50bb27..700171609 100644 --- a/front/core/components/smart-table/index.js +++ b/front/core/components/smart-table/index.js @@ -12,12 +12,18 @@ export default class SmartTable extends Component { this.currentUserId = window.localStorage.currentUserWorkerId; this.$transclude = $transclude; this.sortCriteria = []; + this.$inputScopes = []; this.columns = []; this.autoSave = false; - this.transclude(); } + $onDestroy() { + const styleElement = document.querySelector('style[id="smart-table"]'); + if (this.$.css && styleElement) + styleElement.parentNode.removeChild(styleElement); + } + get options() { return this._options; } @@ -172,11 +178,6 @@ export default class SmartTable extends Component { document.head.appendChild(this.$.css); this.$.css.appendChild(document.createTextNode(rule)); } - - this.$.$on('$destroy', () => { - if (this.$.css && styleElement) - styleElement.parentNode.removeChild(styleElement); - }); } registerColumns() { @@ -238,7 +239,13 @@ export default class SmartTable extends Component { const columns = header.querySelectorAll('th'); const hasSearchRow = tbody.querySelector('tr#searchRow'); - if (hasSearchRow) return hasSearchRow.remove(); + if (hasSearchRow) { + if (this.$inputScopes) { + for (let $inputScope of this.$inputScopes) + $inputScope.$destroy(); + } + return hasSearchRow.remove(); + } const searchRow = document.createElement('tr'); searchRow.setAttribute('id', 'searchRow'); @@ -258,13 +265,13 @@ export default class SmartTable extends Component { continue; } + const $inputScope = this.$.$new(); if (options && options.autocomplete) { let props = ``; const autocomplete = options.autocomplete; for (const prop in autocomplete) props += `${camelToKebab(prop)}="${autocomplete[prop]}"\n`; - input = this.$compile(` `)(this.$); + />`)($inputScope); } else { input = this.$compile(` `)(this.$); + />`)($inputScope); } + this.$inputScopes.push($inputScope); cell.appendChild(input[0]); } searchRow.appendChild(cell); @@ -406,10 +414,6 @@ export default class SmartTable extends Component { this.model.save() .then(() => this.vnApp.showSuccess(this.$t('Data saved!'))); } - - hasChanges() { - return true; - } } SmartTable.$inject = ['$element', '$scope', '$transclude']; From 3e35e7e0b836d4002a9f293b99e224decdab1d78 Mon Sep 17 00:00:00 2001 From: joan Date: Fri, 12 Nov 2021 14:15:35 +0100 Subject: [PATCH 32/43] Changed to single scope for all inputs --- front/core/components/smart-table/index.js | 68 +++++++++++--------- front/core/components/smart-table/table.scss | 6 +- modules/entry/front/latest-buys/index.html | 2 +- 3 files changed, 42 insertions(+), 34 deletions(-) diff --git a/front/core/components/smart-table/index.js b/front/core/components/smart-table/index.js index 530d2fd15..036552086 100644 --- a/front/core/components/smart-table/index.js +++ b/front/core/components/smart-table/index.js @@ -12,7 +12,7 @@ export default class SmartTable extends Component { this.currentUserId = window.localStorage.currentUserWorkerId; this.$transclude = $transclude; this.sortCriteria = []; - this.$inputScopes = []; + this.$inputsScope; this.columns = []; this.autoSave = false; this.transclude(); @@ -118,29 +118,11 @@ export default class SmartTable extends Component { transclude() { const slotTable = this.element.querySelector('#table'); - this.$transclude(($clone, $scope) => { + this.$transclude($clone => { const table = $clone[0]; slotTable.appendChild(table); this.registerColumns(); - - const header = this.element.querySelector('thead > tr'); - const columns = header.querySelectorAll('th'); - const tbody = this.element.querySelector('tbody'); - if (tbody) { - const noSearch = this.$compile(` - - Enter a new search - - `)($scope); - tbody.appendChild(noSearch[0]); - - const noRows = this.$compile(` - - No data - - `)($scope); - tbody.appendChild(noRows[0]); - } + this.emptyDataRows(); }, null, 'table'); } @@ -150,7 +132,8 @@ export default class SmartTable extends Component { viewConfig.configuration = Object.assign({}, viewConfig.configuration); userViewModel.save() .then(() => this.vnApp.showSuccess(this.$t('Data saved!'))) - .then(() => this.applyViewConfig()); + .then(() => this.applyViewConfig()) + .then(() => this.$.smartTableColumns.hide()); } applyViewConfig() { @@ -199,6 +182,27 @@ export default class SmartTable extends Component { } } + emptyDataRows() { + const header = this.element.querySelector('thead > tr'); + const columns = header.querySelectorAll('th'); + const tbody = this.element.querySelector('tbody'); + if (tbody) { + const noSearch = this.$compile(` + + Enter a new search + + `)(this.$); + tbody.appendChild(noSearch[0]); + + const noRows = this.$compile(` + + No data + + `)(this.$); + tbody.appendChild(noRows[0]); + } + } + orderHandler(element) { const field = element.getAttribute('field'); const existingCriteria = this.sortCriteria.find(criteria => { @@ -240,15 +244,17 @@ export default class SmartTable extends Component { const hasSearchRow = tbody.querySelector('tr#searchRow'); if (hasSearchRow) { - if (this.$inputScopes) { - for (let $inputScope of this.$inputScopes) - $inputScope.$destroy(); - } + if (this.$inputsScope) + this.$inputsScope.$destroy(); + return hasSearchRow.remove(); } const searchRow = document.createElement('tr'); searchRow.setAttribute('id', 'searchRow'); + + this.$inputsScope = this.$.$new(); + for (let column of columns) { const field = column.getAttribute('field'); const cell = document.createElement('td'); @@ -265,7 +271,6 @@ export default class SmartTable extends Component { continue; } - const $inputScope = this.$.$new(); if (options && options.autocomplete) { let props = ``; @@ -280,7 +285,7 @@ export default class SmartTable extends Component { ${props} on-change="$ctrl.searchByColumn('${field}')" clear-disabled="true" - />`)($inputScope); + />`)(this.$inputsScope); } else { input = this.$compile(` `)($inputScope); + />`)(this.$inputsScope); } - this.$inputScopes.push($inputScope); cell.appendChild(input[0]); } searchRow.appendChild(cell); @@ -307,7 +311,7 @@ export default class SmartTable extends Component { } searchByColumn(field) { - const searchCriteria = this.$.searchProps[field]; + const searchCriteria = this.$inputsScope.searchProps[field]; const emptySearch = searchCriteria == '' || null; const filters = this.filterSanitizer(field); @@ -316,7 +320,7 @@ export default class SmartTable extends Component { this.model.userFilter = filters.userFilter; if (!emptySearch) - this.addFilter(field, this.$.searchProps[field]); + this.addFilter(field, this.$inputsScope.searchProps[field]); else this.model.refresh(); } diff --git a/front/core/components/smart-table/table.scss b/front/core/components/smart-table/table.scss index d3b9fa990..b5dc631a3 100644 --- a/front/core/components/smart-table/table.scss +++ b/front/core/components/smart-table/table.scss @@ -32,8 +32,12 @@ smart-table table { text-overflow: ellipsis; &[number] { + flex-direction: column; text-align: right; - width: 96px; + align-items:flex-end; + align-content: flex-end; + + justify-content: right; } &[centered] { text-align: center; diff --git a/modules/entry/front/latest-buys/index.html b/modules/entry/front/latest-buys/index.html index a416db00b..25bff0d56 100644 --- a/modules/entry/front/latest-buys/index.html +++ b/modules/entry/front/latest-buys/index.html @@ -137,7 +137,7 @@ - {{::buy.itemFk | zeroFill:6}} + {{::buy.itemFk}} From 906fce5ae35ec0815020f0d6d01665725d7fcad8 Mon Sep 17 00:00:00 2001 From: carlosjr Date: Fri, 12 Nov 2021 15:17:09 +0100 Subject: [PATCH 33/43] extensions refactor and item index e2e fix --- e2e/helpers/extensions.js | 58 +++++++------------ e2e/helpers/selectors.js | 31 +++++----- e2e/paths/01-salix/01_login.spec.js | 8 ++- .../02-client/03_edit_fiscal_data.spec.js | 2 +- e2e/paths/04-item/09_index.spec.js | 12 ++-- e2e/paths/05-ticket/04_packages.spec.js | 2 +- front/core/components/smart-table/index.html | 1 + 7 files changed, 52 insertions(+), 62 deletions(-) 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 9705df60a..0dc26e764 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -312,27 +312,26 @@ export default { }, itemsIndex: { createItemButton: `vn-float-button`, - firstSearchResult: 'vn-item-index tr:nth-child(2)', + 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: { 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/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/front/core/components/smart-table/index.html b/front/core/components/smart-table/index.html index 8051502a7..993774ed0 100644 --- a/front/core/components/smart-table/index.html +++ b/front/core/components/smart-table/index.html @@ -2,6 +2,7 @@
From 86f8e81251d48871ad27f8e67a39d0494e7b6251 Mon Sep 17 00:00:00 2001 From: joan Date: Fri, 12 Nov 2021 15:17:30 +0100 Subject: [PATCH 34/43] Fixed alignment for number columns --- front/core/components/smart-table/style.scss | 11 ++++------- front/core/components/smart-table/table.scss | 5 ----- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/front/core/components/smart-table/style.scss b/front/core/components/smart-table/style.scss index 6b973c5b0..1e882f679 100644 --- a/front/core/components/smart-table/style.scss +++ b/front/core/components/smart-table/style.scss @@ -7,17 +7,14 @@ smart-table { cursor: pointer; align-items: center; - & > * { - display: flex - } } th[field][number] { & > :before { - display: flex; + vertical-align: middle; font-family: 'Material Icons'; content: 'arrow_downward'; color: $color-spacer; - margin: 2px 2px 0 0; + margin-right: 2px; opacity: 0 } @@ -42,11 +39,11 @@ smart-table { th[field]:not([number]) { & > :after { - display: flex; + vertical-align: middle; font-family: 'Material Icons'; content: 'arrow_downward'; color: $color-spacer; - margin: 2px 0 0 2px; + margin-left: 2px; opacity: 0 } diff --git a/front/core/components/smart-table/table.scss b/front/core/components/smart-table/table.scss index b5dc631a3..a654939db 100644 --- a/front/core/components/smart-table/table.scss +++ b/front/core/components/smart-table/table.scss @@ -32,12 +32,7 @@ smart-table table { text-overflow: ellipsis; &[number] { - flex-direction: column; text-align: right; - align-items:flex-end; - align-content: flex-end; - - justify-content: right; } &[centered] { text-align: center; From 58f329c561dbe0866cd9ece8c89ea1ab68e8e695 Mon Sep 17 00:00:00 2001 From: joan Date: Fri, 12 Nov 2021 15:54:07 +0100 Subject: [PATCH 35/43] Updated empty-rows style --- front/core/components/smart-table/table.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front/core/components/smart-table/table.scss b/front/core/components/smart-table/table.scss index a654939db..370027d3e 100644 --- a/front/core/components/smart-table/table.scss +++ b/front/core/components/smart-table/table.scss @@ -100,7 +100,7 @@ smart-table table { .vn-check { margin: 0; } - .empty-rows { + .empty-rows > td { color: $color-font-secondary; font-size: 1.375rem; text-align: center; From 0cd04040f18ccd6703d379bd71b75610fd0b62b7 Mon Sep 17 00:00:00 2001 From: carlosjr Date: Fri, 12 Nov 2021 16:13:47 +0100 Subject: [PATCH 36/43] e2e fixed for client billing data and entry latests buys --- e2e/helpers/selectors.js | 6 +++--- .../02-client/04_edit_billing_data.spec.js | 3 +++ e2e/paths/12-entry/03_latestBuys.spec.js | 2 +- e2e/paths/12-entry/07_buys.spec.js | 21 ++++++++++--------- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 0dc26e764..544437836 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -1107,9 +1107,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/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/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'); }); From b83f0fb52fd2d1bf6a41dd231a48c16f8d1ece35 Mon Sep 17 00:00:00 2001 From: joan Date: Fri, 12 Nov 2021 17:51:27 +0100 Subject: [PATCH 37/43] fix(smart-table): load default viewConfig --- .../10380-allsaints/00-defaultViewConfig.sql | 5 ++- front/core/components/smart-table/index.js | 43 +++++++++++++------ front/core/components/smart-table/table.scss | 2 +- 3 files changed, 33 insertions(+), 17 deletions(-) diff --git a/db/changes/10380-allsaints/00-defaultViewConfig.sql b/db/changes/10380-allsaints/00-defaultViewConfig.sql index 6530fe226..e4b2f6c3d 100644 --- a/db/changes/10380-allsaints/00-defaultViewConfig.sql +++ b/db/changes/10380-allsaints/00-defaultViewConfig.sql @@ -7,7 +7,8 @@ comment 'The default configuration of columns for views'; INSERT INTO `salix`.`defaultViewConfig` (tableCode, columns) VALUES - ('itemsIndex', '{"intrastat":false,"stemMultiplier":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}'); + ('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/front/core/components/smart-table/index.js b/front/core/components/smart-table/index.js index 036552086..819379134 100644 --- a/front/core/components/smart-table/index.js +++ b/front/core/components/smart-table/index.js @@ -55,7 +55,7 @@ export default class SmartTable extends Component { set viewConfigId(value) { this._viewConfigId = value; - if (value) { + /* if (value) { this.defaultViewConfig = {}; const url = 'DefaultViewConfigs'; @@ -67,7 +67,18 @@ export default class SmartTable extends Component { this.defaultViewConfig = columns; } }); - } + } */ + } + + getDefaultViewConfig() { + // this.defaultViewConfig = {}; + const url = 'DefaultViewConfigs'; + const filter = {where: {tableCode: this.viewConfigId}}; + return this.$http.get(url, {filter}) + .then(res => { + if (res && res.data.length) + return res.data[0].columns; + }); } get viewConfig() { @@ -80,19 +91,23 @@ export default class SmartTable extends Component { if (!value) return; if (!value.length) { - const userViewModel = this.$.userViewModel; + this.getDefaultViewConfig().then(columns => { + const defaultViewConfig = columns ? columns : {}; - for (const column of this.columns) { - if (this.defaultViewConfig[column.field] == undefined) - this.defaultViewConfig[column.field] = true; - } - userViewModel.insert({ - userFk: this.currentUserId, - tableConfig: this.viewConfigId, - configuration: this.defaultViewConfig ? this.defaultViewConfig : {} - }); - } - this.applyViewConfig(); + const userViewModel = this.$.userViewModel; + for (const column of this.columns) { + if (defaultViewConfig[column.field] == undefined) + defaultViewConfig[column.field] = true; + } + + userViewModel.insert({ + userFk: this.currentUserId, + tableConfig: this.viewConfigId, + configuration: defaultViewConfig + }); + }).finally(() => this.applyViewConfig()); + } else + this.applyViewConfig(); } get checkedRows() { diff --git a/front/core/components/smart-table/table.scss b/front/core/components/smart-table/table.scss index 370027d3e..e0464465a 100644 --- a/front/core/components/smart-table/table.scss +++ b/front/core/components/smart-table/table.scss @@ -27,7 +27,7 @@ smart-table table { & > th, & > td { text-align: left; - padding: 9px 8px; + padding: 9px 5px; white-space: nowrap; text-overflow: ellipsis; From e62e57bcdef205fcb994e74af72f53039ab675e1 Mon Sep 17 00:00:00 2001 From: joan Date: Mon, 15 Nov 2021 08:45:21 +0100 Subject: [PATCH 38/43] Monitor smart-table ammends --- front/core/components/smart-table/index.html | 2 +- modules/entry/front/latest-buys/index.html | 2 +- modules/monitor/front/index/locale/es.yml | 1 + .../monitor/front/index/tickets/index.html | 31 ++++---- modules/monitor/front/index/tickets/index.js | 71 ++++++++++--------- 5 files changed, 53 insertions(+), 54 deletions(-) diff --git a/front/core/components/smart-table/index.html b/front/core/components/smart-table/index.html index 993774ed0..010cff235 100644 --- a/front/core/components/smart-table/index.html +++ b/front/core/components/smart-table/index.html @@ -7,7 +7,7 @@ ng-click="smartTableColumns.show($event)" vn-tooltip="Shown columns"> -
+
diff --git a/modules/entry/front/latest-buys/index.html b/modules/entry/front/latest-buys/index.html index 25bff0d56..a01d6f303 100644 --- a/modules/entry/front/latest-buys/index.html +++ b/modules/entry/front/latest-buys/index.html @@ -33,7 +33,7 @@ check-field="$checked"> - Picture + Picture Identifier diff --git a/modules/monitor/front/index/locale/es.yml b/modules/monitor/front/index/locale/es.yml index b17861e9f..3a115797d 100644 --- a/modules/monitor/front/index/locale/es.yml +++ b/modules/monitor/front/index/locale/es.yml @@ -9,5 +9,6 @@ Minimize/Maximize: Minimizar/Maximizar Problems: Problemas Theoretical: Teórica Practical: Práctica +Preparation: Preparación Auto-refresh: Auto-refresco Toggle auto-refresh every 2 minutes: Conmuta el refresco automático cada 2 minutos \ No newline at end of file diff --git a/modules/monitor/front/index/tickets/index.html b/modules/monitor/front/index/tickets/index.html index 87fdd407a..34f2841fd 100644 --- a/modules/monitor/front/index/tickets/index.html +++ b/modules/monitor/front/index/tickets/index.html @@ -20,18 +20,6 @@ Tickets monitor - - - - - - + + @@ -58,15 +51,15 @@ - + @@ -156,9 +149,9 @@ {{::ticket.shipped | date: 'dd/MM/yyyy'}} - - - + + + From 3f6e1ce9aa4c3295f8ee8007e902b84147d5d0c9 Mon Sep 17 00:00:00 2001 From: carlosjr Date: Mon, 15 Nov 2021 18:24:01 +0100 Subject: [PATCH 40/43] refactor(entry.buy): moved add button --- e2e/helpers/selectors.js | 2 +- modules/entry/front/buy/index/index.html | 17 +++++++---------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 40d0fb5e2..d8ebaa069 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -1086,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"]', diff --git a/modules/entry/front/buy/index/index.html b/modules/entry/front/buy/index/index.html index dbe43c467..bb33b98b3 100644 --- a/modules/entry/front/buy/index/index.html +++ b/modules/entry/front/buy/index/index.html @@ -188,22 +188,19 @@
Date - Preparation - Theoretical Practical + Preparation + Province {{::ticket.shipped | date: 'HH:mm'}}{{::ticket.zoneLanding | date: 'HH:mm'}}{{::ticket.practicalHour | date: 'HH:mm'}}{{::ticket.zoneLanding | date: 'HH:mm'}}{{::ticket.practicalHour | date: 'HH:mm'}}{{::ticket.shipped | date: 'HH:mm'}} {{::ticket.province}} - Date: Mon, 15 Nov 2021 14:40:35 +0100 Subject: [PATCH 39/43] removed unused code --- front/core/components/smart-table/index.html | 2 -- front/core/components/smart-table/index.js | 1 - modules/entry/front/latest-buys/index.html | 2 +- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/front/core/components/smart-table/index.html b/front/core/components/smart-table/index.html index 010cff235..c2af9b41e 100644 --- a/front/core/components/smart-table/index.html +++ b/front/core/components/smart-table/index.html @@ -45,9 +45,7 @@ -
- + check-field="$checked">
Picture
-
- - -
+ +
Date: Tue, 16 Nov 2021 08:41:27 +0100 Subject: [PATCH 42/43] fix(fixed-price): confirm on deletion --- modules/item/front/fixed-price/index.html | 13 ++++++++++--- modules/item/front/fixed-price/locale/es.yml | 3 ++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/modules/item/front/fixed-price/index.html b/modules/item/front/fixed-price/index.html index 29053d58e..6f98ba65b 100644 --- a/modules/item/front/fixed-price/index.html +++ b/modules/item/front/fixed-price/index.html @@ -116,7 +116,8 @@ class="dense" vn-focus ng-model="price.minPrice" - on-change="$ctrl.upsertPrice(price)"> + on-change="$ctrl.upsertPrice(price)" + step="0.01"> @@ -140,7 +141,7 @@ + ng-click="deleteFixedPrice.show({$index})"> @@ -163,4 +164,10 @@ - \ No newline at end of file + + + \ No newline at end of file diff --git a/modules/item/front/fixed-price/locale/es.yml b/modules/item/front/fixed-price/locale/es.yml index c19b7703c..f52aef02c 100644 --- a/modules/item/front/fixed-price/locale/es.yml +++ b/modules/item/front/fixed-price/locale/es.yml @@ -1,4 +1,5 @@ Fixed prices: Precios fijados Search prices by item ID or code: Buscar por ID de artículo o código Search fixed prices: Buscar precios fijados -Add fixed price: Añadir precio fijado \ No newline at end of file +Add fixed price: Añadir precio fijado +This row will be removed: Esta linea se eliminará \ No newline at end of file From b7e58aa9cdec965c303483059f77ce6db257f54b Mon Sep 17 00:00:00 2001 From: joan Date: Tue, 16 Nov 2021 11:00:48 +0100 Subject: [PATCH 43/43] fix(smtp): log attachment files sent through email --- print/core/smtp.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/print/core/smtp.js b/print/core/smtp.js index 5fb5c4a2c..0017739da 100644 --- a/print/core/smtp.js +++ b/print/core/smtp.js @@ -24,13 +24,24 @@ module.exports = { throw err; }).finally(async() => { + const attachments = []; + for (let attachment of options.attachments) { + const fileName = attachment.filename; + const filePath = attachment.path; + // if (fileName.includes('.png')) return; + + if (fileName || filePath) + attachments.push(filePath ? filePath : fileName); + } + const fileNames = attachments.join(',\n'); await db.rawSql(` - INSERT INTO vn.mail (receiver, replyTo, sent, subject, body, status) - VALUES (?, ?, 1, ?, ?, ?)`, [ + INSERT INTO vn.mail (receiver, replyTo, sent, subject, body, attachment, status) + VALUES (?, ?, 1, ?, ?, ?, ?)`, [ options.to, options.replyTo, options.subject, options.text || options.html, + fileNames, error && error.message || 'Sent' ]); });