Skip to content

Commit

Permalink
MID-9150: fix visible for seletion of relation in assign member panel
Browse files Browse the repository at this point in the history
  • Loading branch information
skublik committed Sep 29, 2023
1 parent 50dde63 commit 3ac1d18
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ protected QName getDefaultRelation() {
@Override
protected boolean isVisibleParameterPanel() {
if (getRelationIfIsStable() == null) {
super.isVisibleParameterPanel();
return super.isVisibleParameterPanel();
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,27 +80,14 @@ private AbstractRoleSearchItemWrapper getMemberSearchItem() {
protected void initParametersPanel(Fragment parametersPanel) {
RelationDropDownChoice relation = new RelationDropDownChoice(ID_RELATION, getDefaultRelation(),
getSupportedRelations(), false);
relation.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;

@Override
public boolean isVisible() {
return CollectionUtils.isNotEmpty(getSupportedRelations());
}

@Override
public boolean isEnabled() {
return CollectionUtils.isNotEmpty(getSupportedRelations())
&& getSupportedRelations().size() > 1;
}
});
parametersPanel.add(relation);

parametersPanel.add(new VisibleBehaviour(() -> isVisibleParameterPanel()));
parametersPanel.add(new VisibleEnableBehaviour(
() -> isVisibleParameterPanel(),
() -> CollectionUtils.isNotEmpty(getSupportedRelations()) && getSupportedRelations().size() > 1));
}

protected boolean isVisibleParameterPanel() {
return getSupportedRelations().size() > 1;
return CollectionUtils.isNotEmpty(getSupportedRelations());
}

protected QName getDefaultRelation() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.evolveum.midpoint.gui.impl.component.search.wrapper.RelationSearchItemWrapper;
import com.evolveum.midpoint.gui.impl.util.RelationUtil;
import com.evolveum.midpoint.prism.PrismConstants;
import com.evolveum.midpoint.prism.path.ItemName;
import com.evolveum.midpoint.prism.util.PolyStringUtils;
import com.evolveum.midpoint.util.QNameUtil;
import com.evolveum.midpoint.web.component.input.DropDownChoicePanel;
Expand All @@ -23,6 +24,9 @@
import org.apache.wicket.Component;
import org.apache.wicket.model.*;

import java.util.ArrayList;
import java.util.List;

public class RelationSearchItemPanel extends SingleSearchItemPanel<RelationSearchItemWrapper> {

public RelationSearchItemPanel(String id, IModel<RelationSearchItemWrapper> searchItemModel) {
Expand All @@ -31,9 +35,25 @@ public RelationSearchItemPanel(String id, IModel<RelationSearchItemWrapper> sear

@Override
protected Component initSearchItemField(String id) {
DropDownChoicePanel inputPanel = new DropDownChoicePanel(id,

IModel<List<QName>> choices;
if (getModel().getObject().getSupportedRelations().size() < 2) {
choices = new PropertyModel<>(getModel(), RelationSearchItemWrapper.F_SUPPORTED_RELATIONS);
} else {
choices = () -> {
List<QName> list = new ArrayList<>();
list.add(PrismConstants.Q_ANY);
list.addAll(getModel().getObject().getSupportedRelations());
return list;
};
}

DropDownChoicePanel inputPanel = new DropDownChoicePanel(
id,
new PropertyModel(getModel(), RelationSearchItemWrapper.F_VALUE),
new PropertyModel<>(getModel(), RelationSearchItemWrapper.F_SUPPORTED_RELATIONS), new RelationChoiceRenderer() , false);
choices,
new RelationChoiceRenderer() ,
false);
return inputPanel;
}

Expand Down

0 comments on commit 3ac1d18

Please sign in to comment.