Skip to content

Commit

Permalink
small improvement for search panel
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed May 4, 2016
1 parent f10ff70 commit 221f93b
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 4 deletions.
Expand Up @@ -111,7 +111,8 @@ public static <T extends ObjectType> Search createSearch(Class<T> type, PrismCon
PrismObjectDefinition objDef = registry.findObjectDefinitionByCompileTimeClass(ObjectType.class);
PrismPropertyDefinition def = objDef.findPropertyDefinition(ObjectType.F_NAME);

search.addItem(def);
SearchItem item = search.addItem(def);
item.setFixed(true);

return search;
}
Expand Down
Expand Up @@ -47,6 +47,9 @@ public enum Type {
private ItemDefinition definition;
private List<DisplayableValue<T>> values;

private boolean fixed;
private boolean editWhenVisible;

public SearchItem(Search search, ItemPath path, ItemDefinition definition) {
Validate.notNull(path, "Item path must not be null.");
Validate.notNull(definition, "Item definition must not be null.");
Expand Down Expand Up @@ -122,6 +125,22 @@ public List<DisplayableValue> getAllowedValues() {
return list;
}

public boolean isFixed() {
return fixed;
}

public void setFixed(boolean fixed) {
this.fixed = fixed;
}

public boolean isEditWhenVisible() {
return editWhenVisible;
}

public void setEditWhenVisible(boolean editWhenVisible) {
this.editWhenVisible = editWhenVisible;
}

@Override
public String toString() {
return new ToStringBuilder(this)
Expand Down
Expand Up @@ -24,6 +24,7 @@
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.component.AjaxButton;
import com.evolveum.midpoint.web.component.AjaxSubmitButton;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
import org.apache.commons.lang.StringUtils;
import org.apache.wicket.AttributeModifier;
Expand Down Expand Up @@ -88,6 +89,20 @@ public SearchItemPanel(String id, IModel<SearchItem> model) {
initLayout();
}

@Override
protected void onConfigure() {
super.onConfigure();

SearchItem item = getModelObject();
if (!item.isEditWhenVisible()) {
return;
}

item.setEditWhenVisible(false);

//todo show popover for this item somehow [lazyman]
}

private void initLayout() {
popoverModel = new LoadableModel<SearchItemPopoverDto>(false) {

Expand Down Expand Up @@ -118,6 +133,13 @@ public void onClick(AjaxRequestTarget target) {
}
};
mainButton.add(deleteButton);
deleteButton.add(new VisibleEnableBehaviour() {

@Override
public boolean isVisible() {
return !getModelObject().isFixed();
}
});

initPopover();
initBrowserPopup();
Expand Down
Expand Up @@ -61,7 +61,10 @@
<dl wicket:id="propList">
<dt><wicket:message key="SearchPanel.properties"/></dt>
<dd wicket:id="properties">
<label><input wicket:id="check" type="checkbox">&nbsp;<span wicket:id="propName">Name</span></label>
<label>
<input wicket:id="check" type="checkbox">&nbsp;
<a wicket:id="propLink"><span wicket:id="propName"/></a>
</label>
</dd>
</dl>
</div>
Expand Down
Expand Up @@ -76,6 +76,7 @@ public class SearchPanel extends BasePanel<Search> {
private static final String ID_PROPERTIES = "properties";
private static final String ID_CHECK = "check";
private static final String ID_PROP_NAME = "propName";
private static final String ID_PROP_LINK = "propLink";
private static final String ID_PROP_LIST = "propList";
private static final String ID_ADVANCED = "advanced";
private static final String ID_ADVANCED_GROUP = "advancedGroup";
Expand Down Expand Up @@ -313,11 +314,20 @@ protected void onUpdate(AjaxRequestTarget target) {
});
item.add(check);

AjaxLink propLink = new AjaxLink(ID_PROP_LINK) {

@Override
public void onClick(AjaxRequestTarget target) {
addOneItemPerformed(item.getModelObject(), target);
}
};
item.add(propLink);

Label name = new Label(ID_PROP_NAME, new PropertyModel<>(item.getModel(), Property.F_NAME));
name.setRenderBodyOnly(true);
item.add(name);
propLink.add(name);

item.add(new VisibleEnableBehaviour() {
propLink.add(new VisibleEnableBehaviour() {

@Override
public boolean isVisible() {
Expand Down Expand Up @@ -397,6 +407,15 @@ private List<Property> createPropertiesList() {
return list;
}

private void addOneItemPerformed(Property property, AjaxRequestTarget target) {
Search search = getModelObject();
SearchItem item = search.addItem(property.getDefinition());
item.setEditWhenVisible(true);

moreDialogModel.reset();
refreshSearchForm(target);
}

private void addItemPerformed(AjaxRequestTarget target) {
Search search = getModelObject();

Expand Down

0 comments on commit 221f93b

Please sign in to comment.