ItEr41S25CUAltaSubcontrataItEr30S08: Implemented the entry points to the edition interface
It uses the existing interface for creation.
This commit is contained in:
parent
dcdf7a03c9
commit
83a5a66b2e
4 changed files with 49 additions and 2 deletions
|
|
@ -75,7 +75,9 @@ public class ExternalCompanyCRUDController extends GenericForwardComposer
|
|||
|
||||
@Override
|
||||
public void goToEditForm(ExternalCompany company) {
|
||||
// TODO implement
|
||||
externalCompanyModel.initEdit(company);
|
||||
getVisibility().showOnly(createWindow);
|
||||
Util.reloadBindings(createWindow);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ package org.navalplanner.web.externalcompanies;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.navalplanner.business.common.exceptions.InstanceNotFoundException;
|
||||
import org.navalplanner.business.externalcompanies.daos.IExternalCompanyDAO;
|
||||
import org.navalplanner.business.externalcompanies.entities.ExternalCompany;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -65,4 +67,39 @@ public class ExternalCompanyModel implements IExternalCompanyModel {
|
|||
externalCompanyDAO.save(externalCompany);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public void initEdit(ExternalCompany company) {
|
||||
Validate.notNull(company);
|
||||
externalCompany = getFromDB(company);
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
private ExternalCompany getFromDB(ExternalCompany company) {
|
||||
return getFromDB(company.getId());
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
private ExternalCompany getFromDB(Long id) {
|
||||
try {
|
||||
ExternalCompany result = externalCompanyDAO.find(id);
|
||||
forceLoadEntities(result);
|
||||
return result;
|
||||
} catch (InstanceNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load entities that will be needed in the conversation
|
||||
*
|
||||
* @param company
|
||||
*/
|
||||
private void forceLoadEntities(ExternalCompany company) {
|
||||
company.getName();
|
||||
if(company.getCompanyUser() != null) {
|
||||
company.getCompanyUser().getLoginName();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,6 +52,14 @@ public interface IExternalCompanyModel {
|
|||
*/
|
||||
void initCreate();
|
||||
|
||||
/**
|
||||
* Makes some operations needed before edit a {@link ExternalCompany}.
|
||||
*
|
||||
* @param company
|
||||
* The object to be edited
|
||||
*/
|
||||
void initEdit(ExternalCompany company);
|
||||
|
||||
/**
|
||||
* Stores the current {@link ExternalCompany}.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
<button sclass="icono" image="/common/img/ico_editar1.png"
|
||||
hoverImage="/common/img/ico_editar.png"
|
||||
tooltiptext="${i18n:_('Edit')}"
|
||||
onClick="">
|
||||
onClick="controller.goToEditForm(self.parent.parent.value)">
|
||||
</button>
|
||||
</hbox>
|
||||
</row>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue