From 1c49c073eebf29a7da16101f6bce11ed1eaa37ad Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 13 Nov 2024 15:45:06 +0100 Subject: [PATCH 1/7] feat: refs #8002 drop support btn --- front/core/components/snackbar/snackbar.js | 11 +---------- front/core/components/support-dialog/index.js | 12 ++++++------ 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/front/core/components/snackbar/snackbar.js b/front/core/components/snackbar/snackbar.js index b380c47c3..49d784067 100644 --- a/front/core/components/snackbar/snackbar.js +++ b/front/core/components/snackbar/snackbar.js @@ -27,17 +27,8 @@ export default class Controller extends Component { setTimeout(() => element.classList.add('shown'), 30); shape.element = element; - if (data.additionalData && this.vnToken.token) { + if (data.additionalData && this.vnToken.token) this.additionalData = data.additionalData; - let supportButton = document.createElement('i'); - supportButton.setAttribute('class', 'material-icons clickable'); - supportButton.addEventListener('click', () => this.$.supportDialog.show()); - element.appendChild(supportButton); - - let buttonIcon = 'support_agent'; - buttonIcon = document.createTextNode(buttonIcon); - supportButton.appendChild(buttonIcon); - } if (shape.type) element.classList.add(shape.type); diff --git a/front/core/components/support-dialog/index.js b/front/core/components/support-dialog/index.js index d15c14b4a..45a8147fe 100644 --- a/front/core/components/support-dialog/index.js +++ b/front/core/components/support-dialog/index.js @@ -10,12 +10,12 @@ export default class Controller extends Dialog { if (response !== 'accept') return super.responseHandler(response); - this.$http.post('Ostickets/send-to-support', { - reason: this.reason, - additionalData: this.additionalData - }) - .then(() => super.responseHandler(response)) - .then(() => this.vnApp.showSuccess(this.$t('Email sended!'))); + // this.$http.post('Ostickets/send-to-support', { + // reason: this.reason, + // additionalData: this.additionalData + // }) + // .then(() => super.responseHandler(response)) + // .then(() => this.vnApp.showSuccess(this.$t('Email sended!'))); } } From b75b369716ded8737a6f32d65ec6c93e0f0c25ad Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 13 Nov 2024 17:35:27 +0100 Subject: [PATCH 2/7] feat: refs #8002 adjust to lilium --- back/methods/osticket/sendToSupport.js | 37 ++++++++++++-------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/back/methods/osticket/sendToSupport.js b/back/methods/osticket/sendToSupport.js index e17093839..d05f1a82e 100644 --- a/back/methods/osticket/sendToSupport.js +++ b/back/methods/osticket/sendToSupport.js @@ -29,35 +29,32 @@ module.exports = Self => { }); Self.sendToSupport = async(ctx, reason, additionalData) => { + const userId = ctx.req.accessToken.userId; const emailUser = - await Self.app.models.EmailUser.findById(ctx.req.accessToken.userId, {fields: ['email']}); + await Self.app.models.EmailUser.findById(userId, {fields: ['email']}); + const {code, message, path, request, status, statusText, config: errConfig, name} = additionalData; - let html = `Motivo:
${reason}
`; - html += `Usuario:
${ctx.req.accessToken.userId} ${emailUser.email}
`; + let html = `

Motivo: ${reason}

`; + html += `

Usuario: ${userId} ${emailUser.email}

`; + html += `

Additional Data:

`; + html += `'; - delete additionalData.backError.config.headers.Authorization; - const httpRequest = JSON.parse(additionalData?.httpRequest); - - if (httpRequest) - delete httpRequest.config.headers.Authorization; - additionalData.httpRequest = httpRequest; - - for (const data in additionalData) - html += `${data}:
${tryParse(additionalData[data])}
`; - - const subjectReason = httpRequest?.data?.error; await smtp.send({ to: `${config.app.reportEmail}, ${emailUser.email}`, - subject: - '[Support-Salix] ' + - additionalData?.frontPath + ' ' + - subjectReason?.name + ':' + - subjectReason?.message, + subject: `[Support-Salix] ${path} ${name}: ${message}`, html }); }; - function tryParse(value) { + function parse(value) { try { try { value = JSON.parse(value); From 873b91f1130beb17cc05367d8aecea310914c386 Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 13 Nov 2024 17:45:15 +0100 Subject: [PATCH 3/7] chore: refs #8002 drop comments --- front/core/components/support-dialog/index.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/front/core/components/support-dialog/index.js b/front/core/components/support-dialog/index.js index 45a8147fe..82f086184 100644 --- a/front/core/components/support-dialog/index.js +++ b/front/core/components/support-dialog/index.js @@ -9,13 +9,6 @@ export default class Controller extends Dialog { responseHandler(response) { if (response !== 'accept') return super.responseHandler(response); - - // this.$http.post('Ostickets/send-to-support', { - // reason: this.reason, - // additionalData: this.additionalData - // }) - // .then(() => super.responseHandler(response)) - // .then(() => this.vnApp.showSuccess(this.$t('Email sended!'))); } } From 285fe67ca5f64c4db744ace0ded4a95d1332372a Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 14 Nov 2024 10:38:44 +0100 Subject: [PATCH 4/7] chore: refs #8002 drop useless code --- front/core/components/snackbar/snackbar.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/front/core/components/snackbar/snackbar.js b/front/core/components/snackbar/snackbar.js index 49d784067..cce285d14 100644 --- a/front/core/components/snackbar/snackbar.js +++ b/front/core/components/snackbar/snackbar.js @@ -27,9 +27,6 @@ export default class Controller extends Component { setTimeout(() => element.classList.add('shown'), 30); shape.element = element; - if (data.additionalData && this.vnToken.token) - this.additionalData = data.additionalData; - if (shape.type) element.classList.add(shape.type); From dbf5953d69f55e5f7bb866318fd01aff6de2a98b Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 14 Nov 2024 10:47:39 +0100 Subject: [PATCH 5/7] refactor: refs #8002 use loop wip --- back/methods/osticket/sendToSupport.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/back/methods/osticket/sendToSupport.js b/back/methods/osticket/sendToSupport.js index d05f1a82e..dabd35f80 100644 --- a/back/methods/osticket/sendToSupport.js +++ b/back/methods/osticket/sendToSupport.js @@ -32,21 +32,23 @@ module.exports = Self => { const userId = ctx.req.accessToken.userId; const emailUser = await Self.app.models.EmailUser.findById(userId, {fields: ['email']}); - const {code, message, path, request, status, statusText, config: errConfig, name} = additionalData; let html = `

Motivo: ${reason}

`; html += `

Usuario: ${userId} ${emailUser.email}

`; html += `

Additional Data:

`; - html += `
  • Code: ${code}
  • `; - html += `
  • Message: ${message}
  • `; - html += `
  • Path: ${path}
  • `; - html += `
  • Request: ${request}
  • `; - html += `
  • Status: ${status}
  • `; - html += `
  • StatusText: ${statusText}
  • `; - html += `
  • Config:
    • `; - for (const [key, val] of Object.entries(errConfig)) html += `
    • ${key}: ${parse(val)}
    • `; - html += '
'; + html += '
    '; + for (const [key, val] of Object.entries(additionalData)) { + if (key !== 'config') html += `
  • ${key}: ${parse(val)}
  • `; + else { + html += `
  • ${key}:
    • `; + for (const [confKey, confVal] of Object.entries(val)) + html += `
    • ${confKey}: ${parse(confVal)}
    • `; + html += '
    '; + } + } + html += '
'; + const {message, path, name} = additionalData; await smtp.send({ to: `${config.app.reportEmail}, ${emailUser.email}`, subject: `[Support-Salix] ${path} ${name}: ${message}`, From fad6f33b7c981536f23ce4d85cd397ee6c61e8c2 Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 4 Dec 2024 12:33:17 +0100 Subject: [PATCH 6/7] fix: refs #7031 remove check --- db/versions/11376-pinkBamboo/00-firstScript.sql | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 db/versions/11376-pinkBamboo/00-firstScript.sql diff --git a/db/versions/11376-pinkBamboo/00-firstScript.sql b/db/versions/11376-pinkBamboo/00-firstScript.sql new file mode 100644 index 000000000..607a22b4d --- /dev/null +++ b/db/versions/11376-pinkBamboo/00-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE `zone` MODIFY COLUMN `price` DECIMAL(10,2) NOT NULL DEFAULT 0.00 CHECK (`price` > 0); + From 483966501a2b6e46ade7e13d79c334df1fa9d565 Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 5 Dec 2024 08:31:09 +0100 Subject: [PATCH 7/7] fix: refs #7031 fix vnPrice --- db/versions/11376-pinkBamboo/00-firstScript.sql | 2 +- loopback/locale/en.json | 7 ++++--- loopback/locale/es.json | 10 +++++----- modules/zone/back/models/zone.js | 14 ++++++++++++++ 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/db/versions/11376-pinkBamboo/00-firstScript.sql b/db/versions/11376-pinkBamboo/00-firstScript.sql index 607a22b4d..0c1e71a2f 100644 --- a/db/versions/11376-pinkBamboo/00-firstScript.sql +++ b/db/versions/11376-pinkBamboo/00-firstScript.sql @@ -1,2 +1,2 @@ -ALTER TABLE `zone` MODIFY COLUMN `price` DECIMAL(10,2) NOT NULL DEFAULT 0.00 CHECK (`price` > 0); +ALTER TABLE vn.`zone` MODIFY COLUMN `price` DECIMAL(10,2); diff --git a/loopback/locale/en.json b/loopback/locale/en.json index ff0281d4a..af07b29fa 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -246,6 +246,7 @@ "ticketLostExpedition": "The ticket [{{ticketId}}]({{{ticketUrl}}}) has the following lost expedition:{{ expeditionId }}", "The raid information is not correct": "The raid information is not correct", "Payment method is required": "Payment method is required", - "Sales already moved": "Sales already moved", - "There are tickets to be invoiced": "There are tickets to be invoiced for this zone, please delete them first" -} + "Sales already moved": "Sales already moved", + "There are tickets to be invoiced": "There are tickets to be invoiced for this zone, please delete them first", + "Price cannot be blank": "Price cannot be blank" +} \ No newline at end of file diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 1eb953d89..37572de03 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -388,8 +388,8 @@ "You do not have permission to modify the booked field": "No tienes permisos para modificar el campo contabilizada", "ticketLostExpedition": "El ticket [{{ticketId}}]({{{ticketUrl}}}) tiene la siguiente expedición perdida:{{ expeditionId }}", "The web user's email already exists": "El correo del usuario web ya existe", - "Sales already moved": "Ya han sido transferidas", - "The raid information is not correct": "La información de la redada no es correcta", - "There are tickets to be invoiced": "Hay tickets para esta zona, borralos primero" -} - + "Sales already moved": "Ya han sido transferidas", + "The raid information is not correct": "La información de la redada no es correcta", + "There are tickets to be invoiced": "Hay tickets para esta zona, borralos primero", + "Price cannot be blank": "Price cannot be blank" +} \ No newline at end of file diff --git a/modules/zone/back/models/zone.js b/modules/zone/back/models/zone.js index 6d5a6cdca..7b5cb4301 100644 --- a/modules/zone/back/models/zone.js +++ b/modules/zone/back/models/zone.js @@ -14,4 +14,18 @@ module.exports = Self => { Self.validatesPresenceOf('agencyModeFk', { message: `Agency cannot be blank` }); + + Self.validatesPresenceOf('price', { + message: 'Price cannot be blank' + }); + Self.validateAsync('price', priceIsValid, { + message: 'Price must be greater than 0' + }); + + async function priceIsValid(err, done) { + if (this.price <= 0) + err(); + + done(); + } };