use of com.evolveum.midpoint.web.component.assignment.AssignmentTablePanel in project midpoint by Evolveum.
the class PageAssignmentsList method initLayout.
public void initLayout() {
setOutputMarkupId(true);
MidpointForm mainForm = new MidpointForm(ID_FORM);
mainForm.setOutputMarkupId(true);
add(mainForm);
AssignmentTablePanel panel = new AssignmentTablePanel<UserType>(ID_ASSIGNMENT_TABLE_PANEL, assignmentsModel) {
private static final long serialVersionUID = 1L;
@Override
protected List<InlineMenuItem> createAssignmentMenu() {
List<InlineMenuItem> items = new ArrayList<>();
InlineMenuItem item = new InlineMenuItem(createStringResource("PageAssignmentsList.deleteAllItemsFromShoppingCart")) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new InlineMenuItemAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
getModelObject().forEach(assignmentEditorDto -> assignmentEditorDto.setSelected(true));
deleteAssignmentPerformed(target, null);
}
};
}
};
items.add(item);
return items;
}
@Override
public IModel<String> getLabel() {
return createStringResource("PageAssignmentsList.assignmentsToRequest");
}
@Override
protected boolean isRelationEditable() {
return false;
}
@Override
protected void reloadMainFormButtons(AjaxRequestTarget target) {
Component requestButton = PageAssignmentsList.this.get(createComponentPath(ID_FORM, ID_REQUEST_BUTTON));
if (requestButton != null) {
refreshRequestButton(requestButton);
}
target.add(getFeedbackPanel());
target.add(requestButton);
}
};
mainForm.add(panel);
UserSelectionButton targetUserPanel = new UserSelectionButton(ID_TARGET_USER_PANEL, new IModel<List<UserType>>() {
@Override
public List<UserType> getObject() {
return WebComponentUtil.loadTargetUsersListForShoppingCart(OPERATION_LOAD_ASSIGNMENT_TARGET_USER_OBJECT, PageAssignmentsList.this);
}
}, true, createStringResource("AssignmentCatalogPanel.selectTargetUser")) {
private static final long serialVersionUID = 1L;
@Override
protected String getUserButtonLabel() {
return getTargetUserSelectionButtonLabel(getModelObject());
}
@Override
protected void onDeleteSelectedUsersPerformed(AjaxRequestTarget target) {
super.onDeleteSelectedUsersPerformed(target);
getSessionStorage().getRoleCatalog().setTargetUserOidsList(new ArrayList<>());
targetUserChangePerformed(target);
}
@Override
protected void multipleUsersSelectionPerformed(AjaxRequestTarget target, List<UserType> usersList) {
if (CollectionUtils.isNotEmpty(usersList)) {
List<String> usersOidsList = new ArrayList<>();
usersList.forEach(user -> usersOidsList.add(user.getOid()));
getSessionStorage().getRoleCatalog().setTargetUserOidsList(usersOidsList);
}
targetUserChangePerformed(target);
}
};
targetUserPanel.setOutputMarkupId(true);
mainForm.add(targetUserPanel);
TextArea<String> descriptionInput = new TextArea<>(ID_DESCRIPTION, descriptionModel);
descriptionInput.add(new AjaxFormComponentUpdatingBehavior("blur") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
getSessionStorage().getRoleCatalog().setRequestDescription(getDescriptionComponent().getValue());
}
});
mainForm.add(descriptionInput);
AjaxButton back = new AjaxButton(ID_BACK, createStringResource("PageAssignmentDetails.backButton")) {
@Override
public void onClick(AjaxRequestTarget target) {
redirectBack();
}
};
mainForm.add(back);
AjaxButton requestAssignments = new AjaxButton(ID_REQUEST_BUTTON, createStringResource("PageAssignmentsList.requestButton")) {
@Override
public void onClick(AjaxRequestTarget target) {
if (getSessionStorage().getRoleCatalog().getTargetUserOidsList() == null || getSessionStorage().getRoleCatalog().getTargetUserOidsList().size() <= 1) {
onSingleUserRequestPerformed(target);
} else {
onMultiUserRequestPerformed(target);
}
}
};
requestAssignments.add(new VisibleEnableBehaviour() {
@Override
public boolean isEnabled() {
return isRequestButtonEnabled();
}
});
mainForm.add(requestAssignments);
refreshRequestButton(requestAssignments);
AjaxSubmitButton resolveAssignments = new AjaxSubmitButton(ID_RESOLVE_CONFLICTS_BUTTON, createStringResource("PageAssignmentsList.resolveConflicts")) {
@Override
protected void onError(AjaxRequestTarget target) {
target.add(getFeedbackPanel());
}
@Override
protected void onSubmit(AjaxRequestTarget target) {
PageAssignmentsList.this.navigateToNext(PageAssignmentConflicts.class);
}
};
resolveAssignments.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return !getSessionStorage().getRoleCatalog().isMultiUserRequest() && !areConflictsResolved();
}
});
mainForm.add(resolveAssignments);
}
use of com.evolveum.midpoint.web.component.assignment.AssignmentTablePanel in project midpoint by Evolveum.
the class FocusAssignmentsTabPanel method initLayout.
private void initLayout() {
WebMarkupContainer assignments = new WebMarkupContainer(ID_ASSIGNMENTS);
assignments.setOutputMarkupId(true);
add(assignments);
AssignmentTablePanel panel = new AssignmentTablePanel(ID_ASSIGNMENTS_PANEL, createStringResource("FocusType.assignment"), assignmentsModel) {
@Override
protected boolean getAssignmentMenuVisibility() {
return !getObjectWrapper().isReadonly();
}
@Override
protected void showAllAssignments(AjaxRequestTarget target) {
List<AssignmentsPreviewDto> assignmentsPreviewDtos = ((PageAdminFocus) getPageBase()).recomputeAssignmentsPerformed(target);
AssignmentPreviewDialog dialog = new AssignmentPreviewDialog(getPageBase().getMainPopupBodyId(), assignmentsPreviewDtos, new ArrayList<String>(), getPageBase());
getPageBase().showMainPopup(dialog, target);
}
};
assignments.add(panel);
}
use of com.evolveum.midpoint.web.component.assignment.AssignmentTablePanel in project midpoint by Evolveum.
the class UserDelegationsPanel method initLayout.
protected void initLayout() {
WebMarkupContainer delegations = new WebMarkupContainer(ID_DELEGATIONS_CONTAINER);
delegations.setOutputMarkupId(true);
add(delegations);
AssignmentTablePanel panel = new AssignmentTablePanel<UserType>(ID_DELEGATIONS_PANEL, getObjectDetailsModels().getDelegationsModel()) {
private static final long serialVersionUID = 1L;
@Override
public void populateAssignmentDetailsPanel(ListItem<AssignmentEditorDto> item) {
DelegationEditorPanel editor = new DelegationEditorPanel(ID_ROW, item.getModel(), false, getObjectDetailsModels().getPrivilegesListModel());
item.add(editor);
}
@Override
public String getExcludeOid() {
return getObjectWrapper().getOid();
}
public IModel<String> getLabel() {
return createStringResource("FocusType.delegations");
}
@Override
protected List<InlineMenuItem> createAssignmentMenu() {
List<InlineMenuItem> items = new ArrayList<>();
InlineMenuItem item;
if (WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_DELEGATE_ACTION_URL)) {
item = new InlineMenuItem(createStringResource("AssignmentTablePanel.menu.addDelegation")) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new InlineMenuItemAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
List<QName> supportedTypes = new ArrayList<>();
supportedTypes.add(UserType.COMPLEX_TYPE);
ObjectFilter filter = getPrismContext().queryFactory().createInOid(getObjectWrapper().getOid());
ObjectFilter notFilter = getPrismContext().queryFactory().createNot(filter);
ObjectBrowserPanel<UserType> panel = new ObjectBrowserPanel<UserType>(getPageBase().getMainPopupBodyId(), UserType.class, supportedTypes, false, getPageBase(), notFilter) {
private static final long serialVersionUID = 1L;
@Override
protected void onSelectPerformed(AjaxRequestTarget target, UserType user) {
getPageBase().hideMainPopup(target);
List<ObjectType> newAssignmentsList = new ArrayList<>();
newAssignmentsList.add(user);
addSelectedAssignablePerformed(target, newAssignmentsList, null, getPageBase().getMainPopup().getId());
}
};
panel.setOutputMarkupId(true);
getPageBase().showMainPopup(panel, target);
}
};
}
};
items.add(item);
}
if (WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_ADMIN_UNASSIGN_ACTION_URI)) {
item = new InlineMenuItem(createStringResource("AssignmentTablePanel.menu.deleteDelegation")) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new InlineMenuItemAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
deleteAssignmentPerformed(target, null);
}
};
}
};
items.add(item);
}
return items;
}
@Override
protected String getNoAssignmentsSelectedMessage() {
return getString("AssignmentTablePanel.message.noDelegationsSelected");
}
@Override
protected String getAssignmentsDeleteMessage(AssignmentEditorDto dto) {
return createStringResource("AssignmentTablePanel.modal.message.deleteDelegation", getSelectedAssignments().size()).getString();
}
@Override
protected List<AssignmentEditorDto> getAssignmentListToProcess(AssignmentEditorDto dto) {
if (dto != null) {
return Collections.singletonList(dto);
} else {
return getSelectedAssignments();
}
}
@Override
protected void addSelectedAssignablePerformed(AjaxRequestTarget target, List<ObjectType> newAssignments, QName relation, String popupId) {
ModalWindow window = (ModalWindow) get(popupId);
if (window != null) {
window.close(target);
}
getPageBase().hideMainPopup(target);
if (newAssignments.isEmpty()) {
warn(getString("AssignmentTablePanel.message.noAssignmentSelected"));
target.add(getPageBase().getFeedbackPanel());
return;
}
for (ObjectType object : newAssignments) {
try {
AssignmentEditorDto dto = AssignmentEditorDto.createDtoAddFromSelectedObject(((PrismObject<UserType>) getObjectWrapper().getObject()).asObjectable(), WebComponentUtil.getDefaultRelationOrFail(RelationKindType.DELEGATION), getPageBase(), (UserType) object);
dto.setPrivilegeLimitationList(getPrivilegesListModel().getObject());
getDelegationModel().getObject().add(dto);
} catch (Exception e) {
error(getString("AssignmentTablePanel.message.couldntAssignObject", object.getName(), e.getMessage()));
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't assign object", e);
}
}
reloadAssignmentsPanel(target);
reloadMainFormButtons(target);
}
};
delegations.add(panel);
}
use of com.evolveum.midpoint.web.component.assignment.AssignmentTablePanel in project midpoint by Evolveum.
the class UserDelegationsTabPanel method initLayout.
private void initLayout() {
WebMarkupContainer delegations = new WebMarkupContainer(ID_DELEGATIONS_CONTAINER);
delegations.setOutputMarkupId(true);
add(delegations);
AssignmentTablePanel panel = new AssignmentTablePanel<UserType>(ID_DELEGATIONS_PANEL, delegationsModel) {
private static final long serialVersionUID = 1L;
@Override
public void populateAssignmentDetailsPanel(ListItem<AssignmentEditorDto> item) {
DelegationEditorPanel editor = new DelegationEditorPanel(ID_ROW, item.getModel(), false, privilegesListModel);
item.add(editor);
}
@Override
public String getExcludeOid() {
return getObjectWrapper().getOid();
}
public IModel<String> getLabel() {
return createStringResource("FocusType.delegations");
}
@Override
protected List<InlineMenuItem> createAssignmentMenu() {
List<InlineMenuItem> items = new ArrayList<>();
InlineMenuItem item;
if (WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_DELEGATE_ACTION_URL)) {
item = new InlineMenuItem(createStringResource("AssignmentTablePanel.menu.addDelegation")) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new InlineMenuItemAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
List<QName> supportedTypes = new ArrayList<>();
supportedTypes.add(UserType.COMPLEX_TYPE);
ObjectFilter filter = getPrismContext().queryFactory().createInOid(getObjectWrapper().getOid());
ObjectFilter notFilter = getPrismContext().queryFactory().createNot(filter);
ObjectBrowserPanel<UserType> panel = new ObjectBrowserPanel<UserType>(getPageBase().getMainPopupBodyId(), UserType.class, supportedTypes, false, getPageBase(), notFilter) {
private static final long serialVersionUID = 1L;
@Override
protected void onSelectPerformed(AjaxRequestTarget target, UserType user) {
getPageBase().hideMainPopup(target);
List<ObjectType> newAssignmentsList = new ArrayList<>();
newAssignmentsList.add(user);
addSelectedAssignablePerformed(target, newAssignmentsList, null, getPageBase().getMainPopup().getId());
}
};
panel.setOutputMarkupId(true);
getPageBase().showMainPopup(panel, target);
}
};
}
};
items.add(item);
}
if (WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_ADMIN_UNASSIGN_ACTION_URI)) {
item = new InlineMenuItem(createStringResource("AssignmentTablePanel.menu.deleteDelegation")) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new InlineMenuItemAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
deleteAssignmentPerformed(target, null);
}
};
}
};
items.add(item);
}
return items;
}
@Override
protected String getNoAssignmentsSelectedMessage() {
return getString("AssignmentTablePanel.message.noDelegationsSelected");
}
@Override
protected String getAssignmentsDeleteMessage(AssignmentEditorDto dto) {
return createStringResource("AssignmentTablePanel.modal.message.deleteDelegation", getSelectedAssignments().size()).getString();
}
@Override
protected List<AssignmentEditorDto> getAssignmentListToProcess(AssignmentEditorDto dto) {
if (dto != null) {
return Collections.singletonList(dto);
} else {
return getSelectedAssignments();
}
}
@Override
protected void addSelectedAssignablePerformed(AjaxRequestTarget target, List<ObjectType> newAssignments, QName relation, String popupId) {
ModalWindow window = (ModalWindow) get(popupId);
if (window != null) {
window.close(target);
}
getPageBase().hideMainPopup(target);
if (newAssignments.isEmpty()) {
warn(getString("AssignmentTablePanel.message.noAssignmentSelected"));
target.add(getPageBase().getFeedbackPanel());
return;
}
for (ObjectType object : newAssignments) {
try {
AssignmentEditorDto dto = AssignmentEditorDto.createDtoAddFromSelectedObject(((PrismObject<UserType>) getObjectWrapper().getObject()).asObjectable(), WebComponentUtil.getDefaultRelationOrFail(RelationKindType.DELEGATION), getPageBase(), (UserType) object);
dto.setPrivilegeLimitationList(privilegesListModel.getObject());
delegationsModel.getObject().add(dto);
} catch (Exception e) {
error(getString("AssignmentTablePanel.message.couldntAssignObject", object.getName(), e.getMessage()));
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't assign object", e);
}
}
reloadAssignmentsPanel(target);
reloadMainFormButtons(target);
}
};
delegations.add(panel);
}
Aggregations