IDEMPIERE-5594 : On detail panel grid, button not respect context par… (#1701)

* IDEMPIERE-5594 : On detail panel grid, button not respect context parsing for DispalyLogic, DefaultValue, MandatoryLogic. take context of previous row.

* IDEMPIERE-5594: Refactored code by Hengsin
Co-authored-by: hengsin@gmail.com
This commit is contained in:
Deepak Pansheriya 2023-03-08 17:31:10 +05:30 committed by GitHub
parent ff4516c86c
commit 09f524910c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 67 additions and 15 deletions

View File

@ -454,10 +454,15 @@ public class GridField
{ {
boolean isAlwaysUpdatable = false; boolean isAlwaysUpdatable = false;
if (m_vo.AlwaysUpdatableLogic.startsWith("@SQL=")) { if (m_vo.AlwaysUpdatableLogic.startsWith("@SQL=")) {
isAlwaysUpdatable = Evaluator.parseSQLLogic(m_vo.AlwaysUpdatableLogic, m_vo.ctx, m_vo.WindowNo, isAlwaysUpdatable = Evaluator.parseSQLLogic(m_vo.AlwaysUpdatableLogic, ctx, m_vo.WindowNo,
m_vo.TabNo, m_vo.ColumnName); m_vo.TabNo, m_vo.ColumnName);
} else { } else {
isAlwaysUpdatable = Evaluator.evaluateLogic(this, m_vo.AlwaysUpdatableLogic); Evaluatee evaluatee = new Evaluatee() {
public String get_ValueAsString(String variableName) {
return GridField.this.get_ValueAsString(ctx, variableName);
}
};
isAlwaysUpdatable = Evaluator.evaluateLogic(evaluatee, m_vo.AlwaysUpdatableLogic);
if (log.isLoggable(Level.FINEST)) if (log.isLoggable(Level.FINEST))
log.finest(m_vo.ColumnName + " R/O(" + m_vo.AlwaysUpdatableLogic + ") => R/W-" + isAlwaysUpdatable); log.finest(m_vo.ColumnName + " R/O(" + m_vo.AlwaysUpdatableLogic + ") => R/W-" + isAlwaysUpdatable);
@ -466,9 +471,6 @@ public class GridField
return true; return true;
} }
//check tab context //check tab context
if (checkContext && getGridTab() != null && if (checkContext && getGridTab() != null &&
! "Y".equals(Env.getContext(Env.getCtx(), getWindowNo(), "_QUICK_ENTRY_MODE_"))) ! "Y".equals(Env.getContext(Env.getCtx(), getWindowNo(), "_QUICK_ENTRY_MODE_")))
@ -534,13 +536,18 @@ public class GridField
{ {
if (m_vo.ReadOnlyLogic.startsWith("@SQL=")) if (m_vo.ReadOnlyLogic.startsWith("@SQL="))
{ {
boolean retValue = !Evaluator.parseSQLLogic(m_vo.ReadOnlyLogic, m_vo.ctx, m_vo.WindowNo, m_vo.TabNo, m_vo.ColumnName); boolean retValue = !Evaluator.parseSQLLogic(m_vo.ReadOnlyLogic, ctx, m_vo.WindowNo, m_vo.TabNo, m_vo.ColumnName);
if (!retValue) if (!retValue)
return false; return false;
} }
else else
{ {
boolean retValue = !Evaluator.evaluateLogic(this, m_vo.ReadOnlyLogic); Evaluatee evaluatee = new Evaluatee() {
public String get_ValueAsString(String variableName) {
return GridField.this.get_ValueAsString(ctx, variableName);
}
};
boolean retValue = !Evaluator.evaluateLogic(evaluatee, m_vo.ReadOnlyLogic);
if (log.isLoggable(Level.FINEST)) log.finest(m_vo.ColumnName + " R/O(" + m_vo.ReadOnlyLogic + ") => R/W-" + retValue); if (log.isLoggable(Level.FINEST)) log.finest(m_vo.ColumnName + " R/O(" + m_vo.ReadOnlyLogic + ") => R/W-" + retValue);
if (!retValue) if (!retValue)
return false; return false;
@ -1261,6 +1268,50 @@ public class GridField
return true; return true;
} // isDisplayed } // isDisplayed
/**************************************************************************
* Is the Displayed Grid Column Visible ?
* @param checkContext - check environment (requires correct row position)
* @return true, if visible
*/
public boolean isDisplayedGrid (boolean checkContext)
{
return isDisplayedGrid(m_vo.ctx, checkContext);
}
/**************************************************************************
* Is the Displayed Grid Column Visible ?
* @param checkContext - check environment (requires correct row position)
* @return true, if visible
*/
public boolean isDisplayedGrid (final Properties ctx, boolean checkContext)
{
// ** static content **
// not displayed
if (!m_vo.IsDisplayedGrid)
return false;
// no restrictions
if (m_vo.DisplayLogic.equals(""))
return true;
// ** dynamic content **
if (checkContext)
{
if (m_vo.DisplayLogic.startsWith("@SQL=")) {
return Evaluator.parseSQLLogic(m_vo.DisplayLogic, ctx, m_vo.WindowNo, m_vo.TabNo, m_vo.ColumnName);
}
Evaluatee evaluatee = new Evaluatee() {
public String get_ValueAsString(String variableName) {
return GridField.this.get_ValueAsString(ctx, variableName);
}
};
boolean retValue = Evaluator.evaluateLogic(evaluatee, m_vo.DisplayLogic);
if (log.isLoggable(Level.FINEST)) log.finest(m_vo.ColumnName
+ " (" + m_vo.DisplayLogic + ") => " + retValue);
return retValue;
}
return true;
} // isDisplayedGrid
/** /**
* Get Variable Value (Evaluatee) * Get Variable Value (Evaluatee)
* @param variableName name * @param variableName name

View File

@ -327,6 +327,7 @@ public class GridTabRowRenderer implements RowRenderer<Object[]>, RowRendererExt
} else if (gridField.isHeading()) { } else if (gridField.isHeading()) {
component = createInvisibleComponent(); component = createInvisibleComponent();
} else if (gridField.getDisplayType() == DisplayType.Button) { } else if (gridField.getDisplayType() == DisplayType.Button) {
// Each row renderer --- ctx per row wise
GridRowCtx gridRowCtx = new GridRowCtx(Env.getCtx(), gridTab, rowIndex); GridRowCtx gridRowCtx = new GridRowCtx(Env.getCtx(), gridTab, rowIndex);
WButtonEditor editor = new WButtonEditor(gridField, rowIndex); WButtonEditor editor = new WButtonEditor(gridField, rowIndex);
editor.setValue(gridTab.getValue(rowIndex, gridField.getColumnName())); editor.setValue(gridTab.getValue(rowIndex, gridField.getColumnName()));
@ -650,7 +651,7 @@ public class GridTabRowRenderer implements RowRenderer<Object[]>, RowRendererExt
} }
GridRowCtx ctx = new GridRowCtx(Env.getCtx(), gridTab, rowIndex); GridRowCtx ctx = new GridRowCtx(Env.getCtx(), gridTab, rowIndex);
if (! (gridPanelFields[i].isDisplayed(ctx, true) || gridPanelFields[i].isDisplayedGrid())){ if (!gridPanelFields[i].isDisplayedGrid(ctx, true)){
// IDEMPIERE-2253 // IDEMPIERE-2253
component.setVisible(false); component.setVisible(false);
} }
@ -813,7 +814,7 @@ public class GridTabRowRenderer implements RowRenderer<Object[]>, RowRendererExt
Properties ctx = isDetailPane() ? new GridRowCtx(Env.getCtx(), gridTab) Properties ctx = isDetailPane() ? new GridRowCtx(Env.getCtx(), gridTab)
: gridPanelFields[i].getVO().ctx; : gridPanelFields[i].getVO().ctx;
//check context //check context
if (!gridPanelFields[i].isDisplayed(ctx, true)){ if (!gridPanelFields[i].isDisplayedGrid(ctx, true)){
// IDEMPIERE-2253 // IDEMPIERE-2253
editor.getComponent().setVisible(false); editor.getComponent().setVisible(false);
} }