use of com.qcadoo.view.api.components.LookupComponent in project mes by qcadoo.
the class AllStoppagesFormHooks method onBeforeRender.
public final void onBeforeRender(final ViewDefinitionState view) throws JSONException {
if (Objects.isNull(((FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM)).getEntityId())) {
JSONObject context = view.getJsonContext();
if (view.isViewAfterRedirect() && context.has(L_CONTEXT_KEY_PRODUCTION_TRACKING)) {
Long productionTrackingId = context.getLong(L_CONTEXT_KEY_PRODUCTION_TRACKING);
Long orderId = context.getLong(L_CONTEXT_KEY_ORDER);
LookupComponent orderLookupComponent = (LookupComponent) view.getComponentByReference(L_ORDER);
orderLookupComponent.setFieldValue(orderId);
orderLookupComponent.setEnabled(false);
orderLookupComponent.requestComponentUpdateState();
LookupComponent productionTrackingComponent = (LookupComponent) view.getComponentByReference(L_PRODUCTION_TRACKING);
productionTrackingComponent.setFieldValue(productionTrackingId);
productionTrackingComponent.setEnabled(false);
productionTrackingComponent.requestComponentUpdateState();
} else if (view.isViewAfterRedirect() && context.has(L_CONTEXT_KEY_ORDER)) {
Long orderId = context.getLong(L_CONTEXT_KEY_ORDER);
LookupComponent orderLookupComponent = (LookupComponent) view.getComponentByReference(L_ORDER);
orderLookupComponent.setFieldValue(orderId);
orderLookupComponent.setEnabled(false);
orderLookupComponent.requestComponentUpdateState();
}
} else {
LookupComponent orderLookupComponent = (LookupComponent) view.getComponentByReference(L_ORDER);
LookupComponent productionTrackingComponent = (LookupComponent) view.getComponentByReference(L_PRODUCTION_TRACKING);
JSONObject context = view.getJsonContext();
if (Objects.nonNull(context) && context.has(L_CONTEXT_KEY_PRODUCTION_TRACKING)) {
orderLookupComponent.setEnabled(false);
productionTrackingComponent.setEnabled(false);
}
Entity order = orderLookupComponent.getEntity();
if (order != null) {
FilterValueHolder holder = productionTrackingComponent.getFilterValue();
holder.put(StoppageFields.ORDER, order.getId());
productionTrackingComponent.setFilterValue(holder);
}
}
}
use of com.qcadoo.view.api.components.LookupComponent in project mes by qcadoo.
the class StoppageForOrderFormHooks method onBeforeRender.
public final void onBeforeRender(final ViewDefinitionState view) throws JSONException {
LookupComponent orderLookupComponent = (LookupComponent) view.getComponentByReference(L_ORDER);
orderLookupComponent.setEnabled(false);
if (Objects.isNull(((FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM)).getEntityId())) {
JSONObject context = view.getJsonContext();
if (view.isViewAfterRedirect() && context.has(L_CONTEXT_KEY_ORDER)) {
Long orderId = context.getLong(L_CONTEXT_KEY_ORDER);
orderLookupComponent.setFieldValue(orderId);
orderLookupComponent.requestComponentUpdateState();
LookupComponent productionTrackingComponent = (LookupComponent) view.getComponentByReference(L_PRODUCTION_TRACKING);
FilterValueHolder holder = productionTrackingComponent.getFilterValue();
holder.put(StoppageFields.ORDER, orderId);
productionTrackingComponent.setFilterValue(holder);
}
} else {
LookupComponent productionTrackingComponent = (LookupComponent) view.getComponentByReference(L_PRODUCTION_TRACKING);
Entity order = orderLookupComponent.getEntity();
if (order != null) {
FilterValueHolder holder = productionTrackingComponent.getFilterValue();
holder.put(StoppageFields.ORDER, order.getId());
productionTrackingComponent.setFilterValue(holder);
}
}
}
use of com.qcadoo.view.api.components.LookupComponent in project mes by qcadoo.
the class AllStoppagesFormListeners method changeOrder.
public void changeOrder(final ViewDefinitionState view, final ComponentState state, final String[] args) {
LookupComponent orderLookup = (LookupComponent) view.getComponentByReference(StoppageFields.ORDER);
LookupComponent productionTrackingLookup = (LookupComponent) view.getComponentByReference(StoppageFields.PRODUCTION_TRACKING);
Entity order = orderLookup.getEntity();
if (order != null) {
FilterValueHolder holder = productionTrackingLookup.getFilterValue();
holder.put(StoppageFields.ORDER, order.getId());
productionTrackingLookup.setFilterValue(holder);
}
}
use of com.qcadoo.view.api.components.LookupComponent in project mes by qcadoo.
the class SupplyNegotiationsServiceImpl method fillOffer.
@Override
public void fillOffer(final ViewDefinitionState view, final Entity offer) {
LookupComponent offerLookup = (LookupComponent) view.getComponentByReference(L_OFFER);
if (offer == null) {
offerLookup.setFieldValue(null);
} else {
offerLookup.setFieldValue(offer.getId());
}
offerLookup.requestComponentUpdateState();
}
use of com.qcadoo.view.api.components.LookupComponent in project mes by qcadoo.
the class OrderedProductDetailsHooksSN method fillPricePerUnit.
public void fillPricePerUnit(final ViewDefinitionState view) {
LookupComponent productLookup = (LookupComponent) view.getComponentByReference(OrderedProductFields.PRODUCT);
LookupComponent offerLookup = (LookupComponent) view.getComponentByReference(OrderedProductFieldsSN.OFFER);
Entity product = productLookup.getEntity();
Entity offer = offerLookup.getEntity();
if ((product != null) && (offer != null)) {
FieldComponent pricePerUnitField = (FieldComponent) view.getComponentByReference(OrderedProductFields.PRICE_PER_UNIT);
FieldComponent totalPriceField = (FieldComponent) view.getComponentByReference(OrderedProductFields.TOTAL_PRICE);
FieldComponent quantityField = (FieldComponent) view.getComponentByReference(OrderedProductFields.ORDERED_QUANTITY);
BigDecimal quantity = deliveriesService.getBigDecimalFromField(quantityField, view.getLocale());
BigDecimal pricePerUnit = supplyNegotiationsService.getPricePerUnit(offer, product);
if ((quantity != null) && (pricePerUnit != null)) {
BigDecimal totalPrice = quantity.multiply(pricePerUnit, numberService.getMathContext());
pricePerUnitField.setFieldValue(numberService.format(pricePerUnit));
totalPriceField.setFieldValue(numberService.format(totalPrice));
} else {
if (pricePerUnit == null) {
pricePerUnitField.setFieldValue(null);
} else {
pricePerUnitField.setFieldValue(numberService.format(pricePerUnit));
}
totalPriceField.setFieldValue(null);
}
totalPriceField.requestComponentUpdateState();
pricePerUnitField.requestComponentUpdateState();
}
}
Aggregations