Skip to content

Commit

Permalink
fix for MID-3528 Role edit - skip mandatory attributes in inducement
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Dec 13, 2016
1 parent f3b9cf3 commit 649b858
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 12 deletions.
Expand Up @@ -17,6 +17,7 @@
package com.evolveum.midpoint.web.component.assignment;

import com.evolveum.midpoint.common.refinery.RefinedAttributeDefinition;
import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.prism.PrismPropertyDefinition;
import com.evolveum.midpoint.web.component.util.BaseDeprecatedPanel;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
Expand All @@ -33,20 +34,20 @@
/**
* @author lazyman
*/
public class ACAttributePanel extends BaseDeprecatedPanel<ACAttributeDto> {
public class ACAttributePanel extends BasePanel<ACAttributeDto> {

private static final String ID_ATTRIBUTE_LABEL = "attributeLabel";
private static final String ID_VALUES = "values";
private static final String ID_VALUE = "value";
private static final String ID_REQUIRED = "required";
private static final String ID_HAS_OUTBOUND = "hasOutbound";

public ACAttributePanel(String id, IModel<ACAttributeDto> model) {
public ACAttributePanel(String id, IModel<ACAttributeDto> model, boolean ignoreMandatoryAttributes) {
super(id, model);
initLayout(ignoreMandatoryAttributes);
}

@Override
protected void initLayout() {
protected void initLayout(boolean ignoreMandatoryAttributes) {
Label attributeLabel = new Label(ID_ATTRIBUTE_LABEL, new PropertyModel(getModel(), ACAttributeDto.F_NAME));
add(attributeLabel);

Expand Down Expand Up @@ -80,7 +81,7 @@ public boolean isVisible() {
@Override
protected void populateItem(ListItem<ACValueConstructionDto> listItem) {
Form form = findParent(Form.class);
listItem.add(new ACAttributeValuePanel(ID_VALUE, listItem.getModel(), form));
listItem.add(new ACAttributeValuePanel(ID_VALUE, listItem.getModel(), ignoreMandatoryAttributes, form));
}
};
add(values);
Expand Down
Expand Up @@ -53,21 +53,23 @@ public class ACAttributeValuePanel extends BasePanel<ACValueConstructionDto> {
private static final String ID_ADD = "add";
private static final String ID_REMOVE = "remove";

public ACAttributeValuePanel(String id, IModel<ACValueConstructionDto> iModel, Form form) {
public ACAttributeValuePanel(String id, IModel<ACValueConstructionDto> iModel,
boolean ignoreMandatoryAttributes, Form form) {
super(id, iModel);

initLayout(form);
initLayout(form, ignoreMandatoryAttributes);
}

private void initLayout(Form form) {
private void initLayout(Form form, boolean ignoreMandatoryAttributes) {
ACValueConstructionDto dto = getModel().getObject();
PrismPropertyDefinition definition = dto.getAttribute().getDefinition();
boolean required = definition.getMinOccurs() > 0;

InputPanel input = createTypedInputComponent(ID_INPUT, definition);
for (FormComponent comp : input.getFormComponents()) {
comp.setLabel(new PropertyModel(dto.getAttribute(), ACAttributeDto.F_NAME));
comp.setRequired(required);
if (!ignoreMandatoryAttributes){
comp.setRequired(definition.getMinOccurs() > 0);
}

comp.add(new AjaxFormComponentUpdatingBehavior("blur") {
@Override
Expand Down
Expand Up @@ -714,7 +714,7 @@ public boolean isVisible() {
@Override
protected void populateItem(ListItem<ACAttributeDto> listItem) {
final IModel<ACAttributeDto> attrModel = listItem.getModel();
ACAttributePanel acAttribute = new ACAttributePanel(ID_AC_ATTRIBUTE, attrModel);
ACAttributePanel acAttribute = new ACAttributePanel(ID_AC_ATTRIBUTE, attrModel, ignoreMandatoryAttributes());
acAttribute.setRenderBodyOnly(true);
listItem.add(acAttribute);
listItem.setOutputMarkupId(true);
Expand Down Expand Up @@ -992,4 +992,7 @@ protected boolean isCreatingNewAssignment() {
return UserDtoStatus.ADD.equals(getModelObject().getStatus());
}

protected boolean ignoreMandatoryAttributes(){
return false;
}
}
Expand Up @@ -168,7 +168,12 @@ public boolean isVisible(){
}

protected void populateItem(ListItem<AssignmentEditorDto> item){
AssignmentEditorPanel editor = new AssignmentEditorPanel(ID_ROW, item.getModel());
AssignmentEditorPanel editor = new AssignmentEditorPanel(ID_ROW, item.getModel()){
@Override
protected boolean ignoreMandatoryAttributes(){
return AssignmentTablePanel.this.ignoreMandatoryAttributes();
}
};
item.add(editor);

editor.add(AttributeModifier.append("class", new AbstractReadOnlyModel<String>() {
Expand Down Expand Up @@ -545,4 +550,8 @@ protected void handlePartialError(OperationResult result) {
protected boolean getAssignmentMenuVisibility(){
return true;
}

protected boolean ignoreMandatoryAttributes(){
return false;
}
}
Expand Up @@ -83,6 +83,11 @@ public List<AssignmentType> getAssignmentTypeList() {
public String getExcludeOid() {
return getObject().getOid();
}

@Override
protected boolean ignoreMandatoryAttributes(){
return true;
}
};
}

Expand Down

0 comments on commit 649b858

Please sign in to comment.