IDEMPIERE-3563 Improvement to Process/COG toolbar button popup.
This commit is contained in:
parent
1c0e3c54b6
commit
68f7100ac0
|
@ -2974,7 +2974,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
||||||
Clients.response(new AuScript(script.toString()));
|
Clients.response(new AuScript(script.toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void executeButtonProcess(final IProcessButton wButton,
|
public void executeButtonProcess(final IProcessButton wButton,
|
||||||
final boolean startWOasking, final int table_ID, final int record_ID,
|
final boolean startWOasking, final int table_ID, final int record_ID,
|
||||||
boolean isProcessMandatory) {
|
boolean isProcessMandatory) {
|
||||||
/**
|
/**
|
||||||
|
@ -3271,8 +3271,10 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
||||||
popup.setWidgetAttribute(AdempiereWebUI.WIDGET_INSTANCE_NAME, "processButtonPopup");
|
popup.setWidgetAttribute(AdempiereWebUI.WIDGET_INSTANCE_NAME, "processButtonPopup");
|
||||||
ADTabpanel adtab = (ADTabpanel) adTabbox.getSelectedTabpanel();
|
ADTabpanel adtab = (ADTabpanel) adTabbox.getSelectedTabpanel();
|
||||||
popup.render(adtab.getToolbarButtons());
|
popup.render(adtab.getToolbarButtons());
|
||||||
|
if (popup.getChildren().size() > 0) {
|
||||||
LayoutUtils.openPopupWindow(toolbar.getButton("Process"), popup, "after_start");
|
popup.setPage(this.getComponent().getPage());
|
||||||
|
popup.open(getToolbar().getButton("Process"), "after_start");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -434,8 +434,10 @@ public class DetailPane extends Panel implements EventListener<Event>, IdSpace {
|
||||||
ProcessButtonPopup popup = new ProcessButtonPopup();
|
ProcessButtonPopup popup = new ProcessButtonPopup();
|
||||||
ADTabpanel adtab = (ADTabpanel) getSelectedADTabpanel();
|
ADTabpanel adtab = (ADTabpanel) getSelectedADTabpanel();
|
||||||
popup.render(adtab.getToolbarButtons());
|
popup.render(adtab.getToolbarButtons());
|
||||||
|
if (popup.getChildren().size() > 0) {
|
||||||
LayoutUtils.openPopupWindow(button, popup, "after_start");
|
popup.setPage(button.getPage());
|
||||||
|
popup.open(button, "after_start");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -5,41 +5,108 @@ package org.adempiere.webui.adwindow;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.adempiere.webui.component.Window;
|
import org.adempiere.util.Callback;
|
||||||
import org.adempiere.webui.util.ZKUpdateUtil;
|
import org.adempiere.webui.component.Menupopup;
|
||||||
|
import org.adempiere.webui.editor.IProcessButton;
|
||||||
|
import org.adempiere.webui.editor.WButtonEditor;
|
||||||
|
import org.adempiere.webui.panel.WDocActionPanel;
|
||||||
|
import org.compiere.model.GridTab;
|
||||||
|
import org.compiere.util.Env;
|
||||||
|
import org.compiere.util.Msg;
|
||||||
|
import org.zkoss.zk.ui.event.Event;
|
||||||
|
import org.zkoss.zk.ui.event.EventListener;
|
||||||
|
import org.zkoss.zk.ui.event.Events;
|
||||||
import org.zkoss.zul.Button;
|
import org.zkoss.zul.Button;
|
||||||
import org.zkoss.zul.Vbox;
|
import org.zkoss.zul.Listitem;
|
||||||
|
import org.zkoss.zul.Menu;
|
||||||
|
import org.zkoss.zul.Menuitem;
|
||||||
|
import org.zkoss.zul.Menuseparator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author hengsin
|
* @author hengsin
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ProcessButtonPopup extends Window {
|
public class ProcessButtonPopup extends Menupopup implements EventListener<Event> {
|
||||||
|
|
||||||
|
private static final String DOCUMENT_ACTION_MENUITEM_ATTRIBUTE = "document-action-menuitem";
|
||||||
|
private static final String DOC_ACTION_PANEL_ATTRIBUTE = "doc-action-panel";
|
||||||
|
private static final String BUTTON_ATTRIBUTE = "button";
|
||||||
/**
|
/**
|
||||||
* generated serial id
|
* generated serial id
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 304878472233552113L;
|
private static final long serialVersionUID = 304878472233552113L;
|
||||||
|
|
||||||
public void render(List<Button> buttons) {
|
public void render(List<Button> buttons) {
|
||||||
setSclass("toolbar-popup-window process-buttons-popup");
|
this.setSclass("z-menu-noimage");
|
||||||
//setWidth("250px");
|
|
||||||
ZKUpdateUtil.setHflex(this, "min");
|
|
||||||
setBorder("normal");
|
|
||||||
|
|
||||||
Vbox vbox = new Vbox();
|
|
||||||
ZKUpdateUtil.setHflex(vbox, "true");
|
|
||||||
appendChild(vbox);
|
|
||||||
vbox.setSclass("toolbar-popup-window-cnt");
|
|
||||||
vbox.setAlign("stretch");
|
|
||||||
|
|
||||||
|
//process button
|
||||||
|
Button docActionBtn = null;
|
||||||
for(Button button : buttons) {
|
for(Button button : buttons) {
|
||||||
if (button.getPage() != null) {
|
if (button.getPage() != null) {
|
||||||
button.detach();
|
button.detach();
|
||||||
}
|
}
|
||||||
ZKUpdateUtil.setHflex(button, "1");
|
if ("DocAction".equals(button.getId())) {
|
||||||
vbox.appendChild(button);
|
docActionBtn = button;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Menuitem mi = new Menuitem(button.getLabel());
|
||||||
|
appendChild(mi);
|
||||||
|
mi.setAttribute(BUTTON_ATTRIBUTE, button);
|
||||||
|
mi.addEventListener(Events.ON_CLICK, this);
|
||||||
|
if (button.isDisabled())
|
||||||
|
mi.setDisabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
//document actions
|
||||||
|
if (docActionBtn != null) {
|
||||||
|
IProcessButton processButton = (IProcessButton) docActionBtn.getAttribute(WButtonEditor.EDITOR_ATTRIBUTE);
|
||||||
|
WDocActionPanel actionPanel = new WDocActionPanel(processButton.getADTabpanel().getGridTab());
|
||||||
|
List<Listitem> actions = actionPanel.getDocActionItems();
|
||||||
|
if (actions.size() > 0) {
|
||||||
|
if (this.getChildren().size() > 0)
|
||||||
|
appendChild(new Menuseparator());
|
||||||
|
Menu menu = new Menu(Msg.getElement(Env.getCtx(), "DocAction"));
|
||||||
|
appendChild(menu);
|
||||||
|
Menupopup popup = new Menupopup();
|
||||||
|
popup.setAttribute(BUTTON_ATTRIBUTE, docActionBtn);
|
||||||
|
popup.setAttribute(DOC_ACTION_PANEL_ATTRIBUTE, actionPanel);
|
||||||
|
popup.setSclass("z-menu-noimage");
|
||||||
|
menu.appendChild(popup);
|
||||||
|
menu.setSclass("z-menu-noimage");
|
||||||
|
for(Listitem action : actions) {
|
||||||
|
Menuitem mi = new Menuitem(action.getLabel());
|
||||||
|
mi.setValue((String)action.getValue());
|
||||||
|
mi.setSclass(DOCUMENT_ACTION_MENUITEM_ATTRIBUTE);
|
||||||
|
mi.addEventListener(Events.ON_CLICK, this);
|
||||||
|
popup.appendChild(mi);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEvent(Event event) throws Exception {
|
||||||
|
Menuitem mi = (Menuitem) event.getTarget();
|
||||||
|
if (DOCUMENT_ACTION_MENUITEM_ATTRIBUTE.equals(mi.getSclass())) {
|
||||||
|
final Button button = (Button) mi.getParent().getAttribute(BUTTON_ATTRIBUTE);
|
||||||
|
WDocActionPanel panel = (WDocActionPanel) mi.getParent().getAttribute(DOC_ACTION_PANEL_ATTRIBUTE);
|
||||||
|
panel.setSelectedItem(mi.getValue());
|
||||||
|
panel.onOk(new Callback<Boolean>() {
|
||||||
|
@Override
|
||||||
|
public void onCallback(Boolean result) {
|
||||||
|
if (result) {
|
||||||
|
IProcessButton pb = (IProcessButton) button.getAttribute(WButtonEditor.EDITOR_ATTRIBUTE);
|
||||||
|
GridTab gridTab = pb.getADTabpanel().getGridTab();
|
||||||
|
ADWindow adwindow = ADWindow.get(gridTab.getWindowNo());
|
||||||
|
ADWindowContent windowContent = adwindow.getADWindowContent();
|
||||||
|
windowContent.executeButtonProcess(pb, true, gridTab.getAD_Table_ID(), gridTab.getRecord_ID(), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Button button = (Button) mi.getAttribute(BUTTON_ATTRIBUTE);
|
||||||
|
Events.sendEvent(Events.ON_CLICK, button, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -55,6 +55,8 @@ import org.zkoss.zk.ui.event.Events;
|
||||||
*/
|
*/
|
||||||
public class WButtonEditor extends WEditor implements IProcessButton
|
public class WButtonEditor extends WEditor implements IProcessButton
|
||||||
{
|
{
|
||||||
|
public static final String EDITOR_ATTRIBUTE = "editor";
|
||||||
|
|
||||||
private static final String[] LISTENER_EVENTS = {Events.ON_CLICK};
|
private static final String[] LISTENER_EVENTS = {Events.ON_CLICK};
|
||||||
|
|
||||||
private static final CLogger logger;
|
private static final CLogger logger;
|
||||||
|
@ -91,6 +93,7 @@ public class WButtonEditor extends WEditor implements IProcessButton
|
||||||
m_text = gridField.getHeader();
|
m_text = gridField.getHeader();
|
||||||
AD_Process_ID = gridField.getAD_Process_ID();
|
AD_Process_ID = gridField.getAD_Process_ID();
|
||||||
gridfield = gridField;
|
gridfield = gridField;
|
||||||
|
getComponent().setAttribute(EDITOR_ATTRIBUTE, this);
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -241,6 +241,10 @@ public class WDocActionPanel extends Window implements EventListener<Event>, Dia
|
||||||
DocAction = DocumentEngine.ACTION_Close;
|
DocAction = DocumentEngine.ACTION_Close;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Listitem> getDocActionItems() {
|
||||||
|
return (List<Listitem>)lstDocAction.getItems();
|
||||||
|
}
|
||||||
|
|
||||||
private boolean checkStatus (String TableName, int Record_ID, String DocStatus)
|
private boolean checkStatus (String TableName, int Record_ID, String DocStatus)
|
||||||
{
|
{
|
||||||
String sql = "SELECT 2 FROM " + TableName
|
String sql = "SELECT 2 FROM " + TableName
|
||||||
|
@ -331,39 +335,7 @@ public class WDocActionPanel extends Window implements EventListener<Event>, Dia
|
||||||
{
|
{
|
||||||
if (confirmPanel.getButton("Ok").equals(event.getTarget()))
|
if (confirmPanel.getButton("Ok").equals(event.getTarget()))
|
||||||
{
|
{
|
||||||
MClientInfo clientInfo = MClientInfo.get(Env.getCtx());
|
onOk(null);
|
||||||
if(clientInfo.isConfirmOnDocClose() || clientInfo.isConfirmOnDocVoid())
|
|
||||||
{
|
|
||||||
String selected = lstDocAction.getSelectedItem().getValue().toString();
|
|
||||||
if((selected.equals(org.compiere.process.DocAction.ACTION_Close) && clientInfo.isConfirmOnDocClose())
|
|
||||||
|| (selected.equals(org.compiere.process.DocAction.ACTION_Void) && clientInfo.isConfirmOnDocVoid())
|
|
||||||
|| (selected.equals(org.compiere.process.DocAction.ACTION_Reverse_Accrual) && clientInfo.isConfirmOnDocVoid())
|
|
||||||
|| (selected.equals(org.compiere.process.DocAction.ACTION_Reverse_Correct) && clientInfo.isConfirmOnDocVoid()))
|
|
||||||
{
|
|
||||||
String docAction = lstDocAction.getSelectedItem().getLabel();
|
|
||||||
MessageFormat mf = new MessageFormat(Msg.getMsg(Env.getAD_Language(Env.getCtx()), "ConfirmOnDocAction"));
|
|
||||||
Object[] arguments = new Object[]{docAction};
|
|
||||||
FDialog.ask(0, this, "", mf.format(arguments), new Callback<Boolean>() {
|
|
||||||
@Override
|
|
||||||
public void onCallback(Boolean result) {
|
|
||||||
if(result)
|
|
||||||
{
|
|
||||||
setValueAndClose();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
setValueAndClose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
setValueAndClose();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (confirmPanel.getButton("Cancel").equals(event.getTarget()))
|
else if (confirmPanel.getButton("Cancel").equals(event.getTarget()))
|
||||||
{
|
{
|
||||||
|
@ -381,6 +353,63 @@ public class WDocActionPanel extends Window implements EventListener<Event>, Dia
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSelectedItem(String value) {
|
||||||
|
lstDocAction.setSelectedIndex(-1);
|
||||||
|
List<Listitem> lst = (List<Listitem>)lstDocAction.getItems();
|
||||||
|
for(Listitem item: lst) {
|
||||||
|
if (value.equals(item.getValue())) {
|
||||||
|
item.setSelected(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onOk(final Callback<Boolean> callback) {
|
||||||
|
MClientInfo clientInfo = MClientInfo.get(Env.getCtx());
|
||||||
|
if(clientInfo.isConfirmOnDocClose() || clientInfo.isConfirmOnDocVoid())
|
||||||
|
{
|
||||||
|
String selected = lstDocAction.getSelectedItem().getValue().toString();
|
||||||
|
if((selected.equals(org.compiere.process.DocAction.ACTION_Close) && clientInfo.isConfirmOnDocClose())
|
||||||
|
|| (selected.equals(org.compiere.process.DocAction.ACTION_Void) && clientInfo.isConfirmOnDocVoid())
|
||||||
|
|| (selected.equals(org.compiere.process.DocAction.ACTION_Reverse_Accrual) && clientInfo.isConfirmOnDocVoid())
|
||||||
|
|| (selected.equals(org.compiere.process.DocAction.ACTION_Reverse_Correct) && clientInfo.isConfirmOnDocVoid()))
|
||||||
|
{
|
||||||
|
String docAction = lstDocAction.getSelectedItem().getLabel();
|
||||||
|
MessageFormat mf = new MessageFormat(Msg.getMsg(Env.getAD_Language(Env.getCtx()), "ConfirmOnDocAction"));
|
||||||
|
Object[] arguments = new Object[]{docAction};
|
||||||
|
FDialog.ask(0, this, mf.format(arguments), new Callback<Boolean>() {
|
||||||
|
@Override
|
||||||
|
public void onCallback(Boolean result) {
|
||||||
|
if(result)
|
||||||
|
{
|
||||||
|
setValueAndClose();
|
||||||
|
if (callback != null)
|
||||||
|
callback.onCallback(Boolean.TRUE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (callback != null)
|
||||||
|
callback.onCallback(Boolean.FALSE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setValueAndClose();
|
||||||
|
if (callback != null)
|
||||||
|
callback.onCallback(Boolean.TRUE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setValueAndClose();
|
||||||
|
if (callback != null)
|
||||||
|
callback.onCallback(Boolean.TRUE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void setValueAndClose() {
|
private void setValueAndClose() {
|
||||||
String statusSql = "SELECT DocStatus FROM " + gridTab.getTableName()
|
String statusSql = "SELECT DocStatus FROM " + gridTab.getTableName()
|
||||||
+ " WHERE " + gridTab.getKeyColumnName() + " = ? ";
|
+ " WHERE " + gridTab.getKeyColumnName() + " = ? ";
|
||||||
|
|
|
@ -178,3 +178,13 @@
|
||||||
font-size: larger;
|
font-size: larger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.z-menu-noimage.z-menupopup .z-menu-content > img.z-menu-image {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.z-menu-noimage.z-menupopup .z-menuitem-content > img.z-menuitem-image {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.z-menu-noimage.z-menupopup > .z-menupopup-separator {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue