use of de.metas.i18n.ITranslatableString in project metasfresh-webui-api by metasfresh.
the class OrderLineQuickInputDescriptorFactory method createProductFieldBuilder.
private Builder createProductFieldBuilder(@NonNull final Optional<Boolean> soTrx) {
final ProductLookupDescriptor productLookupDescriptor = createProductLookupDescriptor(soTrx);
final ITranslatableString caption = Services.get(IMsgBL.class).translatable(IOrderLineQuickInput.COLUMNNAME_M_Product_ID);
final Builder productFieldBuilder = DocumentFieldDescriptor.builder(IOrderLineQuickInput.COLUMNNAME_M_Product_ID).setLookupDescriptorProvider(productLookupDescriptor).setCaption(caption).setWidgetType(DocumentFieldWidgetType.Lookup).setReadonlyLogic(ConstantLogicExpression.FALSE).setAlwaysUpdateable(true).setMandatoryLogic(ConstantLogicExpression.TRUE).setDisplayLogic(ConstantLogicExpression.TRUE).addCallout(OrderLineQuickInputDescriptorFactory::onProductChangedCallout).addCharacteristic(Characteristic.PublicField);
return productFieldBuilder;
}
use of de.metas.i18n.ITranslatableString in project metasfresh-webui-api by metasfresh.
the class AddressCountryLookupDescriptor method createLookupValue.
private IntegerLookupValue createLookupValue(final I_C_Country countryRecord) {
final int countryId = countryRecord.getC_Country_ID();
final ITranslatableString countryName = InterfaceWrapperHelper.getModelTranslationMap(countryRecord).getColumnTrl(I_C_Country.COLUMNNAME_Name, countryRecord.getName());
return IntegerLookupValue.of(countryId, countryName);
}
use of de.metas.i18n.ITranslatableString in project metasfresh-webui-api by metasfresh.
the class ProductLookupDescriptor method createDisplayName.
private ITranslatableString createDisplayName(@NonNull final ITranslatableString productDisplayName, @NonNull final Group availableStockGroup) {
final Quantity qtyOnHand = availableStockGroup.getQty();
final ITranslatableString qtyValueStr = NumberTranslatableString.of(qtyOnHand.getQty(), DisplayType.Quantity);
final ITranslatableString uomSymbolStr = availableStockGroup.getUomSymbolStr();
final ITranslatableString storageAttributeString = availableStockGroup.getStorageAttributesString();
final ITranslatableString displayName = ITranslatableString.compose("", productDisplayName, ": ", qtyValueStr, " ", uomSymbolStr, " (", storageAttributeString, ")");
return displayName;
}
use of de.metas.i18n.ITranslatableString in project metasfresh-webui-api by metasfresh.
the class ProductLookupDescriptor method createLookupValuesFromAvailableStockGroups.
private LookupValuesList createLookupValuesFromAvailableStockGroups(@NonNull final LookupValuesList initialLookupValues, @NonNull final List<Group> availableStockGroups) {
final boolean addOnlyPositiveATP = addOnlyPositiveATP();
final List<LookupValue> explodedProductValues = new ArrayList<>();
for (final Group availableStockGroup : availableStockGroups) {
if (addOnlyPositiveATP && availableStockGroup.getQty().signum() <= 0) {
continue;
}
final int productId = availableStockGroup.getProductId();
final LookupValue productLookupValue = initialLookupValues.getById(productId);
final ITranslatableString displayName = createDisplayName(productLookupValue.getDisplayNameTrl(), availableStockGroup);
final ImmutableMap<String, Object> attributeMap = availableStockGroup.getLookupAttributesMap();
final IntegerLookupValue integerLookupValue = IntegerLookupValue.builder().id(productId).displayName(displayName).attribute(ATTRIBUTE_ASI, attributeMap).build();
explodedProductValues.add(integerLookupValue);
}
if (explodedProductValues.isEmpty()) {
// fallback
return initialLookupValues;
}
return LookupValuesList.fromCollection(explodedProductValues);
}
use of de.metas.i18n.ITranslatableString in project metasfresh-webui-api by metasfresh.
the class DocumentField method getValueAsJsonObject.
@Override
public Object getValueAsJsonObject(final String adLanguage) {
Object value = getValue();
if (value == null) {
return null;
}
//
// If we are dealing with a lookup value, make, sure it's translated (see https://github.com/metasfresh/metasfresh-webui-api/issues/311 )
final LookupDataSource lookupDataSource = getLookupDataSourceOrNull();
if (lookupDataSource != null && value instanceof LookupValue) {
final LookupValue lookupValue = (LookupValue) value;
final ITranslatableString displayNameTrl = lookupValue.getDisplayNameTrl();
if (!displayNameTrl.isTranslatedTo(adLanguage)) {
final LookupValue lookupValueNew = lookupDataSource.findById(lookupValue.getId());
value = lookupValueNew;
}
}
return Values.valueToJsonObject(value);
}
Aggregations