Skip to content

Commit

Permalink
delegation panel fixes: MID-3892, MID-3893
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed May 3, 2017
1 parent c04e263 commit 5063544
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 22 deletions.
Expand Up @@ -51,6 +51,7 @@
import com.evolveum.midpoint.web.component.prism.InputPanel;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
import com.evolveum.midpoint.web.page.admin.configuration.component.ChooseTypePanel;
import com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour;
import com.evolveum.midpoint.web.page.admin.dto.ObjectViewDto;
import com.evolveum.midpoint.web.page.admin.users.component.AssignmentsPreviewDto;
import com.evolveum.midpoint.web.page.admin.users.dto.UserDtoStatus;
Expand Down Expand Up @@ -800,7 +801,7 @@ protected void onUpdate(AjaxRequestTarget target) {
});
}

private void addAjaxOnUpdateBehavior(WebMarkupContainer container) {
protected void addAjaxOnUpdateBehavior(WebMarkupContainer container) {
container.visitChildren(new IVisitor<Component, Object>() {
@Override
public void component(Component component, IVisit<Object> objectIVisit) {
Expand Down
Expand Up @@ -18,18 +18,18 @@

import com.evolveum.midpoint.gui.api.GuiStyleConstants;
import com.evolveum.midpoint.gui.api.component.togglebutton.ToggleIconButton;
import com.evolveum.midpoint.gui.api.model.LoadableModel;
import com.evolveum.midpoint.gui.api.page.PageBase;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.gui.api.util.WebModelServiceUtils;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.web.component.AjaxButton;
import com.evolveum.midpoint.web.component.DateInput;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
import com.evolveum.midpoint.web.page.admin.users.PageUser;
import com.evolveum.midpoint.web.page.admin.users.component.AssignmentPreviewDialog;
import com.evolveum.midpoint.web.page.admin.users.component.AssignmentsPreviewDto;
import com.evolveum.midpoint.web.page.admin.users.dto.UserDtoStatus;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.OtherPrivilegesLimitationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.WorkItemSelectorType;
Expand Down Expand Up @@ -113,11 +113,7 @@ public boolean isVisible(){
headerRow.add(arrowIcon);

WebMarkupContainer typeImage = new WebMarkupContainer(ID_TYPE_IMAGE);
if (delegatedToMe){
typeImage.add(AttributeModifier.append("class", createImageTypeModel(getModel())));
} else {
typeImage.add(AttributeModifier.append("class", AssignmentEditorDtoType.USER.getIconCssClass()));
}
typeImage.add(AttributeModifier.append("class", createImageTypeModel(getModel())));
headerRow.add(typeImage);

AjaxLink name = new AjaxLink(ID_NAME) {
Expand Down Expand Up @@ -147,9 +143,13 @@ public void onClick(AjaxRequestTarget target) {

WebMarkupContainer delegatedToTypeImage = new WebMarkupContainer(ID_DELEGATED_TO_IMAGE);
if (delegatedToMe){
delegatedToTypeImage.add(AttributeModifier.append("class", AssignmentEditorDtoType.USER.getIconCssClass()));
delegatedToTypeImage.add(AttributeModifier.append("class",
WebComponentUtil.createDefaultIcon(((PageUser)pageBase).getObjectWrapper().getObject())));
} else {
delegatedToTypeImage.add(AttributeModifier.append("class", createImageTypeModel(getModel())));
if (getModelObject().getDelegationOwner() != null) {
delegatedToTypeImage.add(AttributeModifier.append("class",
WebComponentUtil.createDefaultIcon(getModelObject().getDelegationOwner().asPrismObject())));
}
}
headerRow.add(delegatedToTypeImage);

Expand Down Expand Up @@ -280,7 +280,7 @@ public boolean isVisible(){
assignmentPrivilegesLabel.setOutputMarkupId(true);
labelContainer.add(assignmentPrivilegesLabel);

addOrReplacePrivilegesPanel(assignmentPrivilegesContainer);
addPrivilegesPanel(assignmentPrivilegesContainer);
AjaxButton limitPrivilegesButton = new AjaxButton(ID_LIMIT_PRIVILEGES_BUTTON,
pageBase.createStringResource("DelegationEditorPanel.limitPrivilegesButton")) {
@Override
Expand All @@ -303,7 +303,6 @@ public StringResourceModel getTitle() {
protected void addButtonClicked(AjaxRequestTarget target, List<AssignmentsPreviewDto> dtoList){
DelegationEditorPanel.this.getModelObject().setPrivilegeLimitationList(dtoList);
pageBase.hideMainPopup(target);
reloadBodyComponent(target);
}
};
pageBase.showMainPopup(assignmentPreviewDialog, target);
Expand Down Expand Up @@ -441,9 +440,11 @@ public boolean isVisible(){
}
});
body.add(managementWorkItems);

addAjaxOnUpdateBehavior(body);
};

private void addOrReplacePrivilegesPanel(WebMarkupContainer body){
private void addPrivilegesPanel(WebMarkupContainer body){
privilegesNames = getPrivilegesNamesList();
ListView<String> privilegesListComponent = new ListView<String>(ID_PRIVILEGES_LIST, privilegesNames){
private static final long serialVersionUID = 1L;
Expand All @@ -463,8 +464,7 @@ public boolean isVisible(){
if (!UserDtoStatus.ADD.equals(getModelObject().getStatus())){
return true;
}
// return !allAssignmentPrivilegesSelected();
return false;
return false;
}
});
body.addOrReplace(privilegesListComponent);
Expand All @@ -487,11 +487,6 @@ private List<String> getPrivilegesNamesList(){
return privilegesNamesList;
}

private void reloadBodyComponent(AjaxRequestTarget target){
addOrReplacePrivilegesPanel((WebMarkupContainer) DelegationEditorPanel.this.get(ID_BODY).get(ID_ASSIGNMENT_PRIVILEGES_CONTAINER));
target.add(get(ID_BODY));
}

private String getUserDisplayName(){
String displayName = "";
UserType delegationUser = getModelObject().getDelegationOwner();
Expand Down
Expand Up @@ -76,7 +76,7 @@ RelationTypes.APPROVER=Approver
RelationTypes.MEMBER=Member
DelegationEditorPanel.from=From
DelegationEditorPanel.to=To
DelegationEditorPanel.meLabel=Me
DelegationEditorPanel.meLabel=Current user
DelegationEditorPanel.limitPrivilegesButton=Limit privileges
DelegationEditorPanel.privileges=Assignment privileges
DelegationEditorPanel.workflowApprovals=Workflow approvals
Expand Down
Expand Up @@ -76,7 +76,7 @@ RelationTypes.APPROVER=Approver
RelationTypes.MEMBER=Member
DelegationEditorPanel.from=From
DelegationEditorPanel.to=To
DelegationEditorPanel.meLabel=Me
DelegationEditorPanel.meLabel=Current user
DelegationEditorPanel.limitPrivilegesButton=Limit privileges
DelegationEditorPanel.privileges=Assignment privileges
DelegationEditorPanel.workflowApprovals=Workflow approvals
Expand Down

0 comments on commit 5063544

Please sign in to comment.