Skip to content

Commit

Permalink
MID-7963 list group menu impl, wip
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Jun 10, 2022
1 parent 2a2d1b5 commit aadc0c2
Show file tree
Hide file tree
Showing 5 changed files with 283 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
* Copyright (c) 2022 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/

package com.evolveum.midpoint.gui.impl.page.self.requestAccess;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
* Created by Viliam Repan (lazyman).
*/
public class ListGroupMenuItem implements Serializable {

private String iconCss;

private String label;

private String badgeCss;

private String badge;

private boolean active;

private boolean disabled;

private List<ListGroupMenuItem> items;

public String getIconCss() {
return iconCss;
}

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

public String getLabel() {
return label;
}

public void setLabel(String label) {
this.label = label;
}

public String getBadgeCss() {
return badgeCss;
}

public void setBadgeCss(String badgeCss) {
this.badgeCss = badgeCss;
}

public String getBadge() {
return badge;
}

public void setBadge(String badge) {
this.badge = badge;
}

public boolean isActive() {
return active;
}

public void setActive(boolean active) {
this.active = active;
}

public boolean isDisabled() {
return disabled;
}

public void setDisabled(boolean disabled) {
this.disabled = disabled;
}

public List<ListGroupMenuItem> getItems() {
if (items == null) {
items = new ArrayList<>();
}
return items;
}

public void setItems(List<ListGroupMenuItem> items) {
this.items = items;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!--
~ Copyright (c) 2010-2017 Evolveum
~
~ This work is dual-licensed under the Apache License 2.0
~ and European Union Public License. See LICENSE file for details.
-->
<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>
<a href="#" class="item-link" wicket:id="link">
<i class="icon fa fa-fw fa-border-all" wicket:id="icon"></i>
<span class="label" wicket:id="label">All roles</span>
<span class="badge badge-primary badge-pill" wicket:id="badge">14</span>
<i class="fa fa-chevron-left" wicket:id="chevron"></i>
</a>
<wicket:container wicket:id="content"/>
</wicket:panel>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/*
* Copyright (c) 2022 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/

package com.evolveum.midpoint.gui.impl.page.self.requestAccess;

import com.evolveum.midpoint.gui.api.component.BasePanel;

import com.evolveum.midpoint.web.component.util.VisibleBehaviour;

import org.apache.commons.lang3.StringUtils;
import org.apache.cxf.message.Attachment;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.markup.ComponentTag;
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 java.util.List;

/**
* Created by Viliam Repan (lazyman).
*/
public class ListGroupMenuItemPanel extends BasePanel<ListGroupMenuItem> {

private static final long serialVersionUID = 1L;

private static final String ID_LINK = "link";
private static final String ID_ICON = "icon";
private static final String ID_LABEL = "label";
private static final String ID_BADGE = "badge";
private static final String ID_CHEVRON = "chevron";
private static final String ID_CONTENT = "content";

public ListGroupMenuItemPanel(String id, IModel<ListGroupMenuItem> model) {
super(id, model);

initLayout();
}

@Override
protected void onComponentTag(ComponentTag tag) {
super.onComponentTag(tag);

checkComponentTag(tag, "li");
}

private void initLayout() {
add(AttributeAppender.append("class", "list-group-menu"));

AjaxLink link = new AjaxLink<>(ID_LINK) {

@Override
public void onClick(AjaxRequestTarget target) {
onClickPerformed(target);
}
};
link.add(AttributeAppender.append("class", () -> getModelObject().isActive() ? "active" : null));
link.add(AttributeAppender.append("class", () -> getModelObject().isDisabled() ? "disabled" : null));
add(link);

WebMarkupContainer icon = new WebMarkupContainer(ID_ICON);
link.add(icon);

Label label = new Label(ID_LABEL, () -> getModelObject().getLabel());
link.add(label);

Label badge = new Label(ID_BADGE, () -> getModelObject().getBadge());
badge.add(AttributeAppender.replace("class", () -> getModelObject().getBadgeCss()));
badge.add(new VisibleBehaviour(() -> StringUtils.isNotEmpty(getModelObject().getBadge())));
link.add(badge);

WebMarkupContainer chevron = new WebMarkupContainer(ID_CHEVRON);
chevron.add(new VisibleBehaviour(() -> {
ListGroupMenuItem item = getModelObject();
return StringUtils.isNotEmpty(item.getBadge()) && !item.getItems().isEmpty();
}));
link.add(chevron);

WebMarkupContainer content = new WebMarkupContainer(ID_CONTENT);
add(content);
}

protected void onClickPerformed(AjaxRequestTarget target) {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!--
~ Copyright (c) 2010-2017 Evolveum
~
~ This work is dual-licensed under the Apache License 2.0
~ and European Union Public License. See LICENSE file for details.
-->
<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>
<wicket:container wicket:id="items">
<li class="list-group-menu-item" wicket:id="item">
<a href="#" class="item-link" wicket:id="link">
<i class="icon fa fa-fw fa-border-all" wicket:id="icon"></i>
<span class="label" wicket:id="label">All roles</span>
<span class="badge badge-primary badge-pill" wicket:id="badge">14</span>
<i class="fa fa-chevron-left" wicket:id="chevron"></i>
</a>
<wicket:container id="content"/>
</li>
</wicket:container>
</wicket:panel>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright (c) 2022 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/

package com.evolveum.midpoint.gui.impl.page.self.requestAccess;

import com.evolveum.midpoint.gui.api.component.BasePanel;

import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.model.IModel;

import java.io.Serializable;
import java.util.List;

/**
* Created by Viliam Repan (lazyman).
*/
public class ListGroupMenuPanel extends BasePanel<List<ListGroupMenuItem>> {

private static final long serialVersionUID = 1L;

private static final String ID_ITEMS = "items";
private static final String ID_ITEM = "item";

public ListGroupMenuPanel(String id, IModel<List<ListGroupMenuItem>> model) {
super(id, model);

initLayout();
}

@Override
protected void onComponentTag(ComponentTag tag) {
super.onComponentTag(tag);

checkComponentTag(tag, "ul");
}

private void initLayout() {
add(AttributeAppender.append("class", "list-group-menu"));

ListView items = new ListView(ID_ITEMS, getModel()) {

@Override
protected void populateItem(ListItem item) {

}
};
add(items);
}

// todo implement
}

0 comments on commit aadc0c2

Please sign in to comment.