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 Mar 24, 2023
2 parents 29488ed + 51584ab commit 0563a42
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 77 deletions.
43 changes: 21 additions & 22 deletions gui/admin-gui/src/frontend/js/midpoint-theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,28 +147,6 @@ export default class MidPointTheme {
});
});

jQuery(function ($) {
$(".word-break-longer-text").css("word-break", function (index, origValue) {

var textOfColumn = $(".word-break-longer-text")[index].innerText;
if (textOfColumn != '' && textOfColumn != ' ') {
var numberOfChars = 15;
var controlValue = numberOfChars;
var indexOfSpace = textOfColumn.indexOf(' ');

while (indexOfSpace == (controlValue - numberOfChars)) {
controlValue = controlValue + 1 + indexOfSpace;
indexOfSpace = textOfColumn.indexOf(' ', (indexOfSpace + 1));
}

if (indexOfSpace + 1 != textOfColumn.length && textOfColumn.length > controlValue) {
return "break-word";
}
}
return "inherit";
});
});

jQuery(function ($) {
$(document).on("click", ".compositedButton[data-toggle='tooltip']", function (e, t) {
var parent = $(this).closest('.modal-dialog-content');
Expand All @@ -179,6 +157,27 @@ export default class MidPointTheme {
});
}

breakLongerTextInTableCell(cellId) {
$("#" + cellId).css("word-break", function (index, origValue) {
var textOfColumn = document.getElementById(cellId).innerText;
if (textOfColumn != '' && textOfColumn != ' ') {
var numberOfChars = 15;
var controlValue = numberOfChars;
var indexOfSpace = textOfColumn.indexOf(' ');

while (indexOfSpace == (controlValue - numberOfChars)) {
controlValue = controlValue + 1 + indexOfSpace;
indexOfSpace = textOfColumn.indexOf(' ', (indexOfSpace + 1));
}

if (indexOfSpace + 1 != textOfColumn.length && textOfColumn.length > controlValue) {
return "break-word";
}
}
return "inherit";
});
}

// I'm not sure why sidebar has 15px padding -> and why I had to use 10px constant here [lazyman]
fixContentHeight() {
if ($(".main-footer").length > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,22 @@
*/
package com.evolveum.midpoint.gui.impl.page.admin.resource.component;

import static com.evolveum.midpoint.web.page.admin.resources.ResourceContentPanel.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

import org.apache.commons.lang3.ArrayUtils;
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
import org.apache.wicket.model.StringResourceModel;

import com.evolveum.midpoint.gui.api.GuiStyleConstants;
import com.evolveum.midpoint.gui.api.component.MainObjectListPanel;
import com.evolveum.midpoint.gui.api.component.ObjectListPanel;
import com.evolveum.midpoint.gui.api.component.data.provider.ISelectableDataProvider;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.gui.impl.page.admin.AbstractObjectMainPanel;
import com.evolveum.midpoint.gui.impl.page.admin.resource.ResourceDetailsModel;
Expand All @@ -25,7 +38,6 @@
import com.evolveum.midpoint.web.application.PanelInstance;
import com.evolveum.midpoint.web.application.PanelType;
import com.evolveum.midpoint.web.component.AjaxButton;
import com.evolveum.midpoint.gui.api.component.data.provider.ISelectableDataProvider;
import com.evolveum.midpoint.web.component.data.column.ColumnUtils;
import com.evolveum.midpoint.web.component.dialog.Popupable;
import com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem;
Expand All @@ -35,19 +47,6 @@
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import com.evolveum.prism.xml.ns._public.types_3.PolyStringType;

import org.apache.commons.lang3.ArrayUtils;
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
import org.apache.wicket.model.StringResourceModel;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

import static com.evolveum.midpoint.schema.util.ResourceObjectTypeDefinitionTypeUtil.getObjectClassName;

@PanelType(name = "resourceTasks")
@PanelInstance(identifier = "resourceTasks", applicableForType = ResourceType.class, applicableForOperation = OperationTypeType.MODIFY,
display = @PanelDisplay(label = "PageResource.tab.content.tasks", icon = GuiStyleConstants.CLASS_OBJECT_TASK_ICON, order = 40))
Expand Down Expand Up @@ -199,17 +198,12 @@ public static TaskType createResourceTask(PrismContext prismContext, PrismObject
resourceRef.setTargetName(new PolyStringType(resource.getName()));
newTask.setObjectRef(resourceRef);

prepopulateTask(newTask, resource, archetypeRefs);
prepopulateTask(newTask, archetypeRefs);

return newTask;
}

private static void prepopulateTask(TaskType task, PrismObject<ResourceType> resource, List<ObjectReferenceType> archetypeRefs) {
SchemaHandlingType schemaHandling = resource.asObjectable().getSchemaHandling();
List<ResourceObjectTypeDefinitionType> objectTypes = Collections.emptyList();
if (schemaHandling != null) {
objectTypes = schemaHandling.getObjectType();
}
private static void prepopulateTask(TaskType task, List<ObjectReferenceType> archetypeRefs) {

if (task.getObjectRef() != null && ResourceType.COMPLEX_TYPE.equals(task.getObjectRef().getType())) {
if (hasArchetype(archetypeRefs, SystemObjectsType.ARCHETYPE_RECONCILIATION_TASK.value())) {
Expand All @@ -221,7 +215,7 @@ private static void prepopulateTask(TaskType task, PrismObject<ResourceType> res
work.setReconciliation(recon);
}

ResourceObjectSetType set = updateResourceObjectsSet(recon.getResourceObjects(), task.getObjectRef(), objectTypes);
ResourceObjectSetType set = updateResourceObjectsSet(recon.getResourceObjects(), task.getObjectRef());
recon.setResourceObjects(set);
} else if (hasArchetype(archetypeRefs, SystemObjectsType.ARCHETYPE_IMPORT_TASK.value())) {
WorkDefinitionsType work = findWork(task);
Expand All @@ -232,7 +226,7 @@ private static void prepopulateTask(TaskType task, PrismObject<ResourceType> res
work.setImport(imp);
}

ResourceObjectSetType set = updateResourceObjectsSet(imp.getResourceObjects(), task.getObjectRef(), objectTypes);
ResourceObjectSetType set = updateResourceObjectsSet(imp.getResourceObjects(), task.getObjectRef());
imp.setResourceObjects(set);
} else if (hasArchetype(archetypeRefs, SystemObjectsType.ARCHETYPE_LIVE_SYNC_TASK.value())) {
WorkDefinitionsType work = findWork(task);
Expand All @@ -243,7 +237,7 @@ private static void prepopulateTask(TaskType task, PrismObject<ResourceType> res
work.setLiveSynchronization(live);
}

ResourceObjectSetType set = updateResourceObjectsSet(live.getResourceObjects(), task.getObjectRef(), objectTypes);
ResourceObjectSetType set = updateResourceObjectsSet(live.getResourceObjects(), task.getObjectRef());
live.setResourceObjects(set);
} else if (hasArchetype(archetypeRefs, SystemObjectsType.ARCHETYPE_ASYNC_UPDATE_TASK.value())) {
WorkDefinitionsType work = findWork(task);
Expand All @@ -254,7 +248,7 @@ private static void prepopulateTask(TaskType task, PrismObject<ResourceType> res
work.setAsynchronousUpdate(async);
}

ResourceObjectSetType set = updateResourceObjectsSet(async.getUpdatedResourceObjects(), task.getObjectRef(), objectTypes);
ResourceObjectSetType set = updateResourceObjectsSet(async.getUpdatedResourceObjects(), task.getObjectRef());
async.setUpdatedResourceObjects(set);
}
}
Expand All @@ -274,7 +268,7 @@ private static WorkDefinitionsType findWork(TaskType task) {
return work;
}

private static ResourceObjectSetType updateResourceObjectsSet(ResourceObjectSetType set, ObjectReferenceType objectRef, List<ResourceObjectTypeDefinitionType> objectTypes) {
private static ResourceObjectSetType updateResourceObjectsSet(ResourceObjectSetType set, ObjectReferenceType objectRef) {
if (set == null) {
set = new ResourceObjectSetType();
}
Expand All @@ -283,12 +277,9 @@ private static ResourceObjectSetType updateResourceObjectsSet(ResourceObjectSetT
set.setResourceRef(objectRef);
}

if (objectTypes.size() == 1) {
ResourceObjectTypeDefinitionType def = objectTypes.get(0);
set.setKind(def.getKind());
set.setIntent(def.getIntent());
set.setObjectclass(getObjectClassName(def));
}
set.setKind(getKind());
set.setIntent(getIntent());
set.setObjectclass(getObjectClass());

return set;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
xmlns:wicket="http://wicket.apache.org">
<body>
<wicket:extend>
<div class="card col-10 mx-auto p-0">
<div class="card col-11 mx-auto p-0">
<div class="card-header">
<span>
<i class="fa fa-table"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
xmlns:wicket="http://wicket.apache.org">
<body>
<wicket:extend>
<div class="card col-10 mx-auto p-0">
<div class="card col-11 mx-auto p-0">
<div class="card-header">
<span>
<i class="fa fa-table"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,20 @@

package com.evolveum.midpoint.web.component.data;

import org.apache.wicket.AttributeModifier;
import com.evolveum.midpoint.web.security.MidPointAuthWebSession;
import com.evolveum.midpoint.web.session.SessionStorage;

import org.apache.wicket.Component;
import org.apache.wicket.Session;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.behavior.Behavior;
import org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable;
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.OnDomReadyHeaderItem;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.markup.repeater.data.IDataProvider;
import org.apache.wicket.model.IModel;
import org.apache.wicket.util.visit.IVisit;
import org.apache.wicket.util.visit.IVisitor;

import java.util.List;

Expand Down Expand Up @@ -49,7 +53,7 @@ public SelectableRowItem(String id, int index, IModel<T> model) {
@Override
protected Item<IColumn<T, String>> newCellItem(String id, int index, IModel<IColumn<T, String>> model) {
Item item = super.newCellItem(id, index, model);
item.add(AttributeAppender.append("class", "word-break-longer-text"));
item.add(new BreakTextBehaviour(item.getMarkupId()));
item.add(AttributeAppender.append("style", "word-wrap: break-word !important;"));

return item;
Expand All @@ -59,4 +63,25 @@ protected Item<IColumn<T, String>> newCellItem(String id, int index, IModel<ICol
protected void onPageChanged() {
super.onPageChanged();
}

private class BreakTextBehaviour extends Behavior {

private final String markId;

private BreakTextBehaviour(String markId) {
this.markId = markId;
}

@Override
public void renderHead(Component component, IHeaderResponse response) {
super.renderHead(component, response);

StringBuilder sb = new StringBuilder();
sb.append("MidPointTheme.breakLongerTextInTableCell('")
.append(markId)
.append("');");

response.render(OnDomReadyHeaderItem.forScript(sb.toString()));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,11 @@ public abstract class ResourceContentPanel extends BasePanel<PrismObject<Resourc
private static final String ID_SIMULATION = "simulation";
private static final String ID_TOTALS = "totals";

private final ShadowKindType kind;
private final String intent;
private final QName objectClass;
private static ShadowKindType kind;
private static String intent;
private static QName objectClass;

private String searchMode;
// private SelectableBeanObjectDataProvider<ShadowType> provider;

IModel<PrismObject<ResourceType>> resourceModel;

Expand All @@ -101,11 +100,11 @@ public abstract class ResourceContentPanel extends BasePanel<PrismObject<Resourc
public ResourceContentPanel(String id, IModel<PrismObject<ResourceType>> resourceModel, QName objectClass,
ShadowKindType kind, String intent, String searchMode, ContainerPanelConfigurationType config) {
super(id);
this.kind = kind;
ResourceContentPanel.kind = kind;
this.searchMode = searchMode;
this.resourceModel = resourceModel;
this.intent = intent;
this.objectClass = objectClass;
ResourceContentPanel.intent = intent;
ResourceContentPanel.objectClass = objectClass;
this.config = config;
}

Expand All @@ -119,20 +118,20 @@ protected void onInitialize() {
initLayout();
}

public ShadowKindType getKind() {
return kind;
public IModel<PrismObject<ResourceType>> getResourceModel() {
return resourceModel;
}

public String getIntent() {
return intent;
public static QName getObjectClass() {
return objectClass;
}

public IModel<PrismObject<ResourceType>> getResourceModel() {
return resourceModel;
public static ShadowKindType getKind() {
return kind;
}

public QName getObjectClass() {
return objectClass;
public static String getIntent() {
return intent;
}

ResourceObjectDefinition createAttributeSearchItemWrappers() {
Expand Down Expand Up @@ -311,7 +310,7 @@ public boolean isVisible() {

WebMarkupContainer taskButtonsContainer = new WebMarkupContainer(ID_TASK_BUTTONS_CONTAINER);
taskButtonsContainer.setOutputMarkupId(true);
taskButtonsContainer.add(new VisibleBehaviour(() -> isTaskButtonsContainerVisible()));
taskButtonsContainer.add(new VisibleBehaviour(this::isTaskButtonsContainerVisible));
add(taskButtonsContainer);

initButton(
Expand Down Expand Up @@ -493,11 +492,16 @@ protected String getSpecialDropdownMenuClass() {
}

private void newTaskPerformed(AjaxRequestTarget target, String archetypeOid, boolean isSimulation) {
List<ObjectReferenceType> archetypeRef = Arrays.asList(
List<ObjectReferenceType> archetypeRef = List.of(
new ObjectReferenceType()
.oid(archetypeOid)
.type(ArchetypeType.COMPLEX_TYPE));
try {

if (Objects.isNull(getObjectClass())) {
updateDefinitions();
}

TaskType newTask = ResourceTasksPanel.createResourceTask(getPrismContext(), getResourceModel().getObject(), archetypeRef);

if (isSimulation) {
Expand Down Expand Up @@ -655,4 +659,23 @@ private ObjectQuery getExistingTasksQuery(String archetypeRefOid) {
public ShadowTablePanel getTable() {
return (ShadowTablePanel) get(ID_TABLE);
}

protected void updateDefinitions() {
LOGGER.trace("Trying to update definitions for kind: {}, intent: {}", getKind(), getIntent());
ResourceObjectDefinition objectClassDef = null;
try {
objectClassDef = getDefinitionByKind();
} catch (SchemaException | ConfigurationException e) {
LOGGER.error("Failed to search for objectClass definition. Reason: {}", e.getMessage(), e);
}
if (objectClassDef == null) {
LOGGER.warn("Cannot find any definition for kind: {}, intent: {}", getKind(), getIntent());
} else {
objectClass = objectClassDef.getTypeName();
if (getIntent() == null) {
intent = ((ResourceObjectTypeDefinitionImpl) objectClassDef).getIntent();
}
}
}

}

0 comments on commit 0563a42

Please sign in to comment.