ItEr43S12CUGravacionModelosUnidadesTraballoItEr42S17: Adding component to assign quality forms to order element template
This commit is contained in:
parent
188e6c205a
commit
ca7ed7446c
5 changed files with 206 additions and 6 deletions
|
|
@ -247,4 +247,12 @@ public abstract class OrderElementTemplate extends BaseEntity implements
|
|||
public Set<QualityForm> getQualityForms() {
|
||||
return Collections.unmodifiableSet(qualityForms);
|
||||
}
|
||||
|
||||
public void addQualityForm(QualityForm qualityForm) {
|
||||
qualityForms.add(qualityForm);
|
||||
}
|
||||
|
||||
public void removeQualityForm(QualityForm qualityForm) {
|
||||
qualityForms.remove(qualityForm);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -140,17 +140,38 @@ public class AssignedTaskQualityFormsToOrderElementController extends
|
|||
* quality form list
|
||||
*/
|
||||
public void onAssignTaskQualityForm() {
|
||||
QualityForm qualityForm = (QualityForm) bdQualityForms
|
||||
BandboxSearch qualityFormFinder = bdQualityForms;
|
||||
QualityForm qualityForm = retrieveQualityFormFrom(qualityFormFinder,
|
||||
new ICheckQualityFormAssigned() {
|
||||
|
||||
@Override
|
||||
public boolean isAssigned(QualityForm qualityForm) {
|
||||
return AssignedTaskQualityFormsToOrderElementController.this
|
||||
.isAssigned(qualityForm);
|
||||
}
|
||||
});
|
||||
assignQualityForm(qualityForm);
|
||||
}
|
||||
|
||||
public interface ICheckQualityFormAssigned {
|
||||
public boolean isAssigned(QualityForm qualityForm);
|
||||
}
|
||||
|
||||
public static QualityForm retrieveQualityFormFrom(
|
||||
BandboxSearch qualityFormFinder,
|
||||
ICheckQualityFormAssigned checkQualityFormAssigned) {
|
||||
QualityForm qualityForm = (QualityForm) qualityFormFinder
|
||||
.getSelectedElement();
|
||||
if (qualityForm == null) {
|
||||
throw new WrongValueException(bdQualityForms,
|
||||
throw new WrongValueException(qualityFormFinder,
|
||||
_("please, select a quality form"));
|
||||
}
|
||||
if (isAssigned(qualityForm)) {
|
||||
throw new WrongValueException(bdQualityForms, _("already assigned"));
|
||||
if (checkQualityFormAssigned.isAssigned(qualityForm)) {
|
||||
throw new WrongValueException(qualityFormFinder,
|
||||
_("already assigned"));
|
||||
}
|
||||
assignQualityForm(qualityForm);
|
||||
bdQualityForms.clear();
|
||||
qualityFormFinder.clear();
|
||||
return qualityForm;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
|
|
|
|||
|
|
@ -134,9 +134,19 @@ public class OrderTemplatesModel implements IOrderTemplatesModel {
|
|||
public void initEdit(OrderElementTemplate template) {
|
||||
initializeAcompanyingObjectsOnConversation();
|
||||
this.template = dao.findExistingEntity(template.getId());
|
||||
loadQualityForms(this.template);
|
||||
treeModel = new TemplatesTree(this.template);
|
||||
}
|
||||
|
||||
private void loadQualityForms(OrderElementTemplate template) {
|
||||
for (QualityForm each : template.getQualityForms()) {
|
||||
each.getName();
|
||||
}
|
||||
for (OrderElementTemplate each : template.getChildrenTemplates()) {
|
||||
loadQualityForms(each);
|
||||
}
|
||||
}
|
||||
|
||||
private void initializeAcompanyingObjectsOnConversation() {
|
||||
getLabelsOnConversation().initializeLabels();
|
||||
getQualityFormsOnConversation().initialize();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,90 @@
|
|||
/*
|
||||
* This file is part of ###PROJECT_NAME###
|
||||
*
|
||||
* Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
|
||||
* Desenvolvemento Tecnolóxico de Galicia
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.navalplanner.web.templates.quality;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.navalplanner.business.qualityforms.entities.QualityForm;
|
||||
import org.navalplanner.business.templates.entities.OrderElementTemplate;
|
||||
import org.navalplanner.web.common.Util;
|
||||
import org.navalplanner.web.common.components.bandboxsearch.BandboxSearch;
|
||||
import org.navalplanner.web.orders.AssignedTaskQualityFormsToOrderElementController;
|
||||
import org.navalplanner.web.orders.AssignedTaskQualityFormsToOrderElementController.ICheckQualityFormAssigned;
|
||||
import org.navalplanner.web.templates.IOrderTemplatesModel;
|
||||
import org.zkoss.zk.ui.HtmlMacroComponent;
|
||||
|
||||
/**
|
||||
* @author Óscar González Fernández <ogonzalez@igalia.com>
|
||||
*
|
||||
*/
|
||||
public class QualityFormAssignerComponent extends HtmlMacroComponent {
|
||||
|
||||
private OrderElementTemplate template;
|
||||
private IOrderTemplatesModel model;
|
||||
|
||||
public void useModel(IOrderTemplatesModel model) {
|
||||
template = model.getTemplate();
|
||||
this.model = model;
|
||||
}
|
||||
|
||||
public List<QualityForm> getNotAssignedQualityForms() {
|
||||
if (model == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
Set<QualityForm> result = model.getAllQualityForms();
|
||||
result.removeAll(template.getQualityForms());
|
||||
return new ArrayList<QualityForm>(result);
|
||||
}
|
||||
|
||||
public List<QualityForm> getAssigned() {
|
||||
if (template == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return new ArrayList<QualityForm>(template.getQualityForms());
|
||||
}
|
||||
|
||||
public void onAssignTaskQualityForm() {
|
||||
ICheckQualityFormAssigned checkQualityFormAssigned = new ICheckQualityFormAssigned() {
|
||||
|
||||
@Override
|
||||
public boolean isAssigned(QualityForm qualityForm) {
|
||||
return template.getQualityForms().contains(qualityForm);
|
||||
}
|
||||
};
|
||||
QualityForm qualityForm = AssignedTaskQualityFormsToOrderElementController
|
||||
.retrieveQualityFormFrom(getQualityFormFinder(),
|
||||
checkQualityFormAssigned);
|
||||
template.addQualityForm(qualityForm);
|
||||
Util.reloadBindings(this);
|
||||
}
|
||||
|
||||
public void remove(QualityForm qualityForm) {
|
||||
template.removeQualityForm(qualityForm);
|
||||
Util.reloadBindings(this);
|
||||
}
|
||||
|
||||
private BandboxSearch getQualityFormFinder() {
|
||||
return (BandboxSearch) getFellow("qualityFormFinder");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
<!--
|
||||
This file is part of ###PROJECT_NAME###
|
||||
|
||||
Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
|
||||
Desenvolvemento Tecnolóxico de Galicia
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
<zk>
|
||||
<zscript><![CDATA[
|
||||
assignedQualityForms = self;
|
||||
]]>
|
||||
</zscript>
|
||||
<vbox>
|
||||
<!-- Quality Forms-->
|
||||
<vbox>
|
||||
<vbox id="messagesContainerQualityForms" />
|
||||
<panel title="${i18n:_('Quality forms')}" border="normal">
|
||||
<panelchildren>
|
||||
<!-- Assign quality form -->
|
||||
<vbox>
|
||||
<label value="${i18n:_('Assign quality form')}" />
|
||||
<hbox>
|
||||
<bandboxSearch id="qualityFormFinder" finder="QualityFormBandboxFinder"
|
||||
model="@{assignedQualityForms.notAssignedQualityForms}" />
|
||||
<button label="${i18n:_('Assign')}"
|
||||
onClick="assignedQualityForms.onAssignTaskQualityForm()"
|
||||
style="margin-top: -4px" />
|
||||
</hbox>
|
||||
</vbox>
|
||||
<separator bar="false" spacing="40px" orient="vertical"/>
|
||||
<grid height="300px" fixedLayout="true"
|
||||
model="@{assignedQualityForms.assigned}">
|
||||
<columns>
|
||||
<column width="25px"/>
|
||||
<column label="${i18n:_('Name name')}" sort="auto(name)" sortDirection="descending"/>
|
||||
<column label="${i18n:_('Type')}" />
|
||||
<column label="${i18n:_('Operations')}" />
|
||||
</columns>
|
||||
<rows>
|
||||
<row self="@{each='qualityForm'}" value="@{qualityForm}">
|
||||
<label />
|
||||
<label value="@{qualityForm.name}"/>
|
||||
<label value="@{qualityForm.qualityFormType}"/>
|
||||
<hbox>
|
||||
<button sclass="icono" image="/common/img/ico_borrar1.png"
|
||||
hoverImage="/common/img/ico_borrar.png"
|
||||
onClick="assignedQualityForms.remove(self.parent.parent.value);"
|
||||
/>
|
||||
</hbox>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
|
||||
<separator bar="false" spacing="40px" orient="vertical"/>
|
||||
</panelchildren>
|
||||
</panel>
|
||||
</vbox>
|
||||
</vbox>
|
||||
</zk>
|
||||
Loading…
Add table
Reference in a new issue