From 0fe78a2b8f5b96eec51cc6cffca335d26d7653d0 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Thu, 28 May 2020 08:07:26 +0200 Subject: [PATCH 1/8] 2176 - Added contextmenu --- front/core/components/contextmenu/index.html | 5 ++ front/core/components/contextmenu/index.js | 68 ++++++++++++++++++++ front/core/components/index.js | 1 + modules/client/front/index/index.js | 4 ++ modules/item/front/index/index.html | 11 +++- 5 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 front/core/components/contextmenu/index.html create mode 100755 front/core/components/contextmenu/index.js diff --git a/front/core/components/contextmenu/index.html b/front/core/components/contextmenu/index.html new file mode 100644 index 000000000..0028c1186 --- /dev/null +++ b/front/core/components/contextmenu/index.html @@ -0,0 +1,5 @@ +
+ + + +
diff --git a/front/core/components/contextmenu/index.js b/front/core/components/contextmenu/index.js new file mode 100755 index 000000000..9bd1c0d24 --- /dev/null +++ b/front/core/components/contextmenu/index.js @@ -0,0 +1,68 @@ +import ngModule from '../../module'; +export default class Contextmenu { + constructor($element, $, $window) { + this.$element = $element; + this.element = $element[0]; + this.$ = $; + this.$window = $window; + // this.displayMode = 'relative'; + + // Foreach element, apply an addEventListener??? + /* + document.body.addEventListener('contextmenu', event => { + if (!event.defaultPrevented) + event.preventDefault(); + + const target = event.target; + const rect = target.getBoundingClientRect(); + + console.log('ScreenY', event.pageY); + console.log('OffsetY', event.pageX); + + const parent = $.contextmenu; + parent.style.top = event.pageY + 'px'; + parent.style.left = event.pageX + 'px'; + + $.menu.show(parent); + }); */ + } + + get target() { + return this._target; + } + + set target(value) { + this._target = value; + + if (!value) return; + + const target = document.querySelector(value);// Find elements + console.log(this.element); + + if (!target) return; + + target.addEventListener('contextmenu', event => { + if (!event.defaultPrevented) + event.preventDefault(); + + const parent = this.$.contextmenu; + parent.style.top = event.pageY + 'px'; + parent.style.left = event.pageX + 'px'; + + this.$.menu.show(parent); + }); + } +} + +Contextmenu.$inject = ['$element', '$scope', '$window']; + +ngModule.vnComponent('vnContextmenu', { + controller: Contextmenu, + template: require('./index.html'), + bindings: { + target: '@?' + }, + transclude: { + menu: '?slotMenu' + } +}); diff --git a/front/core/components/index.js b/front/core/components/index.js index 8f636cb4c..ea568bf2b 100644 --- a/front/core/components/index.js +++ b/front/core/components/index.js @@ -50,3 +50,4 @@ import './th'; import './treeview'; import './wday-picker'; import './datalist'; +import './contextmenu'; diff --git a/modules/client/front/index/index.js b/modules/client/front/index/index.js index f5400e05a..4832391ce 100644 --- a/modules/client/front/index/index.js +++ b/modules/client/front/index/index.js @@ -19,6 +19,10 @@ export default class Controller extends Section { this.$state.go(`ticket.index`, {q: JSON.stringify({clientFk: client.id})}); } + + filterBySelection() { + console.log('Filtro por seleccion'); + } } ngModule.component('vnClientIndex', { diff --git a/modules/item/front/index/index.html b/modules/item/front/index/index.html index 0ee6a8815..6470f4640 100644 --- a/modules/item/front/index/index.html +++ b/modules/item/front/index/index.html @@ -122,4 +122,13 @@ - \ No newline at end of file + + + + Filter by selection + Exclude selection + Remove filter by selection + Order DESC + Order ASC + + \ No newline at end of file From 90ae1562ddfe0c6283776a3ef02855ccc30761ea Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 29 May 2020 11:10:58 +0200 Subject: [PATCH 2/8] Added filters --- front/core/components/contextmenu/index.html | 2 +- front/core/components/contextmenu/index.js | 138 +++++++++++++++--- modules/client/front/descriptor/index.html | 2 +- modules/client/front/descriptor/locale/es.yml | 2 +- modules/client/front/index/index.js | 4 - .../invoiceOut/front/descriptor/index.html | 2 +- modules/invoiceOut/front/descriptor/index.js | 7 + modules/item/front/index/index.html | 11 +- modules/ticket/back/methods/ticket/filter.js | 2 + modules/ticket/front/index/index.html | 24 ++- modules/ticket/front/index/index.js | 55 +++++++ modules/ticket/front/index/locale/es.yml | 5 +- 12 files changed, 211 insertions(+), 43 deletions(-) diff --git a/front/core/components/contextmenu/index.html b/front/core/components/contextmenu/index.html index 0028c1186..7e7cae138 100644 --- a/front/core/components/contextmenu/index.html +++ b/front/core/components/contextmenu/index.html @@ -1,5 +1,5 @@
- +
diff --git a/front/core/components/contextmenu/index.js b/front/core/components/contextmenu/index.js index 9bd1c0d24..a99009d50 100755 --- a/front/core/components/contextmenu/index.js +++ b/front/core/components/contextmenu/index.js @@ -1,10 +1,10 @@ import ngModule from '../../module'; export default class Contextmenu { - constructor($element, $, $window) { + constructor($element, $, $transclude) { this.$element = $element; this.element = $element[0]; this.$ = $; - this.$window = $window; + this.$transclude = $transclude; // this.displayMode = 'relative'; // Foreach element, apply an addEventListener??? @@ -27,40 +27,140 @@ export default class Contextmenu { }); */ } - get target() { - return this._target; + $onInit() { + /* const transcludeElement = this.element.querySelector('vn-menu'); + const content = angular.element(transcludeElement); + + this.$transclude(($clone, $scope) => { + this.$contentScope = $scope; + // $scope.$target = 'hola??'; + const list = angular.element(''); + list.append($clone); + + content.append(list); + }, null, 'menu'); */ } - set target(value) { - this._target = value; + get targets() { + return this._targets; + } + + set targets(value) { + this._targets = value; if (!value) return; - const target = document.querySelector(value);// Find elements - console.log(this.element); + for (let selector of value) { + const target = document.querySelector(selector);// Find elements + if (!target) continue; - if (!target) return; + target.addEventListener('contextmenu', event => { + if (!event.defaultPrevented) + event.preventDefault(); - target.addEventListener('contextmenu', event => { - if (!event.defaultPrevented) - event.preventDefault(); + const parent = this.$.contextmenu; + parent.style.top = event.pageY + 'px'; + parent.style.left = event.pageX + 'px'; - const parent = this.$.contextmenu; - parent.style.top = event.pageY + 'px'; - parent.style.left = event.pageX + 'px'; + this.eventTarget = event.target; - this.$.menu.show(parent); - }); + /* const menu = this.element.querySelector('vn-menu'); + const list = document.createElement('vn-list'); + menu.append(list); + + const transcludeElement = this.element.querySelector('vn-list'); + const content = angular.element(transcludeElement); + console.log(transcludeElement); + + this.$transclude(($clone, $scope) => { + this.$contentScope = $scope; + $scope.$target = 'hola??'; + console.log($clone); + content.append($clone); + }, null, 'menu'); */ + + this.$.menu.show(parent); + }); + } + } + + /* const transcludeElement = this.element.querySelector('vn-list'); + const content = angular.element(transcludeElement); + console.log(transcludeElement); + + this.$transclude(($clone, $scope) => { + this.$contentScope = $scope; + $scope.$target = 'hola??'; + content.append($clone); + }); */ + + filterBySelection() { + // const target = $event.target; + const model = this.model; + const target = this.eventTarget; + console.log(target); + + const table = target.closest('.vn-table'); + const headerCols = table.querySelectorAll('vn-thead vn-th'); + + const row = target.closest('.vn-tr'); + const col = target.closest('vn-td'); + + const rowIndex = row.getAttribute('data-index'); + + const columns = Array.from(row.querySelectorAll('vn-td')); + + const fieldIndex = columns.findIndex(column => column == col); + const fieldName = headerCols[fieldIndex].getAttribute('field'); + + const rowData = model.data[rowIndex]; + + const filter = {where: {}}; + filter['where'][fieldName] = rowData[fieldName]; + console.log(filter); + + model.addFilter(filter); + } + + excludeSelection() { + const model = this.model; + const target = this.eventTarget; + + const table = target.closest('.vn-table'); + const headerCols = table.querySelectorAll('vn-thead vn-th'); + + const row = target.closest('.vn-tr'); + const col = target.closest('vn-td'); + + const rowIndex = row.getAttribute('data-index'); + + const columns = Array.from(row.querySelectorAll('vn-td')); + + const fieldIndex = columns.findIndex(column => column == col); + const fieldName = headerCols[fieldIndex].getAttribute('field'); + + const rowData = model.data[rowIndex]; + + const filter = {where: {}}; + filter['where'][fieldName] = {neq: rowData[fieldName]}; + console.log(filter); + + model.addFilter(filter); + } + + removeFilter() { + this.model.removeFilter(); } } -Contextmenu.$inject = ['$element', '$scope', '$window']; +Contextmenu.$inject = ['$element', '$scope', '$transclude']; ngModule.vnComponent('vnContextmenu', { controller: Contextmenu, template: require('./index.html'), bindings: { - target: '@?' + targets: ' - Send consumer report + View consumer report diff --git a/modules/client/front/descriptor/locale/es.yml b/modules/client/front/descriptor/locale/es.yml index 88720ab44..3f59aede8 100644 --- a/modules/client/front/descriptor/locale/es.yml +++ b/modules/client/front/descriptor/locale/es.yml @@ -1,4 +1,4 @@ Simple ticket: Ticket simple -Send consumer report: Enviar informe de consumo +View consumer report: Ver informe de consumo From date: Fecha desde To date: Fecha hasta \ No newline at end of file diff --git a/modules/client/front/index/index.js b/modules/client/front/index/index.js index 4832391ce..f5400e05a 100644 --- a/modules/client/front/index/index.js +++ b/modules/client/front/index/index.js @@ -19,10 +19,6 @@ export default class Controller extends Section { this.$state.go(`ticket.index`, {q: JSON.stringify({clientFk: client.id})}); } - - filterBySelection() { - console.log('Filtro por seleccion'); - } } ngModule.component('vnClientIndex', { diff --git a/modules/invoiceOut/front/descriptor/index.html b/modules/invoiceOut/front/descriptor/index.html index 9baebb636..093d9edf7 100644 --- a/modules/invoiceOut/front/descriptor/index.html +++ b/modules/invoiceOut/front/descriptor/index.html @@ -56,7 +56,7 @@
diff --git a/modules/invoiceOut/front/descriptor/index.js b/modules/invoiceOut/front/descriptor/index.js index f642c3ba7..cb4b131ac 100644 --- a/modules/invoiceOut/front/descriptor/index.js +++ b/modules/invoiceOut/front/descriptor/index.js @@ -22,6 +22,13 @@ class Controller extends Descriptor { .then(() => this.vnApp.showSuccess(this.$t('InvoiceOut booked'))); } + get filter() { + if (this.invoiceOut) + return JSON.stringify({refFk: this.invoiceOut.ref}); + + return null; + } + loadData() { const filter = { include: [ diff --git a/modules/item/front/index/index.html b/modules/item/front/index/index.html index 6470f4640..0ee6a8815 100644 --- a/modules/item/front/index/index.html +++ b/modules/item/front/index/index.html @@ -122,13 +122,4 @@ - - - - Filter by selection - Exclude selection - Remove filter by selection - Order DESC - Order ASC - - \ No newline at end of file + \ No newline at end of file diff --git a/modules/ticket/back/methods/ticket/filter.js b/modules/ticket/back/methods/ticket/filter.js index cedbe8f3b..a81f3794a 100644 --- a/modules/ticket/back/methods/ticket/filter.js +++ b/modules/ticket/back/methods/ticket/filter.js @@ -199,9 +199,11 @@ module.exports = Self => { t.routeFk, t.warehouseFk, t.clientFk, + a.provinceFk, p.name AS province, w.name AS warehouse, am.name AS agencyMode, + am.id AS agencyModeFk, st.name AS state, wk.lastName AS salesPerson, ts.stateFk as stateFk, diff --git a/modules/ticket/front/index/index.html b/modules/ticket/front/index/index.html index ab2501a13..150dcde8f 100644 --- a/modules/ticket/front/index/index.html +++ b/modules/ticket/front/index/index.html @@ -15,13 +15,13 @@ Id - Salesperson + Salesperson Date Hour Alias - Province - State - Agency + Province + State + Agency Warehouse Invoice Closure @@ -30,7 +30,7 @@ - @@ -151,3 +151,17 @@ + + + Filter by selection + Exclude selection + Remove filter + + Filter by selection 2 + Exclude selection 2 + Remove filter 2 + + + \ No newline at end of file diff --git a/modules/ticket/front/index/index.js b/modules/ticket/front/index/index.js index 59e5d949d..bb56f9cbf 100644 --- a/modules/ticket/front/index/index.js +++ b/modules/ticket/front/index/index.js @@ -92,6 +92,61 @@ export default class Controller extends Section { this.selectedTicket = ticket; this.$.summary.show(); } + + filterBySelection(target) { + // const target = $event.target; + const model = this.$.model; + console.log(target); + const table = target.closest('.vn-table'); + const headerCols = table.querySelectorAll('vn-thead vn-th'); + + const row = target.closest('.vn-tr'); + const col = target.closest('vn-td'); + + const rowIndex = row.getAttribute('data-index'); + + const columns = Array.from(row.querySelectorAll('vn-td')); + + const fieldIndex = columns.findIndex(column => column == col); + const fieldName = headerCols[fieldIndex].getAttribute('field'); + + const rowData = model.data[rowIndex]; + + const filter = {where: {}}; + filter['where'][fieldName] = rowData[fieldName]; + console.log(filter); + + model.addFilter(filter); + } + + excludeSelection($event, target) { + const model = this.$.model; + + const table = target.closest('.vn-table'); + const headerCols = table.querySelectorAll('vn-thead vn-th'); + + const row = target.closest('.vn-tr'); + const col = target.closest('vn-td'); + + const rowIndex = row.getAttribute('data-index'); + + const columns = Array.from(row.querySelectorAll('vn-td')); + + const fieldIndex = columns.findIndex(column => column == col); + const fieldName = headerCols[fieldIndex].getAttribute('field'); + + const rowData = model.data[rowIndex]; + + const filter = {where: {}}; + filter['where'][fieldName] = {neq: rowData[fieldName]}; + console.log(filter); + + model.addFilter(filter); + } + + removeFilter() { + this.$.model.removeFilter(); + } } ngModule.component('vnTicketIndex', { diff --git a/modules/ticket/front/index/locale/es.yml b/modules/ticket/front/index/locale/es.yml index dea55b199..acc8adc80 100644 --- a/modules/ticket/front/index/locale/es.yml +++ b/modules/ticket/front/index/locale/es.yml @@ -3,4 +3,7 @@ Go to lines: Ir a lineas Not available: No disponible Payment on account...: Pago a cuenta... Closure: Cierre -You cannot make a payment on account from multiple clients: No puedes realizar un pago a cuenta de clientes diferentes \ No newline at end of file +You cannot make a payment on account from multiple clients: No puedes realizar un pago a cuenta de clientes diferentes +Filter by selection: Filtro por selección +Exclude selection: Excluir selección +Remove filter: Eliminar filtro \ No newline at end of file From 3f1109aee30e11386bd34ae99119035ed32e9e13 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 29 May 2020 12:10:04 +0200 Subject: [PATCH 3/8] Test changes --- modules/ticket/back/methods/ticket/filter.js | 43 +++++++++++++++++++- modules/ticket/front/index/index.html | 4 +- 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/modules/ticket/back/methods/ticket/filter.js b/modules/ticket/back/methods/ticket/filter.js index a81f3794a..a7c545562 100644 --- a/modules/ticket/back/methods/ticket/filter.js +++ b/modules/ticket/back/methods/ticket/filter.js @@ -187,7 +187,7 @@ module.exports = Self => { stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.filter'); - stmt = new ParameterizedSQL( + /* stmt = new ParameterizedSQL( `CREATE TEMPORARY TABLE tmp.filter (INDEX (id)) ENGINE = MEMORY @@ -224,7 +224,46 @@ module.exports = Self => { LEFT JOIN state st ON st.id = ts.stateFk LEFT JOIN client c ON c.id = t.clientFk LEFT JOIN worker wk ON wk.id = c.salesPersonFk - LEFT JOIN account.user u ON u.id = wk.userFk`); + LEFT JOIN account.user u ON u.id = wk.userFk`); */ + stmt = new ParameterizedSQL( + `CREATE TEMPORARY TABLE tmp.filter + (INDEX (id)) + ENGINE = MEMORY + SELECT id, shipped, nickname, refFk, routeFk, warehouseFk + (SELECT + t.id, + t.shipped, + t.nickname, + t.refFk, + t.routeFk, + t.warehouseFk, + t.clientFk, + a.provinceFk, + p.name AS province, + w.name AS warehouse, + am.name AS agencyMode, + am.id AS agencyModeFk, + st.name AS state, + wk.lastName AS salesPerson, + ts.stateFk as stateFk, + ts.alertLevel as alertLevel, + ts.code as alertLevelCode, + u.nickname userNickname, + c.salesPersonFk, + z.hour zoneLanding, + HOUR(z.hour) zoneHour, + MINUTE(z.hour) zoneMinute + FROM ticket t + LEFT JOIN zone z ON z.id = t.zoneFk + LEFT JOIN address a ON a.id = t.addressFk + LEFT JOIN province p ON p.id = a.provinceFk + LEFT JOIN warehouse w ON w.id = t.warehouseFk + LEFT JOIN agencyMode am ON am.id = t.agencyModeFk + LEFT JOIN ticketState ts ON ts.ticketFk = t.id + LEFT JOIN state st ON st.id = ts.stateFk + LEFT JOIN client c ON c.id = t.clientFk + LEFT JOIN worker wk ON wk.id = c.salesPersonFk + LEFT JOIN account.user u ON u.id = wk.userFk)`); if (args.orderFk) { stmt.merge({ diff --git a/modules/ticket/front/index/index.html b/modules/ticket/front/index/index.html index 150dcde8f..a10ec6b06 100644 --- a/modules/ticket/front/index/index.html +++ b/modules/ticket/front/index/index.html @@ -15,11 +15,11 @@ Id - Salesperson + Salesperson Date Hour Alias - Province + Province State Agency Warehouse From ab1e8fb6220a4fd4d849f79326fb6bd8b060a6dc Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Mon, 8 Jun 2020 12:14:27 +0200 Subject: [PATCH 4/8] 2176 First working version --- front/core/components/contextmenu/index.js | 214 ++++++++++--------- modules/ticket/back/methods/ticket/filter.js | 110 ++++------ modules/ticket/front/index/index.html | 32 +-- modules/ticket/front/index/index.js | 55 ----- 4 files changed, 164 insertions(+), 247 deletions(-) diff --git a/front/core/components/contextmenu/index.js b/front/core/components/contextmenu/index.js index a99009d50..5f8a165a5 100755 --- a/front/core/components/contextmenu/index.js +++ b/front/core/components/contextmenu/index.js @@ -5,40 +5,6 @@ export default class Contextmenu { this.element = $element[0]; this.$ = $; this.$transclude = $transclude; - // this.displayMode = 'relative'; - - // Foreach element, apply an addEventListener??? - /* - document.body.addEventListener('contextmenu', event => { - if (!event.defaultPrevented) - event.preventDefault(); - - const target = event.target; - const rect = target.getBoundingClientRect(); - - console.log('ScreenY', event.pageY); - console.log('OffsetY', event.pageX); - - const parent = $.contextmenu; - parent.style.top = event.pageY + 'px'; - parent.style.left = event.pageX + 'px'; - - $.menu.show(parent); - }); */ - } - - $onInit() { - /* const transcludeElement = this.element.querySelector('vn-menu'); - const content = angular.element(transcludeElement); - - this.$transclude(($clone, $scope) => { - this.$contentScope = $scope; - // $scope.$target = 'hola??'; - const list = angular.element(''); - list.append($clone); - - content.append(list); - }, null, 'menu'); */ } get targets() { @@ -51,103 +17,143 @@ export default class Contextmenu { if (!value) return; for (let selector of value) { - const target = document.querySelector(selector);// Find elements + const target = document.querySelector(selector); if (!target) continue; target.addEventListener('contextmenu', event => { + this.target = event.target; + if (!event.defaultPrevented) event.preventDefault(); + if (!this.isFilterEnabled()) return; + const parent = this.$.contextmenu; parent.style.top = event.pageY + 'px'; parent.style.left = event.pageX + 'px'; - this.eventTarget = event.target; - - /* const menu = this.element.querySelector('vn-menu'); - const list = document.createElement('vn-list'); - menu.append(list); - - const transcludeElement = this.element.querySelector('vn-list'); - const content = angular.element(transcludeElement); - console.log(transcludeElement); - - this.$transclude(($clone, $scope) => { - this.$contentScope = $scope; - $scope.$target = 'hola??'; - console.log($clone); - content.append($clone); - }, null, 'menu'); */ - this.$.menu.show(parent); }); } } - /* const transcludeElement = this.element.querySelector('vn-list'); - const content = angular.element(transcludeElement); - console.log(transcludeElement); + get row() { + if (!this.target) return null; - this.$transclude(($clone, $scope) => { - this.$contentScope = $scope; - $scope.$target = 'hola??'; - content.append($clone); - }); */ + return this.target.closest('vn-tr, .vn-tr'); + } + get rowIndex() { + if (!this.row) return null; + const table = this.row.closest('vn-table, .vn-table'); + const tBody = table.querySelector('vn-tbody, .vn-tbody'); + const rows = tBody.querySelectorAll('vn-tr, .vn-tr'); + + return Array.from(rows).findIndex( + rowItem => rowItem == this.row + ); + } + + get rowData() { + const model = this.model; + const rowData = model.data[this.rowIndex]; + + return rowData; + } + + get cell() { + if (!this.target) return null; + + return this.target.closest('vn-td, .vn-td'); + } + + get cellIndex() { + if (!this.row) return null; + + const cells = this.row.querySelectorAll('vn-td, .vn-td'); + return Array.from(cells).findIndex( + cellItem => cellItem == this.cell + ); + } + + 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 headerCell = headerCells && headerCells[this.cellIndex]; + + return headerCell; + } + + /** + * Selected model field name + * + * @return {string} + */ + get fieldName() { + if (!this.rowHeader) return null; + + return this.rowHeader.getAttribute('field'); + } + + /** + * Selected field value + * + * @return {any} + */ + get fieldValue() { + return this.rowData[this.fieldName]; + } + + /** + * Returns true if filter is not disabled + * + * @return {Boolean} + */ + isFilterEnabled() { + if (!this.rowHeader) return true; + const isEnabled = this.rowHeader.getAttribute('filter-enabled'); + + return isEnabled != 'false'; + } + + /** + * Returns true if filter + * by selection is allowed + * + * @return {Boolean} + */ + isFilterAllowed() { + if (!this.target) return false; + const isTableCell = this.target.closest('vn-td, .vn-td'); + + return isTableCell && this.fieldName; + } + + /** + * Filter by current field selection + */ filterBySelection() { - // const target = $event.target; - const model = this.model; - const target = this.eventTarget; - console.log(target); - - const table = target.closest('.vn-table'); - const headerCols = table.querySelectorAll('vn-thead vn-th'); - - const row = target.closest('.vn-tr'); - const col = target.closest('vn-td'); - - const rowIndex = row.getAttribute('data-index'); - - const columns = Array.from(row.querySelectorAll('vn-td')); - - const fieldIndex = columns.findIndex(column => column == col); - const fieldName = headerCols[fieldIndex].getAttribute('field'); - - const rowData = model.data[rowIndex]; - const filter = {where: {}}; - filter['where'][fieldName] = rowData[fieldName]; - console.log(filter); + filter['where'][this.fieldName] = this.fieldValue; - model.addFilter(filter); + this.model.addFilter(filter); } + /** + * Exclude by current field selection + */ excludeSelection() { - const model = this.model; - const target = this.eventTarget; - - const table = target.closest('.vn-table'); - const headerCols = table.querySelectorAll('vn-thead vn-th'); - - const row = target.closest('.vn-tr'); - const col = target.closest('vn-td'); - - const rowIndex = row.getAttribute('data-index'); - - const columns = Array.from(row.querySelectorAll('vn-td')); - - const fieldIndex = columns.findIndex(column => column == col); - const fieldName = headerCols[fieldIndex].getAttribute('field'); - - const rowData = model.data[rowIndex]; - const filter = {where: {}}; - filter['where'][fieldName] = {neq: rowData[fieldName]}; - console.log(filter); + filter['where'][this.fieldName] = {neq: this.fieldValue}; - model.addFilter(filter); + this.model.addFilter(filter); } + /** + * Removes all applied filters + */ removeFilter() { this.model.removeFilter(); } diff --git a/modules/ticket/back/methods/ticket/filter.js b/modules/ticket/back/methods/ticket/filter.js index a7c545562..f191247cf 100644 --- a/modules/ticket/back/methods/ticket/filter.js +++ b/modules/ticket/back/methods/ticket/filter.js @@ -186,84 +186,46 @@ module.exports = Self => { let stmt; stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.filter'); - - /* stmt = new ParameterizedSQL( - `CREATE TEMPORARY TABLE tmp.filter - (INDEX (id)) - ENGINE = MEMORY - SELECT - t.id, - t.shipped, - t.nickname, - t.refFk, - t.routeFk, - t.warehouseFk, - t.clientFk, - a.provinceFk, - p.name AS province, - w.name AS warehouse, - am.name AS agencyMode, - am.id AS agencyModeFk, - st.name AS state, - wk.lastName AS salesPerson, - ts.stateFk as stateFk, - ts.alertLevel as alertLevel, - ts.code as alertLevelCode, - u.nickname userNickname, - c.salesPersonFk, - z.hour zoneLanding, - HOUR(z.hour) zoneHour, - MINUTE(z.hour) zoneMinute - FROM ticket t - LEFT JOIN zone z ON z.id = t.zoneFk - LEFT JOIN address a ON a.id = t.addressFk - LEFT JOIN province p ON p.id = a.provinceFk - LEFT JOIN warehouse w ON w.id = t.warehouseFk - LEFT JOIN agencyMode am ON am.id = t.agencyModeFk - LEFT JOIN ticketState ts ON ts.ticketFk = t.id - LEFT JOIN state st ON st.id = ts.stateFk - LEFT JOIN client c ON c.id = t.clientFk - LEFT JOIN worker wk ON wk.id = c.salesPersonFk - LEFT JOIN account.user u ON u.id = wk.userFk`); */ stmt = new ParameterizedSQL( `CREATE TEMPORARY TABLE tmp.filter (INDEX (id)) ENGINE = MEMORY - SELECT id, shipped, nickname, refFk, routeFk, warehouseFk - (SELECT - t.id, - t.shipped, - t.nickname, - t.refFk, - t.routeFk, - t.warehouseFk, - t.clientFk, - a.provinceFk, - p.name AS province, - w.name AS warehouse, - am.name AS agencyMode, - am.id AS agencyModeFk, - st.name AS state, - wk.lastName AS salesPerson, - ts.stateFk as stateFk, - ts.alertLevel as alertLevel, - ts.code as alertLevelCode, - u.nickname userNickname, - c.salesPersonFk, - z.hour zoneLanding, - HOUR(z.hour) zoneHour, - MINUTE(z.hour) zoneMinute - FROM ticket t - LEFT JOIN zone z ON z.id = t.zoneFk - LEFT JOIN address a ON a.id = t.addressFk - LEFT JOIN province p ON p.id = a.provinceFk - LEFT JOIN warehouse w ON w.id = t.warehouseFk - LEFT JOIN agencyMode am ON am.id = t.agencyModeFk - LEFT JOIN ticketState ts ON ts.ticketFk = t.id - LEFT JOIN state st ON st.id = ts.stateFk - LEFT JOIN client c ON c.id = t.clientFk - LEFT JOIN worker wk ON wk.id = c.salesPersonFk - LEFT JOIN account.user u ON u.id = wk.userFk)`); + SELECT * FROM ( + SELECT + t.id, + t.shipped, + CAST(DATE(t.shipped) AS CHAR) AS shippedDate, + t.nickname, + t.refFk, + t.routeFk, + t.warehouseFk, + t.clientFk, + a.provinceFk, + p.name AS province, + w.name AS warehouse, + am.name AS agencyMode, + am.id AS agencyModeFk, + st.name AS state, + wk.lastName AS salesPerson, + ts.stateFk as stateFk, + ts.alertLevel as alertLevel, + ts.code as alertLevelCode, + u.nickname userNickname, + c.salesPersonFk, + z.hour zoneLanding, + HOUR(z.hour) zoneHour, + MINUTE(z.hour) zoneMinute + FROM ticket t + LEFT JOIN zone z ON z.id = t.zoneFk + LEFT JOIN address a ON a.id = t.addressFk + LEFT JOIN province p ON p.id = a.provinceFk + LEFT JOIN warehouse w ON w.id = t.warehouseFk + LEFT JOIN agencyMode am ON am.id = t.agencyModeFk + LEFT JOIN ticketState ts ON ts.ticketFk = t.id + LEFT JOIN state st ON st.id = ts.stateFk + LEFT JOIN client c ON c.id = t.clientFk + LEFT JOIN worker wk ON wk.id = c.salesPersonFk + LEFT JOIN account.user u ON u.id = wk.userFk) t`); if (args.orderFk) { stmt.merge({ diff --git a/modules/ticket/front/index/index.html b/modules/ticket/front/index/index.html index a10ec6b06..ee6e53a12 100644 --- a/modules/ticket/front/index/index.html +++ b/modules/ticket/front/index/index.html @@ -15,14 +15,14 @@ Id - Salesperson - Date + Salesperson + Date Hour Alias - Province + Province State Agency - Warehouse + Warehouse Invoice Closure Total @@ -153,15 +153,19 @@ - Filter by selection - Exclude selection - Remove filter - - Filter by selection 2 - Exclude selection 2 - Remove filter 2 - + + Filter by selection + + + Exclude selection + + + Remove filter + \ No newline at end of file diff --git a/modules/ticket/front/index/index.js b/modules/ticket/front/index/index.js index bb56f9cbf..59e5d949d 100644 --- a/modules/ticket/front/index/index.js +++ b/modules/ticket/front/index/index.js @@ -92,61 +92,6 @@ export default class Controller extends Section { this.selectedTicket = ticket; this.$.summary.show(); } - - filterBySelection(target) { - // const target = $event.target; - const model = this.$.model; - console.log(target); - const table = target.closest('.vn-table'); - const headerCols = table.querySelectorAll('vn-thead vn-th'); - - const row = target.closest('.vn-tr'); - const col = target.closest('vn-td'); - - const rowIndex = row.getAttribute('data-index'); - - const columns = Array.from(row.querySelectorAll('vn-td')); - - const fieldIndex = columns.findIndex(column => column == col); - const fieldName = headerCols[fieldIndex].getAttribute('field'); - - const rowData = model.data[rowIndex]; - - const filter = {where: {}}; - filter['where'][fieldName] = rowData[fieldName]; - console.log(filter); - - model.addFilter(filter); - } - - excludeSelection($event, target) { - const model = this.$.model; - - const table = target.closest('.vn-table'); - const headerCols = table.querySelectorAll('vn-thead vn-th'); - - const row = target.closest('.vn-tr'); - const col = target.closest('vn-td'); - - const rowIndex = row.getAttribute('data-index'); - - const columns = Array.from(row.querySelectorAll('vn-td')); - - const fieldIndex = columns.findIndex(column => column == col); - const fieldName = headerCols[fieldIndex].getAttribute('field'); - - const rowData = model.data[rowIndex]; - - const filter = {where: {}}; - filter['where'][fieldName] = {neq: rowData[fieldName]}; - console.log(filter); - - model.addFilter(filter); - } - - removeFilter() { - this.$.model.removeFilter(); - } } ngModule.component('vnTicketIndex', { From ba9a44dec1b9f0855c0cf30239fa206f8816c77e Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Mon, 8 Jun 2020 13:06:33 +0200 Subject: [PATCH 5/8] Updated back unit test --- modules/ticket/back/methods/ticket/filter.js | 26 ++++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/modules/ticket/back/methods/ticket/filter.js b/modules/ticket/back/methods/ticket/filter.js index f191247cf..5f3332173 100644 --- a/modules/ticket/back/methods/ticket/filter.js +++ b/modules/ticket/back/methods/ticket/filter.js @@ -138,22 +138,22 @@ module.exports = Self => { switch (param) { case 'search': return /^\d+$/.test(value) - ? {'t.id': {inq: value}} - : {'t.nickname': {like: `%${value}%`}}; + ? {'id': {inq: value}} + : {'nickname': {like: `%${value}%`}}; case 'from': - return {'t.shipped': {gte: value}}; + return {'shipped': {gte: value}}; case 'to': - return {'t.shipped': {lte: value}}; + return {'shipped': {lte: value}}; case 'nickname': - return {'t.nickname': {like: `%${value}%`}}; + return {'nickname': {like: `%${value}%`}}; case 'refFk': - return {'t.refFk': value}; + return {'refFk': value}; case 'salesPersonFk': - return {'c.salesPersonFk': value}; + return {'salesPersonFk': value}; case 'provinceFk': - return {'a.provinceFk': value}; + return {'provinceFk': value}; case 'stateFk': - return {'ts.stateFk': value}; + return {'stateFk': value}; case 'mine': case 'myTeam': return {'c.salesPersonFk': {inq: teamIds}}; @@ -162,13 +162,13 @@ module.exports = Self => { case 'pending': if (value) { return {and: [ - {'st.alertLevel': 0}, - {'st.code': {neq: 'OK'}}, - {'st.code': {neq: 'BOARDING'}} + {'alertLevel': 0}, + {'alertLevelCode': {neq: 'OK'}}, + {'alertLevelCode': {neq: 'BOARDING'}} ]}; } else { return {and: [ - {'st.alertLevel': {gt: 0}} + {'alertLevel': {gt: 0}} ]}; } case 'id': From cda6e3762042fd2da538af785c8306aae6040d91 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Mon, 8 Jun 2020 13:07:34 +0200 Subject: [PATCH 6/8] Removed console.log --- modules/zone/front/descriptor/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/zone/front/descriptor/index.js b/modules/zone/front/descriptor/index.js index 4b51c8011..288267bfe 100644 --- a/modules/zone/front/descriptor/index.js +++ b/modules/zone/front/descriptor/index.js @@ -19,7 +19,6 @@ class Controller extends Descriptor { const ticketsAmount = res.data.length; if (ticketsAmount) { const params = {ticketsAmount}; - console.log('ticketsAmount', res.data); const question = $t('This zone contains tickets', params, null, null, 'sanitizeParameters'); this.$.deleteZone.question = question; this.$.deleteZone.show(); From 6883303bb1101917549814294448e4befc3377be Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Mon, 8 Jun 2020 13:15:48 +0200 Subject: [PATCH 7/8] Added scss file --- front/core/components/contextmenu/index.html | 2 +- front/core/components/contextmenu/index.js | 2 ++ front/core/components/contextmenu/style.scss | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 front/core/components/contextmenu/style.scss diff --git a/front/core/components/contextmenu/index.html b/front/core/components/contextmenu/index.html index 7e7cae138..600a5ca03 100644 --- a/front/core/components/contextmenu/index.html +++ b/front/core/components/contextmenu/index.html @@ -1,4 +1,4 @@ -
+
diff --git a/front/core/components/contextmenu/index.js b/front/core/components/contextmenu/index.js index 5f8a165a5..061d4cf09 100755 --- a/front/core/components/contextmenu/index.js +++ b/front/core/components/contextmenu/index.js @@ -1,4 +1,6 @@ import ngModule from '../../module'; +import './style.scss'; + export default class Contextmenu { constructor($element, $, $transclude) { this.$element = $element; diff --git a/front/core/components/contextmenu/style.scss b/front/core/components/contextmenu/style.scss new file mode 100644 index 000000000..eac46554e --- /dev/null +++ b/front/core/components/contextmenu/style.scss @@ -0,0 +1,3 @@ +section[vn-id="contextmenu"] { + position: absolute +} \ No newline at end of file From 05b5c452a991c4a6db10f222bb1ddb27e0965b37 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Mon, 8 Jun 2020 13:17:18 +0200 Subject: [PATCH 8/8] Removed attribute --- modules/ticket/front/index/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/front/index/index.html b/modules/ticket/front/index/index.html index ee6e53a12..07857c381 100644 --- a/modules/ticket/front/index/index.html +++ b/modules/ticket/front/index/index.html @@ -30,7 +30,7 @@ -