ItEr41S25CUAltaSubcontrataItEr30S08: Implemented a basic creation interface.
It doesn't perform complex validations. Edition is not implemented, so the button 'Save & Continue' doesn't work as expected. The field 'User' is not implemented either.
This commit is contained in:
parent
5c57bd7384
commit
dcdf7a03c9
5 changed files with 157 additions and 3 deletions
|
|
@ -20,11 +20,16 @@
|
|||
|
||||
package org.navalplanner.web.externalcompanies;
|
||||
|
||||
import static org.navalplanner.web.I18nHelper._;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.navalplanner.business.common.exceptions.ValidationException;
|
||||
import org.navalplanner.business.externalcompanies.entities.ExternalCompany;
|
||||
import org.navalplanner.business.users.entities.User;
|
||||
import org.navalplanner.web.common.ConstraintChecker;
|
||||
import org.navalplanner.web.common.IMessagesForUser;
|
||||
import org.navalplanner.web.common.Level;
|
||||
import org.navalplanner.web.common.MessagesForUser;
|
||||
import org.navalplanner.web.common.OnlyOneVisible;
|
||||
import org.navalplanner.web.common.Util;
|
||||
|
|
@ -63,8 +68,9 @@ public class ExternalCompanyCRUDController extends GenericForwardComposer
|
|||
|
||||
@Override
|
||||
public void goToCreateForm() {
|
||||
// TODO implement
|
||||
|
||||
externalCompanyModel.initCreate();
|
||||
getVisibility().showOnly(createWindow);
|
||||
Util.reloadBindings(createWindow);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -78,10 +84,45 @@ public class ExternalCompanyCRUDController extends GenericForwardComposer
|
|||
Util.reloadBindings(listWindow);
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
goToList();
|
||||
}
|
||||
|
||||
public void saveAndExit() {
|
||||
if (save()) {
|
||||
goToList();
|
||||
}
|
||||
}
|
||||
|
||||
public void saveAndContinue() {
|
||||
if (save()) {
|
||||
goToEditForm(getCompany());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean save() {
|
||||
if(!ConstraintChecker.isValid(createWindow)) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
externalCompanyModel.confirmSave();
|
||||
messagesForUser.showMessage(Level.INFO,
|
||||
_("Company saved"));
|
||||
return true;
|
||||
} catch (ValidationException e) {
|
||||
messagesForUser.showInvalidValues(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<ExternalCompany> getCompanies() {
|
||||
return externalCompanyModel.getCompanies();
|
||||
}
|
||||
|
||||
public ExternalCompany getCompany() {
|
||||
return externalCompanyModel.getCompany();
|
||||
}
|
||||
|
||||
private OnlyOneVisible getVisibility() {
|
||||
return (visibility == null) ? new OnlyOneVisible(createWindow,
|
||||
listWindow)
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* Model for UI operations related to {@link ExternalCompany}
|
||||
|
|
@ -41,9 +42,27 @@ public class ExternalCompanyModel implements IExternalCompanyModel {
|
|||
@Autowired
|
||||
private IExternalCompanyDAO externalCompanyDAO;
|
||||
|
||||
private ExternalCompany externalCompany;
|
||||
|
||||
@Override
|
||||
public List<ExternalCompany> getCompanies() {
|
||||
return externalCompanyDAO.list(ExternalCompany.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExternalCompany getCompany() {
|
||||
return externalCompany;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initCreate() {
|
||||
externalCompany = ExternalCompany.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void confirmSave() {
|
||||
externalCompanyDAO.save(externalCompany);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ package org.navalplanner.web.externalcompanies;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.navalplanner.business.common.exceptions.ValidationException;
|
||||
import org.navalplanner.business.externalcompanies.entities.ExternalCompany;
|
||||
|
||||
/**
|
||||
|
|
@ -37,4 +38,25 @@ public interface IExternalCompanyModel {
|
|||
* @return A list of {@link ExternalCompany} objects.
|
||||
*/
|
||||
List<ExternalCompany> getCompanies();
|
||||
|
||||
/**
|
||||
* Gets the current {@link ExternalCompany}.
|
||||
*
|
||||
* @return A {@link ExternalCompany}
|
||||
*/
|
||||
ExternalCompany getCompany();
|
||||
|
||||
/**
|
||||
* Makes some operations needed before create a new {@link ExternalCompany}.
|
||||
*
|
||||
*/
|
||||
void initCreate();
|
||||
|
||||
/**
|
||||
* Stores the current {@link ExternalCompany}.
|
||||
*
|
||||
* @throws ValidationException
|
||||
* If validation fails
|
||||
*/
|
||||
void confirmSave();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,4 +22,76 @@
|
|||
|
||||
<window id="${arg.top_id}" title="${i18n:_('Edit external company')}">
|
||||
|
||||
<tabbox>
|
||||
<tabs>
|
||||
<tab label="${i18n:_('Company data')}"></tab>
|
||||
</tabs>
|
||||
<tabpanels>
|
||||
<tabpanel>
|
||||
<vbox>
|
||||
<grid fixedLayout="false">
|
||||
<columns>
|
||||
<column width="200px" />
|
||||
<column />
|
||||
</columns>
|
||||
<rows>
|
||||
<row>
|
||||
<label value="${i18n:_('Company name')}:" />
|
||||
<textbox id="name"
|
||||
value="@{controller.company.name}" width="300px"
|
||||
constraint="no empty:${i18n:_('cannot be null or empty')}"/>
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('NIF')}:" />
|
||||
<textbox id="nif"
|
||||
value="@{controller.company.nif}" width="300px"
|
||||
constraint="no empty:${i18n:_('cannot be null or empty')}"/>
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Client')}:" />
|
||||
<checkbox id="client"
|
||||
checked="@{controller.company.client}" width="300px" />
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Subcontractor')}:" />
|
||||
<checkbox id="subcontractor"
|
||||
checked="@{controller.company.subcontractor}" width="300px" />
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('User')}:" />
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Interacts with applications')}:" />
|
||||
<checkbox id="interactsWithApplication"
|
||||
checked="@{controller.company.interactsWithApplications}" width="300px" />
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Application URI')}:" />
|
||||
<textbox id="appURI"
|
||||
value="@{controller.company.appURI}" width="300px" />
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Our company login')}:" />
|
||||
<textbox id="ourCompanyLogin"
|
||||
value="@{controller.company.ourCompanyLogin}" width="300px" />
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Our company password')}:" />
|
||||
<textbox id="ourCompanyPassword"
|
||||
value="@{controller.company.ourCompanyPassword}" width="300px" />
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
</vbox>
|
||||
</tabpanel>
|
||||
</tabpanels>
|
||||
</tabbox>
|
||||
|
||||
<button onClick="controller.saveAndExit();"
|
||||
label="${i18n:_('Save')}" sclass="save-button global-action" />
|
||||
<button onClick="controller.saveAndContinue();"
|
||||
label="${i18n:_('Save & Continue')}" sclass="saveandcontinue-button global-action" />
|
||||
<button onClick="controller.cancel();"
|
||||
label="${i18n:_('Cancel')}" sclass="cancel-button global-action" />
|
||||
|
||||
</window>
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@
|
|||
</row>
|
||||
</rows>
|
||||
</newdatasortablegrid>
|
||||
<button id="show_create_form" onClick=""
|
||||
<button id="show_create_form" onClick="controller.goToCreateForm();"
|
||||
label="${i18n:_('Create')}" sclass="create-button global-action" >
|
||||
</button>
|
||||
</window>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue