details: https://code.openbravo.com/erp/devel/pi/rev/20fc93af5344 changeset: 15172:20fc93af5344 user: Asier Lostalé <asier.lostale <at> openbravo.com> date: Fri Jan 20 12:02:29 2012 +0100 summary: related to issue 19382: applied code review
details: https://code.openbravo.com/erp/devel/pi/rev/b05447dc9ed7 changeset: 15173:b05447dc9ed7 user: Asier Lostalé <asier.lostale <at> openbravo.com> date: Fri Jan 20 12:03:26 2012 +0100 summary: fixed bug 16688: List References and DateTime references are not displayed correctly in a Query Widget diffstat: modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js | 2 +- modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-action-button.js | 19 ++--- modules/org.openbravo.client.querylist/src/org/openbravo/client/querylist/QueryListDataSource.java | 33 +++++++++- 3 files changed, 40 insertions(+), 14 deletions(-) diffs (133 lines): diff -r fcf34718278a -r b05447dc9ed7 modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js --- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js Fri Jan 20 11:34:47 2012 +0100 +++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js Fri Jan 20 12:03:26 2012 +0100 @@ -1711,7 +1711,7 @@ // New records in grid have a dummy id (see OBViewGrid.createNewRecordForEditing) // whereas new form records don't have it. This temporary id starts with _. Removing this // id so it behaves in the same way in form and grid - if (record[OB.Constants.ID] && record[OB.Constants.ID].startsWith('_')) { + if (record[OB.Constants.ID] && record[OB.Constants.ID].indexOf('_') === 0) { // startsWith a SC function, is slower than indexOf record[OB.Constants.ID] = undefined; } diff -r fcf34718278a -r b05447dc9ed7 modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-action-button.js --- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-action-button.js Fri Jan 20 11:34:47 2012 +0100 +++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-action-button.js Fri Jan 20 12:03:26 2012 +0100 @@ -102,7 +102,7 @@ // ad_process definition handling if (this.modal) { allProperties.Command = this.command; - callbackFunction = function(){ + callbackFunction = function () { var popup = OB.Layout.ClassicOBCompatibility.Popup.open('process', 900, 600, OB.Utilities.applicationUrl(me.obManualURL), '', null, false, false, true, allProperties); if (autosaveButton) { // Back to header if autosave button @@ -135,7 +135,10 @@ //Keep current view for the callback function. Refresh and look for tab message. var contextView = OB.ActionButton.executingProcess.contextView, currentView = this.view, - afterRefresh = function(){ + afterRefresh = function (doRefresh) { + var undef, + refresh = (doRefresh === undef || doRefresh); + // Refresh context view contextView.getTabMessage(); currentView.toolBar.refreshCustomButtons(); @@ -147,7 +150,9 @@ } // Refresh in order to show possible new records - currentView.refresh(null, false, true); + if (refresh) { + currentView.refresh(null, false, true); + } }; if (this.autosave) { @@ -166,13 +171,7 @@ } } else { // If the button is not autosave, do not refresh but get message. - contextView.getTabMessage(); - currentView.toolBar.refreshCustomButtons(); - if (contextView !== currentView && currentView.state === isc.OBStandardView.STATE_TOP_MAX) { - // Executing an action defined in parent tab, current tab is maximized, - // let's set half for each in order to see the message - contextView.setHalfSplit(); - } + afterRefresh(false); } OB.ActionButton.executingProcess = null; diff -r fcf34718278a -r b05447dc9ed7 modules/org.openbravo.client.querylist/src/org/openbravo/client/querylist/QueryListDataSource.java --- a/modules/org.openbravo.client.querylist/src/org/openbravo/client/querylist/QueryListDataSource.java Fri Jan 20 11:34:47 2012 +0100 +++ b/modules/org.openbravo.client.querylist/src/org/openbravo/client/querylist/QueryListDataSource.java Fri Jan 20 12:03:26 2012 +0100 @@ -28,9 +28,11 @@ import java.util.Comparator; import java.util.Date; import java.util.HashMap; +import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Set; import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; @@ -47,6 +49,7 @@ import org.openbravo.base.model.domaintype.PrimitiveDomainType; import org.openbravo.client.application.Parameter; import org.openbravo.client.application.ParameterUtils; +import org.openbravo.client.kernel.reference.EnumUIDefinition; import org.openbravo.client.kernel.reference.ForeignKeyUIDefinition; import org.openbravo.client.kernel.reference.NumberUIDefinition; import org.openbravo.client.kernel.reference.UIDefinition; @@ -170,13 +173,14 @@ if (queryAliases[i].equals(column.getDisplayExpression()) || (!isExport && queryAliases[i].equals(column.getLinkExpression()))) { Object value = resultList[i]; - if (value instanceof Date) { - value = xmlDateFormat.format(value); - } if (value instanceof Timestamp) { value = xmlDateTimeFormat.format(value); value = JsonUtils.convertToCorrectXSDFormat((String) value); } + if (value instanceof Date) { + value = xmlDateFormat.format(value); + } + data.put(queryAliases[i], value); } } @@ -327,6 +331,29 @@ dsProperty.setPrimitiveObjectType(((PrimitiveDomainType) uiDefinition.getDomainType()) .getPrimitiveType()); dsProperty.setNumericType(uiDefinition instanceof NumberUIDefinition); + + if (uiDefinition instanceof EnumUIDefinition) { + if (column.getReferenceSearchKey() == null) { + log.warn("In widget " + column.getWidgetQuery().getWidgetClass().getWidgetTitle() + + " column " + column.getDisplayExpression() + + " is of enum type but does not define sub reference."); + } else { + Set<String> allowedValues = new HashSet<String>(); + + final String hql = "select al.searchKey from ADList al" + + " where al.reference=:ref"; + final Query qry = OBDal.getInstance().getSession().createQuery(hql); + qry.setParameter("ref", column.getReferenceSearchKey()); + for (Object o : qry.list()) { + final String value = (String) o; + allowedValues.add(value); + } + + dsProperty.setAllowedValues(allowedValues); + dsProperty.setValueMap(DataSourceProperty.createValueMap(allowedValues, column + .getReferenceSearchKey().getId())); + } + } } else { } dsProperties.add(dsProperty); ------------------------------------------------------------------------------ Keep Your Developer Skills Current with LearnDevNow! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-d2d _______________________________________________ Openbravo-commits mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openbravo-commits
