Skip to content

Commit

Permalink
MID-7963 role catalog item details, wip
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Jun 14, 2022
1 parent 8e4a54f commit d99efda
Show file tree
Hide file tree
Showing 9 changed files with 199 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ public void onClick(AjaxRequestTarget target) {
Label cartCount = new Label(ID_CART_COUNT, () -> {
List list = getSessionStorage().getRequestAccess().getShoppingCartAssignments();
return list.isEmpty() ? null : list.size();
} );
});
cartLink.add(cartCount);
}

Expand Down Expand Up @@ -510,6 +510,11 @@ public void showMainPopup(Popupable popupable, AjaxRequestTarget target) {
popupable.getWidthUnit(),
"" + (popupable.getHeight() > 0 ? popupable.getHeight() : ""), popupable.getHeightUnit())));
dialog.setContent(popupable.getComponent());
Component footer = popupable.getFooter();
if (footer != null) {
dialog.setFooter(footer);
}

dialog.setTitle(popupable.getTitle());
dialog.open(target);
}
Expand All @@ -520,8 +525,8 @@ public void hideMainPopup(AjaxRequestTarget target) {

private VisibleBehaviour getShoppingCartVisibleBehavior() {
return new VisibleBehaviour(() -> !isErrorPage() && isSideMenuVisible() &&
(WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_SELF_REQUESTS_ASSIGNMENTS_URL, PageSelf.AUTH_SELF_ALL_URI)
&& getSessionStorage().getRoleCatalog().getAssignmentShoppingCart().size() > 0));
(WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_SELF_REQUESTS_ASSIGNMENTS_URL, PageSelf.AUTH_SELF_ALL_URI)
&& getSessionStorage().getRoleCatalog().getAssignmentShoppingCart().size() > 0));
}

private VisibleBehaviour createUserStatusBehaviour() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ public class TileTablePanel<T extends Tile, O extends Serializable> extends Base

private IModel<Search> searchModel;

