IDEMPIERE-4887 Chosenbox: Make multi selection easier (#789)

This commit is contained in:
hengsin 2021-07-22 17:34:10 +08:00 committed by GitHub
parent 2975ff6429
commit 8d5cf4539d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 0 deletions

View File

@ -34,6 +34,7 @@ import org.zkoss.lang.Objects;
import org.zkoss.xel.VariableResolver;
import org.zkoss.zk.au.out.AuSetAttribute;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.HtmlBasedComponent;
import org.zkoss.zk.ui.UiException;
import org.zkoss.zk.ui.WrongValueException;
@ -808,6 +809,12 @@ public class Chosenbox<T> extends HtmlBasedComponent {
final Set<T> objects = getSelectedObjects();
Events.postEvent(new SelectEvent<Component, T>(Events.ON_SELECT, this, null, null, null,
objects, null, null, null, index, 0));
if (selItems.size() < (getSubListModel() != null ? getSubListModel().getSize() : getModel().getSize())) {
StringBuilder script = new StringBuilder();
script.append("var w=zk.Widget.$('#").append(getUuid()).append("');");
script.append("w.$n('inp').focus();");
Executions.schedule(getDesktop(), e -> {setOpen(true);Clients.evalJavaScript(script.toString());}, new Event("onPostSelect"));
}
_onSelectTimestamp = System.currentTimeMillis();
} else if (cmd.equals(Events.ON_OPEN)) {
_open = (Boolean)request.getData().get("open");