Skip to content

Commit

Permalink
debug search panel
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Dec 6, 2021
1 parent 2e8e555 commit d45ab6d
Show file tree
Hide file tree
Showing 9 changed files with 158 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,6 @@
</div>
</wicket:fragment>

<wicket:child/>

</wicket:panel>
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,10 @@ private <S extends SearchItem, T extends Serializable> void initLayout() {
MidpointForm<?> form = new MidpointForm<>(ID_FORM);
add(form);

initSearchItemsPanel(form);
RepeatingView searchItemsRepeatingView = new RepeatingView(ID_SEARCH_ITEMS_PANEL);
searchItemsRepeatingView.setOutputMarkupId(true);
form.add(searchItemsRepeatingView);
initSearchItemsPanel(searchItemsRepeatingView);

WebMarkupContainer searchContainer = new WebMarkupContainer(ID_SEARCH_CONTAINER);
searchContainer.setOutputMarkupId(true);
Expand All @@ -186,7 +189,7 @@ protected void onError(AjaxRequestTarget target) {

@Override
protected void onSubmit(AjaxRequestTarget target) {
// searchPerformed(target);
searchPerformed(target);
}
};

Expand Down Expand Up @@ -255,34 +258,25 @@ public boolean isVisible() {

}

private void initSearchItemsPanel(MidpointForm form) {
RepeatingView listItems = new RepeatingView(ID_SEARCH_ITEMS_PANEL);
listItems.setOutputMarkupId(true);
form.add(listItems);

BasicSearchFragment basicSearchFragment = new BasicSearchFragment(listItems.newChildId(), ID_BASIC_SEARCH_FRAGMENT,
protected void initSearchItemsPanel(RepeatingView searchItemsRepeatingView) {
BasicSearchFragment basicSearchFragment = new BasicSearchFragment(searchItemsRepeatingView.newChildId(), ID_BASIC_SEARCH_FRAGMENT,
AbstractSearchPanel.this);
basicSearchFragment.setOutputMarkupId(true);
basicSearchFragment.add(new VisibleBehaviour(() -> getModelObject().isBasicSearchMode()));
listItems.add(basicSearchFragment);
searchItemsRepeatingView.add(basicSearchFragment);

AdvancedSearchFragment advancedSearchFragment = new AdvancedSearchFragment(listItems.newChildId(), ID_ADVANCED_SEARCH_FRAGMENT,
AdvancedSearchFragment advancedSearchFragment = new AdvancedSearchFragment(searchItemsRepeatingView.newChildId(), ID_ADVANCED_SEARCH_FRAGMENT,
AbstractSearchPanel.this);
advancedSearchFragment.setOutputMarkupId(true);
advancedSearchFragment.add(new VisibleBehaviour(() -> getModelObject().isAdvancedSearchMode()));
listItems.add(advancedSearchFragment);

// AdvancedSearchFragment axiomSearchFragment = new AdvancedSearchFragment(listItems.newChildId(), ID_ADVANCED_SEARCH_FRAGMENT,
// AbstractSearchPanel.this);
// advancedSearchFragment.setOutputMarkupId(true);
// advancedSearchFragment.add(new VisibleBehaviour(() -> getModelObject().isAdvancedSearchMode()));
// listItems.add(advancedSearchFragment);
searchItemsRepeatingView.add(advancedSearchFragment);

FulltextSearchFragment fulltextSearchFragment = new FulltextSearchFragment(listItems.newChildId(), ID_FULLTEXT_SEARCH_FRAGMENT,
FulltextSearchFragment fulltextSearchFragment = new FulltextSearchFragment(searchItemsRepeatingView.newChildId(), ID_FULLTEXT_SEARCH_FRAGMENT,
AbstractSearchPanel.this);
fulltextSearchFragment.setOutputMarkupId(true);
fulltextSearchFragment.add(new VisibleBehaviour(() -> getModelObject().isFulltextSearchMode()));
listItems.add(fulltextSearchFragment);
fulltextSearchFragment.add(new VisibleBehaviour(() -> getModelObject().isFullTextSearchEnabled()
&& getModelObject().getSearchType().equals(SearchBoxModeType.FULLTEXT)));
searchItemsRepeatingView.add(fulltextSearchFragment);
}

private CompositedIcon getSubmitSearchButtonBuilder() {
Expand Down Expand Up @@ -367,7 +361,7 @@ private void closeMorePopoverPerformed(AjaxRequestTarget target) {
target.appendJavaScript("$('#" + popoverId + "').toggle();");
}

public abstract void searchPerformed(AjaxRequestTarget target);
protected abstract void searchPerformed(AjaxRequestTarget target);

void refreshSearchForm(AjaxRequestTarget target) {
target.add(get(ID_FORM));
Expand Down Expand Up @@ -823,15 +817,6 @@ public FulltextSearchFragment(String id, String markupId, AbstractSearchPanel ma

private void initFulltextLayout() {
WebMarkupContainer fullTextContainer = new WebMarkupContainer(ID_FULL_TEXT_CONTAINER);
fullTextContainer.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;

@Override
public boolean isVisible() {
return getModelObject().isFullTextSearchEnabled()
&& getModelObject().getSearchType().equals(SearchBoxModeType.FULLTEXT);
}
});
fullTextContainer.setOutputMarkupId(true);
add(fullTextContainer);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2021 Evolveum
~
~ This work is dual-licensed under the Apache License 2.0
~ and European Union Public License. See LICENSE file for details.
-->

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
<body>
<wicket:extend>
<wicket:fragment wicket:id="debugSearchFragment">
<div class="form-group" style="margin-right: 10px;">
<label class="control-label">
<wicket:message key="pageDebugList.options"/>
</label>
</div>
<div class="checkbox">
<label>
<input type="checkbox" wicket:id="zipCheck">
<wicket:message key="pageDebugList.zipCheck"/>
</label>
</div>
&nbsp;&nbsp; <!-- todo implement in a nicer way -->
<div class="checkbox">
<label>
<input type="checkbox" wicket:id="showAllItemsCheck">
<wicket:message key="pageDebugList.showAllItems"/>
</label>
</div>

<div wicket:id="oidItem" class="form-group" style="float:right; padding-right: 5px; margin-bottom: 5px; text-align-last: left;"/>
</wicket:fragment>
</wicket:extend>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (C) 2021 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/
package com.evolveum.midpoint.web.component.search;

import com.evolveum.midpoint.web.page.admin.configuration.component.DebugSearchFragment;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.repeater.RepeatingView;
import org.apache.wicket.model.IModel;
/**
* @author honchar
*/
public class DebugSearchPanel<O extends ObjectType> extends AbstractSearchPanel<O> {

IModel<Boolean> showAllItemsModel;
private static final String ID_DEBUG_SEARCH_FRAGMENT = "debugSearchFragment";

public DebugSearchPanel(String id, IModel<Search<O>> model, IModel<Boolean> showAllItemsModel) {
super(id, model);
this.showAllItemsModel = showAllItemsModel;
}

protected void initSearchItemsPanel(RepeatingView searchItemsRepeatingView) {
DebugSearchFragment debugSearchFragment = new DebugSearchFragment(searchItemsRepeatingView.newChildId(), ID_DEBUG_SEARCH_FRAGMENT,
DebugSearchPanel.this, getModel(), showAllItemsModel);
debugSearchFragment.setOutputMarkupId(true);
searchItemsRepeatingView.add(debugSearchFragment);

super.initSearchItemsPanel(searchItemsRepeatingView);
}

protected void searchPerformed(AjaxRequestTarget target) {

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,9 @@ public boolean isAllowedSearchMode(SearchBoxModeType searchBoxModeType){
if (!allowedSearchType.isEmpty()) {
return allowedSearchType.contains(searchBoxModeType);
}
if (SearchBoxModeType.FULLTEXT.equals(searchBoxModeType)) {
return isFullTextSearchEnabled;
}
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,18 @@ protected void initLayout() {
add(searchForm);
searchForm.setOutputMarkupId(true);

AbstractSearchPanel<C> search = new AbstractSearchPanel<>(ID_SEARCH, getModel()) {
SearchPanel<C> search = new SearchPanel<>(ID_SEARCH, getModel()) {
private static final long serialVersionUID = 1L;

@Override
public void searchPerformed(AjaxRequestTarget target) {
SearchFormPanel.this.searchPerformed(target);
}

// @Override
// protected void saveSearch(Search search, AjaxRequestTarget target) {
// SearchFormPanel.this.saveSearch(search, target);
// }
@Override
protected void saveSearch(Search search, AjaxRequestTarget target) {
SearchFormPanel.this.saveSearch(search, target);
}
};
searchForm.add(search);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,36 +13,38 @@
<div wicket:id="table"/>
</form>

<wicket:fragment wicket:id="tableHeader">
<div class="pull-left">
<div class="form-group" style="margin-right: 10px;">
<label class="control-label"><wicket:message key="pageDebugList.options"/></label>
</div>
<div class="checkbox">
<label>
<input type="checkbox" wicket:id="zipCheck">
<wicket:message key="pageDebugList.zipCheck" />
</label>
</div>
&nbsp;&nbsp; <!-- todo implement in a nicer way -->
<div class="checkbox">
<label>
<input type="checkbox" wicket:id="showAllItemsCheck">
<wicket:message key="pageDebugList.showAllItems" />
</label>
</div>
</div>
<!-- <wicket:fragment wicket:id="tableHeader">-->
<!-- <div wicket:id="debugSearchPanel" />-->

<form class="form-inline pull-right search-form" style="width: 100%;" wicket:id="searchForm">
<!-- <div class="pull-left">-->
<!-- <div class="form-group" style="margin-right: 10px;">-->
<!-- <label class="control-label"><wicket:message key="pageDebugList.options"/></label>-->
<!-- </div>-->
<!-- <div class="checkbox">-->
<!-- <label>-->
<!-- <input type="checkbox" wicket:id="zipCheck">-->
<!-- <wicket:message key="pageDebugList.zipCheck" />-->
<!-- </label>-->
<!-- </div>-->
<!-- &nbsp;&nbsp; &lt;!&ndash; todo implement in a nicer way &ndash;&gt;-->
<!-- <div class="checkbox">-->
<!-- <label>-->
<!-- <input type="checkbox" wicket:id="showAllItemsCheck">-->
<!-- <wicket:message key="pageDebugList.showAllItems" />-->
<!-- </label>-->
<!-- </div>-->
<!-- </div>-->

<!-- <form class="form-inline pull-right search-form" style="width: 100%;" wicket:id="searchForm">-->

<!-- <div class="form-group" style="float: left; padding-right: 5px;" wicket:id="choiceContainer">-->
<!-- <label class="sr-only"><wicket:message key="pageDebugList.objectType"/></label>-->
<!-- <div wicket:id="choice"/>-->
<!-- </div>-->

<div class="form-group" style="width: 100%;" wicket:id="search"/>
</form>
</wicket:fragment>
<!-- <div class="form-group" style="width: 100%;" wicket:id="search"/>-->
<!-- </form>-->
<!-- </wicket:fragment>-->
</wicket:extend>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ private void create(RepositoryObjectDataProvider provider) {

@Override
protected WebMarkupContainer createHeader(String headerId) {
DebugSearchFragment headerFragment = new DebugSearchFragment(headerId, ID_TABLE_HEADER, PageDebugList.this, searchModel,
DebugSearchPanel debugSearchPanel = new DebugSearchPanel(headerId, searchModel,
showAllItemsModel) {

private static final long serialVersionUID = 1L;
Expand All @@ -208,8 +208,8 @@ protected void searchPerformed(AjaxRequestTarget target) {
listObjectsPerformed(target);
}
};
headerFragment.setOutputMarkupId(true);
return headerFragment;
debugSearchPanel.setOutputMarkupId(true);
return debugSearchPanel;
}

};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@
*/
package com.evolveum.midpoint.web.page.admin.configuration.component;

import com.evolveum.midpoint.web.component.input.TextPanel;
import com.evolveum.midpoint.web.component.search.SearchSpecialItemPanel;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SearchBoxModeType;

import org.apache.wicket.MarkupContainer;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.form.AjaxCheckBox;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.panel.Fragment;
Expand All @@ -20,15 +25,18 @@
import com.evolveum.midpoint.web.component.search.SearchPanel;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;

public class DebugSearchFragment extends Fragment {
import org.apache.wicket.model.PropertyModel;

public class DebugSearchFragment<O extends ObjectType> extends Fragment {

private static final String ID_SEARCH = "search";
private static final String ID_ZIP_CHECK = "zipCheck";
private static final String ID_SHOW_ALL_ITEMS_CHECK = "showAllItemsCheck";
private static final String ID_SEARCH_FORM = "searchForm";
private static final String ID_OID_ITEM = "oidItem";

public DebugSearchFragment(String id, String markupId, MarkupContainer markupProvider,
IModel<Search<? extends ObjectType>> model, IModel<Boolean> showAllItemsModel) {
IModel<Search<O>> model, IModel<Boolean> showAllItemsModel) {
super(id, markupId, markupProvider, model);

initLayout(showAllItemsModel);
Expand Down Expand Up @@ -61,6 +69,25 @@ protected void onUpdate(AjaxRequestTarget target) {
};
add(showAllItemsCheck);

SearchSpecialItemPanel oidItem = new SearchSpecialItemPanel<String>(ID_OID_ITEM, new PropertyModel<String>(getModel(), Search.F_OID)) {
@Override
protected WebMarkupContainer initSearchItemField(String id) {
TextPanel<String> inputPanel = new TextPanel<String>(id, getModelValue());
inputPanel.getBaseFormComponent().add(AttributeAppender.append("style", "width: 220px; max-width: 400px !important;"));
return inputPanel;
}

@Override
protected IModel<String> createLabelModel() {
return getPageBase().createStringResource("SearchPanel.oid");
}

@Override
protected IModel<String> createHelpModel() {
return getPageBase().createStringResource("SearchPanel.oid.help");
}
};
add(oidItem);
}

private void createSearchForm() {
Expand Down

0 comments on commit d45ab6d

Please sign in to comment.