mirror of
https://gitee.com/jmix/cuba.git
synced 2024-12-03 03:38:33 +08:00
Adding multiple conditions to filter at time #PL-4488
This commit is contained in:
parent
2f1bcc8b38
commit
d3f34eec30
@ -22,6 +22,7 @@ import com.haulmont.cuba.gui.components.filter.edit.RuntimePropConditionEditor;
|
||||
import com.haulmont.cuba.gui.config.WindowConfig;
|
||||
import com.haulmont.cuba.gui.config.WindowInfo;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ -72,14 +73,15 @@ public class AddConditionHelper {
|
||||
@Override
|
||||
public void windowClosed(String actionId) {
|
||||
if (Window.COMMIT_ACTION_ID.equals(actionId)) {
|
||||
AbstractConditionDescriptor descriptor = window.getDescriptor();
|
||||
if (descriptor != null) {
|
||||
_addCondition(descriptor);
|
||||
Collection<AbstractConditionDescriptor> descriptors = window.getDescriptors();
|
||||
if (descriptors != null) {
|
||||
for (AbstractConditionDescriptor descriptor : descriptors) {
|
||||
_addCondition(descriptor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
protected void _addCondition(AbstractConditionDescriptor descriptor) {
|
||||
|
@ -6,6 +6,7 @@
|
||||
package com.haulmont.cuba.gui.components.filter.addcondition;
|
||||
|
||||
import com.haulmont.chile.core.model.MetaProperty;
|
||||
import com.haulmont.cuba.core.entity.Entity;
|
||||
import com.haulmont.cuba.core.global.AppBeans;
|
||||
import com.haulmont.cuba.core.global.Metadata;
|
||||
import com.haulmont.cuba.gui.components.*;
|
||||
@ -19,6 +20,7 @@ import com.haulmont.cuba.gui.xml.layout.ComponentsFactory;
|
||||
import javax.inject.Inject;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
@ -85,16 +87,23 @@ public class AddConditionWindow extends AbstractWindow {
|
||||
}
|
||||
|
||||
public void select() {
|
||||
AbstractConditionDescriptor item = conditionDescriptorsDs.getItem();
|
||||
if (item == null) {
|
||||
Set<Entity> selectedItems = tree.getSelected();
|
||||
if (selectedItems.isEmpty()) {
|
||||
showNotification(getMessage("AddCondition.selectCondition"), NotificationType.WARNING);
|
||||
} else if (item instanceof HeaderConditionDescriptor) {
|
||||
showNotification(getMessage("AddCondition.youSelectedGroup"), NotificationType.WARNING);
|
||||
} else if (isEmbeddedProperty(item)) {
|
||||
showNotification(getMessage("AddCondition.youSelectedEmbedded"), NotificationType.WARNING);
|
||||
return;
|
||||
} else {
|
||||
close(COMMIT_ACTION_ID);
|
||||
for (Entity item : selectedItems) {
|
||||
if (item instanceof HeaderConditionDescriptor) {
|
||||
showNotification(getMessage("AddCondition.youSelectedGroup"), NotificationType.WARNING);
|
||||
return;
|
||||
} else if (isEmbeddedProperty((AbstractConditionDescriptor) item)) {
|
||||
showNotification(getMessage("AddCondition.youSelectedEmbedded"), NotificationType.WARNING);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
close(COMMIT_ACTION_ID);
|
||||
}
|
||||
|
||||
protected boolean isEmbeddedProperty(AbstractConditionDescriptor item) {
|
||||
@ -111,8 +120,7 @@ public class AddConditionWindow extends AbstractWindow {
|
||||
close(CLOSE_ACTION_ID);
|
||||
}
|
||||
|
||||
public AbstractConditionDescriptor getDescriptor() {
|
||||
AbstractConditionDescriptor item = conditionDescriptorsDs.getItem();
|
||||
return item;
|
||||
public Collection<AbstractConditionDescriptor> getDescriptors() {
|
||||
return tree.getSelected();
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
<textField id="treeFilter"/>
|
||||
<button id="searchBtn" action="search"/>
|
||||
</hbox>
|
||||
<tree id="tree" width="100%">
|
||||
<tree id="tree" width="100%" multiselect="true">
|
||||
<treechildren datasource="conditionDescriptorsDs" captionProperty="treeCaption"/>
|
||||
</tree>
|
||||
<hbox spacing="true">
|
||||
|
Loading…
Reference in New Issue
Block a user