@Override
public Component getActionComponent(String componentId, final Contract contract) {
final boolean isModificationAllowed = authorizedUserService.isUserLogged() &&
ContractStatus.COMPLETED != contract.getStatus();
return new AjaxLinkPanel(componentId, new ResourceModel(isModificationAllowed ?
MKEY_CONTRACT_EDIT : MKEY_CONTRACT_VIEW)) {
private static final long serialVersionUID = 1L;
@Override
protected void onClick(AjaxRequestTarget target) {
setResponsePage(isModificationAllowed ? EditContract.class : ViewContract.class,
new PageParameters().add(
ContractDetails.PARAM_CONTRACT_ID,
contract.getId()));
}
};
}
});
// 'Remove' action
actions.add(new ParentAwareRowAction<Contract>() {
private static final long serialVersionUID = 1L;
@Override
public Component getActionComponent(String componentId, final Contract contract) {
if(contract.getStatus() != ContractStatus.UNCOMPLETED) {
return null;
}
Integer currentUserId = authorizedUserService.getCurrentUserId();
User contractOwner = contract.getOwner();
if(contractOwner == null || currentUserId == null || !currentUserId.equals(contractOwner.getId())) {
return null;
}
return new AjaxLinkPanel(componentId, new ResourceModel(MKEY_CONTRACT_REMOVE)) {
private static final long serialVersionUID = 1L;
@Override
protected void onClick(AjaxRequestTarget target) {
contractRemover.remove(contract.getId());