Search in sources :

Example 1 with ITranslatableString

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;
}
Also used : ProductLookupDescriptor(de.metas.ui.web.window.descriptor.sql.ProductLookupDescriptor) IMsgBL(de.metas.i18n.IMsgBL) Builder(de.metas.ui.web.window.descriptor.DocumentFieldDescriptor.Builder) ITranslatableString(de.metas.i18n.ITranslatableString)

Example 2 with ITranslatableString

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);
}
Also used : ITranslatableString(de.metas.i18n.ITranslatableString)

Example 3 with ITranslatableString

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;
}
Also used : ITranslatableString(de.metas.i18n.ITranslatableString) Quantity(de.metas.quantity.Quantity)

Example 4 with ITranslatableString

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);
}
Also used : Group(de.metas.ui.web.material.adapter.AvailableToPromiseResultForWebui.Group) ArrayList(java.util.ArrayList) ITranslatableString(de.metas.i18n.ITranslatableString) ITranslatableString(de.metas.i18n.ITranslatableString) NumberTranslatableString(de.metas.i18n.NumberTranslatableString) IntegerLookupValue(de.metas.ui.web.window.datatypes.LookupValue.IntegerLookupValue) IntegerLookupValue(de.metas.ui.web.window.datatypes.LookupValue.IntegerLookupValue) LookupValue(de.metas.ui.web.window.datatypes.LookupValue)

Example 5 with ITranslatableString

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);
}
Also used : LookupDataSource(de.metas.ui.web.window.model.lookup.LookupDataSource) ITranslatableString(de.metas.i18n.ITranslatableString) IntegerLookupValue(de.metas.ui.web.window.datatypes.LookupValue.IntegerLookupValue) LookupValue(de.metas.ui.web.window.datatypes.LookupValue)

Aggregations

ITranslatableString (de.metas.i18n.ITranslatableString)26 ImmutableTranslatableString (de.metas.i18n.ImmutableTranslatableString)9 IMsgBL (de.metas.i18n.IMsgBL)8 IModelTranslationMap (de.metas.i18n.IModelTranslationMap)5 DocumentFieldWidgetType (de.metas.ui.web.window.descriptor.DocumentFieldWidgetType)4 NumberTranslatableString (de.metas.i18n.NumberTranslatableString)3 DocumentEntityDescriptor (de.metas.ui.web.window.descriptor.DocumentEntityDescriptor)3 LookupDescriptor (de.metas.ui.web.window.descriptor.LookupDescriptor)3 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 ImmutableList (com.google.common.collect.ImmutableList)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 DateTimeTranslatableString (de.metas.i18n.DateTimeTranslatableString)2 BoardFieldLoader (de.metas.ui.web.board.BoardCardFieldDescriptor.BoardFieldLoader)2 WindowConstants (de.metas.ui.web.window.WindowConstants)2 DocumentPath (de.metas.ui.web.window.datatypes.DocumentPath)2 LookupValue (de.metas.ui.web.window.datatypes.LookupValue)2 IntegerLookupValue (de.metas.ui.web.window.datatypes.LookupValue.IntegerLookupValue)2 WindowId (de.metas.ui.web.window.datatypes.WindowId)2 DocumentFieldDescriptor (de.metas.ui.web.window.descriptor.DocumentFieldDescriptor)2