Skip to content

Commit

Permalink
support for list group menu title/icon
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Jan 26, 2023
1 parent 8e9cf52 commit acb6c14
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,28 @@
*/
public class ListGroupMenu<T extends Serializable> implements Serializable {

private String iconCss;

private String title;

private List<ListGroupMenuItem<T>> items;

public String getIconCss() {
return iconCss;
}

public void setIconCss(String iconCss) {
this.iconCss = iconCss;
}

public String getTitle() {
return title;
}

public void setTitle(String title) {
this.title = title;
}

public List<ListGroupMenuItem<T>> getItems() {
if (items == null) {
items = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>
<li class="list-group-menu-item flex-row align-items-center gap-2 p-3" wicket:id="header">
<i class="mr-1" wicket:id="icon"></i>
<h5 class="mb-0" wicket:id="title"/>
</li>
<wicket:container wicket:id="items">
<li class="list-group-menu-item" wicket:id="item"/>
</wicket:container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,20 @@

package com.evolveum.midpoint.gui.impl.component.menu.listGroup;

import java.io.Serializable;
import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.web.component.util.VisibleBehaviour;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.html.WebComponent;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.model.IModel;

import com.evolveum.midpoint.gui.api.component.BasePanel;
import java.io.Serializable;

/**
* Created by Viliam Repan (lazyman).
Expand All @@ -25,6 +29,9 @@ public class ListGroupMenuPanel<T extends Serializable> extends BasePanel<ListGr

private static final long serialVersionUID = 1L;

private static final String ID_HEADER = "header";
private static final String ID_ICON = "icon";
private static final String ID_TITLE = "title";
private static final String ID_ITEMS = "items";
private static final String ID_ITEM = "item";

Expand All @@ -45,6 +52,24 @@ private void initLayout() {
add(AttributeAppender.append("class", "list-group-menu"));
setOutputMarkupId(true);

WebMarkupContainer header = new WebMarkupContainer(ID_HEADER);
header.add(new VisibleBehaviour(() -> {
ListGroupMenu menu = getModelObject();
return menu.getTitle() != null || menu.getIconCss() != null;
}));
add(header);

WebComponent icon = new WebComponent(ID_ICON);
icon.add(new VisibleBehaviour(() -> getModelObject().getIconCss() != null));
icon.add(AttributeAppender.replace("class", () -> getModelObject().getIconCss()));
header.add(icon);

Label title = new Label(ID_TITLE, () -> {
String text = getModel().getObject().getTitle();
return getString(text);
});
header.add(title);

ListView<ListGroupMenuItem<T>> items = new ListView<>(ID_ITEMS, () -> getModelObject().getItems()) {

@Override
Expand Down

0 comments on commit acb6c14

Please sign in to comment.