Add UI to filter by criteria
FEA: ItEr77S09WBSReport
This commit is contained in:
parent
474b349712
commit
cdc733ce8d
4 changed files with 114 additions and 0 deletions
|
|
@ -26,6 +26,7 @@ import java.util.Set;
|
|||
import org.libreplan.business.labels.entities.Label;
|
||||
import org.libreplan.business.orders.entities.Order;
|
||||
import org.libreplan.business.reports.dtos.ProjectStatusReportDTO;
|
||||
import org.libreplan.business.resources.entities.Criterion;
|
||||
|
||||
/**
|
||||
* Contract for Project Status report model.
|
||||
|
|
@ -54,4 +55,12 @@ public interface IProjectStatusReportModel {
|
|||
|
||||
ProjectStatusReportDTO getTotalDTO();
|
||||
|
||||
List<Criterion> getAllCriteria();
|
||||
|
||||
void addSelectedCriterion(Criterion criterion);
|
||||
|
||||
void removeSelectedCriterion(Criterion criterion);
|
||||
|
||||
Set<Criterion> getSelectedCriteria();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
|
|||
import org.libreplan.business.labels.entities.Label;
|
||||
import org.libreplan.business.orders.entities.Order;
|
||||
import org.libreplan.business.reports.dtos.ProjectStatusReportDTO;
|
||||
import org.libreplan.business.resources.entities.Criterion;
|
||||
import org.libreplan.web.common.Util;
|
||||
import org.libreplan.web.common.components.bandboxsearch.BandboxSearch;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
|
|
@ -58,6 +59,10 @@ public class ProjectStatusReportController extends LibrePlanReportController {
|
|||
|
||||
private Listbox listboxLabels;
|
||||
|
||||
private BandboxSearch bandboxCriteria;
|
||||
|
||||
private Listbox listboxCriteria;
|
||||
|
||||
@Override
|
||||
public void doAfterCompose(Component comp) throws Exception {
|
||||
super.doAfterCompose(comp);
|
||||
|
|
@ -145,4 +150,28 @@ public class ProjectStatusReportController extends LibrePlanReportController {
|
|||
return projectStatusReportModel.getSelectedLabels();
|
||||
}
|
||||
|
||||
public List<Criterion> getAllCriteria() {
|
||||
return projectStatusReportModel.getAllCriteria();
|
||||
}
|
||||
|
||||
public void addCriterion() {
|
||||
Criterion criterion = (Criterion) bandboxCriteria.getSelectedElement();
|
||||
if (criterion == null) {
|
||||
throw new WrongValueException(bandboxCriteria,
|
||||
_("please, select a criterion"));
|
||||
}
|
||||
projectStatusReportModel.addSelectedCriterion(criterion);
|
||||
Util.reloadBindings(listboxCriteria);
|
||||
bandboxCriteria.clear();
|
||||
}
|
||||
|
||||
public void removeCriterion(Criterion criterion) {
|
||||
projectStatusReportModel.removeSelectedCriterion(criterion);
|
||||
Util.reloadBindings(listboxCriteria);
|
||||
}
|
||||
|
||||
public Set<Criterion> getSelectedCriteria() {
|
||||
return projectStatusReportModel.getSelectedCriteria();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -33,6 +33,8 @@ import org.libreplan.business.orders.entities.Order;
|
|||
import org.libreplan.business.orders.entities.OrderElement;
|
||||
import org.libreplan.business.planner.entities.IMoneyCostCalculator;
|
||||
import org.libreplan.business.reports.dtos.ProjectStatusReportDTO;
|
||||
import org.libreplan.business.resources.daos.ICriterionDAO;
|
||||
import org.libreplan.business.resources.entities.Criterion;
|
||||
import org.libreplan.business.scenarios.IScenarioManager;
|
||||
import org.libreplan.business.workingday.EffortDuration;
|
||||
import org.libreplan.web.security.SecurityUtils;
|
||||
|
|
@ -58,6 +60,9 @@ public class ProjectStatusReportModel implements IProjectStatusReportModel {
|
|||
@Autowired
|
||||
private ILabelDAO labelDAO;
|
||||
|
||||
@Autowired
|
||||
private ICriterionDAO criterionDAO;
|
||||
|
||||
@Autowired
|
||||
private IScenarioManager scenarioManager;
|
||||
|
||||
|
|
@ -66,6 +71,8 @@ public class ProjectStatusReportModel implements IProjectStatusReportModel {
|
|||
|
||||
private Set<Label> selectedLabels = new HashSet<Label>();
|
||||
|
||||
private Set<Criterion> selectedCriteria = new HashSet<Criterion>();
|
||||
|
||||
private ProjectStatusReportDTO totalDTO;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
|
@ -224,4 +231,33 @@ public class ProjectStatusReportModel implements IProjectStatusReportModel {
|
|||
return totalDTO;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public List<Criterion> getAllCriteria() {
|
||||
List<Criterion> criteria = criterionDAO.findAll();
|
||||
for (Criterion criterion : criteria) {
|
||||
forceLoadCriterionType(criterion);
|
||||
}
|
||||
return criteria;
|
||||
}
|
||||
|
||||
private void forceLoadCriterionType(Criterion criterion) {
|
||||
criterion.getType().getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSelectedCriterion(Criterion criterion) {
|
||||
selectedCriteria.add(criterion);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeSelectedCriterion(Criterion criterion) {
|
||||
selectedCriteria.remove(criterion);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Criterion> getSelectedCriteria() {
|
||||
return Collections.unmodifiableSet(selectedCriteria);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -100,6 +100,46 @@
|
|||
</panelchildren>
|
||||
</panel>
|
||||
|
||||
<panel title="${i18n:_('Filter by criteria')}" border="normal"
|
||||
style="overflow:auto">
|
||||
<panelchildren>
|
||||
<vbox>
|
||||
<separator spacing="5px"/>
|
||||
<hbox>
|
||||
<bandboxSearch id="bandboxCriteria" finder="CriterionBandboxFinder"
|
||||
model="@{controller.allCriteria}"
|
||||
widthListbox="380px"
|
||||
widthBandbox="350px" />
|
||||
<button label="${i18n:_('Add')}"
|
||||
onClick="controller.addCriterion()"
|
||||
style="margin-top: -4px" />
|
||||
</hbox>
|
||||
</vbox>
|
||||
<separator spacing="10px"/>
|
||||
<listbox id="listboxCriteria"
|
||||
width="700px"
|
||||
multiple="true"
|
||||
model="@{controller.selectedCriteria}">
|
||||
<listhead>
|
||||
<listheader label="${i18n:_('Type')}" align="center" />
|
||||
<listheader label="${i18n:_('Name')}" align="center" />
|
||||
<listheader label="${i18n:_('Operations')}" align="center" width="100px"/>
|
||||
</listhead>
|
||||
<listitem self="@{each='criterion'}" value="@{criterion}">
|
||||
<listcell label="@{criterion.type.name}" />
|
||||
<listcell label="@{criterion.name}" />
|
||||
<listcell>
|
||||
<button sclass="icono" image="/common/img/ico_borrar1.png"
|
||||
hoverImage="/common/img/ico_borrar.png"
|
||||
tooltiptext="${i18n:_('Delete')}"
|
||||
onClick="controller.removeCriterion(self.parent.parent.value);">
|
||||
</button>
|
||||
</listcell>
|
||||
</listitem>
|
||||
</listbox>
|
||||
</panelchildren>
|
||||
</panel>
|
||||
|
||||
<separator spacing="10px" orient="horizontal" />
|
||||
|
||||
<!-- Select output format -->
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue