Openbravo Issue Tracking System - POS2
View Issue Details
0052402POS2Corepublic2023-05-09 19:402023-06-29 15:57
gorka_gil 
meriem_azaf 
highminorN/A
closedfixed 
5
 
23Q4 
No
0052402: WrapTextParams: not working with $ symbol and when the name of the params appears more than once
WrapTextParams makes parameters of a message to transfrom into a span that can be set css styles.

but it firsts reemplace the parameters and then replace the params with the html span components

In this example label:
'a %1 b %2 c'

Problem 1:
%1 = $ -> it doesn't create the span because the regex don't recognize it since the $ it has meaning in regex
Example:
Message: "You are going to deposit $8 in USA Cash"
Parameters: ['$8', 'USA Cash']
Expected: "You are going to deposit <span>$8</span> in <span>USA Cash</span>"
Received: "You are going to deposit $8 in <span>USA Cash</span>"

Problem 2:
%2 = c -> it gives an error in console because it setting the same span in two ocassions, since the c value exists so try to create 2 spans for it instead one.
Example:
Parameter: "Cash"
Message: "You are going to add Cash with Cashier shift event."
Expected: "You are going to add [[Cash]] with Cashier shift event."
Received: "You are going to add [[Cash]] with [[Cash]]ier shift event."
- Login in POS2
- Open Cash Management option in the menu
- Do a New Deposit in Cash of 10 with "Other Cash Deposit"
- Check the error in the console log (check attached screenshot)
- Do a New Deposit in USA Cash of 5 with any event
- Check that the confirm popup is highlighting "deposit" word instead of "$8"
No tags attached.
png Screenshot from 2023-05-09 11-28-28.png (108,664) 2023-05-10 12:11
https://issues.openbravo.com/file_download.php?file_id=18511&type=bug
png

diff WarningFix.diff (895) 2023-05-10 13:21
https://issues.openbravo.com/file_download.php?file_id=18513&type=bug
Issue History
2023-05-09 19:40gorka_gilNew Issue
2023-05-09 19:40gorka_gilAssigned To => Triage Platform Base
2023-05-09 19:40gorka_gilTriggers an Emergency Pack => No
2023-05-10 08:38migueldejuanaDescription Updatedbug_revision_view_page.php?rev_id=26056#r26056
2023-05-10 12:10migueldejuanaDescription Updatedbug_revision_view_page.php?rev_id=26057#r26057
2023-05-10 12:10migueldejuanaSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=26059#r26059
2023-05-10 12:11migueldejuanaFile Added: Screenshot from 2023-05-09 11-28-28.png
2023-05-10 12:19migueldejuanaSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=26060#r26060
2023-05-10 12:20migueldejuanaSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=26061#r26061
2023-05-10 13:21migueldejuanaFile Added: WarningFix.diff
2023-05-10 13:35migueldejuanaNote Added: 0149561
2023-06-21 11:21AugustoMauchAssigned ToTriage Platform Base => meriem_azaf
2023-06-22 12:18hgbotNote Added: 0151495
2023-06-22 14:04AugustoMauchStatusnew => scheduled
2023-06-29 15:57hgbotNote Added: 0151864
2023-06-29 15:57hgbotResolutionopen => fixed
2023-06-29 15:57hgbotStatusscheduled => closed
2023-06-29 15:57hgbotFixed in Version => 23Q4
2023-06-29 15:57hgbotNote Added: 0151865

Notes
(0149561)
migueldejuana   
2023-05-10 13:35   
See attached "WarningFix.diff" file to fix Problem 2. Changes done:

- Replace transformedLabel only the FIRST match labelParam instead of ALL matches
- Order labelParams by length descendent to replace first long params that could have in other params. Doing this, we avoid replacing a param with a word inside anothe param --> "Other Cash Deposit" and "Cash"
(0151495)
hgbot   
2023-06-22 12:18   
Merge Request created: https://gitlab.com/openbravo/product/pmods/org.openbravo.core2/-/merge_requests/1149 [^]
(0151864)
hgbot   
2023-06-29 15:57   
Merge request merged: https://gitlab.com/openbravo/product/pmods/org.openbravo.core2/-/merge_requests/1149 [^]
(0151865)
hgbot   
2023-06-29 15:57   
Directly closing issue as related merge request is already approved.

Repository: https://gitlab.com/openbravo/product/pmods/org.openbravo.core2 [^]
Changeset: 10273a72687dc8fc4ab384c24ae943345726ab7a
Author: Meriem Azaf <meriem.azaf@openbravo.com>
Date: 29-06-2023 15:56:44
URL: https://gitlab.com/openbravo/product/pmods/org.openbravo.core2/-/commit/10273a72687dc8fc4ab384c24ae943345726ab7a [^]

Fixes ISSUE-52402: WrapTextParams: not working with $ symbol and when the name of the params appears more than once

WrapTextParams makes parameters of a message to transfrom into a span that can be set css styles, but it firsts replace the parameters and then replace the params with the html span components.

The problem was in the regex expression so we added a regex expression that will escape regex special caracters that we have in our parametrs.

---
M web-jspack/org.openbravo.core2/src/components/Translate/Translate.jsx
M web-jspack/org.openbravo.core2/src/components/Translate/__test__/Translate.test.jsx
M web-jspack/org.openbravo.core2/src/components/Translate/__test__/TranslateLabels.test.json
M web-jspack/org.openbravo.core2/src/core/I18N.js
M web-jspack/org.openbravo.core2/src/core/__test__/I18N.test.js
M web-jspack/org.openbravo.core2/src/core/useLabel.js
---