Skip to content

Commit

Permalink
MID-6271 repository query, check form group html/css fix
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed May 6, 2022
1 parent 1e141fb commit 1f7a8e8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,10 @@

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
<wicket:panel>
<span class="control-label" wicket:id="labelContainer">
<span wicket:id="label"/>
<input class="form-check-input" type="checkbox" wicket:id="check">
<wicket:enclosure child="label">
<label class="form-check-label" wicket:id="label"/>
<i wicket:id="tooltip"/>
</span>

<div wicket:id="checkWrapper">
<div class="checkbox">
<label>
<input class="form-check-input" type="checkbox" wicket:id="check">
</label>
</div>
</div>
</wicket:enclosure>
</wicket:panel>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@

import org.apache.commons.lang3.StringUtils;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.CheckBox;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;

import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.web.component.util.VisibleBehaviour;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
import com.evolveum.midpoint.web.util.InfoTooltipBehavior;

/**
Expand All @@ -26,7 +24,6 @@ public class CheckFormGroup extends BasePanel<Boolean> {

private static final String ID_CHECK = "check";
private static final String ID_CHECK_WRAPPER = "checkWrapper";
private static final String ID_LABEL_CONTAINER = "labelContainer";
private static final String ID_LABEL = "label";
private static final String ID_TOOLTIP = "tooltip";

Expand All @@ -42,54 +39,36 @@ public CheckFormGroup(String id, IModel<Boolean> value, IModel<String> label, St
}

private void initLayout(IModel<String> label, final String tooltipKey, String labelSize, String textSize) {
WebMarkupContainer labelContainer = new WebMarkupContainer(ID_LABEL_CONTAINER);
labelContainer.setOutputMarkupId(true);
add(labelContainer);
add(AttributeAppender.prepend("class", "form-check"));

Label l = new Label(ID_LABEL, label);
l.setOutputMarkupId(true);
l.add(new VisibleBehaviour(() -> getLabelVisible()));

if (StringUtils.isNotEmpty(labelSize)) {
labelContainer.add(AttributeAppender.prepend("class", labelSize));
l.add(AttributeAppender.prepend("class", labelSize));
}
labelContainer.add(l);
add(l);

Label tooltipLabel = new Label(ID_TOOLTIP, new Model<>());
tooltipLabel.add(new AttributeAppender("data-original-title",
(IModel<String>) () -> getString(tooltipKey)));
tooltipLabel.add(AttributeAppender.append("data-original-title", () -> getString(tooltipKey)));
tooltipLabel.add(new InfoTooltipBehavior());
tooltipLabel.add(new VisibleEnableBehaviour() {

@Override
public boolean isVisible() {
return tooltipKey != null;
}
});
tooltipLabel.add(new VisibleBehaviour(() -> tooltipKey != null));
tooltipLabel.setOutputMarkupId(true);
tooltipLabel.setOutputMarkupPlaceholderTag(true);
labelContainer.add(tooltipLabel);
labelContainer.add(new VisibleBehaviour(() -> getLabelVisible()) {
});

WebMarkupContainer checkWrapper = new WebMarkupContainer(ID_CHECK_WRAPPER);
if (StringUtils.isNotEmpty(textSize)) {
checkWrapper.add(AttributeAppender.prepend("class", textSize));
}
add(checkWrapper);
checkWrapper.setOutputMarkupId(true);
add(tooltipLabel);

CheckBox check = new CheckBox(ID_CHECK, getModel());
check.add(AttributeAppender.prepend("class", textSize));
check.setOutputMarkupId(true);
check.setLabel(label);
checkWrapper.add(check);
setOutputMarkupId(true);
add(check);
}

protected boolean getLabelVisible() {
return true;
}

public CheckBox getCheck() {
return (CheckBox) get(ID_CHECK_WRAPPER + ":" + ID_CHECK);
return (CheckBox) get(ID_CHECK);
}

public Boolean getValue() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ <h3 class="card-title" wicket:id="repositoryQueryLabel"/>
<label for="objectType" class="mr-2 col-form-label"><wicket:message key="PageRepositoryQuery.objectType"/></label>
<div id="objectType" wicket:id="objectType"/>
</div>
<div class="mr-2 flex-grow-1 form-group" wicket:id="distinct"/>
<div class="mr-2 flex-grow-1 form-group justify-content-start" wicket:id="distinct"/>
<div class="form-group row">
<div class="col" wicket:id="viewButtonPanel"/>
</div>
Expand Down

0 comments on commit 1f7a8e8

Please sign in to comment.