IDEMPIERE-5068 Improvement to report viewer find dialog (#1023)

* IDEMPIERE-5068 Improvement to report viewer find dialog

* IDEMPIERE-5068 Improvement to report viewer find dialog

Fix javascript error
This commit is contained in:
hengsin 2021-12-02 21:00:14 +08:00 committed by GitHub
parent 7b1c9322f9
commit c9b563f408
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 70 additions and 17 deletions

View File

@ -191,7 +191,7 @@ public final class LayoutUtils {
}
/**
* open popup window relative to the ref component
* open embedded window relative to the ref component
* @param ref
* @param window
* @param position
@ -207,7 +207,26 @@ public final class LayoutUtils {
.append("');");
window.setVisible(true);
window.setMode(Mode.EMBEDDED);
Clients.response("_openPopupWindow_", new AuScript(window, script.toString()));
Clients.response("_openEmbeddedWindow_", new AuScript(window, script.toString()));
}
/**
* open highlighted window relative to the ref component
* @param ref
* @param window
* @param position
*/
public static void openHighlightedWindow(Component ref, Window window, String position) {
StringBuilder script = new StringBuilder();
script.append("idempiere.show_popup_window('#")
.append(ref.getUuid())
.append("','#")
.append(window.getUuid())
.append("','")
.append(position)
.append("');");
window.setMode(Mode.HIGHLIGHTED);
Clients.response("_openHighlightedWindow_", new AuScript(window, script.toString()));
}
/**
@ -509,4 +528,18 @@ public final class LayoutUtils {
}
});
}
/**
* set target same width as ref using client side script
* @param target
* @param ref
*/
public static void sameWidth(HtmlBasedComponent target, HtmlBasedComponent ref) {
StringBuilder script = new StringBuilder()
.append("var t=zk.Widget.$('#").append(target.getUuid()).append("');")
.append("var r=zk.Widget.$('#").append(ref.getUuid()).append("');")
.append("jq(t).css({'width':").append("jq(r).width()+'px'});")
.append("t.setWidth(\"").append("jq(r).width()+'px'\");");
Clients.response("_sameWidth_", new AuScript(target, script.toString()));
}
}

View File

@ -227,6 +227,8 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
private final Map<String, Supplier<AMedia>> mediaSuppliers = new HashMap<String, Supplier<AMedia>>();
private Center center;
private FindWindow find;
/**
* Static Layout
* @throws Exception
@ -1513,22 +1515,30 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
bFind.setVisible(false);
else
{
final FindWindow find = new FindWindow(m_WindowNo, 0, title, AD_Table_ID, tableName,m_reportEngine.getWhereExtended(), findFields, 1, AD_Tab_ID);
if (!find.initialize())
return;
if (find == null)
{
find = new FindWindow(m_WindowNo, 0, title, AD_Table_ID, tableName,m_reportEngine.getWhereExtended(), findFields, 1, AD_Tab_ID);
if (!find.initialize())
{
find = null;
return;
}
find.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
if (!find.isCancel())
{
m_reportEngine.setQuery(find.getQuery());
postRenderReportEvent();
}
}
});
find.setTitle(null);
LayoutUtils.openPopupWindow(toolBar, find, "after_start");
find.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
if (!find.isCancel())
{
m_reportEngine.setQuery(find.getQuery());
postRenderReportEvent();
}
}
});
setupFindwindow(find);
}
getParent().appendChild(find);
LayoutUtils.openHighlightedWindow(toolBar, find, "after_start");
LayoutUtils.sameWidth(find, this);
}
} // cmd_find
@ -1893,4 +1903,14 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
return m_reportEngine.getName();
}
private void setupFindwindow(FindWindow findWindow) {
findWindow.setTitle(null);
findWindow.setBorder("none");
if (ClientInfo.maxHeight(ClientInfo.MEDIUM_HEIGHT-1))
ZKUpdateUtil.setHeight(findWindow, "100%");
else
ZKUpdateUtil.setHeight(findWindow, "60%");
findWindow.setSizable(false);
findWindow.setContentStyle("background-color: #fff; width: 99%; margin: auto;");
}
}