Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
skublik committed Oct 11, 2022
2 parents 5f45980 + 799b0d6 commit 58bdb13
Show file tree
Hide file tree
Showing 54 changed files with 1,301 additions and 650 deletions.
4 changes: 4 additions & 0 deletions gui/admin-gui/src/frontend/scss/midpoint.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1152,6 +1152,10 @@ span.tree-content > table tr td:first-child {
display: inline-block;
}

.small-box-default-icon{
font-size: 50px !important;
}

.small-box{
cursor: default;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ protected List<CompiledObjectCollectionView> getNewObjectInfluencesList() {
return getAllApplicableArchetypeViews();
}

private void deleteConfirmedPerformed(AjaxRequestTarget target, IModel<SelectableBean<O>> objectToDelete) {
public void deleteConfirmedPerformed(AjaxRequestTarget target, IModel<SelectableBean<O>> objectToDelete) {
List<SelectableBean<O>> objects = isAnythingSelected(target, objectToDelete);

if (objects.isEmpty()) {
Expand Down Expand Up @@ -528,26 +528,8 @@ public List<SelectableBean<O>> isAnythingSelected(AjaxRequestTarget target, IMod
selectedObjects.add(selectedObject.getObject());
} else {
selectedObjects = TableUtil.getSelectedModels(getTable().getDataTable());
// if (users.isEmpty() && StringUtils.isNotEmpty(getNothingSelectedMessage())) {
// warn(getNothingSelectedMessage());
// target.add(getFeedbackPanel());
// }
}
return selectedObjects;
// List<SelectableObjectModel<UserType>> users;
// if (selectedObject != null) {
// users = new ArrayList<>();
// users.add(selectedObject);
// } else {
// users = (List<SelectableObjectModel<UserType>>) TableUtil.getSelectedModels(getTable().getDataTable());
// if (users.isEmpty() && StringUtils.isNotEmpty(getNothingSelectedMessage())) {
// warn(getNothingSelectedMessage());
// target.add(getFeedbackPanel());
// }
// }
//
// return users;
// return new ArrayList<>();
}

protected String getNothingSelectedMessage() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ public <T> void exportData(IDataProvider<T> dataProvider,
}
}

@Override
protected String quoteValue(String value) {
value = value.replaceAll("^\\[|\\]$", "");
return super.quoteValue(value);
}

@Override
protected <T> IModel<T> wrapModel(IModel<T> model) {
if (model.getObject() == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ default boolean onBackPerformed(AjaxRequestTarget target) {

/**
* @return flag whether default "next" button action should be executed.
* If true, default behaviour of back button will be executed as well
* If true, default behaviour of next button will be executed as well
* If false, only code in this method will be executed
*/
default boolean onNextPerformed(AjaxRequestTarget target) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class WrapperContext {
@Experimental
private Map<String, LookupTableType> lookupTableCache = new HashMap();

private List<ContainerPanelConfigurationType> detailsPageTypeConfiguration;
private List<? extends ContainerPanelConfigurationType> detailsPageTypeConfiguration;
private Collection<VirtualContainersSpecificationType> virtualContainers = new ArrayList<>();

//Attribute mapping related attributes
Expand Down Expand Up @@ -221,7 +221,7 @@ public Collection<VirtualContainersSpecificationType> getVirtualContainers() {
if (detailsPageTypeConfiguration == null) {
return virtualContainers;
}
List<ContainerPanelConfigurationType> containerPanelConfigurationTypes = detailsPageTypeConfiguration;
List<? extends ContainerPanelConfigurationType> containerPanelConfigurationTypes = detailsPageTypeConfiguration;
if (containerPanelConfigurationTypes.isEmpty()) {
return virtualContainers;
}
Expand All @@ -230,7 +230,7 @@ public Collection<VirtualContainersSpecificationType> getVirtualContainers() {
return virtualContainers;
}

protected void collectVirtualContainers(@NotNull Collection<ContainerPanelConfigurationType> panelConfigs, Collection<VirtualContainersSpecificationType> virtualContainers) {
protected void collectVirtualContainers(@NotNull Collection<? extends ContainerPanelConfigurationType> panelConfigs, Collection<VirtualContainersSpecificationType> virtualContainers) {
for (ContainerPanelConfigurationType panelConfig : panelConfigs) {
if (objectStatus == null || panelConfig.getApplicableForOperation() == null
|| (ItemStatus.NOT_CHANGED.equals(objectStatus)
Expand All @@ -252,7 +252,7 @@ public VirtualContainersSpecificationType findVirtualContainerConfiguration(Item
return null;
}

public void setDetailsPageTypeConfiguration(List<ContainerPanelConfigurationType> detailsPageTypeConfiguration) {
public void setDetailsPageTypeConfiguration(List<? extends ContainerPanelConfigurationType> detailsPageTypeConfiguration) {
this.detailsPageTypeConfiguration = detailsPageTypeConfiguration;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/*
* Copyright (c) 2010-2021 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.component;

import com.evolveum.midpoint.gui.api.util.GuiDisplayTypeUtil;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.prism.*;
import com.evolveum.midpoint.web.component.AjaxIconButton;
import com.evolveum.midpoint.web.component.util.SelectableRow;
import com.evolveum.midpoint.web.component.util.VisibleBehaviour;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import com.evolveum.prism.xml.ns._public.types_3.PolyStringType;

import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.markup.html.panel.Fragment;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.*;

import java.util.*;

/**
* @param <C> the container of displayed objects in table
* @param <PO> the type of the object processed by provider
* @author skublik
*
* Abstract class for List panels with table.
*/
public class ButtonBar<C extends Containerable, PO extends SelectableRow> extends Fragment {
private static final long serialVersionUID = 1L;

// private PreviewContainerPanelConfigurationType previewConfig;
private static final String ID_BUTTON_REPEATER = "buttonsRepeater";
private static final String ID_BUTTON = "button";

public ButtonBar(String id, String markupId, Panel markupProvider, PreviewContainerPanelConfigurationType previewContainerPanelConfigurationType) {
super(id, markupId, markupProvider);

List<Component> buttonsList = createNavigationButtons(ID_BUTTON, previewContainerPanelConfigurationType);
initLayout(buttonsList);
}

public ButtonBar(String id, String markupId, Panel markupProvider, List<Component> buttonsList) {
super(id, markupId, markupProvider);

initLayout(buttonsList);
}

private void initLayout(final List<Component> buttonsList) {
ListView<Component> buttonsView = new ListView<>(ID_BUTTON_REPEATER, Model.ofList(buttonsList)) {
@Override
protected void populateItem(ListItem<Component> listItem) {
listItem.add(listItem.getModelObject());
}
};
add(buttonsView);
}

private List<Component> createNavigationButtons(String idButton, PreviewContainerPanelConfigurationType previewConfig) {
List<Component> buttonsList = new ArrayList<>();
for (GuiActionType action : previewConfig.getAction()) {
AjaxIconButton button = createViewAllButton(idButton, action);
buttonsList.add(button);
}

return buttonsList;
}

private AjaxIconButton createViewAllButton(String buttonId, GuiActionType action) {
DisplayType displayType = action.getDisplay();
AjaxIconButton viewAll = new AjaxIconButton(buttonId, new Model<>(GuiDisplayTypeUtil.getIconCssClass(displayType)),
createButtonLabel(displayType)) {

@Override
public void onClick(AjaxRequestTarget target) {
viewAllActionPerformed(target, action);
}
};
viewAll.add(new VisibleBehaviour(() -> WebComponentUtil.getElementVisibility(action.getVisibility())));
viewAll.add(AttributeAppender.append("class", "btn btn-info btn-sm mr-2"));
viewAll.showTitleAsLabel(true);
return viewAll;
}

private IModel<String> createButtonLabel(DisplayType displayType) {
return () -> {
if (displayType == null) {
return "N/A";
}
PolyStringType label = GuiDisplayTypeUtil.getLabel(displayType);
if (label == null) {
return "N/A";
}
return WebComponentUtil.getTranslatedPolyString(label);
};
}

protected void viewAllActionPerformed(AjaxRequestTarget target, GuiActionType action) {
WebComponentUtil.redirectFromDashboardWidget(action, WebComponentUtil.getPageBase(this), this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public abstract class ContainerableListPanel<C extends Containerable, PO extends
private static final String OPERATION_LOAD_LOOKUP_TABLE = DOT_CLASS + "loadLookupTable";
private static final String ID_ITEMS_TABLE = "itemsTable";
private static final String ID_BUTTON_BAR = "buttonBar";
private static final String ID_BUTTON_REPEATER = "buttonsRepeater";
// private static final String ID_BUTTON_REPEATER = "buttonsRepeater";
private static final String ID_BUTTON = "button";

private final Class<C> defaultType;
Expand Down Expand Up @@ -295,7 +295,7 @@ protected org.apache.wicket.markup.repeater.Item<PO> customizeNewRowItem(org.apa
@Override
protected WebMarkupContainer createButtonToolbar(String id) {
if (isPreview()) {
return new ButtonBar(id, ID_BUTTON_BAR, ContainerableListPanel.this, createNavigationButtons(ID_BUTTON));
return new ButtonBar(id, ID_BUTTON_BAR, ContainerableListPanel.this, (PreviewContainerPanelConfigurationType) config);
}
return new ButtonBar(id, ID_BUTTON_BAR, ContainerableListPanel.this, createToolbarButtonsList(ID_BUTTON));
}
Expand Down Expand Up @@ -965,38 +965,6 @@ protected List<Component> createToolbarButtonsList(String idButton) {
return new ArrayList<>();
}

//TODO TODO TODO what about other buttons? e.g. request access?
private List<Component> createNavigationButtons(String idButton) {
List<Component> buttonsList = new ArrayList<>();
PreviewContainerPanelConfigurationType previewConfig = (PreviewContainerPanelConfigurationType) config;
for (GuiActionType action : previewConfig.getAction()) {
AjaxIconButton button = createViewAllButton(idButton, action);
buttonsList.add(button);
}

return buttonsList;
}

private AjaxIconButton createViewAllButton(String buttonId, GuiActionType action) {
DisplayType displayType = action.getDisplay();
AjaxIconButton viewAll = new AjaxIconButton(buttonId, new Model<>(GuiDisplayTypeUtil.getIconCssClass(displayType)),
() -> WebComponentUtil.getTranslatedPolyString(GuiDisplayTypeUtil.getLabel(displayType))) {

@Override
public void onClick(AjaxRequestTarget target) {
viewAllActionPerformed(target, action);
}
};
viewAll.add(new VisibleBehaviour(() -> WebComponentUtil.getElementVisibility(action.getVisibility())));
viewAll.add(AttributeAppender.append("class", "btn btn-info btn-sm mr-2"));
viewAll.showTitleAsLabel(true);
return viewAll;
}

protected void viewAllActionPerformed(AjaxRequestTarget target, GuiActionType action) {
WebComponentUtil.redirectFromDashboardWidget(action, getPageBase(), ContainerableListPanel.this);
}

protected String getStorageKey() {
if (isCollectionViewPanelForCompiledView()) {
StringValue collectionName = WebComponentUtil.getCollectionNameParameterValue(getPageBase());
Expand Down Expand Up @@ -1266,27 +1234,6 @@ public LoadableDetachableModel<Search<C>> getSearchModel() {
return searchModel;
}

private static class ButtonBar extends Fragment {

private static final long serialVersionUID = 1L;

public ButtonBar(String id, String markupId, ContainerableListPanel markupProvider, List<Component> buttonsList) {
super(id, markupId, markupProvider);

initLayout(buttonsList);
}

private void initLayout(final List<Component> buttonsList) {
ListView<Component> buttonsView = new ListView<>(ID_BUTTON_REPEATER, Model.ofList(buttonsList)) {
@Override
protected void populateItem(ListItem<Component> listItem) {
listItem.add(listItem.getModelObject());
}
};
add(buttonsView);
}
}

protected void createReportPerformed(AjaxRequestTarget target) {
PrismContext prismContext = getPageBase().getPrismContext();
PrismObjectDefinition<ReportType> def = prismContext.getSchemaRegistry().findObjectDefinitionByType(ReportType.COMPLEX_TYPE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public class SmallBox extends BasePanel<SmallBoxData> {
private static final String ID_LINK_ICON = "linkIcon";
private static final String ID_LINK_TEXT = "linkText";

private static final String ICON_SMALL_FONT_STYLE = "small-box-default-icon";

public SmallBox(String id, @NotNull IModel<SmallBoxData> model) {
super(id, model);

Expand All @@ -63,7 +65,7 @@ private void initLayout() {
addLabel(ID_DESCRIPTION, () -> getModelObject().getDescription());

WebMarkupContainer icon = new WebMarkupContainer(ID_ICON);
icon.add(AttributeAppender.append("class", () -> getModelObject().getIcon()));
icon.add(AttributeAppender.append("class", () -> getIconStyle(getModelObject().getIcon())));
add(icon);

AjaxLink link = new AjaxLink<>(ID_LINK) {
Expand Down Expand Up @@ -105,4 +107,8 @@ protected void onClickLink(AjaxRequestTarget target) {
protected boolean isLinkVisible() {
return getModelObject().getLink() != null;
}

private String getIconStyle(String iconClass) {
return isLinkVisible() ? iconClass : iconClass + " " + ICON_SMALL_FONT_STYLE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ public DisplayableValue<Boolean> getDefaultValue() {
return new SearchValue<>(Boolean.FALSE);
}

@Override
public DisplayableValue<Boolean> getValue() {
return new SearchValue<>(getSearchConfig().isIndirect());
}

@Override
protected String getNameResourceKey() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;

import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SearchBoxModeType;

import org.apache.commons.lang3.StringUtils;
import org.apache.wicket.model.IModel;

public class ProjectSearchItemWrapper extends AbstractRoleSearchItemWrapper{

Expand All @@ -42,7 +44,17 @@ public Class<ProjectSearchItemPanel> getSearchItemPanelClass() {

@Override
public DisplayableValue<ObjectReferenceType> getDefaultValue() {
return new SearchValue<>(new ObjectReferenceType());
ObjectReferenceType ref = new ObjectReferenceType();
ref.setType(OrgType.COMPLEX_TYPE);
return new SearchValue<>(ref);
}

@Override
public DisplayableValue<ObjectReferenceType> getValue() {
if (getSearchConfig().getProjectRef() == null) {
return getDefaultValue();
}
return new SearchValue<>(getSearchConfig().getProjectRef());
}

@Override
Expand Down

0 comments on commit 58bdb13

Please sign in to comment.