From c270ec620762092ed5170db6316f82d33e2c1c45 Mon Sep 17 00:00:00 2001 From: joan Date: Thu, 11 Feb 2021 15:06:41 +0100 Subject: [PATCH] Contextmenu fixes --- db/changes/10281-valentineDay/00-ACL.sql | 1 + front/core/components/contextmenu/index.js | 38 +++++++++++++++++-- .../back/methods/invoice-in/filter.js | 22 ++++++----- modules/invoiceIn/front/index/index.html | 3 +- modules/invoiceIn/front/index/index.js | 2 + modules/item/front/last-entries/index.html | 5 +++ modules/item/front/request/index.html | 5 +++ modules/ticket/front/index/index.html | 5 +++ modules/ticket/front/index/locale/es.yml | 1 + modules/travel/front/index/index.html | 5 +++ 10 files changed, 74 insertions(+), 13 deletions(-) create mode 100644 db/changes/10281-valentineDay/00-ACL.sql diff --git a/db/changes/10281-valentineDay/00-ACL.sql b/db/changes/10281-valentineDay/00-ACL.sql new file mode 100644 index 0000000000..67b8fc8c3f --- /dev/null +++ b/db/changes/10281-valentineDay/00-ACL.sql @@ -0,0 +1 @@ +INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId) VALUES ('InvoiceIn', '*', '*', 'ALLOW', 'ROLE', 'administrative'); diff --git a/front/core/components/contextmenu/index.js b/front/core/components/contextmenu/index.js index add5a8b66a..2f91404fe4 100755 --- a/front/core/components/contextmenu/index.js +++ b/front/core/components/contextmenu/index.js @@ -29,7 +29,7 @@ export default class Contextmenu { if (!event.defaultPrevented) event.preventDefault(); - if (!this.isFilterEnabled()) return; + if (!this.isMenuEnabled()) return; const parent = this.$.contextmenu; parent.style.top = event.pageY + 'px'; @@ -121,13 +121,31 @@ export default class Contextmenu { return isEnabled != 'false'; } + isMenuEnabled() { + if (!this.rowHeader) return true; + const isEnabled = this.rowHeader.getAttribute('menu-enabled'); + + return isEnabled != 'false'; + } + /** * Returns true if filter - * by selection is allowed + * by selection is enabled and + * the menu can be interacted * * @return {Boolean} */ isFilterAllowed() { + return this.isActionAllowed() && this.isFilterEnabled(); + } + + /** + * Returns true if the + * context menu can be interacted + * + * @return {Boolean} + */ + isActionAllowed() { if (!this.target) return false; const isTableCell = this.target.closest('vn-td, .vn-td'); @@ -179,9 +197,13 @@ export default class Contextmenu { if (!where) return; const whereKeys = Object.keys(where); - for (let key of whereKeys) + for (let key of whereKeys) { removeProp(where, filterKey, key); + if (!Object.keys(where)) + delete userFilter.where; + } + function removeProp(instance, findProp, prop) { if (prop == findProp) delete instance[prop]; @@ -208,6 +230,16 @@ export default class Contextmenu { const userParams = this.model.userParams; this.model.applyFilter(null, userParams); } + + /** + * Copies the current field + * value to the clipboard + */ + copyValue() { + console.log(this.field); + if (navigator && navigator.clipboard) + navigator.clipboard.writeText(this.fieldValue); + } } Contextmenu.$inject = ['$element', '$scope', '$transclude']; diff --git a/modules/invoiceIn/back/methods/invoice-in/filter.js b/modules/invoiceIn/back/methods/invoice-in/filter.js index 0afbcf2c9d..3575462252 100644 --- a/modules/invoiceIn/back/methods/invoice-in/filter.js +++ b/modules/invoiceIn/back/methods/invoice-in/filter.js @@ -60,11 +60,6 @@ module.exports = Self => { type: 'number', description: 'The account number' }, - { - arg: 'hasPdf', - type: 'boolean', - description: 'Whether the the invoice has PDF or not', - }, { arg: 'isBooked', type: 'boolean', @@ -90,12 +85,9 @@ module.exports = Self => { return /^\d+$/.test(value) ? {'ii.id': value} : {'s.name': {like: `%${value}%`}}; - case 'hasPdf': - return {'i.hasPdf': value}; case 'account': case 'fi': return {[`s.${param}`]: value}; - case 'amount': case 'supplierRef': case 'serialNumber': case 'serial': @@ -130,13 +122,25 @@ module.exports = Self => { LEFT JOIN company co ON co.id = ii.companyFk` ); - stmt.merge(conn.makeWhere(filter.where)); + const sqlWhere = conn.makeWhere(filter.where); + + stmt.merge(sqlWhere); stmt.merge(`GROUP BY ii.id`); + + const amount = ctx.args.amount; + if (amount) { + stmt.merge({ + sql: `HAVING SUM(iid.amount) = ?`, + params: [amount], + }); + } + stmt.merge(conn.makePagination(filter)); let itemsIndex = stmts.push(stmt) - 1; let sql = ParameterizedSQL.join(stmts, ';'); + console.log(sql.sql); let result = await conn.executeStmt(sql); return itemsIndex === 0 ? result : result[itemsIndex]; }; diff --git a/modules/invoiceIn/front/index/index.html b/modules/invoiceIn/front/index/index.html index fecf2a635f..b975d0905f 100644 --- a/modules/invoiceIn/front/index/index.html +++ b/modules/invoiceIn/front/index/index.html @@ -16,7 +16,7 @@ Account Issued Is booked - Amount + Amount @@ -93,6 +93,7 @@ Remove all filters Copy value diff --git a/modules/invoiceIn/front/index/index.js b/modules/invoiceIn/front/index/index.js index b7e9d04c11..c8de337838 100644 --- a/modules/invoiceIn/front/index/index.js +++ b/modules/invoiceIn/front/index/index.js @@ -30,6 +30,8 @@ export default class Controller extends Section { case 'account': case 'fi': return {[`s.${param}`]: value}; + default: + return {[param]: value}; } } } diff --git a/modules/item/front/last-entries/index.html b/modules/item/front/last-entries/index.html index 4d8dea570d..1a79cb7f27 100644 --- a/modules/item/front/last-entries/index.html +++ b/modules/item/front/last-entries/index.html @@ -109,5 +109,10 @@ ng-click="contextmenu.removeAllFilters()" > Remove all filters + + Copy value + \ No newline at end of file diff --git a/modules/item/front/request/index.html b/modules/item/front/request/index.html index 9b129a0170..5b8f0d3fca 100644 --- a/modules/item/front/request/index.html +++ b/modules/item/front/request/index.html @@ -153,5 +153,10 @@ ng-click="contextmenu.removeAllFilters()" > Remove all filters + + Copy value + \ No newline at end of file diff --git a/modules/ticket/front/index/index.html b/modules/ticket/front/index/index.html index 4243ef1ab9..364ad8448a 100644 --- a/modules/ticket/front/index/index.html +++ b/modules/ticket/front/index/index.html @@ -213,5 +213,10 @@ ng-click="contextmenu.removeAllFilters()" > Remove all filters + + Copy value + \ No newline at end of file diff --git a/modules/ticket/front/index/locale/es.yml b/modules/ticket/front/index/locale/es.yml index 006ac9f6eb..1545c5e535 100644 --- a/modules/ticket/front/index/locale/es.yml +++ b/modules/ticket/front/index/locale/es.yml @@ -9,4 +9,5 @@ Filter by selection: Filtro por selección Exclude selection: Excluir selección Remove filter: Quitar filtro por selección Remove all filters: Eliminar todos los filtros +Copy value: Copiar valor No verified data: Sin datos comprobados \ No newline at end of file diff --git a/modules/travel/front/index/index.html b/modules/travel/front/index/index.html index 1a0f59e149..77af415ebe 100644 --- a/modules/travel/front/index/index.html +++ b/modules/travel/front/index/index.html @@ -106,5 +106,10 @@ ng-click="contextmenu.removeAllFilters()" > Remove all filters + + Copy value + \ No newline at end of file