Skip to content

Commit

Permalink
fixing MID-7964, changed implementation for expanding/collapsing pane…
Browse files Browse the repository at this point in the history
…ls. Now it sets style attribute to display:none instead of using wicket visible settings. The item is still present, and therefore validation is performed.
  • Loading branch information
katkav committed Aug 31, 2022
1 parent a9e9be1 commit 30f5d16
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ public void setShowInVirtualContainer(boolean showInVirtualContainer) {
@Override
public boolean isVisible(PrismContainerValueWrapper parentContainer, ItemVisibilityHandler visibilityHandler) {

if (!isVisibleByVisibilityHandler(parentContainer.isExpanded(), visibilityHandler)) {
if (!isVisibleByVisibilityHandler(visibilityHandler)) {
return false;
}

Expand All @@ -397,11 +397,7 @@ public boolean isVisible(PrismContainerValueWrapper parentContainer, ItemVisibil
return false;
}

protected boolean isVisibleByVisibilityHandler(boolean parentExpanded, ItemVisibilityHandler visibilityHandler) {
if (!parentExpanded) {
return false;
}

protected boolean isVisibleByVisibilityHandler(ItemVisibilityHandler visibilityHandler) {

if (visibilityHandler != null) {
ItemVisibility visible = visibilityHandler.isVisible(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.markup.html.panel.Panel;
Expand Down Expand Up @@ -83,6 +84,8 @@ protected Component createValuePanel(ListItem<PrismContainerValueWrapper<C>> ite
PrismContainerValuePanel<C, PrismContainerValueWrapper<C>> valuePanel = new PrismContainerValuePanel<C, PrismContainerValueWrapper<C>>("value", item.getModel(), getVisibilityHandler());
valuePanel.setOutputMarkupId(true);
valuePanel.add(new VisibleBehaviour(() -> getModelObject() != null && (getModelObject().isExpanded() || getModelObject().isSingleValue())));
valuePanel.add(AttributeAppender.replace("style", getModelObject().isMultiValue() && !getModelObject().isExpanded() ? "display:none" : ""));

valuePanel.add(AttributeModifier.append("class", () -> {
String cssClasses = "";
if (getModelObject() != null && getModelObject().isMultiValue()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ private <IW extends ItemWrapper> void populateNonContainer(ListItem<IW> item) {

ItemPanelSettingsBuilder builder = new ItemPanelSettingsBuilder().visibilityHandler(visibilityHandler);
Panel panel = getPageBase().initItemPanel("property", typeName, item.getModel(), builder.build());
panel.add(AttributeAppender.replace("style", () -> getModelObject().isExpanded() ? "" : "display:none"));

panel.setOutputMarkupId(true);
item.add(new VisibleEnableBehaviour() {

Expand Down Expand Up @@ -259,6 +261,8 @@ private void populateContainer(ListItem<PrismContainerWrapper> container) {
try {
ItemPanelSettingsBuilder builder = new ItemPanelSettingsBuilder().visibilityHandler(visibilityHandler);
Panel panel = getPageBase().initItemPanel("container", itemWrapper.getTypeName(), container.getModel(), builder.build());
panel.add(AttributeAppender.replace("style", () -> getModelObject().isExpanded() ? "" : "display:none"));

panel.setOutputMarkupId(true);
container.add(new VisibleBehaviour(() -> {
CVW parent = PrismContainerValuePanel.this.getModelObject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ public boolean isVisible(PrismContainerValueWrapper parent, ItemVisibilityHandle
return (getParent() != null && getParent().isShowMetadata());
}

return isVisibleByVisibilityHandler(parent.isExpanded(), visibilityHandler);
return isVisibleByVisibilityHandler(visibilityHandler);
}

@Override
Expand Down

0 comments on commit 30f5d16

Please sign in to comment.