Skip to content

Commit

Permalink
MID-8124 fix how to load saved filters
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Oct 4, 2022
1 parent 57f833e commit 68ba42c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ public boolean isVisible() {

}

public void setSelectedValue(E newValue) {
selectedValue = newValue;
}

protected VisibleEnableBehaviour getSearchButtonVisibleEnableBehavior() {
return new VisibleEnableBehaviour();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@
import java.util.stream.Collectors;
import javax.xml.namespace.QName;

import com.evolveum.midpoint.gui.api.DefaultGuiConfigurationCompiler;
import com.evolveum.midpoint.gui.api.page.PageBase;
import com.evolveum.midpoint.gui.api.util.GuiDisplayTypeUtil;
import com.evolveum.midpoint.gui.api.util.WebModelServiceUtils;
import com.evolveum.midpoint.gui.impl.component.ContainerableListPanel;
import com.evolveum.midpoint.gui.impl.component.button.SelectableItemListPopoverPanel;
import com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView;
import com.evolveum.midpoint.prism.Containerable;

import com.evolveum.midpoint.prism.PrismContainerValue;
Expand Down Expand Up @@ -97,7 +95,6 @@ public abstract class SearchPanel<C extends Containerable> extends BasePanel<Sea

private static final String ID_FORM = "form";
private static final String ID_SEARCH_ITEMS_PANEL = "searchItemsPanel";
private static final String ID_SEARCH_CONTAINER = "searchContainer";
private static final String ID_SEARCH_BUTTON_PANEL = "searchButtonPanel";
private static final String ID_SAVE_SEARCH_CONTAINER = "saveSearchContainer";
private static final String ID_SAVE_SEARCH_BUTTON = "saveSearchButton";
Expand Down Expand Up @@ -267,6 +264,7 @@ protected void saveSearchFilterPerformed(AjaxRequestTarget target) {

@Override
protected void addItemsPerformed(List<AvailableFilterWrapper> itemList, AjaxRequestTarget target) {
savedSearchListModel.reset();
selectSavedFilterPerformed(itemList.stream().map(AvailableFilterWrapper::getFilter).collect(Collectors.toList()), target);
}

Expand Down Expand Up @@ -408,11 +406,15 @@ private void selectSavedFilterPerformed(List<AvailableFilterType> filterList, Aj
}
if (SearchBoxModeType.BASIC.equals(filter.getSearchMode())) {
applyFilterToBasicMode(filter.getSearchItem());
} else if (SearchBoxModeType.AXIOM_QUERY.equals(filter.getSearchMode())) {
applyFilterToAxiomMode(filter.getSearchItem());
} else if (SearchBoxModeType.AXIOM_QUERY.equals(filter.getSearchMode())
|| SearchBoxModeType.ADVANCED.equals(filter.getSearchMode())) {
applyFilterToAxiomOrAdvancedMode(filter.getSearchItem(), filter.getSearchMode());
} else if (SearchBoxModeType.FULLTEXT.equals(filter.getSearchMode())) {
applyFilterToFulltextMode(filter.getSearchItem());
}
SearchButtonWithDropdownMenu searchButton = getSearchButton();
searchButton.setSelectedValue(filter.getSearchMode());
target.add(searchButton);
searchPerformed(target);
}

Expand All @@ -424,6 +426,10 @@ private Component getSavedSearchMenuButton() {
return get(ID_FORM).get(ID_SAVE_SEARCH_CONTAINER).get(ID_SAVED_SEARCH_MENU);
}

private SearchButtonWithDropdownMenu getSearchButton() {
return (SearchButtonWithDropdownMenu) get(ID_FORM).get(ID_SEARCH_BUTTON_PANEL);
}

private boolean isCollectionInstancePage() {
return getCollectionInstance() != null;
}
Expand Down Expand Up @@ -640,8 +646,8 @@ private void applyFilterToBasicMode(List<SearchItemType> items) {
items.forEach(this::applyBasicModeSearchItem);
}

private void applyFilterToAxiomMode(List<SearchItemType> items) {
getModelObject().setSearchMode(SearchBoxModeType.AXIOM_QUERY);
private void applyFilterToAxiomOrAdvancedMode(List<SearchItemType> items, SearchBoxModeType mode) {
getModelObject().setSearchMode(mode);
if (CollectionUtils.isEmpty(items)) {
return;
}
Expand Down

0 comments on commit 68ba42c

Please sign in to comment.