Skip to content

Commit

Permalink
MID-7804: fix for configurable clickable first column with multi segm…
Browse files Browse the repository at this point in the history
…ent item path
  • Loading branch information
skublik committed Apr 4, 2022
1 parent b672b76 commit 15fa334
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ private Component createNewObjectButton(String buttonId) {
builder.setBasicIcon(WebComponentUtil.getIconCssClass(newObjectButtonDisplayType), IconCssStyle.IN_ROW_STYLE)
.appendColorHtmlValue(WebComponentUtil.getIconColor(newObjectButtonDisplayType));
CompiledObjectCollectionView view = getObjectCollectionView();
if (isCollectionViewPanelForCompiledView() && GuiDisplayTypeUtil.existsIconDisplay(view)) {
if (isCollectionViewPanelForCompiledView() && GuiDisplayTypeUtil.existsIconDisplay(view)
&& GuiDisplayTypeUtil.containsDifferentIcon(newObjectButtonDisplayType, GuiStyleConstants.CLASS_ADD_NEW_OBJECT)) {
IconType plusIcon = new IconType();
plusIcon.setCssClass(GuiStyleConstants.CLASS_ADD_NEW_OBJECT);
plusIcon.setColor("green");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.evolveum.midpoint.prism.util.PolyStringUtils;
import com.evolveum.midpoint.schema.constants.RelationTypes;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.util.MiscSchemaUtil;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.component.data.column.ColumnUtils;
Expand Down Expand Up @@ -184,6 +185,11 @@ public static DisplayType getNewObjectDisplayTypeFromCollectionView(CompiledObje
if (displayType == null) {
displayType = createDisplayType(GuiStyleConstants.CLASS_ADD_NEW_OBJECT, "green", "");
}

if (displayType.getIcon() == null || displayType.getIcon().getCssClass() == null){
MiscSchemaUtil.mergeDisplay(displayType, createDisplayType(GuiStyleConstants.CLASS_ADD_NEW_OBJECT, "green", ""));
}

if (PolyStringUtils.isEmpty(displayType.getTooltip()) && !PolyStringUtils.isEmpty(displayType.getLabel())) {
StringBuilder sb = new StringBuilder();
sb.append(pageBase.createStringResource("MainObjectListPanel.newObject").getString());
Expand Down Expand Up @@ -219,12 +225,23 @@ public static boolean existsIconDisplay(CompiledObjectCollectionView view) {
if (view == null){
return false;
}
if (view.getDisplay() == null){
return existsIconDisplay(view.getDisplay());
}

private static boolean existsIconDisplay(DisplayType display) {
if (display == null){
return false;
}
if (view.getDisplay().getIcon() == null){
if (display.getIcon() == null){
return false;
}
return StringUtils.isNotBlank(view.getDisplay().getIcon().getCssClass());
return StringUtils.isNotBlank(display.getIcon().getCssClass());
}

public static boolean containsDifferentIcon(DisplayType display, String iconCss) {
if (existsIconDisplay(display)) {
return !display.getIcon().getCssClass().contains(iconCss);
}
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,14 @@ public String getObject() {
return getName(value, selectableBean);
}

Object itemPathPropertyValue = new PropertyModel<>(rowModel, "value." + itemPath).getObject();
StringBuilder path = new StringBuilder("value");
itemPath.getSegments().forEach(segment -> {
if (segment != null) {
path.append(".").append(segment);
}
});

Object itemPathPropertyValue = new PropertyModel<>(rowModel, path.toString()).getObject();
return itemPathPropertyValue != null ? itemPathPropertyValue.toString() : "";

}
Expand Down

0 comments on commit 15fa334

Please sign in to comment.