use of com.qcadoo.view.api.components.FieldComponent in project mes by qcadoo.
the class ProductionCountingQuantityAdvancedDetailsHooks method hideTab.
private void hideTab(ViewDefinitionState view) {
ComponentState attributesTab = view.getComponentByReference(ATTRIBUTES);
ComponentState batchesTab = view.getComponentByReference(L_BATCHES_TAB);
FieldComponent roleField = (FieldComponent) view.getComponentByReference(ProductionCountingQuantityFields.ROLE);
FieldComponent materialField = (FieldComponent) view.getComponentByReference(ProductionCountingQuantityFields.TYPE_OF_MATERIAL);
boolean isProduced = checkIfIsProduced((String) roleField.getFieldValue());
boolean isUsedMaterial = checkIfIsUsed((String) roleField.getFieldValue()) && checkIfIsComponent((String) materialField.getFieldValue());
attributesTab.setVisible(isProduced);
batchesTab.setVisible(isUsedMaterial);
}
use of com.qcadoo.view.api.components.FieldComponent in project mes by qcadoo.
the class ProductionCountingQuantityAdvancedDetailsHooks method onBeforeRender.
public void onBeforeRender(final ViewDefinitionState view) {
setCriteriaModifierParameters(view);
disableFieldsDependsOfState(view);
hideFieldsDependsOfState(view);
fillProductField(view);
fillUnitFields(view);
setTechnologyOperationComponentFieldRequired(view);
fillBatchLookupFilter(view);
hideTab(view);
FormComponent productionCountingQuantityForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
if (productionCountingQuantityForm.getEntityId() != null) {
Entity productionCountingQuantityDto = dataDefinitionService.get(BasicProductionCountingConstants.PLUGIN_IDENTIFIER, BasicProductionCountingConstants.MODEL_PRODUCTION_COUNTING_QUANTITY_DTO).get(productionCountingQuantityForm.getEntityId());
FieldComponent usedQuantity = (FieldComponent) view.getComponentByReference(ProductionCountingQuantityDtoFields.USED_QUANTITY);
FieldComponent producedQuantity = (FieldComponent) view.getComponentByReference(ProductionCountingQuantityDtoFields.PRODUCED_QUANTITY);
usedQuantity.setFieldValue(productionCountingQuantityDto.getDecimalField(ProductionCountingQuantityDtoFields.USED_QUANTITY));
producedQuantity.setFieldValue(productionCountingQuantityDto.getDecimalField(ProductionCountingQuantityDtoFields.PRODUCED_QUANTITY));
}
}
use of com.qcadoo.view.api.components.FieldComponent in project mes by qcadoo.
the class BasicProductionCountingDetailsListeners method fillDoneQuantityField.
public void fillDoneQuantityField(final ViewDefinitionState view, final ComponentState state, final String[] args) {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
FieldComponent producedQuantity = (FieldComponent) view.getComponentByReference(BasicProductionCountingFields.PRODUCED_QUANTITY);
Long basicProductionCountingId = form.getEntityId();
if (basicProductionCountingId != null) {
Entity basicProductionCounting = basicProductionCountingService.getBasicProductionCounting(basicProductionCountingId);
Entity order = basicProductionCounting.getBelongsToField(BasicProductionCountingFields.ORDER);
Entity product = basicProductionCounting.getBelongsToField(BasicProductionCountingFields.PRODUCT);
if (order.getBelongsToField(OrderFields.PRODUCT).getId().equals(product.getId())) {
final String fieldValue = (String) producedQuantity.getFieldValue();
if (fieldValue == null || fieldValue.isEmpty()) {
return;
}
try {
final BigDecimal doneQuantity = new BigDecimal(fieldValue.replace(",", ".").replace(" ", "").replace("\u00A0", ""));
order.setField(OrderFields.DONE_QUANTITY, doneQuantity);
order = order.getDataDefinition().save(order);
} catch (NumberFormatException ex) {
return;
}
if (!order.isValid()) {
producedQuantity.addMessage(order.getError(OrderFields.DONE_QUANTITY));
}
}
}
}
use of com.qcadoo.view.api.components.FieldComponent in project mes by qcadoo.
the class ProductionCountingAttributeValueDetailsListeners method onChangeAttribute.
public void onChangeAttribute(final ViewDefinitionState view, final ComponentState state, final String[] args) {
LookupComponent attributeValueLookup = (LookupComponent) view.getComponentByReference(ProductionCountingAttributeValueFields.ATTRIBUTE_VALUE);
FieldComponent valueField = (FieldComponent) view.getComponentByReference(ProductionCountingAttributeValueFields.VALUE);
attributeValueLookup.setFieldValue(null);
attributeValueLookup.requestComponentUpdateState();
valueField.setFieldValue(null);
valueField.requestComponentUpdateState();
}
use of com.qcadoo.view.api.components.FieldComponent in project mes by qcadoo.
the class ProductionCountingReplacementListeners method onPlannedQuantityChange.
public void onPlannedQuantityChange(final ViewDefinitionState view, final ComponentState state, final String[] args) {
FieldComponent plannedQuantity = (FieldComponent) view.getComponentByReference(L_PLANNED_QUANTITY);
FieldComponent replacesQuantity = (FieldComponent) view.getComponentByReference(L_REPLACES_QUANTITY);
replacesQuantity.setFieldValue(plannedQuantity.getFieldValue());
}
Aggregations