ItEr50S13AdaptacionServiciosRESTItEr49S18: Autogeneration of the codes in the Label edition page can be enabled or disabled using a checkbox.
This commit is contained in:
parent
a935a579b0
commit
8208d6a95c
4 changed files with 58 additions and 4 deletions
|
|
@ -94,4 +94,15 @@ public interface ILabelTypeModel {
|
|||
*/
|
||||
boolean labelNameIsUnique(String value);
|
||||
|
||||
/**
|
||||
* Checks if the autogeneration of codes for Labels is active
|
||||
* @return
|
||||
*/
|
||||
boolean isCodeGenerated();
|
||||
|
||||
/**
|
||||
* Sets the state of the autogeneration of codes for Labels
|
||||
*/
|
||||
void setCodeGenerated(boolean codeGenerated);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -340,4 +340,11 @@ public class LabelTypeCRUDController extends GenericForwardComposer {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean isCodeGenerated() {
|
||||
return labelTypeModel.isCodeGenerated();
|
||||
}
|
||||
|
||||
public void setCodeGenerated(boolean codeGenerated) {
|
||||
labelTypeModel.setCodeGenerated(codeGenerated);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import java.util.List;
|
|||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.hibernate.validator.InvalidValue;
|
||||
import org.navalplanner.business.common.daos.IConfigurationDAO;
|
||||
import org.navalplanner.business.common.exceptions.InstanceNotFoundException;
|
||||
import org.navalplanner.business.common.exceptions.ValidationException;
|
||||
import org.navalplanner.business.labels.daos.ILabelTypeDAO;
|
||||
|
|
@ -49,8 +50,13 @@ public class LabelTypeModel implements ILabelTypeModel {
|
|||
@Autowired
|
||||
private ILabelTypeDAO labelTypeDAO;
|
||||
|
||||
@Autowired
|
||||
private IConfigurationDAO configurationDAO;
|
||||
|
||||
private LabelType labelType;
|
||||
|
||||
private boolean codeGenerated;
|
||||
|
||||
public LabelTypeModel() {
|
||||
|
||||
}
|
||||
|
|
@ -72,8 +78,15 @@ public class LabelTypeModel implements ILabelTypeModel {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly=true)
|
||||
public void initCreate() {
|
||||
labelType = LabelType.create("");
|
||||
codeGenerated = configurationDAO.getConfiguration().getGenerateCodeForLabel();
|
||||
if(codeGenerated) {
|
||||
labelType = LabelType.create("");
|
||||
}
|
||||
else {
|
||||
labelType = LabelType.create("", "");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -134,6 +147,7 @@ public class LabelTypeModel implements ILabelTypeModel {
|
|||
public void initEdit(LabelType labelType) {
|
||||
Validate.notNull(labelType);
|
||||
this.labelType = getFromDB(labelType);
|
||||
codeGenerated = configurationDAO.getConfiguration().getGenerateCodeForLabel();
|
||||
}
|
||||
|
||||
private LabelType getFromDB(LabelType labelType) {
|
||||
|
|
@ -169,7 +183,13 @@ public class LabelTypeModel implements ILabelTypeModel {
|
|||
|
||||
@Override
|
||||
public void addLabel(String value) {
|
||||
Label label = Label.create(value);
|
||||
Label label;
|
||||
if(codeGenerated) {
|
||||
label = Label.create(value);
|
||||
}
|
||||
else {
|
||||
label = Label.create("", value);
|
||||
}
|
||||
label.setType(labelType);
|
||||
labelType.addLabel(label);
|
||||
}
|
||||
|
|
@ -191,4 +211,14 @@ public class LabelTypeModel implements ILabelTypeModel {
|
|||
return (count == 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCodeGenerated() {
|
||||
return codeGenerated;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCodeGenerated(boolean codeGenerated) {
|
||||
this.codeGenerated = codeGenerated;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,8 +44,13 @@
|
|||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Code')}" />
|
||||
<textbox width="500px" value="@{controller.labelType.code}"
|
||||
constraint="no empty:${i18n:_('cannot be null or empty')}" />
|
||||
<hbox>
|
||||
<textbox width="350px" value="@{controller.labelType.code}"
|
||||
constraint="no empty:${i18n:_('cannot be null or empty')}"
|
||||
disabled="@{controller.codeGenerated}" />
|
||||
<checkbox id="generateCode" label="${i18n:_('Generate code')}"
|
||||
checked="@{controller.codeGenerated}" />
|
||||
</hbox>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
|
|
@ -76,6 +81,7 @@
|
|||
constraint="no empty:${i18n:_('cannot be null or empty')}" />
|
||||
|
||||
<textbox value="@{label.code}" width="95%"
|
||||
disabled="@{controller.codeGenerated}"
|
||||
constraint="no empty:${i18n:_('cannot be null or empty')}" />
|
||||
|
||||
<button sclass="icono" image="/common/img/ico_borrar1.png"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue