ItEr35S15CUAdministracionCategoriaCosteItEr34S15: edition and creation of CostCategories
Interface to create and edit CostCategories. At the moment, only the simple attributes can be edited, the relation with HourCost is not managed yet.
This commit is contained in:
parent
4d4c565ba7
commit
e98db057c0
6 changed files with 141 additions and 4 deletions
|
|
@ -43,6 +43,10 @@ public class CostCategory extends BaseEntity {
|
|||
|
||||
}
|
||||
|
||||
public static CostCategory create() {
|
||||
return (CostCategory) create(new CostCategory());
|
||||
}
|
||||
|
||||
public static CostCategory create(String name) {
|
||||
return (CostCategory) create(new CostCategory(name));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,10 +20,17 @@
|
|||
|
||||
package org.navalplanner.web.costcategories;
|
||||
|
||||
import java.util.List;
|
||||
import static org.navalplanner.web.I18nHelper._;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hibernate.validator.InvalidValue;
|
||||
import org.navalplanner.business.common.exceptions.ValidationException;
|
||||
import org.navalplanner.business.costcategories.entities.CostCategory;
|
||||
import org.navalplanner.business.costcategories.entities.HourCost;
|
||||
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;
|
||||
|
|
@ -62,12 +69,16 @@ public class CostCategoryCRUDController extends GenericForwardComposer
|
|||
|
||||
@Override
|
||||
public void goToCreateForm() {
|
||||
//TODO
|
||||
costCategoryModel.initCreate();
|
||||
getVisibility().showOnly(createWindow);
|
||||
Util.reloadBindings(createWindow);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void goToEditForm(CostCategory costCategory) {
|
||||
//TODO
|
||||
costCategoryModel.initEdit(costCategory);
|
||||
getVisibility().showOnly(createWindow);
|
||||
Util.reloadBindings(createWindow);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -76,10 +87,51 @@ public class CostCategoryCRUDController extends GenericForwardComposer
|
|||
Util.reloadBindings(listWindow);
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
goToList();
|
||||
}
|
||||
|
||||
|
||||
public void saveAndExit() {
|
||||
if (save()) {
|
||||
goToList();
|
||||
}
|
||||
}
|
||||
|
||||
public void saveAndContinue() {
|
||||
if (save()) {
|
||||
goToEditForm(getCostCategory());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean save() {
|
||||
try {
|
||||
costCategoryModel.confirmSave();
|
||||
messagesForUser.showMessage(Level.INFO,
|
||||
_("Type of work hours saved"));
|
||||
return true;
|
||||
} catch (ValidationException e) {
|
||||
String message = _("The following errors were found: ");
|
||||
for(InvalidValue each: e.getInvalidValues()) {
|
||||
message += each.getMessage();
|
||||
}
|
||||
messagesForUser.showMessage(Level.ERROR, message);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public CostCategory getCostCategory() {
|
||||
return costCategoryModel.getCostCategory();
|
||||
}
|
||||
|
||||
public List<CostCategory> getCostCategories() {
|
||||
return costCategoryModel.getCostCategories();
|
||||
}
|
||||
|
||||
public Set<HourCost> getHourCosts() {
|
||||
return costCategoryModel.getHourCosts();
|
||||
}
|
||||
|
||||
private OnlyOneVisible getVisibility() {
|
||||
return (visibility == null) ? new OnlyOneVisible(createWindow,
|
||||
listWindow)
|
||||
|
|
|
|||
|
|
@ -21,13 +21,17 @@
|
|||
package org.navalplanner.web.costcategories;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.navalplanner.business.common.exceptions.ValidationException;
|
||||
import org.navalplanner.business.costcategories.daos.ICostCategoryDAO;
|
||||
import org.navalplanner.business.costcategories.entities.CostCategory;
|
||||
import org.navalplanner.business.costcategories.entities.HourCost;
|
||||
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 CostCategory}
|
||||
|
|
@ -38,6 +42,8 @@ import org.springframework.stereotype.Service;
|
|||
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
|
||||
public class CostCategoryModel implements ICostCategoryModel {
|
||||
|
||||
private CostCategory costCategory;
|
||||
|
||||
@Autowired
|
||||
private ICostCategoryDAO costCategoryDAO;
|
||||
|
||||
|
|
@ -45,4 +51,32 @@ public class CostCategoryModel implements ICostCategoryModel {
|
|||
public List<CostCategory> getCostCategories() {
|
||||
return costCategoryDAO.list(CostCategory.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public void initCreate() {
|
||||
costCategory = CostCategory.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public void initEdit(CostCategory costCategory) {
|
||||
this.costCategory = costCategory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<HourCost> getHourCosts() {
|
||||
return costCategory.getHourCosts();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CostCategory getCostCategory() {
|
||||
return costCategory;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void confirmSave() throws ValidationException {
|
||||
costCategoryDAO.save(costCategory);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,8 +21,11 @@
|
|||
package org.navalplanner.web.costcategories;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.navalplanner.business.common.exceptions.ValidationException;
|
||||
import org.navalplanner.business.costcategories.entities.CostCategory;
|
||||
import org.navalplanner.business.costcategories.entities.HourCost;
|
||||
|
||||
/**
|
||||
* Model for UI operations related to {@link CostCategory}
|
||||
|
|
@ -38,4 +41,13 @@ public interface ICostCategoryModel {
|
|||
*/
|
||||
List<CostCategory> getCostCategories();
|
||||
|
||||
Set<HourCost> getHourCosts();
|
||||
|
||||
CostCategory getCostCategory();
|
||||
|
||||
void initCreate();
|
||||
|
||||
void initEdit(CostCategory costCategory);
|
||||
|
||||
void confirmSave() throws ValidationException;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,5 +21,40 @@
|
|||
<?taglib uri="/WEB-INF/tld/i18n.tld" prefix="i18n" ?>
|
||||
|
||||
<window id="${arg.top_id}" title="${i18n:_('Edit cost category')}">
|
||||
<tabbox>
|
||||
<tabs>
|
||||
<tab label="${i18n:_('Category data')}"></tab>
|
||||
</tabs>
|
||||
<tabpanels>
|
||||
<tabpanel>
|
||||
<vbox>
|
||||
<!-- CostCategory details -->
|
||||
<grid fixedLayout="false">
|
||||
<columns>
|
||||
<column width="200px" />
|
||||
<column />
|
||||
</columns>
|
||||
<rows>
|
||||
<row>
|
||||
<label value="${i18n:_('Name')}:" />
|
||||
<textbox id="name"
|
||||
value="@{controller.costCategory.name}" width="300px"
|
||||
constraint="no empty:${i18n:_('cannot be null or empty')}"/>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
|
||||
<!-- TODO: Hour costs list -->
|
||||
</vbox>
|
||||
</tabpanel>
|
||||
</tabpanels>
|
||||
</tabbox>
|
||||
|
||||
<button onClick="controller.saveAndExit();"
|
||||
label="${i18n:_('Save')}" />
|
||||
<button onClick="controller.saveAndContinue();"
|
||||
label="${i18n:_('Save & Continue')}" />
|
||||
<button onClick="controller.cancel();"
|
||||
label="${i18n:_('Cancel')}" />
|
||||
|
||||
</window>
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
<newdatasortablecolumn label="${i18n:_('Actions')}" />
|
||||
</columns>
|
||||
<rows>
|
||||
<row self="@{each='costCategory'}" value="@{costCategories}">
|
||||
<row self="@{each='costCategory'}" value="@{costCategory}">
|
||||
<label value="@{costCategory.name}" />
|
||||
<hbox>
|
||||
<button sclass="icono" image="/common/img/ico_editar1.png"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue