use of com.evolveum.midpoint.web.component.DefaultAjaxSubmitButton in project midpoint by Evolveum.
the class PageWorkItem method initButtons.
private void initButtons(Form mainForm) {
VisibleBehaviour isAllowedToSubmit = new VisibleBehaviour(() -> getWorkflowManager().isCurrentUserAuthorizedToSubmit(workItemDtoModel.getObject().getWorkItem()));
VisibleBehaviour isAllowedToDelegate = new VisibleBehaviour(() -> getWorkflowManager().isCurrentUserAuthorizedToDelegate(workItemDtoModel.getObject().getWorkItem()));
VisibleBehaviour isAllowedToClaim = new VisibleBehaviour(() -> workItemDtoModel.getObject().getWorkItem().getAssigneeRef() == null && getWorkflowManager().isCurrentUserAuthorizedToClaim(workItemDtoModel.getObject().getWorkItem()));
VisibleBehaviour isAllowedToRelease = new VisibleBehaviour(() -> {
WorkItemType workItem = workItemDtoModel.getObject().getWorkItem();
MidPointPrincipal principal;
try {
principal = (MidPointPrincipal) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
} catch (ClassCastException e) {
return false;
}
String principalOid = principal.getOid();
return workItem.getAssigneeRef() != null && workItem.getAssigneeRef().stream().anyMatch(ref -> ref.getOid().equals(principalOid)) && (!workItem.getCandidateRef().isEmpty());
});
AjaxSubmitButton claim = new DefaultAjaxSubmitButton(ID_CLAIM, createStringResource("pageWorkItem.button.claim"), this, (target, form) -> claimPerformed(target));
claim.add(isAllowedToClaim);
mainForm.add(claim);
AjaxSubmitButton release = new DefaultAjaxSubmitButton(ID_RELEASE, createStringResource("pageWorkItem.button.release"), this, (target, form) -> releasePerformed(target));
release.add(isAllowedToRelease);
mainForm.add(release);
AjaxSubmitButton approve = new DefaultAjaxSubmitButton(ID_APPROVE, createStringResource("pageWorkItem.button.approve"), this, (target, form) -> savePerformed(target, true));
approve.add(isAllowedToSubmit);
mainForm.add(approve);
AjaxSubmitButton reject = new DefaultAjaxSubmitButton(ID_REJECT, createStringResource("pageWorkItem.button.reject"), this, (target, form) -> savePerformed(target, false));
reject.add(isAllowedToSubmit);
mainForm.add(reject);
AjaxSubmitButton delegate = new DefaultAjaxSubmitButton(ID_DELEGATE, createStringResource("pageWorkItem.button.delegate"), this, (target, form) -> delegatePerformed(target));
delegate.add(isAllowedToDelegate);
mainForm.add(delegate);
AjaxButton cancel = new DefaultAjaxButton(ID_CANCEL, createStringResource("pageWorkItem.button.cancel"), this::cancelPerformed);
mainForm.add(cancel);
}
Aggregations