use of com.qcadoo.view.api.components.LookupComponent in project mes by qcadoo.
the class WarehouseMinimumStateListListener method createMultiMinimalStates.
@Transactional
public void createMultiMinimalStates(final ViewDefinitionState view, final ComponentState componentState, final String[] args) {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Entity state = form.getPersistedEntityWithIncludedFormValues();
if (state.getBelongsToField(WarehouseMinimumStateFields.LOCATION) == null) {
LookupComponent location = (LookupComponent) view.getComponentByReference(WarehouseMinimumStateFields.LOCATION);
location.addMessage(new ErrorMessage(L_QCADOO_VIEW_VALIDATE_FIELD_ERROR_MISSING));
location.requestComponentUpdateState();
return;
}
if (state.getManyToManyField("products") == null || state.getManyToManyField("products").isEmpty()) {
view.addMessage(new ErrorMessage("warehouseMinimalState.warehouseMinimumStateAddMulti.error.productsEmpthy"));
return;
}
state.getManyToManyField("products").forEach(p -> createMinimalStateEntity(state, p));
componentState.addMessage("warehouseMinimalState.warehouseMinimumStateAddMulti.info.generated", ComponentState.MessageType.SUCCESS);
}
use of com.qcadoo.view.api.components.LookupComponent in project mes by qcadoo.
the class TechOperCompWorkstationTimeDetailsHooks method onBeforeRender.
public void onBeforeRender(final ViewDefinitionState view) {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
LookupComponent workstationLookup = (LookupComponent) view.getComponentByReference(TechOperCompWorkstationTimeFields.WORKSTATION);
Entity techOperCompWorkstationTime = form.getEntity();
Entity technologyOperationComponent = techOperCompWorkstationTime.getBelongsToField(TechOperCompWorkstationTimeFields.TECHNOLOGY_OPERATION_COMPONENT);
Entity workstation = techOperCompWorkstationTime.getBelongsToField(TechOperCompWorkstationTimeFields.WORKSTATION);
filterWorkstationLookup(workstationLookup, technologyOperationComponent, workstation);
}
use of com.qcadoo.view.api.components.LookupComponent in project mes by qcadoo.
the class StaffDetailsHooks method fillFieldAboutWageGroup.
public void fillFieldAboutWageGroup(final ViewDefinitionState view) {
LookupComponent lookup = (LookupComponent) view.getComponentByReference("wageGroup");
Entity wageGroup = lookup.getEntity();
FieldComponent laborCostFromWageGroups = (FieldComponent) view.getComponentByReference("laborCostFromWageGroups");
FieldComponent superiorWageGroups = (FieldComponent) view.getComponentByReference("superiorWageGroups");
if (wageGroup != null) {
laborCostFromWageGroups.setFieldValue(wageGroup.getField(LABOR_HOURLY_COST));
superiorWageGroups.setFieldValue(wageGroup.getStringField(SUPERIOR_WAGE_GROUP));
} else {
laborCostFromWageGroups.setFieldValue(null);
superiorWageGroups.setFieldValue(null);
}
}
use of com.qcadoo.view.api.components.LookupComponent in project mes by qcadoo.
the class ProductionCountingAttributeValueDetailsHooks method onBeforeRender.
public void onBeforeRender(final ViewDefinitionState view) {
setValueBold(view);
setFilters(view);
LookupComponent attributeLookup = (LookupComponent) view.getComponentByReference(ProductionCountingAttributeValueFields.ATTRIBUTE);
LookupComponent attributeValueLookup = (LookupComponent) view.getComponentByReference(ProductionCountingAttributeValueFields.ATTRIBUTE_VALUE);
FieldComponent valueField = (FieldComponent) view.getComponentByReference(ProductionCountingAttributeValueFields.VALUE);
if (Objects.nonNull(attributeLookup.getEntity())) {
Entity attribute = attributeLookup.getEntity();
FieldComponent unitField = (FieldComponent) view.getComponentByReference(L_UNIT);
unitField.setFieldValue(attribute.getStringField(AttributeFields.UNIT));
unitField.requestComponentUpdateState();
if (AttributeDataType.CONTINUOUS.getStringValue().equals(attribute.getStringField(AttributeFields.DATA_TYPE))) {
valueField.setVisible(true);
attributeValueLookup.setVisible(false);
} else {
valueField.setVisible(false);
attributeValueLookup.setVisible(true);
}
} else {
valueField.setVisible(false);
attributeValueLookup.setVisible(false);
}
}
use of com.qcadoo.view.api.components.LookupComponent in project mes by qcadoo.
the class ProductionCountingAttributeValueDetailsHooks method setFilters.
private void setFilters(ViewDefinitionState view) {
LookupComponent attributeLookup = (LookupComponent) view.getComponentByReference(ProductionCountingAttributeValueFields.ATTRIBUTE);
LookupComponent attributeValueLookup = (LookupComponent) view.getComponentByReference(ProductionCountingAttributeValueFields.ATTRIBUTE_VALUE);
FilterValueHolder attributeValueLookupFilters = attributeValueLookup.getFilterValue();
if (Objects.nonNull(attributeLookup.getEntity())) {
attributeValueLookupFilters.put(L_ATTRIBUTE_ID, attributeLookup.getEntity().getId());
} else if (attributeValueLookupFilters.has(L_ATTRIBUTE_ID)) {
attributeValueLookupFilters.remove(L_ATTRIBUTE_ID);
}
attributeValueLookup.setFilterValue(attributeValueLookupFilters);
}
Aggregations