IDEMPIERE-382 Prevent users to go to detail tabs if link fields are not filled (zk)

This commit is contained in:
Carlos Ruiz 2012-09-21 09:24:30 -05:00
parent a2cd4a1326
commit dcc0773920
5 changed files with 33 additions and 9 deletions

View File

@ -122,7 +122,7 @@ public abstract class AbstractADTab extends AbstractUIPart implements IADTab
if (newIndex != oldIndex)
{
canJump = canNavigateTo(oldIndex, newIndex);
canJump = canNavigateTo(oldIndex, newIndex, true);
if (canJump)
{
prepareContext(newIndex, newTab);
@ -206,6 +206,10 @@ public abstract class AbstractADTab extends AbstractUIPart implements IADTab
}
public boolean canNavigateTo(int fromIndex, int toIndex) {
return canNavigateTo(fromIndex, toIndex, false);
}
public boolean canNavigateTo(int fromIndex, int toIndex, boolean checkRecordID) {
IADTabpanel newTab = tabPanelList.get(toIndex);
if (newTab instanceof ADTabpanel)
{
@ -222,8 +226,7 @@ public abstract class AbstractADTab extends AbstractUIPart implements IADTab
IADTabpanel oldTabpanel = fromIndex >= 0 ? tabPanelList.get(fromIndex) : null;
if (oldTabpanel != null)
{
IADTabpanel oldTab = oldTabpanel;
if (newTab.getTabLevel() > oldTab.getTabLevel())
if (newTab.getTabLevel() > oldTabpanel.getTabLevel())
{
int currentLevel = newTab.getTabLevel();
for (int i = toIndex - 1; i >= 0; i--)
@ -239,6 +242,8 @@ public abstract class AbstractADTab extends AbstractUIPart implements IADTab
currentLevel = tabPanel.getTabLevel();
}
}
if (canJump && checkRecordID && oldTabpanel.getRecord_ID() <= 0)
canJump = false;
}
}
}

View File

@ -68,9 +68,10 @@ import org.zkoss.zul.event.ListDataEvent;
*/
public class ADSortTab extends Panel implements IADTabpanel
{
private static final long serialVersionUID = 4289328613547509587L;
private int m_AD_ColumnSortOrder_ID;
/**
*
*/
private static final long serialVersionUID = 4461514427222034848L;
/**
* Sort Tab Constructor
@ -869,6 +870,10 @@ public class ADSortTab extends Panel implements IADTabpanel
return gridTab.getTabLevel();
}
public int getRecord_ID() {
return gridTab.getRecord_ID();
}
public String getTitle() {
return gridTab.getName();
}

View File

@ -98,7 +98,7 @@ DataStatusListener, IADTabpanel
/**
*
*/
private static final long serialVersionUID = -975129028953555569L;
private static final long serialVersionUID = -6082680802978974909L;
private static final String ON_DEFER_SET_SELECTED_NODE = "onDeferSetSelectedNode";
@ -670,6 +670,14 @@ DataStatusListener, IADTabpanel
return gridTab.getTabLevel();
}
/**
* @return The record ID of this Tabpanel
*/
public int getRecord_ID()
{
return gridTab.getRecord_ID();
}
/**
* Is panel need refresh
* @return boolean

View File

@ -1025,6 +1025,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
FDialog.warn(curWindowNo, "TabSwitchJumpGo", title);
if (callback != null)
callback.onCallback(false);
return;
}
IADTabpanel oldTabpanel = curTabpanel;

View File

@ -33,6 +33,11 @@ public interface IADTabpanel extends Component, Evaluatee {
*/
public int getTabLevel();
/**
* @return record ID
*/
public int getRecord_ID();
/**
* @return true if refresh is not needed
*/