use of com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto in project midpoint by Evolveum.
the class AbstractRoleMainPanel method initShoppingCartPanel.
private void initShoppingCartPanel(PageAdminObjectDetails<R> parentPage) {
RoleCatalogStorage storage = parentPage.getSessionStorage().getRoleCatalog();
WebMarkupContainer shoppingCartButtonsPanel = new WebMarkupContainer(ID_SHOPPING_CART_BUTTONS_PANEL);
shoppingCartButtonsPanel.setOutputMarkupId(true);
shoppingCartButtonsPanel.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
// Role Catalog page
return PageAssignmentShoppingKart.class.equals(getPreviousPage(parentPage));
}
});
getMainForm().add(shoppingCartButtonsPanel);
AjaxButton addToCartButton = new AjaxButton(ID_ADD_TO_CART_BUTTON, parentPage.createStringResource("PageAssignmentDetails.addToCartButton")) {
private static final long serialVersionUID = 1L;
@Override
protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
attributes.setChannel(new AjaxChannel("blocking", AjaxChannel.Type.ACTIVE));
}
@Override
public void onClick(AjaxRequestTarget target) {
AssignmentEditorDto dto = AssignmentEditorDto.createDtoFromObject(getObject().asObjectable(), UserDtoStatus.ADD, parentPage);
storage.getAssignmentShoppingCart().add(dto);
target.add(shoppingCartButtonsPanel);
}
};
addToCartButton.setOutputMarkupId(true);
addToCartButton.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isEnabled() {
AssignmentEditorDto dto = AssignmentEditorDto.createDtoFromObject(getObject().asObjectable(), UserDtoStatus.ADD, parentPage);
return storage.isMultiUserRequest() || dto.isAssignable();
}
});
shoppingCartButtonsPanel.add(addToCartButton);
AjaxButton shoppingCartButton = new AjaxButton(ID_SHOPPING_CART_BUTTON) {
private static final long serialVersionUID = 1L;
@Override
protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
attributes.setChannel(new AjaxChannel("blocking", AjaxChannel.Type.ACTIVE));
}
@Override
public void onClick(AjaxRequestTarget ajaxRequestTarget) {
parentPage.navigateToNext(PageAssignmentsList.class);
}
};
shoppingCartButton.setOutputMarkupId(true);
shoppingCartButtonsPanel.add(shoppingCartButton);
Label cartItemsCount = new Label(ID_ITEMS_COUNT, new LoadableModel<String>(true) {
private static final long serialVersionUID = 1L;
@Override
public String load() {
return Integer.toString(storage.getAssignmentShoppingCart().size());
}
});
cartItemsCount.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
if (storage.getAssignmentShoppingCart().size() == 0) {
return false;
} else {
return true;
}
}
});
cartItemsCount.setOutputMarkupId(true);
shoppingCartButton.add(cartItemsCount);
}
use of com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto in project midpoint by Evolveum.
the class PageRequestRole method loadAssignments.
private List<AssignmentEditorDto> loadAssignments() {
List<AssignmentEditorDto> list = new ArrayList<AssignmentEditorDto>();
List<AssignmentType> assignments = user.asObjectable().getAssignment();
for (AssignmentType assignment : assignments) {
list.add(new AssignmentEditorDto(UserDtoStatus.MODIFY, assignment, this));
}
Collections.sort(list);
return list;
}
use of com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto in project midpoint by Evolveum.
the class PageAssignmentDetails method initLayout.
public void initLayout(final IModel<AssignmentEditorDto> assignmentModel) {
setOutputMarkupId(true);
Form mainForm = new Form(ID_FORM);
mainForm.setOutputMarkupId(true);
add(mainForm);
AssignmentDetailsPanel detailsPanel = new AssignmentDetailsPanel(ID_DETAILS_PANEL, assignmentModel, PageAssignmentDetails.this);
detailsPanel.setOutputMarkupId(true);
mainForm.add(detailsPanel);
AjaxButton back = new AjaxButton(ID_BACK, createStringResource("PageAssignmentDetails.backButton")) {
@Override
public void onClick(AjaxRequestTarget target) {
redirectBack();
}
};
mainForm.add(back);
AjaxButton addToCart = new AjaxButton(ID_ADD_TO_CART, createStringResource("PageAssignmentDetails.addToCartButton")) {
@Override
public void onClick(AjaxRequestTarget target) {
RoleCatalogStorage storage = getSessionStorage().getRoleCatalog();
if (storage.getAssignmentShoppingCart() == null) {
storage.setAssignmentShoppingCart(new ArrayList<AssignmentEditorDto>());
}
AssignmentEditorDto dto = assignmentModel.getObject();
dto.setMinimized(true);
dto.setSimpleView(false);
storage.getAssignmentShoppingCart().add(dto);
redirectBack();
}
};
mainForm.add(addToCart);
}
use of com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto in project midpoint by Evolveum.
the class PageAssignmentsList method addAssignmentsToUser.
private List<AssignmentEditorDto> addAssignmentsToUser(UserType user) {
List<String> assignmentsToDeselect = getAssignmentsToDeselectList(user);
List<AssignmentEditorDto> assignmentsToRemove = getAssignmentsToRemoveList(user);
List<AssignmentEditorDto> assignmentsList = new ArrayList<>();
assignmentsList.addAll(assignmentsToRemove);
if (assignmentsModel != null && assignmentsModel.getObject() != null) {
for (AssignmentEditorDto assignmentsToAdd : assignmentsModel.getObject()) {
if (!assignmentsToDeselect.contains(assignmentsToAdd.getTargetRef().getOid())) {
assignmentsToAdd.setStatus(UserDtoStatus.ADD);
assignmentsList.add(assignmentsToAdd);
}
}
}
return assignmentsList;
}
use of com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto in project midpoint by Evolveum.
the class PageAssignmentsList method handleAssignmentDeltas.
private ContainerDelta handleAssignmentDeltas(ObjectDelta<UserType> focusDelta, List<AssignmentEditorDto> assignments, PrismContainerDefinition def) throws SchemaException {
ContainerDelta assDelta = new ContainerDelta(new ItemPath(), def.getName(), def, getPrismContext());
for (AssignmentEditorDto assDto : assignments) {
PrismContainerValue newValue = assDto.getNewValue(getPrismContext());
switch(assDto.getStatus()) {
case ADD:
newValue.applyDefinition(def, false);
assDelta.addValueToAdd(newValue.clone());
break;
case DELETE:
PrismContainerValue oldValue = assDto.getOldValue();
oldValue.applyDefinition(def);
assDelta.addValueToDelete(oldValue.clone());
break;
case MODIFY:
if (!assDto.isModified(getPrismContext())) {
LOGGER.trace("Assignment '{}' not modified.", new Object[] { assDto.getName() });
continue;
}
handleModifyAssignmentDelta(assDto, def, newValue, focusDelta);
break;
default:
warn(getString("pageAdminUser.message.illegalAssignmentState", assDto.getStatus()));
}
}
if (!assDelta.isEmpty()) {
assDelta = focusDelta.addModification(assDelta);
}
return assDelta;
}
Aggregations