Skip to content

Commit

Permalink
adding new activation wizard step
Browse files Browse the repository at this point in the history
  • Loading branch information
skublik committed Jun 26, 2023
1 parent ee926a5 commit 7a60f96
Show file tree
Hide file tree
Showing 39 changed files with 1,294 additions and 774 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5810,29 +5810,37 @@ public static String createMappingIcon(PrismContainerValueWrapper<? extends Cont
}

PrismContainerDefinition<ResourceBidirectionalMappingType> parentDef = parent.getDefinition();
if (parentDef == null) {
return "fa fa-circle";
}
return createMappingIcon(parentDef);

if (QNameUtil.match(parentDef.getItemName(), ResourceActivationDefinitionType.F_ADMINISTRATIVE_STATUS)) {
return "fa fa-id-card-clip";
} else if (QNameUtil.match(parentDef.getItemName(), ResourceActivationDefinitionType.F_EXISTENCE)) {
return "fa fa-universal-access";
} else if (QNameUtil.match(parentDef.getItemName(), ResourceActivationDefinitionType.F_VALID_FROM)) {
return "fa fa-arrow-right-from-bracket";
} else if (QNameUtil.match(parentDef.getItemName(), ResourceActivationDefinitionType.F_VALID_TO)) {
return "fa fa-arrow-right-to-bracket";
} else if (QNameUtil.match(parentDef.getItemName(), ResourceActivationDefinitionType.F_LOCKOUT_STATUS)) {
return "fa fa-user-lock";
}
} else if (QNameUtil.match(def.getItemName(), ResourceActivationDefinitionType.F_DISABLE_INSTEAD_DELETE)) {
return "fa fa-user-slash";
} else if (QNameUtil.match(def.getItemName(), ResourceActivationDefinitionType.F_DELAYED_DELETE)) {
return "fa fa-clock";
} else if (QNameUtil.match(def.getItemName(), ResourceActivationDefinitionType.F_PRE_PROVISION)) {
return "fa fa-user-plus";
} else {
return createMappingIcon(def);
}
}
return "fa fa-circle";
}

