IDEMPIERE-4101 [Chosenbox] Multi select don't work in Firefox (#435)
- add display of button - fix dropdown doesn't render properly at Firefox
This commit is contained in:
parent
b9964ce7ab
commit
894ceb8c4f
|
@ -51,6 +51,7 @@ Copyright (C) 2007 Ashley G Ramdass (ADempiere WebUI).
|
|||
<javascript-module name="org.idempiere.commons" version="202012030330"/>
|
||||
<javascript-module name="jquery.maskedinput" version="1.4.1" />
|
||||
<javascript-module name="photobooth" version="0.7-rsd3" />
|
||||
<javascript-module name="chosenbox" version="202012041500"/>
|
||||
|
||||
<!-- this js module doesn't actually exists and it is here for default theme version -->
|
||||
<!-- since loading of js module is on demand, it doesn't cause any error as long as you don't try to load it -->
|
||||
|
|
|
@ -38,6 +38,18 @@ public class ChosenSearchBox extends Div {
|
|||
protected Chosenbox<ValueNamePair> chosenbox;
|
||||
protected Button btn;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param chosenbox custom implementation of Chosenbox
|
||||
*/
|
||||
public ChosenSearchBox(Chosenbox<ValueNamePair> chosenbox) {
|
||||
this.chosenbox = chosenbox;
|
||||
initComponents();
|
||||
}
|
||||
|
||||
/**
|
||||
* default constructor
|
||||
*/
|
||||
public ChosenSearchBox() {
|
||||
initComponents();
|
||||
}
|
||||
|
@ -50,7 +62,8 @@ public class ChosenSearchBox extends Div {
|
|||
}
|
||||
|
||||
private void initComponents() {
|
||||
chosenbox = new Chosenbox<>();
|
||||
if (chosenbox == null)
|
||||
chosenbox = new Chosenbox<>();
|
||||
chosenbox.setSclass("editor-input");
|
||||
chosenbox.setWidth("100%");
|
||||
appendChild(chosenbox);
|
||||
|
|
|
@ -21,9 +21,11 @@ import java.util.Properties;
|
|||
import java.util.Set;
|
||||
|
||||
import org.adempiere.webui.ValuePreference;
|
||||
import org.adempiere.webui.component.ChosenSearchBox;
|
||||
import org.adempiere.webui.event.ContextMenuEvent;
|
||||
import org.adempiere.webui.event.ContextMenuListener;
|
||||
import org.adempiere.webui.event.ValueChangeEvent;
|
||||
import org.adempiere.webui.theme.ThemeManager;
|
||||
import org.adempiere.webui.window.WFieldRecordInfo;
|
||||
import org.compiere.model.GridField;
|
||||
import org.compiere.model.Lookup;
|
||||
|
@ -59,7 +61,7 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener
|
|||
|
||||
static
|
||||
{
|
||||
logger = CLogger.getCLogger(WTableDirEditor.class);
|
||||
logger = CLogger.getCLogger(WChosenboxListEditor.class);
|
||||
}
|
||||
|
||||
private Lookup lookup;
|
||||
|
@ -88,7 +90,7 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener
|
|||
*/
|
||||
public WChosenboxListEditor(GridField gridField, boolean tableEditor, IEditorConfiguration editorConfiguration)
|
||||
{
|
||||
this(new ChosenboxEditor(), gridField, tableEditor, editorConfiguration);
|
||||
this(new ChosenSearchBox(new ChosenboxEditor()), gridField, tableEditor, editorConfiguration);
|
||||
}
|
||||
|
||||
private WChosenboxListEditor(Component comp, GridField gridField, boolean tableEditor, IEditorConfiguration editorConfiguration)
|
||||
|
@ -113,9 +115,19 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener
|
|||
this(lookup, label, description, mandatory, readonly, updateable, false);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param lookup
|
||||
* @param label
|
||||
* @param description
|
||||
* @param mandatory
|
||||
* @param readonly
|
||||
* @param updateable
|
||||
* @param autocomplete
|
||||
*/
|
||||
public WChosenboxListEditor(Lookup lookup, String label, String description, boolean mandatory, boolean readonly, boolean updateable, boolean autocomplete)
|
||||
{
|
||||
this(new ChosenboxEditor(), lookup, label, description, mandatory, readonly, updateable);
|
||||
this(new ChosenSearchBox(new ChosenboxEditor()), lookup, label, description, mandatory, readonly, updateable);
|
||||
}
|
||||
|
||||
private WChosenboxListEditor(Component comp, Lookup lookup, String label, String description, boolean mandatory, boolean readonly, boolean updateable)
|
||||
|
@ -145,9 +157,18 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener
|
|||
this(columnName, mandatory, isReadOnly, isUpdateable, lookup, false);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param columnName
|
||||
* @param mandatory
|
||||
* @param isReadOnly
|
||||
* @param isUpdateable
|
||||
* @param lookup
|
||||
* @param autocomplete
|
||||
*/
|
||||
public WChosenboxListEditor(String columnName, boolean mandatory, boolean isReadOnly, boolean isUpdateable, Lookup lookup, boolean autocomplete)
|
||||
{
|
||||
this(new ChosenboxEditor(), columnName, mandatory, isReadOnly, isUpdateable, lookup);
|
||||
this(new ChosenSearchBox(new ChosenboxEditor()), columnName, mandatory, isReadOnly, isUpdateable, lookup);
|
||||
}
|
||||
|
||||
private WChosenboxListEditor(Component comp, String columnName, boolean mandatory, boolean isReadOnly, boolean isUpdateable, Lookup lookup)
|
||||
|
@ -164,8 +185,26 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener
|
|||
private void init()
|
||||
{
|
||||
getComponent().setHflex("true");
|
||||
getComponent().editor = this;
|
||||
getComponent().setModel(model);
|
||||
((ChosenboxEditor)getComponent().getChosenbox()).editor = this;
|
||||
getComponent().getChosenbox().setModel(model);
|
||||
String imageUrl;
|
||||
if (ThemeManager.isUseFontIconForImage())
|
||||
imageUrl = "z-icon-More";
|
||||
else
|
||||
imageUrl = ThemeManager.getThemeResource("images/ShowMore16.png");
|
||||
if (ThemeManager.isUseFontIconForImage())
|
||||
getComponent().getButton().setIconSclass(imageUrl);
|
||||
else
|
||||
getComponent().getButton().setImage(imageUrl);
|
||||
|
||||
getComponent().getButton().addEventListener(Events.ON_CLICK, e -> {
|
||||
if (getComponent().isEnabled()) {
|
||||
if (!getComponent().getChosenbox().isOpen()) {
|
||||
getComponent().getChosenbox().setOpen(true);
|
||||
getComponent().getChosenbox().focus();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (lookup != null)
|
||||
{
|
||||
|
@ -189,6 +228,9 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* refresh lookup list
|
||||
*/
|
||||
protected void refreshLookup() {
|
||||
lookup.refresh();
|
||||
updateModel();
|
||||
|
@ -198,7 +240,7 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener
|
|||
public String getDisplay()
|
||||
{
|
||||
StringBuilder display = new StringBuilder();
|
||||
LinkedHashSet<ValueNamePair> selected = getComponent().getSelectedObjects();
|
||||
LinkedHashSet<ValueNamePair> selected = getComponent().getChosenbox().getSelectedObjects();
|
||||
if (selected != null && selected.size() > 0)
|
||||
{
|
||||
for(ValueNamePair pair : selected)
|
||||
|
@ -220,7 +262,7 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener
|
|||
private String getValueFromComponent()
|
||||
{
|
||||
StringBuilder retVal = new StringBuilder();
|
||||
LinkedHashSet<ValueNamePair> selected = getComponent().getSelectedObjects();
|
||||
LinkedHashSet<ValueNamePair> selected = getComponent().getChosenbox().getSelectedObjects();
|
||||
if (selected != null && selected.size() > 0)
|
||||
{
|
||||
for(ValueNamePair pair : selected)
|
||||
|
@ -239,6 +281,9 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener
|
|||
return retVal.length() > 0 ? retVal.toString() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value
|
||||
*/
|
||||
public void setValue(Object value)
|
||||
{
|
||||
if (onselecting) {
|
||||
|
@ -259,8 +304,8 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener
|
|||
selected.add(pair);
|
||||
}
|
||||
}
|
||||
getComponent().setSelectedObjects(selected);
|
||||
if (getComponent().getSelectedObjects().size() != selected.size())
|
||||
getComponent().getChosenbox().setSelectedObjects(selected);
|
||||
if (getComponent().getChosenbox().getSelectedObjects().size() != selected.size())
|
||||
{
|
||||
Object curValue = oldValue;
|
||||
oldValue = value;
|
||||
|
@ -273,12 +318,12 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener
|
|||
{
|
||||
updateModel();
|
||||
}
|
||||
getComponent().setSelectedObjects(selected);
|
||||
getComponent().getChosenbox().setSelectedObjects(selected);
|
||||
|
||||
//still not in list, reset to zero
|
||||
if (getComponent().getSelectedObjects().size() != selected.size())
|
||||
if (getComponent().getChosenbox().getSelectedObjects().size() != selected.size())
|
||||
{
|
||||
getComponent().setSelectedObjects(new LinkedHashSet<ValueNamePair>());
|
||||
getComponent().getChosenbox().setSelectedObjects(new LinkedHashSet<ValueNamePair>());
|
||||
if (curValue == null)
|
||||
curValue = value;
|
||||
ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), curValue, null);
|
||||
|
@ -293,14 +338,14 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener
|
|||
}
|
||||
else
|
||||
{
|
||||
getComponent().setSelectedObjects(new LinkedHashSet<ValueNamePair>());
|
||||
getComponent().getChosenbox().setSelectedObjects(new LinkedHashSet<ValueNamePair>());
|
||||
oldValue = value;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChosenboxEditor getComponent() {
|
||||
return (ChosenboxEditor) component;
|
||||
public ChosenSearchBox getComponent() {
|
||||
return (ChosenSearchBox) component;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -364,6 +409,9 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener
|
|||
model.addAll(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param event
|
||||
*/
|
||||
public void onEvent(Event event)
|
||||
{
|
||||
if (Events.ON_SELECT.equalsIgnoreCase(event.getName()))
|
||||
|
@ -394,12 +442,16 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener
|
|||
|| ((oldValue != null && newValue != null) && !oldValue.equals(newValue));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getEvents()
|
||||
{
|
||||
return LISTENER_EVENTS;
|
||||
}
|
||||
|
||||
public void actionRefresh()
|
||||
/**
|
||||
* action for requery menu
|
||||
*/
|
||||
protected void actionRefresh()
|
||||
{
|
||||
if (lookup != null)
|
||||
{
|
||||
|
@ -416,11 +468,16 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return {@link Lookup}
|
||||
*/
|
||||
public Lookup getLookup()
|
||||
{
|
||||
return lookup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMenu(ContextMenuEvent evt)
|
||||
{
|
||||
if (WEditorPopupMenu.REQUERY_EVENT.equals(evt.getContextEvent()))
|
||||
|
@ -439,6 +496,7 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent evt)
|
||||
{
|
||||
if ("FieldValue".equals(evt.getPropertyName()))
|
||||
|
@ -455,7 +513,7 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener
|
|||
((MLookup) lookup).getLookupInfo().ctx = ctx;
|
||||
}
|
||||
if ((lookup != null) && (!lookup.isValidated() || !lookup.isLoaded()
|
||||
|| (isReadWrite() && lookup.getSize() != getComponent().getModel().getSize())))
|
||||
|| (isReadWrite() && lookup.getSize() != getComponent().getChosenbox().getModel().getSize())))
|
||||
this.actionRefresh();
|
||||
|
||||
super.dynamicDisplay(ctx);
|
||||
|
@ -484,14 +542,6 @@ public class WChosenboxListEditor extends WEditor implements ContextMenuListener
|
|||
protected ChosenboxEditor() {
|
||||
}
|
||||
|
||||
public void setEnabled(boolean readWrite) {
|
||||
setDisabled(readWrite==false);
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return isDisabled() == false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPage(Page page) {
|
||||
super.setPage(page);
|
||||
|
|
|
@ -873,6 +873,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
|
|||
this.setFloating_(true);
|
||||
this.setTopmost();
|
||||
ppstyle.zIndex = n.style.zIndex;
|
||||
ppstyle.display = 'block';
|
||||
if (opts) {
|
||||
var inp = this.$n();
|
||||
zk(pp).position(inp, "after_start");
|
||||
|
|
Loading…
Reference in New Issue