public TileTablePanel(String id, ISortableDataProvider provider, List<IColumn> columns) {
public TileTablePanel(String id, ISortableDataProvider provider, List<IColumn<O, String>> columns) {
this(id, provider, columns, null);
}

public TileTablePanel(String id, ISortableDataProvider provider, List<IColumn> columns, IModel<ViewToggle> viewToggle) {
public TileTablePanel(String id, ISortableDataProvider provider, List<IColumn<O, String>> columns, IModel<ViewToggle> viewToggle) {
super(id);

if (viewToggle == null) {
Expand All @@ -70,7 +70,7 @@ public IModel<ViewToggle> getViewToggleModel() {
return viewToggleModel;
}

private void initLayout(ISortableDataProvider provider, List<IColumn> columns) {
private void initLayout(ISortableDataProvider<O, String> provider, List<IColumn<O, String>> columns) {
setOutputMarkupId(true);

add(createTilesHeader(ID_TILES_HEADER));
Expand All @@ -79,7 +79,7 @@ private void initLayout(ISortableDataProvider provider, List<IColumn> columns) {
tilesContainer.add(new VisibleBehaviour(() -> viewToggleModel.getObject() == ViewToggle.TILE));
add(tilesContainer);

PageableListView<T, O> tiles = new PageableListView<T, O>(ID_TILES, provider) {
PageableListView<T, O> tiles = new PageableListView<>(ID_TILES, provider) {

@Override
protected void populateItem(ListItem<T> item) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,32 @@
<body>
<wicket:extend>

<wicket:remove>
<div style="width:600px;">
<div class="card">
<div class="card-header">
<h3 class="card-title">Office 365</h3>
</div>
<div class="card-body">
<table class="table table-borderless">
<tr>
<td>Archetype</td>
<td>Business role</td>
</tr>
<tr>
<td>Owner</td>
<td>John Doe</td>
</tr>
</table>
<h3>Description</h3>
<div></div>
</div>
</div>
</div>
</wicket:remove>

<hr class="m-5"/>

<div style="width:300px;">
<ul wicket:id="sample"/>
<hr class="m-5"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!--
~ 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>
asdf

<wicket:fragment wicket:id="buttons">
<div class="d-flex flex-wrap gap-2 w-100">
<a class="btn btn-success">
<i class="fas fa-cart-plus mr-1"></i>
Add to cart
</a>
<a class="btn btn-outline-primary">
<i class="fa-solid fa-xmark mr-1"></i>
Close
</a>
</div>
</wicket:fragment>
<!-- <table class="table table-borderless">-->
<!-- <tr>-->
<!-- <td>Archetype</td>-->
<!-- <td wicket:id="archetype">Business role</td>-->
<!-- </tr>-->
<!-- <tr>-->
<!-- <td>Owner</td>-->
<!-- <td wicket:id="owner">John Doe</td>-->
<!-- </tr>-->
<!-- </table>-->
<!-- <h3>Description</h3>-->
<!-- <div wicket:id="description"/>-->
</wicket:panel>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* 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.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.web.component.dialog.Popupable;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;

import org.apache.wicket.Component;
import org.apache.wicket.markup.html.panel.Fragment;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.StringResourceModel;

/**
* Created by Viliam Repan (lazyman).
*/
public class CatalogItemDetailsPanel extends BasePanel<ObjectType> implements Popupable {

private static final String ID_BUTTONS = "buttons";

public CatalogItemDetailsPanel(String id, IModel<ObjectType> model) {
super(id, model);

initLayout();
}

private void initLayout() {
}

@Override
public Component getFooter() {
return new Fragment("footer", ID_BUTTONS, this);
}

@Override
public int getWidth() {
return 905;
}

@Override
public int getHeight() {
return 1139;
}

@Override
public String getWidthUnit() {
return "px";
}

@Override
public String getHeightUnit() {
return "px";
}

@Override
public IModel<String> getTitle() {
return () -> WebComponentUtil.getTranslatedPolyString(getModelObject().getName());
}

@Override
public Component getComponent() {
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@
import java.util.Objects;
import javax.xml.namespace.QName;

import com.evolveum.midpoint.util.logging.Trace;

import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.gui.api.page.PageBase;

import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;
import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn;
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.panel.Fragment;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.util.string.Strings;

import com.evolveum.midpoint.gui.api.component.wizard.Badge;
Expand All @@ -45,7 +45,10 @@
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.security.api.SecurityUtil;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.component.data.ObjectDataProvider;
import com.evolveum.midpoint.web.component.data.column.AjaxLinkPanel;
import com.evolveum.midpoint.web.component.data.column.CheckBoxHeaderColumn;
import com.evolveum.midpoint.web.component.data.column.IconColumn;
import com.evolveum.midpoint.web.component.util.SelectableBean;
Expand Down Expand Up @@ -128,9 +131,9 @@ protected Search load() {

ObjectDataProvider provider = new ObjectDataProvider(this, searchModel);

List<IColumn> columns = createColumns();
List<IColumn<SelectableBean<ObjectType>, String>> columns = createColumns();
TileTablePanel<CatalogTile<SelectableBean<ObjectType>>, SelectableBean<ObjectType>> tilesTable =
new TileTablePanel<>(ID_TILES, provider, columns, createViewToggleModel()) {
new TileTablePanel<CatalogTile<SelectableBean<ObjectType>>, SelectableBean<ObjectType>>(ID_TILES, provider, columns, createViewToggleModel()) {

@Override
protected WebMarkupContainer createTableButtonToolbar(String id) {
Expand Down Expand Up @@ -306,8 +309,9 @@ private List<ListGroupMenuItem> loadMenuItems(ObjectReferenceType ref) {
return list;
}

private List<IColumn> createColumns() {
List<IColumn> columns = new ArrayList<>();
private List<IColumn<SelectableBean<ObjectType>, String>> createColumns() {
List<IColumn<SelectableBean<ObjectType>, String>> columns = new ArrayList<>();

columns.add(new CheckBoxHeaderColumn());
columns.add(new IconColumn(null) {
@Override
Expand All @@ -318,15 +322,15 @@ protected DisplayType getIconDisplayType(IModel rowModel) {
columns.add(new PropertyColumn(createStringResource("ObjectType.name"), "value.name"));
columns.add(new PropertyColumn(createStringResource("ObjectType.description"), "value.description"));

columns.add(new AbstractColumn(null) {
columns.add(new AbstractColumn<>(null) {

@Override
public void populateItem(Item item, String id, IModel rowModel) {
item.add(new AjaxLink<>(id, createStringResource("RoleCatalogPanel.details")) {
public void populateItem(Item<ICellPopulator<SelectableBean<ObjectType>>> item, String id, IModel<SelectableBean<ObjectType>> model) {
item.add(new AjaxLinkPanel(id, createStringResource("RoleCatalogPanel.details")) {

@Override
public void onClick(AjaxRequestTarget target) {
// itemDetailsPerformed(target, );
itemDetailsPerformed(target, model.getObject().getValue());
}
});
}
Expand All @@ -336,7 +340,10 @@ public void onClick(AjaxRequestTarget target) {
}

private void itemDetailsPerformed(AjaxRequestTarget target, ObjectType object) {
PageBase page = getPageBase();
CatalogItemDetailsPanel panel = new CatalogItemDetailsPanel(page.getMainPopupBodyId(), Model.of(object));

page.showMainPopup(panel, target);
}

private void addAllItemsPerformed(AjaxRequestTarget target) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
<h4 class="modal-title" wicket:id="title"/>
</div>
</wicket:enclosure>
<div wicket:id="content" class="modal-body"/>
<div class="modal-body" wicket:id="content"/>
<div class="modal-footer" wicket:id="footer"/>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
import org.apache.wicket.extensions.ajax.markup.html.modal.ModalDialog;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.model.StringResourceModel;
import org.apache.wicket.model.IModel;

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

import org.jetbrains.annotations.NotNull;

/**
* @author Viliam Repan (lazyman)
* @author katkav
Expand All @@ -26,9 +28,24 @@ public class MainPopupDialog extends ModalDialog {
private static final long serialVersionUID = 1L;

private static final String ID_TITLE = "title";
private static final String ID_FOOTER = "footer";

private IModel<String> title;

public MainPopupDialog(String id) {
super(id);

initLayout();
}

private void initLayout() {
Label titleLabel = new Label(ID_TITLE, () -> title != null ? title.getObject() : null);
titleLabel.add(new VisibleBehaviour(() -> title != null && StringUtils.isNotEmpty(title.getObject())));
getDialogComponent().add(titleLabel);

WebMarkupContainer footer = new WebMarkupContainer(ID_FOOTER);
footer.add(VisibleBehaviour.ALWAYS_INVISIBLE);
getDialogComponent().add(footer);
}

@Override
Expand Down Expand Up @@ -76,9 +93,15 @@ public String generateWidthHeightParameter(String width, String widthUnit, Strin
return sb.toString();
}

public void setTitle(StringResourceModel title) {
Label titleLabel = new Label(ID_TITLE, title);
titleLabel.add(new VisibleBehaviour(() -> StringUtils.isNotEmpty(title.getString())));
getDialogComponent().addOrReplace(titleLabel);
public void setTitle(IModel<String> title) {
this.title = title;
}

public void setFooter(@NotNull Component footer) {
if (!ID_FOOTER.equals(footer.getId())) {
throw new IllegalArgumentException("Footer component id has to be " + ID_FOOTER + ", but real value is " + footer.getId());
}

getDialogComponent().addOrReplace(footer);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package com.evolveum.midpoint.web.component.dialog;

import org.apache.wicket.Component;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.StringResourceModel;

public interface Popupable {
Expand All @@ -15,7 +16,10 @@ public interface Popupable {
int getHeight();
String getWidthUnit();
String getHeightUnit();
StringResourceModel getTitle();
IModel<String> getTitle();
Component getComponent();

default Component getFooter() {
return null;
}
}

0 comments on commit d99efda

Please sign in to comment.