public static String createMappingIcon(PrismContainerDefinition<? extends Containerable> def) {
if (def == null) {
return "fa fa-circle";
}

if (QNameUtil.match(def.getItemName(), ResourceActivationDefinitionType.F_ADMINISTRATIVE_STATUS)) {
return "fa fa-id-card-clip";
} else if (QNameUtil.match(def.getItemName(), ResourceActivationDefinitionType.F_EXISTENCE)) {
return "fa fa-universal-access";
} else if (QNameUtil.match(def.getItemName(), ResourceActivationDefinitionType.F_VALID_FROM)) {
return "fa fa-arrow-right-from-bracket";
} else if (QNameUtil.match(def.getItemName(), ResourceActivationDefinitionType.F_VALID_TO)) {
return "fa fa-arrow-right-to-bracket";
} else if (QNameUtil.match(def.getItemName(), ResourceActivationDefinitionType.F_LOCKOUT_STATUS)) {
return "fa fa-user-lock";
} else if (QNameUtil.match(def.getItemName(), ResourceActivationDefinitionType.F_DISABLE_INSTEAD_DELETE)) {
return "fa fa-user-slash";
} else if (QNameUtil.match(def.getItemName(), ResourceActivationDefinitionType.F_DELAYED_DELETE)) {
return "fa fa-clock";
} else if (QNameUtil.match(def.getItemName(), ResourceActivationDefinitionType.F_PRE_PROVISION)) {
return "fa fa-user-plus";
}
return "fa fa-circle";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
</div>
</wicket:fragment>
<wicket:fragment wicket:id="tilesFragment">
<div wicket:id="tiles" style="min-height: 250px;">
<div wicket:id="tiles">
<div wicket:id="tile"/>
</div>
</wicket:fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public abstract class TileTablePanel<T extends Tile, O extends Serializable> ext
private static final long serialVersionUID = 1L;

static final String ID_TILES_CONTAINER = "tilesContainer";
static final String ID_TILES_FRAGMENT = "tilesFragment";
protected static final String ID_TILES_FRAGMENT = "tilesFragment";
protected static final String ID_TILES = "tiles";

private static final String ID_HEADER_FRAGMENT = "headerFragment";
Expand Down Expand Up @@ -106,6 +106,7 @@ private void initLayout() {
add(tilesContainer);

WebMarkupContainer footerContainer = new WebMarkupContainer(ID_FOOTER_CONTAINER);
footerContainer.add(new VisibleBehaviour(this::showFooter));
footerContainer.setOutputMarkupId(true);
footerContainer.add(AttributeAppender.append("class", getTilesFooterCssClasses()));
add(footerContainer);
Expand All @@ -127,6 +128,10 @@ protected String getPaginationCssClass() {
add(table);
}

protected boolean showFooter() {
return true;
}

protected WebMarkupContainer createTilesContainer(String idTilesContainer, ISortableDataProvider<O, String> provider, UserProfileStorage.TableId tableId) {
Fragment tilesFragment = new Fragment(idTilesContainer, ID_TILES_FRAGMENT, TileTablePanel.this);

Expand All @@ -143,6 +148,7 @@ protected PageableListView createTilesPanel(
@Override
protected void populateItem(ListItem<T> item) {
item.add(AttributeAppender.append("class", () -> getTileCssClasses()));
item.add(AttributeAppender.append("style", () -> getTileCssStyle()));

Component tile = createTile(ID_TILE, item.getModel());
item.add(tile);
Expand All @@ -155,6 +161,10 @@ protected List<T> createItem(O object) {
};
}

protected String getTileCssStyle() {
return "min-height: 250px;";
}

protected UserProfileStorage.TableId getTableId() {
return tableId;
}
Expand Down Expand Up @@ -266,7 +276,7 @@ public void refresh(AjaxRequestTarget target) {
if (viewToggleModel.getObject() == ViewToggle.TABLE) {
target.add(get(ID_TABLE));
} else {
target.add(get(ID_TILES_CONTAINER), getTilesNavigation());
target.add(get(ID_TILES_CONTAINER), getTilesNavigation(), get(ID_FOOTER_CONTAINER));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package com.evolveum.midpoint.gui.impl.factory.wrapper;

import com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractPredefinedActivationMappingType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.CollectionRefSpecificationType;

import org.springframework.stereotype.Component;
Expand All @@ -27,7 +28,9 @@ public class NoEmptyValueContainerWrapperFactoryImpl<C extends Containerable> ex
public boolean match(ItemDefinition<?> def) {
return def instanceof PrismContainerDefinition && def.isMultiValue()
|| AbstractWorkItemOutputType.COMPLEX_TYPE.equals(def.getTypeName())
|| ApprovalSchemaType.COMPLEX_TYPE.equals(def.getTypeName());
|| ApprovalSchemaType.COMPLEX_TYPE.equals(def.getTypeName())
|| (def.getTypeClass() != null
&& AbstractPredefinedActivationMappingType.class.isAssignableFrom(def.getTypeClass()));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,24 @@
/**
* @author lskublik
*/
public class ResourceTilePanel<O extends Serializable> extends BasePanel<TemplateTile<O>> {
public class ResourceTilePanel<O extends Serializable, T extends TemplateTile<O>> extends BasePanel<T> {

private static final long serialVersionUID = 1L;


private static final String ID_ICON = "icon";
private static final String ID_TITLE = "title";
private static final String ID_DESCRIPTION = "description";
protected static final String ID_DESCRIPTION = "description";

private static final String ID_TAG = "tag";

public ResourceTilePanel(String id, IModel<TemplateTile<O>> model) {
public ResourceTilePanel(String id, IModel<T> model) {
super(id, model);

initLayout();
}

private void initLayout() {
protected void initLayout() {
add(AttributeAppender.append(
"class",
"card selectable col-12 catalog-tile-panel d-flex flex-column align-items-center p-3 pb-5 pt-4 h-100 mb-0 btn"));
Expand All @@ -67,19 +67,28 @@ private void initLayout() {
add(descriptionPanel);

Label tagPanel = new Label(ID_TAG, () -> {
if (getModelObject().getTags().isEmpty()) {
return null;
}
DisplayType tag = getModelObject().getTags().iterator().next();
return tag != null ? WebComponentUtil.getTranslatedPolyString(tag.getLabel()) : null;
});
tagPanel.add(new VisibleBehaviour(() -> getModelObject().getTags() != null));
add(tagPanel);

add(new AjaxEventBehavior("click") {
if (addClickBehaviour()) {
add(new AjaxEventBehavior("click") {

@Override
protected void onEvent(AjaxRequestTarget target) {
ResourceTilePanel.this.onClick(target);
}
});
@Override
protected void onEvent(AjaxRequestTarget target) {
ResourceTilePanel.this.onClick(target);
}
});
}
}

protected boolean addClickBehaviour() {
return true;
}

protected void onClick(AjaxRequestTarget target) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* Copyright (C) 2010-2023 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.resource.component.wizard.objectType.activation;

import com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper;
import com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper;
import com.evolveum.midpoint.gui.api.util.MappingDirection;
import com.evolveum.midpoint.gui.api.util.WebPrismUtil;
import com.evolveum.midpoint.gui.impl.component.data.provider.BaseSortableDataProvider;
import com.evolveum.midpoint.prism.Containerable;
import com.evolveum.midpoint.prism.PrismContainerDefinition;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceActivationDefinitionType;

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

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

public class ActivationContainerProvider extends BaseSortableDataProvider<PrismContainerDefinition> {

private final MappingDirection mappingDirection;
private final IModel<PrismContainerValueWrapper<ResourceActivationDefinitionType>> parentModel;

public ActivationContainerProvider(
Component component,
IModel<PrismContainerValueWrapper<ResourceActivationDefinitionType>> parentModel,
MappingDirection mappingDirection) {
super(component, false, false);
this.mappingDirection = mappingDirection;
this.parentModel = parentModel;
}

@Override
public Iterator<? extends PrismContainerDefinition> internalIterator(long first, long count) {
List<PrismContainerDefinition> list = new ArrayList<>();
PrismContainerValueWrapper<? extends Containerable> parent = parentModel.getObject();
if (parent != null) {
WebPrismUtil.sortContainers(parent.getContainers());
for (PrismContainerWrapper<? extends Containerable> child : parent.getContainers()) {
if (skipContainerDefinition(child.getItem().getDefinition())) {
continue;
}
list.add(child.getItem().getDefinition());
}
}
return list.iterator();
}

private boolean skipContainerDefinition(PrismContainerDefinition<? extends Containerable> definition){
if (MappingDirection.INBOUND.equals(mappingDirection)) {
if (ResourceActivationDefinitionType.F_EXISTENCE.equivalent(definition.getItemName())
|| ResourceActivationDefinitionType.F_DISABLE_INSTEAD_DELETE.equivalent(definition.getItemName())
|| ResourceActivationDefinitionType.F_DELAYED_DELETE.equivalent(definition.getItemName())
|| ResourceActivationDefinitionType.F_PRE_PROVISION.equivalent(definition.getItemName())) {
return true;
}
}
return false;
}

@Override
public int internalSize() {
PrismContainerValueWrapper<? extends Containerable> parent = parentModel.getObject();
if (parent == null) {
return 0;
}
return parent.getContainers().size();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
xmlns:wicket="http://wicket.apache.org">
<body>
<wicket:extend>
<div class="col-11 mx-auto p-0">
<div class="card-body p-0" wicket:id="table"/>
</div>
<div class="ml-auto mr-auto col-11 px-0" wicket:id="tabTable"/>
</wicket:extend>
</body>
</html>

0 comments on commit 7a60f96

Please sign in to comment.