Skip to content

Commit

Permalink
fix MID-5239 show all assignments button + some refactoring for assig…
Browse files Browse the repository at this point in the history
…nments panel
  • Loading branch information
KaterynaHonchar committed Apr 1, 2019
1 parent dc9dbe1 commit 2347712
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 127 deletions.
Expand Up @@ -3360,20 +3360,19 @@ public static List<AssignmentObjectRelation> getRelationsDividedList(List<Assign
return combinedRelationList;
}

public static DisplayType getAssignmentObjectRelationDisplayType(AssignmentObjectRelation assignmentTargetRelation, PageBase pageBase){
public static DisplayType getAssignmentObjectRelationDisplayType(AssignmentObjectRelation assignmentTargetRelation, String defaultTitle){
QName relation = assignmentTargetRelation != null && !org.apache.commons.collections.CollectionUtils.isEmpty(assignmentTargetRelation.getRelations()) ?
assignmentTargetRelation.getRelations().get(0) : null;
if (relation != null){
RelationDefinitionType def = WebComponentUtil.getRelationDefinition(relation);
if (def != null){
DisplayType displayType = def.getDisplay();
if (displayType == null || displayType.getIcon() == null){
displayType = createDisplayType(GuiStyleConstants.EVO_ASSIGNMENT_ICON, "green",
pageBase.createStringResource("assignment.details.newValue").getString());
displayType = createDisplayType(GuiStyleConstants.EVO_ASSIGNMENT_ICON, "green", defaultTitle);
}
if (PolyStringUtils.isEmpty(displayType.getTooltip())){
StringBuilder sb = new StringBuilder();
sb.append(pageBase.createStringResource("MainObjectListPanel.newObject").getString());
sb.append(defaultTitle);
sb.append(" ");
sb.append(relation.getLocalPart());
displayType.setTooltip(createPolyFromOrigString(sb.toString()));
Expand Down

This file was deleted.

Expand Up @@ -67,58 +67,41 @@ public class AbstractRoleAssignmentPanel extends AssignmentPanel {

private static final Trace LOGGER = TraceManager.getTrace(AssignmentPanel.class);

private static final String ID_NEW_ITEM_BUTTON = "newItemButton";
private static final String ID_SHOW_ALL_ASSIGNMENTS_BUTTON = "showAllAssignmentsButton";
private static final String ID_BUTTON_TOOLBAR_FRAGMENT = "buttonToolbarFragment";

protected static final String DOT_CLASS = AbstractRoleAssignmentPanel.class.getName() + ".";
private static final String OPERATION_LOAD_TARGET_REF_OBJECT = DOT_CLASS + "loadAssignmentTargetRefObject";

public AbstractRoleAssignmentPanel(String id, IModel<ContainerWrapper<AssignmentType>> assignmentContainerWrapperModel){
super(id, assignmentContainerWrapperModel);
}

protected Fragment initCustomButtonToolbar(String contentAreaId){
Fragment searchContainer = new Fragment(contentAreaId, ID_BUTTON_TOOLBAR_FRAGMENT, this);

MultifunctionalButton newObjectIcon = getMultivalueContainerListPanel().getNewItemButton(ID_NEW_ITEM_BUTTON);
searchContainer.add(newObjectIcon);

AjaxIconButton showAllAssignmentsButton = new AjaxIconButton(ID_SHOW_ALL_ASSIGNMENTS_BUTTON, new Model<>("fa fa-address-card"),
createStringResource("AssignmentTablePanel.menu.showAllAssignments")) {

private static final long serialVersionUID = 1L;

@Override
public void onClick(AjaxRequestTarget ajaxRequestTarget) {
showAllAssignments(ajaxRequestTarget);
}
};
searchContainer.addOrReplace(showAllAssignmentsButton);
showAllAssignmentsButton.setOutputMarkupId(true);
showAllAssignmentsButton.add(new VisibleEnableBehaviour(){

private static final long serialVersionUID = 1L;

public boolean isVisible(){
return showAllAssignmentsVisible();
}
});
return searchContainer;
}

protected void showAllAssignments(AjaxRequestTarget target) {
PageBase pageBase = getPageBase();
List<AssignmentInfoDto> previewAssignmentsList;
if (pageBase instanceof PageAdminFocus) {
previewAssignmentsList = ((PageAdminFocus<?>) pageBase).showAllAssignmentsPerformed(target);
} else {
previewAssignmentsList = Collections.emptyList();
}
AllAssignmentsPreviewDialog assignmentsDialog = new AllAssignmentsPreviewDialog(pageBase.getMainPopupBodyId(), previewAssignmentsList,
pageBase);
pageBase.showMainPopup(assignmentsDialog, target);
}
// protected Fragment initCustomButtonToolbar(String contentAreaId){
// Fragment searchContainer = new Fragment(contentAreaId, ID_BUTTON_TOOLBAR_FRAGMENT, this);
//
// MultifunctionalButton newObjectIcon = getMultivalueContainerListPanel().getNewItemButton(ID_NEW_ITEM_BUTTON);
// searchContainer.add(newObjectIcon);
//
// AjaxIconButton showAllAssignmentsButton = new AjaxIconButton(ID_SHOW_ALL_ASSIGNMENTS_BUTTON, new Model<>("fa fa-address-card"),
// createStringResource("AssignmentTablePanel.menu.showAllAssignments")) {
//
// private static final long serialVersionUID = 1L;
//
// @Override
// public void onClick(AjaxRequestTarget ajaxRequestTarget) {
// showAllAssignments(ajaxRequestTarget);
// }
// };
// searchContainer.addOrReplace(showAllAssignmentsButton);
// showAllAssignmentsButton.setOutputMarkupId(true);
// showAllAssignmentsButton.add(new VisibleEnableBehaviour(){
//
// private static final long serialVersionUID = 1L;
//
// public boolean isVisible(){
// return showAllAssignmentsVisible();
// }
// });
// return searchContainer;
// }

protected List<IColumn<ContainerValueWrapper<AssignmentType>, String>> initColumns() {
List<IColumn<ContainerValueWrapper<AssignmentType>, String>> columns = new ArrayList<>();
Expand Down Expand Up @@ -174,9 +157,6 @@ private String getRelationLabelValue(ContainerValueWrapper<AssignmentType> assig
return assignmentWrapper.getContainerValue().getValue().getTargetRef().getRelation().getLocalPart();
}

protected boolean showAllAssignmentsVisible(){
return true;
}

protected void initCustomPaging(){
getAssignmentsTabStorage().setPaging(getPrismContext().queryFactory()
Expand Down
Expand Up @@ -18,8 +18,11 @@
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>
<div wicket:id="assignments"/>
<wicket:fragment wicket:id="searchFragment">
<wicket:fragment wicket:id="buttonToolbarFragment">
<div wicket:id="newItemButton" />
<div class="btn btn-default btn-sm" wicket:id="showAllAssignmentsButton" />
</wicket:fragment>

<wicket:fragment wicket:id="specificContainersFragment">
<div wicket:id="specificContainers" />
<div wicket:id="activationPanel" />
Expand Down
Expand Up @@ -34,12 +34,19 @@
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.component.AjaxIconButton;
import com.evolveum.midpoint.web.component.MultifunctionalButton;
import com.evolveum.midpoint.web.component.data.column.*;
import com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem;
import com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction;
import com.evolveum.midpoint.web.component.prism.*;
import com.evolveum.midpoint.web.component.search.SearchFactory;
import com.evolveum.midpoint.web.component.search.SearchItemDefinition;
import com.evolveum.midpoint.web.component.util.VisibleBehaviour;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
import com.evolveum.midpoint.web.page.admin.PageAdminFocus;
import com.evolveum.midpoint.web.page.admin.users.component.AllAssignmentsPreviewDialog;
import com.evolveum.midpoint.web.page.admin.users.component.AssignmentInfoDto;
import com.evolveum.midpoint.web.session.UserProfileStorage;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import org.apache.commons.collections.CollectionUtils;
Expand Down Expand Up @@ -83,6 +90,10 @@ public class AssignmentPanel extends BasePanel<ContainerWrapper<AssignmentType>>
protected static final String ID_SPECIFIC_CONTAINERS_FRAGMENT = "specificContainersFragment";
private final static String ID_ACTIVATION_PANEL = "activationPanel";
protected static final String ID_SPECIFIC_CONTAINER = "specificContainers";
private static final String ID_NEW_ITEM_BUTTON = "newItemButton";
private static final String ID_SHOW_ALL_ASSIGNMENTS_BUTTON = "showAllAssignmentsButton";
private static final String ID_BUTTON_TOOLBAR_FRAGMENT = "buttonToolbarFragment";


private static final String DOT_CLASS = AssignmentPanel.class.getName() + ".";
protected static final String OPERATION_LOAD_ASSIGNMENTS_LIMIT = DOT_CLASS + "loadAssignmentsLimit";
Expand Down Expand Up @@ -155,12 +166,15 @@ protected List<AssignmentObjectRelation> getNewObjectInfluencesList() {
@Override
protected DisplayType getNewObjectButtonDisplayType() {
return WebComponentUtil.createDisplayType(GuiStyleConstants.EVO_ASSIGNMENT_ICON, "green",
AssignmentPanel.this.createStringResource("assignment.details.newValue").getString());
AssignmentPanel.this.createStringResource(isInducement() ?
"AssignmentPanel.newInducementTitle" : "AssignmentPanel.newAssignmentTitle").getString());
}

@Override
protected DisplayType getNewObjectAdditionalButtonDisplayType(AssignmentObjectRelation assignmentTargetRelation) {
return WebComponentUtil.getAssignmentObjectRelationDisplayType(assignmentTargetRelation, AssignmentPanel.this.getPageBase());
return WebComponentUtil.getAssignmentObjectRelationDisplayType(assignmentTargetRelation,
AssignmentPanel.this.createStringResource(isInducement() ?
"AssignmentPanel.newInducementTitle" : "AssignmentPanel.newAssignmentTitle").getString());
}

@Override
Expand Down Expand Up @@ -222,8 +236,39 @@ protected WebMarkupContainer initButtonToolbar(String id) {
setOutputMarkupId(true);
}

protected WebMarkupContainer initCustomButtonToolbar(String id) {
return null;
protected Fragment initCustomButtonToolbar(String contentAreaId){
Fragment searchContainer = new Fragment(contentAreaId, ID_BUTTON_TOOLBAR_FRAGMENT, this);

MultifunctionalButton newObjectIcon = getMultivalueContainerListPanel().getNewItemButton(ID_NEW_ITEM_BUTTON);
searchContainer.add(newObjectIcon);

AjaxIconButton showAllAssignmentsButton = new AjaxIconButton(ID_SHOW_ALL_ASSIGNMENTS_BUTTON, new Model<>("fa fa-address-card"),
createStringResource("AssignmentTablePanel.menu.showAllAssignments")) {

private static final long serialVersionUID = 1L;

@Override
public void onClick(AjaxRequestTarget ajaxRequestTarget) {
showAllAssignments(ajaxRequestTarget);
}
};
searchContainer.addOrReplace(showAllAssignmentsButton);
showAllAssignmentsButton.setOutputMarkupId(true);
showAllAssignmentsButton.add(new VisibleBehaviour(() -> !isInducement()));
return searchContainer;
}

protected void showAllAssignments(AjaxRequestTarget target) {
PageBase pageBase = getPageBase();
List<AssignmentInfoDto> previewAssignmentsList;
if (pageBase instanceof PageAdminFocus) {
previewAssignmentsList = ((PageAdminFocus<?>) pageBase).showAllAssignmentsPerformed(target);
} else {
previewAssignmentsList = Collections.emptyList();
}
AllAssignmentsPreviewDialog assignmentsDialog = new AllAssignmentsPreviewDialog(pageBase.getMainPopupBodyId(), previewAssignmentsList,
pageBase);
pageBase.showMainPopup(assignmentsDialog, target);
}

protected List<SearchItemDefinition> createSearchableItems(PrismContainerDefinition<AssignmentType> containerDef){
Expand Down Expand Up @@ -255,8 +300,7 @@ protected void initCustomPaging(){
}

protected ObjectTabStorage getAssignmentsTabStorage(){
boolean isInducement = getModelObject().getPath().containsNameExactly(AbstractRoleType.F_INDUCEMENT);
if (isInducement){
if (isInducement()){
return getParentPage().getSessionStorage().getInducementsTabStorage();
} else {
return getParentPage().getSessionStorage().getAssignmentsTabStorage();
Expand Down Expand Up @@ -957,6 +1001,10 @@ protected boolean isAssignmentsLimitReached(int selectedAssignmentsCount, boolea
(changedItems + selectedAssignmentsCount) >= assignmentsRequestsLimit;
}

protected boolean isInducement(){
return getModelObject().getPath().containsNameExactly(AbstractRoleType.F_INDUCEMENT);
}

protected ObjectFilter getSubtypeFilter(){
return null;
}
Expand Down
Expand Up @@ -49,11 +49,4 @@ protected UserProfileStorage.TableId getTableId() {
private ObjectTabStorage getInducementsTabStorage(){
return getParentPage().getSessionStorage().getInducementsTabStorage();
}

@Override
protected boolean showAllAssignmentsVisible(){
return false;
}


}

This file was deleted.

Expand Up @@ -244,7 +244,8 @@ protected DisplayType getMainButtonDisplayType(){

@Override
protected DisplayType getAdditionalButtonDisplayType(AssignmentObjectRelation assignmentTargetRelation){
return WebComponentUtil.getAssignmentObjectRelationDisplayType(assignmentTargetRelation, AbstractRoleMemberPanel.this.getPageBase());
return WebComponentUtil.getAssignmentObjectRelationDisplayType(assignmentTargetRelation,
createStringResource("abstractRoleMemberPanel.menu.assignMember").getString());
}

@Override
Expand Down
Expand Up @@ -3514,6 +3514,8 @@ chooseMemberForOrgPopup.otherTypesLabel=Others
AssignmentPanel.newAssignmentParameters=Parameters
AssignmentPanel.allLabel=All
AssignmentPanel.viewTargetObject=View target object
AssignmentPanel.newAssignmentTitle=New assignment
AssignmentPanel.newInducementTitle=New inducement
SearchPanel.more=More...
SearchPanel.add=Add
SearchPanel.close=Close
Expand Down
@@ -1,6 +1,6 @@
username=administrator
password=5ecr3t
base_url=http://localhost:8180/midpoint
base_url=http://localhost:8080/midpoint
webdriver=webdriver.chrome.driver
webdriverLocation=/opt/chromedriver
# By default if no value is specified for headless start then the value is: false
Expand Down

0 comments on commit 2347712

Please sign in to comment.