Skip to content

Commit

Permalink
work on Delegations tab
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Nov 11, 2016
1 parent 657043d commit d8de9e5
Show file tree
Hide file tree
Showing 13 changed files with 397 additions and 100 deletions.
Expand Up @@ -17,10 +17,7 @@
package com.evolveum.midpoint.web.component.assignment;

import com.evolveum.midpoint.gui.api.GuiStyleConstants;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ServiceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;

import javax.xml.namespace.QName;

Expand All @@ -35,6 +32,8 @@ public enum AssignmentEditorDtoType {

SERVICE(ServiceType.class, ServiceType.COMPLEX_TYPE, GuiStyleConstants.CLASS_OBJECT_SERVICE_ICON),

USER(UserType.class, UserType.COMPLEX_TYPE, GuiStyleConstants.CLASS_OBJECT_USER_ICON),

CONSTRUCTION(null, null, GuiStyleConstants.CLASS_OBJECT_RESOURCE_ICON);

private Class<? extends ObjectType> type;
Expand Down
Expand Up @@ -132,6 +132,20 @@ public class AssignmentEditorPanel extends BasePanel<AssignmentEditorDto> {

private IModel<List<ACAttributeDto>> attributesModel;
protected WebMarkupContainer headerRow;
protected PageBase pageBase;

public AssignmentEditorPanel(String id, IModel<AssignmentEditorDto> model, PageBase pageBase) {
super(id, model);
this.pageBase = pageBase;
attributesModel = new LoadableModel<List<ACAttributeDto>>(false) {
@Override
protected List<ACAttributeDto> load() {
return loadAttributes();
}
};

initLayout();
}

public AssignmentEditorPanel(String id, IModel<AssignmentEditorDto> model) {
super(id, model);
Expand All @@ -154,13 +168,31 @@ public void renderHead(IHeaderResponse response) {
new PackageResourceReference(AssignmentEditorPanel.class, "AssignmentEditorPanel.css")));
}

private void initLayout() {
protected void initLayout() {
setOutputMarkupId(true);
headerRow = new WebMarkupContainer(ID_HEADER_ROW);
headerRow.add(AttributeModifier.append("class", createHeaderClassModel(getModel())));
headerRow.setOutputMarkupId(true);
add(headerRow);

initHeaderRow();

WebMarkupContainer body = new WebMarkupContainer(ID_BODY);
body.setOutputMarkupId(true);
body.add(new VisibleEnableBehaviour() {

@Override
public boolean isVisible() {
AssignmentEditorDto editorDto = AssignmentEditorPanel.this.getModel().getObject();
return !editorDto.isMinimized();
}
});
add(body);

initBodyLayout(body);
}

protected void initHeaderRow(){
AjaxCheckBox selected = new AjaxCheckBox(ID_SELECTED,
new PropertyModel<Boolean>(getModel(), AssignmentEditorDto.F_SELECTED)) {
private static final long serialVersionUID = 1L;
Expand All @@ -170,12 +202,12 @@ protected void onUpdate(AjaxRequestTarget target) {
// do we want to update something?
}
};
selected.add(new VisibleEnableBehaviour(){
@Override
public boolean isVisible(){
return !getModel().getObject().isSimpleView();
}
});
selected.add(new VisibleEnableBehaviour(){
@Override
public boolean isVisible(){
return !getModel().getObject().isSimpleView();
}
});
headerRow.add(selected);

WebMarkupContainer typeImage = new WebMarkupContainer(ID_TYPE_IMAGE);
Expand Down Expand Up @@ -242,30 +274,16 @@ public boolean isOn() {
return !AssignmentEditorPanel.this.getModelObject().isMinimized();
}
};
expandButton.add(new VisibleEnableBehaviour(){
@Override
public boolean isVisible(){
return !getModel().getObject().isSimpleView();
}
});
headerRow.add(expandButton);

WebMarkupContainer body = new WebMarkupContainer(ID_BODY);
body.setOutputMarkupId(true);
body.add(new VisibleEnableBehaviour() {

expandButton.add(new VisibleEnableBehaviour(){
@Override
public boolean isVisible() {
AssignmentEditorDto editorDto = AssignmentEditorPanel.this.getModel().getObject();
return !editorDto.isMinimized();
public boolean isVisible(){
return !getModel().getObject().isSimpleView();
}
});
add(body);

initBodyLayout(body);
headerRow.add(expandButton);
}

private IModel<String> createAssignmentNameLabelModel(final boolean isManager) {
protected IModel<String> createAssignmentNameLabelModel(final boolean isManager) {
return new AbstractReadOnlyModel<String>() {

@Override
Expand Down Expand Up @@ -304,7 +322,7 @@ private boolean isTargetValid() {
return true;
}

private IModel<String> createHeaderClassModel(final IModel<AssignmentEditorDto> model) {
protected IModel<String> createHeaderClassModel(final IModel<AssignmentEditorDto> model) {
return new AbstractReadOnlyModel<String>() {
private static final long serialVersionUID = 1L;

Expand Down Expand Up @@ -823,7 +841,7 @@ private ResourceAttributeDefinitionType findOrCreateValueConstruction(PrismPrope
return construction;
}

private IModel<String> createImageTypeModel(final IModel<AssignmentEditorDto> model) {
protected IModel<String> createImageTypeModel(final IModel<AssignmentEditorDto> model) {
return new AbstractReadOnlyModel<String>() {
private static final long serialVersionUID = 1L;

Expand Down
Expand Up @@ -169,7 +169,7 @@ public String getObject() {
}));
}

private List<InlineMenuItem> createAssignmentMenu() {
protected List<InlineMenuItem> createAssignmentMenu() {
List<InlineMenuItem> items = new ArrayList<>();

InlineMenuItem item;
Expand Down Expand Up @@ -324,10 +324,12 @@ private void deleteAssignmentConfirmedPerformed(AjaxRequestTarget target,
}
}



target.add(getPageBase().getFeedbackPanel(), get(ID_ASSIGNMENTS));
}

private void addSelectedAssignablePerformed(AjaxRequestTarget target, List<ObjectType> newAssignments,
protected void addSelectedAssignablePerformed(AjaxRequestTarget target, List<ObjectType> newAssignments,
String popupId) {
ModalWindow window = (ModalWindow) get(popupId);
if (window != null) {
Expand Down
Expand Up @@ -25,12 +25,6 @@
<a class="check-table-header-name" wicket:id="name">
<span class="name" wicket:id="nameLabel"/>
</a>
<span class="check-table-header-description" wicket:id="activation"/>
<i class="check-table-header-additional-icon fa fa-fw fa-exclamation-circle text-danger"
wicket:id="errorIcon"></i>
<a class="check-table-header-show-more" wicket:id="errorLink">
<wicket:message key="AssignmentEditorPanel.showMore"/>
</a>
<i class="check-table-header-additional-icon fa fa-arrow-right text-info" wicket:id="arrowIcon"
style="font-size: 24px; margin-left: 5px; margin-right: 5px;"></i>
<i class="check-table-header-icon" wicket:id="delegatedToImage"></i>
Expand All @@ -39,17 +33,17 @@
</a>
</div>
</div>
<div class="row">
<label class="col-sm-1">
<wicket:message key="DelegationEditorPanel.from" />
</label>
<div class="col-sm-5" wicket:id="delegationValidFrom"/>
<label class="col-sm-1">
<wicket:message key="DelegationEditorPanel.to" />
</label>
<div class="col-sm-5" wicket:id="delegationValidTo"/>
<!--<div class="row">-->
<!--<label class="col-sm-1">-->
<!--<wicket:message key="DelegationEditorPanel.from" />-->
<!--</label>-->
<!--<div class="col-sm-5" wicket:id="delegationValidFrom"/>-->
<!--<label class="col-sm-1">-->
<!--<wicket:message key="DelegationEditorPanel.to" />-->
<!--</label>-->
<!--<div class="col-sm-5" wicket:id="delegationValidTo"/>-->

</div>
<!--</div>-->
</div>
</wicket:panel>
</html>
Expand Up @@ -16,6 +16,7 @@

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

import com.evolveum.midpoint.gui.api.page.PageBase;
import com.evolveum.midpoint.web.component.DateInput;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;
Expand All @@ -24,11 +25,13 @@
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.ajax.markup.html.form.AjaxCheckBox;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.model.StringResourceModel;

import javax.xml.datatype.XMLGregorianCalendar;

Expand All @@ -42,22 +45,94 @@ public class DelegationEditorPanel extends AssignmentEditorPanel {
private static final String ID_DELEGATED_TO_IMAGE = "delegatedToImage";
private static final String ID_DELEGATED_TO = "delegatedTo";
private static final String ID_DELEGATED_TO_LABEL = "delegatedToLabel";
private static final String ID_SELECTED = "selected";
private static final String ID_TYPE_IMAGE = "typeImage";
private static final String ID_NAME_LABEL = "nameLabel";
private static final String ID_NAME = "name";
private static final String ID_HEADER_ROW = "headerRow";

public DelegationEditorPanel(String id, IModel<AssignmentEditorDto> model) {
super(id, model);
initLayout();
private boolean delegatedToMe;

public DelegationEditorPanel(String id, IModel<AssignmentEditorDto> delegationTargetObjectModel,
boolean delegatedToMe, PageBase pageBase) {
super(id, delegationTargetObjectModel, pageBase);
// this.delegatedToMe = delegatedToMe;
// this.pageBase = pageBase;
// super.initLayout();
}

private void initLayout() {
// @Override
// protected void initLayout() {

// DateInput validFrom = new DateInput(ID_DELEGATION_VALID_FROM,
// createDateModel(new PropertyModel<XMLGregorianCalendar>(getModel(),
// AssignmentEditorDto.F_ACTIVATION + ".validFrom")));
// headerRow.add(validFrom);
//
// DateInput validTo = new DateInput(ID_DELEGATION_VALID_TO,
// createDateModel(new PropertyModel<XMLGregorianCalendar>(getModel(),
// AssignmentEditorDto.F_ACTIVATION + ".validTo")));
// headerRow.add(validTo);
// }

@Override
protected void initHeaderRow(){
AjaxCheckBox selected = new AjaxCheckBox(ID_SELECTED,
new PropertyModel<Boolean>(getModel(), AssignmentEditorDto.F_SELECTED)) {
private static final long serialVersionUID = 1L;

@Override
protected void onUpdate(AjaxRequestTarget target) {
// do we want to update something?
}
};
selected.add(new VisibleEnableBehaviour(){
@Override
public boolean isVisible(){
return !getModel().getObject().isSimpleView();
}
});
headerRow.add(selected);
Label arrowIcon = new Label(ID_ARROW_ICON);
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()));
}
headerRow.add(typeImage);

AjaxLink name = new AjaxLink(ID_NAME) {
private static final long serialVersionUID = 1L;

@Override
public void onClick(AjaxRequestTarget target) {
// nameClickPerformed(target);
}
};
headerRow.add(name);

Label nameLabel;
if (delegatedToMe) {
nameLabel = new Label(ID_NAME_LABEL, createAssignmentNameLabelModel(false));
} else {
nameLabel = new Label(ID_NAME_LABEL, pageBase.createStringResource("DelegationEditorPanel.meLabel"));
}
nameLabel.setOutputMarkupId(true);
name.add(nameLabel);

AssignmentEditorDto dto = getModelObject();
dto.getTargetRef();
WebMarkupContainer typeImage = new WebMarkupContainer(ID_DELEGATED_TO_IMAGE);
// typeImage.add(AttributeModifier.append("class", createImageTypeModel(getModel())));
headerRow.add(typeImage);

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

AjaxLink delegatedToName = new AjaxLink(ID_DELEGATED_TO) {
private static final long serialVersionUID = 1L;
Expand All @@ -69,19 +144,13 @@ public void onClick(AjaxRequestTarget target) {
};
headerRow.add(delegatedToName);

Label delegatedToNameLabel = new Label(ID_DELEGATED_TO_LABEL, createTargetModel());
Label delegatedToNameLabel;
if (delegatedToMe) {
delegatedToNameLabel = new Label(ID_NAME_LABEL, pageBase.createStringResource("DelegationEditorPanel.meLabel"));
} else {
delegatedToNameLabel = new Label(ID_DELEGATED_TO_LABEL, createTargetModel());
}
delegatedToNameLabel.setOutputMarkupId(true);
delegatedToName.add(delegatedToNameLabel);

DateInput validFrom = new DateInput(ID_DELEGATION_VALID_FROM,
createDateModel(new PropertyModel<XMLGregorianCalendar>(getModel(),
AssignmentEditorDto.F_ACTIVATION + ".validFrom")));
headerRow.add(validFrom);

DateInput validTo = new DateInput(ID_DELEGATION_VALID_TO,
createDateModel(new PropertyModel<XMLGregorianCalendar>(getModel(),
AssignmentEditorDto.F_ACTIVATION + ".validTo")));
headerRow.add(validTo);
}

}
Expand Up @@ -91,8 +91,8 @@ public void setBody(Popupable popupable){
popupable.getComponent().setOutputMarkupId(true);
content.addOrReplace(popupable.getComponent());
}




}

0 comments on commit d8de9e5

Please sign in to comment.