From cff1e6cfbfa084cdc51f333867ce5f04f2576212 Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 4 Mar 2022 11:28:26 +0100 Subject: [PATCH] feat: check cannot attach more than one pdf --- modules/route/back/methods/agency-term/filter.js | 7 ++++++- modules/route/front/agency-term/createInvoiceIn/index.js | 4 +++- modules/route/front/agency-term/locale/es.yml | 3 ++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/modules/route/back/methods/agency-term/filter.js b/modules/route/back/methods/agency-term/filter.js index 0b6e2635a..48a85e629 100644 --- a/modules/route/back/methods/agency-term/filter.js +++ b/modules/route/back/methods/agency-term/filter.js @@ -1,4 +1,5 @@ const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; +const mergeFilters = require('vn-loopback/util/filter').mergeFilters; module.exports = Self => { Self.remoteMethodCtx('filter', { @@ -24,6 +25,10 @@ module.exports = Self => { Self.filter = async(ctx, filter, options) => { const conn = Self.dataSource.connector; + const myOptions = {}; + + if (typeof options == 'object') + Object.assign(myOptions, options); let stmts = []; let stmt; @@ -62,7 +67,7 @@ module.exports = Self => { let agencyTerm = stmts.push(stmt) - 1; let sql = ParameterizedSQL.join(stmts, ';'); - let result = await conn.executeStmt(sql); + let result = await conn.executeStmt(sql, myOptions); const models = Self.app.models; for (let agencyTerm of result) diff --git a/modules/route/front/agency-term/createInvoiceIn/index.js b/modules/route/front/agency-term/createInvoiceIn/index.js index 9bfa30d51..7ab8adbfa 100644 --- a/modules/route/front/agency-term/createInvoiceIn/index.js +++ b/modules/route/front/agency-term/createInvoiceIn/index.js @@ -1,6 +1,7 @@ import ngModule from '../../module'; import Section from 'salix/components/section'; import './style.scss'; +import UserError from 'core/lib/user-error'; class Controller extends Section { constructor($element, $) { @@ -81,7 +82,8 @@ class Controller extends Section { }; this.$http(options).then(res => { if (res) { - let addedDms = res.data; + const addedDms = res.data; + if (addedDms.length > 1) throw new UserError('You cannot attach more than one document'); this.$.watcher.updateOriginalData(); const params = { diff --git a/modules/route/front/agency-term/locale/es.yml b/modules/route/front/agency-term/locale/es.yml index 98301ea6e..1ba1d9ef5 100644 --- a/modules/route/front/agency-term/locale/es.yml +++ b/modules/route/front/agency-term/locale/es.yml @@ -3,4 +3,5 @@ Buy requests: Peticiones de compra Agency route: Agencia ruta Agency Agreement: Agencia acuerdo Autonomous: Autónomos -Two autonomous cannot be counted at the same time: Dos autonónomos no pueden ser contabilizados al mismo tiempo \ No newline at end of file +Two autonomous cannot be counted at the same time: Dos autonónomos no pueden ser contabilizados al mismo tiempo +You cannot attach more than one document: No puedes adjuntar más de un documento \ No newline at end of file