Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Jun 20, 2022
2 parents b7b4632 + a29b44d commit 30e5a16
Show file tree
Hide file tree
Showing 21 changed files with 558 additions and 274 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* and European Union Public License. See LICENSE file for details.
*/

package com.evolveum.midpoint.gui.api.component.wizard;
package com.evolveum.midpoint.gui.api.component;

import java.io.Serializable;

Expand All @@ -14,6 +14,27 @@
*/
public class Badge implements Serializable {

public enum State {
PRIMARY("badge badge-primary"),
SECONDARY("badge badge-secondary"),
SUCCESS("badge badge-success"),
DANGER("badge badge-danger"),
WARNING("badge badge-warning"),
INFO("badge badge-info"),
LIGHT("badge badge-light"),
DARK("badge badge-dark");

String css;

State(String css) {
this.css = css;
}

public String getCss() {
return css;
}
}

private String cssClass;

private String iconCssClass;
Expand Down Expand Up @@ -42,6 +63,14 @@ public void setCssClass(String cssClass) {
this.cssClass = cssClass;
}

public void setCssClass(State state) {
if (state == null) {
setCssClass((String) null);
} else {
setCssClass(state.getCss());
}
}

public String getIconCssClass() {
return iconCssClass;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
~ Copyright (c) 2010-2018 Evolveum
~ 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.
Expand All @@ -9,10 +9,7 @@
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>
<wicket:container wicket:id="badges">
<span wicket:id="badge">
<i class="mr-1" wicket:id="icon"></i>
<span wicket:id="text"/>
</span>
<span wicket:id="badge"/>
</wicket:container>
</wicket:panel>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
* and European Union Public License. See LICENSE file for details.
*/

package com.evolveum.midpoint.gui.api.component.wizard;
package com.evolveum.midpoint.gui.api.component;

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

import com.evolveum.midpoint.web.component.util.VisibleBehaviour;
Expand All @@ -24,16 +26,14 @@
/**
* Created by Viliam Repan (lazyman).
*/
public class BadgePanel extends BasePanel<List<Badge>> {
public class BadgeListPanel extends BasePanel<List<Badge>> {

private static final long serialVersionUID = 1L;

private static final String ID_BADGES = "badges";
private static final String ID_BADGE = "badge";
private static final String ID_ICON = "icon";
private static final String ID_TEXT = "text";

public BadgePanel(String id, IModel<List<Badge>> model) {
public BadgeListPanel(String id, IModel<List<Badge>> model) {
super(id, model);

initLayout();
Expand All @@ -46,20 +46,7 @@ private void initLayout() {

@Override
protected void populateItem(ListItem<Badge> item) {
WebMarkupContainer badge = new WebMarkupContainer(ID_BADGE);
badge.add(AttributeAppender.append("class", () -> item.getModelObject().getCssClass()));
badge.add(new VisibleBehaviour(() ->
StringUtils.isNotEmpty(item.getModelObject().getText()) || StringUtils.isNotEmpty(item.getModelObject().getIconCssClass())));

WebMarkupContainer icon = new WebMarkupContainer(ID_ICON);
icon.add(AttributeAppender.append("class", () -> item.getModelObject().getIconCssClass()));
icon.add(new VisibleBehaviour(() -> StringUtils.isNotEmpty(item.getModelObject().getIconCssClass())));
badge.add(icon);

Label text = new Label(ID_TEXT, () -> item.getModelObject().getText());
badge.add(text);

item.add(badge);
item.add(new BadgePanel(ID_BADGE, item.getModel()));
}
};
add(badges);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!--
~ Copyright (c) 2010-2018 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>
<i class="mr-1" wicket:id="icon"></i>
<span wicket:id="text"/>
</wicket:panel>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* 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.api.component;

import org.apache.commons.lang3.StringUtils;
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.model.IModel;

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

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

private static final long serialVersionUID = 1L;
private static final String ID_ICON = "icon";
private static final String ID_TEXT = "text";

public BadgePanel(String id, IModel<Badge> model) {
super(id, model);

initLayout();
}

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

checkComponentTag(tag, "span");
}

private void initLayout() {
add(AttributeAppender.append("class", () -> getModelObject().getCssClass()));
add(new VisibleBehaviour(() -> StringUtils.isNotEmpty(getModelObject().getText()) || StringUtils.isNotEmpty(getModelObject().getIconCssClass())));

WebMarkupContainer icon = new WebMarkupContainer(ID_ICON);
icon.add(AttributeAppender.append("class", () -> getModelObject().getIconCssClass()));
icon.add(new VisibleBehaviour(() -> StringUtils.isNotEmpty(getModelObject().getIconCssClass())));
add(icon);

Label text = new Label(ID_TEXT, () -> getModelObject().getText());
add(text);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public WizardHeader(String id, IModel<String> currentPanelTitle, IModel<String>
}

@Override
protected void onBeforeRender() {
super.onBeforeRender();
protected void onConfigure() {
super.onConfigure();

addOrReplace(createHeaderContent(ID_CONTENT));
}
Expand All @@ -54,7 +54,6 @@ private void initLayout(IModel<String> currentPanelTitle, IModel<String> nextPan
add(next);

add(new Label(ID_TITLE, currentPanelTitle));

}

protected Component createHeaderContent(String id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ protected void onComponentTag(ComponentTag tag) {
}

@Override
protected void onBeforeRender() {
super.onBeforeRender();
protected void onConfigure() {
super.onConfigure();

addOrReplace((Component) getCurrentPanel());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import java.util.ArrayList;
import java.util.List;

import com.evolveum.midpoint.web.component.util.SerializableConsumer;
import com.evolveum.midpoint.web.component.util.SerializableSupplier;
import com.evolveum.midpoint.gui.api.component.Badge;
import com.evolveum.midpoint.gui.api.component.BadgeListPanel;

import org.apache.wicket.Application;
import org.apache.wicket.Component;
Expand All @@ -39,7 +39,7 @@ default String appendCssToWizard() {
}

default Component createHeaderContent(String id) {
return new BadgePanel(id, getTitleBadges());
return new BadgeListPanel(id, getTitleBadges());
}

default IModel<String> getTitle() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
/*
* Copyright (c) 2018 Evolveum and contributors
* Copyright (C) 2018-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.admin.assignmentholder.component.assignmentType.assignment;

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

import javax.annotation.Nullable;
import javax.xml.namespace.QName;

import org.apache.wicket.model.IModel;

import com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper;
import com.evolveum.midpoint.gui.api.prism.wrapper.PrismObjectWrapper;
import com.evolveum.midpoint.gui.api.util.WebModelServiceUtils;
Expand All @@ -29,8 +28,6 @@
import com.evolveum.midpoint.web.application.PanelType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;

import org.apache.wicket.model.IModel;

@PanelType(name = "dataProtectionAssignments", experimental = true)
@PanelInstance(identifier = "dataProtectionAssignments",
applicableForType = FocusType.class,
Expand All @@ -48,23 +45,21 @@ public GenericAbstractRoleAssignmentPanel(String id, IModel<PrismObjectWrapper<F
protected ObjectQuery getCustomizeQuery() {
// This should do customPostSearch on repository level.
return QueryBuilder.queryFor(AssignmentType.class, getPrismContext())
.ref(AssignmentType.F_TARGET_REF, OrgType.COMPLEX_TYPE, null)
.item(ObjectType.F_SUBTYPE).contains("access")
.build();
.ref(AssignmentType.F_TARGET_REF, OrgType.COMPLEX_TYPE, null)
.item(ObjectType.F_SUBTYPE).contains("access")
.build();
}

@Override
protected List<PrismContainerValueWrapper<AssignmentType>> customPostSearch(List<PrismContainerValueWrapper<AssignmentType>> assignments) {

if(assignments == null) {
protected List<PrismContainerValueWrapper<AssignmentType>> customPostSearch(
List<PrismContainerValueWrapper<AssignmentType>> assignments) {
if (assignments == null) {
return null;
}

List<PrismContainerValueWrapper<AssignmentType>> resultList = new ArrayList<>();
Task task = getPageBase().createSimpleTask("load assignment targets");
Iterator<PrismContainerValueWrapper<AssignmentType>> assignmentIterator = assignments.iterator();
while (assignmentIterator.hasNext()) {
PrismContainerValueWrapper<AssignmentType> ass = assignmentIterator.next();
for (PrismContainerValueWrapper<AssignmentType> ass : assignments) {
AssignmentType assignment = ass.getRealValue();
if (assignment == null || assignment.getTargetRef() == null) {
continue;
Expand All @@ -81,7 +76,7 @@ protected List<PrismContainerValueWrapper<AssignmentType>> customPostSearch(List
}

@Override
protected ObjectFilter getSubtypeFilter(){
protected ObjectFilter getSubtypeFilter() {
return getPageBase().getPrismContext().queryFor(OrgType.class)
.block()
.item(OrgType.F_SUBTYPE)
Expand All @@ -94,5 +89,4 @@ protected ObjectFilter getSubtypeFilter(){
protected QName getAssignmentType() {
return OrgType.COMPLEX_TYPE;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* 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;

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

private ConflictItem added;

private ConflictItem exclusion;

private ConflictState state = ConflictState.UNRESOLVED;

private boolean warning;

public Conflict(ConflictItem added, ConflictItem exclusion, boolean warning) {
this.added = added;
this.exclusion = exclusion;
this.warning = warning;
}

public ConflictItem getAdded() {
return added;
}

public ConflictItem getExclusion() {
return exclusion;
}

public ConflictState getState() {
return state;
}

public void setState(ConflictState state) {
this.state = state;
}

public boolean isWarning() {
return warning;
}
}

0 comments on commit 30e5a16

Please sign in to comment.