Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Evolveum/midpoint
Browse files Browse the repository at this point in the history
# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
  • Loading branch information
1azyman committed Sep 29, 2016
2 parents 1f50d99 + 6e3b7fb commit b96223d
Show file tree
Hide file tree
Showing 23 changed files with 419 additions and 92 deletions.
Expand Up @@ -19,6 +19,13 @@
xmlns:wicket="http://wicket.apache.org">
<body>
<wicket:panel>

<div class="col-md-12">
<a wicket:id="cartButton" class="col-md-1 pull-right" style="font-size: 24px">
<i class="fa fa-shopping-cart" style="width: 50%;"></i>
<span wicket:id="itemsCount" class="badge bg-red" style="font-size: 10px; position: absolute; top: -1px; right: 50%;"></span>
</a>
</div>
<div class="col-md-4">
<div wicket:id="treePanel"/>
</div>
Expand Down
@@ -1,58 +1,95 @@
package com.evolveum.midpoint.web.component.assignment;

import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.gui.api.page.PageBase;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.query.*;
import com.evolveum.midpoint.schema.GetOperationOptions;
import com.evolveum.midpoint.schema.SelectorOptions;
import com.evolveum.midpoint.web.component.data.BaseSortableDataProvider;
import com.evolveum.midpoint.web.component.AjaxButton;
import com.evolveum.midpoint.web.component.data.MultiButtonTable;
import com.evolveum.midpoint.web.component.data.ObjectDataProvider;
import com.evolveum.midpoint.web.component.data.SelectableBeanObjectDataProvider;
import com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem;
import com.evolveum.midpoint.web.component.search.Search;
import com.evolveum.midpoint.web.component.util.SelectableBean;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
import com.evolveum.midpoint.web.page.admin.orgs.OrgTreePanel;
import com.evolveum.midpoint.web.page.admin.users.component.TreeTablePanel;
import com.evolveum.midpoint.web.page.admin.users.dto.UserDtoStatus;
import com.evolveum.midpoint.web.session.PageStorage;
import com.evolveum.midpoint.web.session.SessionStorage;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import org.apache.commons.lang3.StringUtils;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.form.DropDownChoice;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.model.IModel;

import javax.xml.namespace.QName;
import java.util.ArrayList;
import java.util.List;

/**
* Created by Kate on 20.09.2016.
* Created by honchar.
*/
public class AssignmentShoppingCartPanel<F extends FocusType> extends BasePanel<String> {
public class AssignmentCatalogPanel<F extends FocusType> extends BasePanel<String> {
private static String ID_TREE_PANEL = "treePanel";
private static String ID_ASSIGNMENTS_PANEL = "assignmentsPanel";
private static String ID_CART_BUTTON = "cartButton";
private static String ID_CART_ITEMS_COUNT = "itemsCount";

public AssignmentShoppingCartPanel(String id) {
public AssignmentCatalogPanel(String id) {
super(id);
}

public AssignmentShoppingCartPanel(String id, IModel<String> rootOidModel) {
public AssignmentCatalogPanel(String id, IModel<String> rootOidModel) {
super(id, rootOidModel);
initLayout();
}

private void initLayout() {
setOutputMarkupId(true);
OrgTreePanel treePanel = new OrgTreePanel(ID_TREE_PANEL, getModel(), false) {

AjaxButton cartButton = new AjaxButton(ID_CART_BUTTON) {
@Override
public void onClick(AjaxRequestTarget ajaxRequestTarget) {

}
};
cartButton.setOutputMarkupId(true);
add(cartButton);

Label cartItemsCount = new Label(ID_CART_ITEMS_COUNT, new IModel<String>() {
@Override
public String getObject() {
SessionStorage storage = getPageBase().getSessionStorage();
return Integer.toString(storage.getUsers().getAssignmentShoppingCart().size());
}

@Override
public void setObject(String s) {


}

@Override
public void detach() {

}
});
cartItemsCount.add(new VisibleEnableBehaviour(){
@Override
public boolean isVisible(){
SessionStorage storage = getPageBase().getSessionStorage();
if (storage.getUsers().getAssignmentShoppingCart().size() == 0){
return false;
} else {
return true;
}
}
});
cartItemsCount.setOutputMarkupId(true);
cartButton.add(cartItemsCount);

OrgTreePanel treePanel = new OrgTreePanel(ID_TREE_PANEL, getModel(), false, "AssignmentShoppingCartPanel.treeTitle") {
private static final long serialVersionUID = 1L;

@Override
protected void selectTreeItemPerformed(SelectableBean<OrgType> selected,
AjaxRequestTarget target) {
AssignmentShoppingCartPanel.this.selectTreeItemPerformed(selected, target);
AssignmentCatalogPanel.this.selectTreeItemPerformed(selected, target);
}

protected List<InlineMenuItem> createTreeMenu() {
Expand Down Expand Up @@ -137,19 +174,19 @@ protected ObjectQuery createContentQuery(String oid) {
return createMemberQuery(oid);
}

protected ObjectQuery createMemberQuery(String oid) {
ObjectQuery query = null;
private ObjectQuery createMemberQuery(String oid) {
ObjectFilter filter = OrgFilter.createOrg(oid, OrgFilter.Scope.ONE_LEVEL);
query = ObjectQuery.createObjectQuery(AndFilter.createAnd(filter));

// TypeFilter roleTypeFilter = TypeFilter.createType(RoleType.COMPLEX_TYPE, filter);
// TypeFilter orgTypeFilter = TypeFilter.createType(OrgType.COMPLEX_TYPE, filter);
// TypeFilter serviceTypeFilter = TypeFilter.createType(ServiceType.COMPLEX_TYPE, filter);
// query = ObjectQuery.createObjectQuery(OrFilter.createOr(roleTypeFilter, orgTypeFilter, serviceTypeFilter));
return ObjectQuery.createObjectQuery(TypeFilter.createType(RoleType.COMPLEX_TYPE, query.getFilter()));
TypeFilter roleTypeFilter = TypeFilter.createType(RoleType.COMPLEX_TYPE, filter);
TypeFilter orgTypeFilter = TypeFilter.createType(OrgType.COMPLEX_TYPE, filter);
TypeFilter serviceTypeFilter = TypeFilter.createType(ServiceType.COMPLEX_TYPE, filter);
ObjectQuery query = ObjectQuery.createObjectQuery(OrFilter.createOr(roleTypeFilter, orgTypeFilter, serviceTypeFilter));
return query;

}


public void reloadCartButton(AjaxRequestTarget target){
target.add(get(ID_CART_BUTTON));
}
}

Expand Up @@ -24,31 +24,9 @@ public AssignmentDetailsPanel(String id, IModel<AssignmentEditorDto> model) {

private void initLayout() {
setOutputMarkupId(true);

// AssignmentEditorDto aa = assignmentModel.getObject();
// if (aa == null){}
AssignmentEditorPanel assignmentDetailsPanel = new AssignmentEditorPanel(ID_DETAILS_PANEL, getModel()) {

};
AssignmentEditorPanel assignmentDetailsPanel = new AssignmentEditorPanel(ID_DETAILS_PANEL, getModel());
assignmentDetailsPanel.setOutputMarkupId(true);
add(assignmentDetailsPanel);

}

public int getWidth() {
return 900;
}

public int getHeight() {
return 600;
}

public StringResourceModel getTitle() {
return createStringResource("MultiButtonPanel.assignmentDetailsPopupTitle");
}

public Component getComponent() {
return this;
}

}
Expand Up @@ -95,6 +95,7 @@ public class AssignmentEditorDto extends SelectableBean implements Comparable<As
private boolean showEmpty = false;
private boolean minimized = true;
private boolean editable = true;
private boolean simpleView = false;

private Boolean isOrgUnitManager = Boolean.FALSE;
private AssignmentType newAssignment;
Expand Down Expand Up @@ -612,7 +613,15 @@ public void setAltName(String altName) {
this.altName = altName;
}

@Override
public boolean isSimpleView() {
return simpleView;
}

public void setSimpleView(boolean simpleView) {
this.simpleView = simpleView;
}

@Override
public boolean equals(Object o) {
if (this == o)
return true;
Expand All @@ -629,6 +638,8 @@ public boolean equals(Object o) {
return false;
if (editable != that.editable)
return false;
if (simpleView != that.simpleView)
return false;
if (altName != null ? !altName.equals(that.altName) : that.altName != null)
return false;
if (attributes != null ? !attributes.equals(that.attributes) : that.attributes != null)
Expand Down Expand Up @@ -662,6 +673,7 @@ public int hashCode() {
result = 31 * result + (orgRef != null ? orgRef.hashCode() : 0);
result = 31 * result + (showEmpty ? 1 : 0);
result = 31 * result + (minimized ? 1 : 0);
result = 31 * result + (simpleView ? 1 : 0);
result = 31 * result + (isOrgUnitManager ? 1 : 0);
result = 31 * result + (newAssignment != null ? newAssignment.hashCode() : 0);
result = 31 * result + (attributes != null ? attributes.hashCode() : 0);
Expand Down
Expand Up @@ -167,6 +167,12 @@ 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);

WebMarkupContainer typeImage = new WebMarkupContainer(ID_TYPE_IMAGE);
Expand Down Expand Up @@ -233,6 +239,12 @@ 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);
Expand Down
Expand Up @@ -2,10 +2,11 @@

import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.web.component.AjaxButton;
import com.evolveum.midpoint.web.component.assignment.AssignmentDetailsPanel;
import com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto;
import com.evolveum.midpoint.web.component.assignment.AssignmentEditorDtoType;
import com.evolveum.midpoint.web.component.assignment.AssignmentEditorPanel;
import com.evolveum.midpoint.web.component.assignment.*;
import com.evolveum.midpoint.web.page.admin.roles.PageRole;
import com.evolveum.midpoint.web.page.self.PageAssignmentDetails;
import com.evolveum.midpoint.web.session.SessionStorage;
import com.evolveum.midpoint.web.session.UsersStorage;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;
Expand All @@ -20,6 +21,7 @@
import org.apache.wicket.markup.repeater.RepeatingView;
import org.apache.wicket.model.IModel;

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

/**
Expand All @@ -36,6 +38,8 @@ public class MultiButtonTable extends BasePanel<List<AssignmentEditorDto>> {
private int itemsCount = 0;
private int itemsPerRow = 0;

private boolean plusIconClicked = false;

public MultiButtonTable (String id){
super(id);
}
Expand All @@ -48,10 +52,9 @@ public MultiButtonTable (String id, int itemsPerRow, IModel<List<AssignmentEdito

private void initLayout(){
itemsCount = getModel() != null ? (getModel().getObject() != null ? getModel().getObject().size() : 0) : 0;
RepeatingView rows = new RepeatingView(ID_ROW);
rows.setOutputMarkupId(true);
if (itemsCount > 0){
RepeatingView rows = new RepeatingView(ID_ROW);
rows.setOutputMarkupId(true);
add(rows);
int index = 0;
List<AssignmentEditorDto> assignmentsList = getModelObject();
for (int rowNumber = 0; rowNumber <= itemsCount / itemsPerRow; rowNumber++){
Expand All @@ -73,6 +76,7 @@ private void initLayout(){
}
}
}
add(rows);
}

protected void populateCell(WebMarkupContainer cellContainer, final AssignmentEditorDto assignment){
Expand All @@ -81,27 +85,41 @@ protected void populateCell(WebMarkupContainer cellContainer, final AssignmentEd

@Override
public void onClick(AjaxRequestTarget ajaxRequestTarget) {
IModel<AssignmentEditorDto> assignmentModel = new IModel<AssignmentEditorDto>() {
@Override
public AssignmentEditorDto getObject() {
return null;
}

@Override
public void setObject(AssignmentEditorDto assignmentEditorDto) {

}

@Override
public void detach() {

}
};
// getPageBase().showMainPopup(new AssignmentDetailsPanel(getPageBase().getMainPopupBodyId(), assignmentModel), ajaxRequestTarget);
if (!plusIconClicked) {
IModel<AssignmentEditorDto> assignmentModel = new IModel<AssignmentEditorDto>() {
@Override
public AssignmentEditorDto getObject() {
assignment.setMinimized(false);
assignment.setSimpleView(true);
return assignment;
}

@Override
public void setObject(AssignmentEditorDto assignmentEditorDto) {

}

@Override
public void detach() {

}
};
setResponsePage(new PageAssignmentDetails(assignmentModel));
} else {
plusIconClicked = false;
}
}
};
Label plusLabel = new Label(ID_BUTTON_PLUS_ICON, "+");
// plusLabel.add(new AttributeAppender("title", getPageBase().createStringResource("MultiButtonPanel.plusIconTitle")));
plusLabel.add(new AjaxEventBehavior("click") {
private static final long serialVersionUID = 1L;

@Override
protected void onEvent(AjaxRequestTarget target) {
addAssignmentPerformed(assignment, target);
}
});
assignmentButton.add(plusLabel);

WebMarkupContainer icon = new WebMarkupContainer(ID_BUTTON_TYPE_ICON);
Expand Down Expand Up @@ -134,4 +152,18 @@ private String getIconClass(AssignmentEditorDtoType type){
return "";
}
}

private void addAssignmentPerformed(AssignmentEditorDto assignment, AjaxRequestTarget target){
plusIconClicked = true;
UsersStorage storage = getPageBase().getSessionStorage().getUsers();
if (storage.getAssignmentShoppingCart() == null){
storage.setAssignmentShoppingCart(new ArrayList<AssignmentEditorDto>());
}
List<AssignmentEditorDto> assignmentsToAdd = storage.getAssignmentShoppingCart();
assignmentsToAdd.add(assignment);
storage.setAssignmentShoppingCart(assignmentsToAdd);
AssignmentCatalogPanel parent = (AssignmentCatalogPanel)MultiButtonTable.this.getParent();
parent.reloadCartButton(target);

}
}
Expand Up @@ -19,7 +19,7 @@

<div class="box box-solid object-org-box">
<div class="box-header with-border" wicket:id="treeHeader">
<h3 class="box-title"><wicket:message key="TreeTablePanel.hierarchy"/></h3>
<h3 class="box-title"><div wicket:id="treeTitle"/></h3>
<div class="box-tools pull-right">
<div class="cog" wicket:id="treeMenu" about="treeMenu"/>
</div>
Expand Down

0 comments on commit b96223d

Please sign in to comment.