Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0019712Openbravo ERPA. Platformpublic2012-02-09 16:052012-03-02 15:37
VictorVillar 
AugustoMauch 
highminoralways
closedfixed 
5
 
 
Core
No
0019712: It should not generate a property name with a key words
If the user creates a column, for instance name: Default, the system creates a property with this name, but is the same as a reserved word for Javascript.
An error messages appear in log file, because one fields use a display logic with this property.
This example has been discovered due to the Human Capital Management module.
the Human capital management module has a column called: Default, and the DB name: Isdefault, in the table HCMC_Contact.
Then the 'Make default' field has a display logic defined: @Isdefault@='N', so it is using this property, and the property uses the same reserved name in javascript.

we check the log file, and we can see this error:

" 92295e8 2012-02-09 11:49:57,953 [http-8080-11] ERROR org.openbravo.client.kernel.ComponentGenerator - Error parsing component View
>>>>>>> Issues found in javascript <<<<<<<<<
Human Capital Management Common.View:261:408: Expected an identifier and instead saw 'default' (a reserved word). >> offending code: {id: '3AE00E40575F11DEA0C3E7AD063433B2', title: 'Make Default', obManualURL: '/org.openbravo.hcm.commonEmployeeManagerView/Contact3ADEB662575F11DEAF7CB722376EC9B9_Edition.html', command: 'BUTTONMakedefaultB9CF97C70EB84448B34A8316C997E96A', property: 'makeDefaultContact', processId: 'B9CF97C70EB84448B34A8316C997E96A', modal: false, displayIf: function(form, currentValues, context) { return (currentValues.default === false); }, autosave: true } ],"
No tags attached.
Issue History
2012-02-09 16:05VictorVillarNew Issue
2012-02-09 16:05VictorVillarAssigned To => iperdomo
2012-02-09 16:05VictorVillarModules => Core
2012-02-09 16:06VictorVillarIssue Monitored: networkb
2012-02-09 16:42iperdomoAssigned Toiperdomo => AugustoMauch
2012-02-09 16:51iperdomoNote Added: 0044972
2012-02-15 13:31hgbotCheckin
2012-02-15 13:31hgbotNote Added: 0045147
2012-02-15 13:31hgbotStatusnew => resolved
2012-02-15 13:31hgbotResolutionopen => fixed
2012-02-15 13:31hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/26012ec9699fae395f9d12f8126973a5f90c505f [^]
2012-02-15 13:39AugustoMauchNote Added: 0045150
2012-02-15 13:41AugustoMauchNote Added: 0045151
2012-02-20 13:20iperdomoNote Added: 0045277
2012-02-20 13:20iperdomoStatusresolved => closed
2012-03-02 15:37hudsonbotCheckin
2012-03-02 15:37hudsonbotNote Added: 0045856

Notes
(0044972)
iperdomo   
2012-02-09 16:51   
Perhaps we need to implement the expression generation using a getValue() function, instead of context.property.

getValue(object, property) {
  return object[property];
}

getValue(context, 'default') instead of context.default
(0045147)
hgbot   
2012-02-15 13:31   
Repository: erp/devel/pi
Changeset: 26012ec9699fae395f9d12f8126973a5f90c505f
Author: Augusto Mauch <augusto.mauch <at> openbravo.com>
Date: Wed Feb 15 13:29:57 2012 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/26012ec9699fae395f9d12f8126973a5f90c505f [^]

Fixes issue 19712: Square bracket notation used for displaylogic

---
M modules/org.openbravo.client.application/src/org/openbravo/client/application/DynamicExpressionParser.java
M modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-utilities.js
---
(0045150)
AugustoMauch   
2012-02-15 13:39   
Now, when creating the javascript code for the display logics, the square brackets notation will be used.

Before the fix, the displaylogic @IsCustomer@ === 'Y' was translated to currentValues.customer === true. Now, it is going to be translated to OB.Utilities.getValue(currentValues,'customer') === true.

This prevents an error when using a reserved javascript word as a property name.
(0045151)
AugustoMauch   
2012-02-15 13:41   
Test plan:
- Check that displaylogics keep working.

I think the fix is not risky. Dot and square bracket notations are equivalent, so if a.b works, a['b'] is going to work.
(0045277)
iperdomo   
2012-02-20 13:20   
Tested on pi @ rev e5b1fd6ab7c6

- Using System Administrator role
- Added a display logic to the Mapping tab of AD Implementation window
  @IsDefault@ = 'Y'
- Check that the display logic works
- Check that JSLint doesn't complain about language keywords
(0045856)
hudsonbot   
2012-03-02 15:37   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/544d64e0c159 [^]

Maturity status: Test