Search in sources :

Example 6 with ITranslatableString

use of de.metas.i18n.ITranslatableString in project metasfresh-webui-api by metasfresh.

the class JSONLookupValue method stringLookupValueFromJsonMap.

public static final StringLookupValue stringLookupValueFromJsonMap(final Map<String, Object> map) {
    final Object keyObj = map.get(PROPERTY_Key);
    final String key = keyObj != null ? keyObj.toString() : null;
    final Object captionObj = map.get(PROPERTY_Caption);
    final String caption = captionObj != null ? captionObj.toString() : "";
    final ITranslatableString displayName = ImmutableTranslatableString.anyLanguage(caption);
    @SuppressWarnings("unchecked") final Map<String, Object> attributes = (Map<String, Object>) map.get(PROPERTY_Attributes);
    if (attributes == null || attributes.isEmpty()) {
        return StringLookupValue.of(key, displayName);
    }
    return StringLookupValue.builder().id(key).displayName(displayName).attributes(attributes).build();
}
Also used : ITranslatableString(de.metas.i18n.ITranslatableString) ITranslatableString(de.metas.i18n.ITranslatableString) ImmutableTranslatableString(de.metas.i18n.ImmutableTranslatableString) ImmutableMap(com.google.common.collect.ImmutableMap) Map(java.util.Map)

Example 7 with ITranslatableString

use of de.metas.i18n.ITranslatableString in project metasfresh-webui-api by metasfresh.

the class JSONLookupValue method ofLookupValue.

public static final JSONLookupValue ofLookupValue(final LookupValue lookupValue) {
    final String id = lookupValue.getIdAsString();
    final ITranslatableString displayNameTrl = lookupValue.getDisplayNameTrl();
    // FIXME add it as parameter!
    final String adLanguage = Env.getAD_Language(Env.getCtx());
    final String displayName = displayNameTrl.translate(adLanguage);
    return new JSONLookupValue(id, displayName, lookupValue.getAttributes());
}
Also used : ITranslatableString(de.metas.i18n.ITranslatableString) ITranslatableString(de.metas.i18n.ITranslatableString) ImmutableTranslatableString(de.metas.i18n.ImmutableTranslatableString)

Example 8 with ITranslatableString

use of de.metas.i18n.ITranslatableString in project metasfresh-webui-api by metasfresh.

the class WEBUI_PP_Order_HUEditor_Create_M_Source_HUs method checkPreconditionsApplicable.

@Override
public final ProcessPreconditionsResolution checkPreconditionsApplicable() {
    final boolean anyHuMatches = retrieveSelectedAndEligibleHUEditorRows().anyMatch(huRow -> huRow.isTopLevel());
    if (anyHuMatches) {
        return ProcessPreconditionsResolution.accept();
    }
    final ITranslatableString reason = Services.get(IMsgBL.class).getTranslatableMsgText(MSG_WEBUI_SELECT_ACTIVE_UNSELECTED_HU);
    return ProcessPreconditionsResolution.reject(reason);
}
Also used : IMsgBL(de.metas.i18n.IMsgBL) ITranslatableString(de.metas.i18n.ITranslatableString)

Example 9 with ITranslatableString

use of de.metas.i18n.ITranslatableString in project metasfresh-webui-api by metasfresh.

the class WEBUI_PP_Order_HUEditor_IssueTUs method checkPreconditionsApplicable.

@Override
public final ProcessPreconditionsResolution checkPreconditionsApplicable() {
    if (!getSelectedRowIds().isSingleDocumentId()) {
        return ProcessPreconditionsResolution.rejectBecauseNotSingleSelection();
    }
    final boolean anyHuMatches = retrieveSelectedAndEligibleHUEditorRows().anyMatch(huRow -> huRow.isTU() || huRow.isTopLevel());
    if (anyHuMatches) {
        return ProcessPreconditionsResolution.accept();
    }
    final ITranslatableString reason = Services.get(IMsgBL.class).getTranslatableMsgText(MSG_WEBUI_SELECT_ACTIVE_UNSELECTED_HU);
    return ProcessPreconditionsResolution.reject(reason);
}
Also used : IMsgBL(de.metas.i18n.IMsgBL) ITranslatableString(de.metas.i18n.ITranslatableString)

Example 10 with ITranslatableString

use of de.metas.i18n.ITranslatableString in project metasfresh-webui-api by metasfresh.

the class WEBUI_PP_Order_HUEditor_IssueTopLevelHUs method checkPreconditionsApplicable.

@Override
public final ProcessPreconditionsResolution checkPreconditionsApplicable() {
    final boolean anyHuMatches = retrieveSelectedAndEligibleHUEditorRows().anyMatch(huRow -> huRow.isTopLevel());
    if (anyHuMatches) {
        return ProcessPreconditionsResolution.accept();
    }
    final ITranslatableString reason = Services.get(IMsgBL.class).getTranslatableMsgText(MSG_WEBUI_SELECT_ACTIVE_UNSELECTED_HU);
    return ProcessPreconditionsResolution.reject(reason);
}
Also used : IMsgBL(de.metas.i18n.IMsgBL) ITranslatableString(de.metas.i18n.ITranslatableString)

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