use of de.metas.i18n.ITranslatableString in project metasfresh-webui-api by metasfresh.
the class BoardDescriptorRepository method buildDescription.
private static final ITranslatableString buildDescription(final Map<String, Object> cardValues, final BoardDescriptor board) {
final List<ITranslatableString> fieldDescriptions = cardValues.entrySet().stream().map(fieldNameAndValue -> {
final String fieldName = fieldNameAndValue.getKey();
final Object fieldValue = fieldNameAndValue.getValue();
final BoardCardFieldDescriptor cardField = board.getCardFieldByName(fieldName);
return buildDescription(fieldValue, cardField);
}).filter(fieldDescription -> fieldDescription != null).collect(ImmutableList.toImmutableList());
return ITranslatableString.compose("\n", fieldDescriptions);
}
use of de.metas.i18n.ITranslatableString in project metasfresh-webui-api by metasfresh.
the class WEBUI_HUsToPick_PickCU method checkPreconditionsApplicable.
@Override
public ProcessPreconditionsResolution checkPreconditionsApplicable() {
final DocumentIdsSelection selectedRowIds = getSelectedRowIds();
if (selectedRowIds.isEmpty()) {
return ProcessPreconditionsResolution.rejectBecauseNoSelection();
} else if (selectedRowIds.isMoreThanOneDocumentId()) {
return ProcessPreconditionsResolution.rejectBecauseNotSingleSelection();
}
final HUEditorRow huRow = getSingleSelectedRow();
if (!isEligible(huRow)) {
final ITranslatableString reason = Services.get(IMsgBL.class).getTranslatableMsgText(MSG_WEBUI_SELECT_ACTIVE_UNSELECTED_HU);
return ProcessPreconditionsResolution.reject(reason);
}
return ProcessPreconditionsResolution.accept();
}
use of de.metas.i18n.ITranslatableString in project metasfresh-webui-api by metasfresh.
the class MQueryDocumentFilterHelper method createDocumentFilterFromMQuery.
public static DocumentFilter createDocumentFilterFromMQuery(final MQuery mquery, final ITranslatableString caption) {
final List<DocumentFilterParam> parameters = new ArrayList<>();
for (int restrictionIdx = 0, restrictionsCount = mquery.getRestrictionCount(); restrictionIdx < restrictionsCount; restrictionIdx++) {
final DocumentFilterParam param = createDocumentFilterParamFromMQueryRestriction(mquery, restrictionIdx);
parameters.add(param);
}
final String filterId;
if (parameters.size() == 1 && !parameters.get(0).isSqlFilter()) {
filterId = parameters.get(0).getFieldName();
} else {
// FIXME: find a better filterId
filterId = "MQuery-" + UUID.randomUUID();
}
return DocumentFilter.builder().setFilterId(filterId).setCaption(caption).setParameters(parameters).build();
}
use of de.metas.i18n.ITranslatableString in project metasfresh-webui-api by metasfresh.
the class UserQueryDocumentFilterDescriptorsProvider method createFilterDescriptor0.
private static final DocumentFilterDescriptor createFilterDescriptor0(@NonNull final IUserQuery userQuery) {
final DocumentFilterDescriptor.Builder filter = DocumentFilterDescriptor.builder().setFilterId("userquery-" + userQuery.getId()).setDisplayName(userQuery.getCaption()).setFrequentUsed(false);
if (WindowConstants.isProtocolDebugging()) {
filter.putDebugProperty("userQuery", userQuery.toString());
}
for (final IUserQueryRestriction queryRestriction : userQuery.getRestrictions()) {
final Join join = queryRestriction.getJoin();
final UserQueryField searchField = UserQueryField.cast(queryRestriction.getSearchField());
final String fieldName = searchField.getColumnName();
final Operator operator = MQueryDocumentFilterHelper.fromMQueryOperator(queryRestriction.getOperator());
final Object value = queryRestriction.getValue();
final Object valueTo = queryRestriction.getValueTo();
final boolean isParameter;
if (operator.isRangeOperator()) {
isParameter = value == null || valueTo == null;
} else {
isParameter = value == null;
}
if (isParameter) {
final ITranslatableString displayName = searchField.getDisplayName();
final DocumentFieldWidgetType widgetType = searchField.getWidgetType();
final LookupDescriptor lookupDescriptor = searchField.getLookupDescriptor();
filter.addParameter(DocumentFilterParamDescriptor.builder().setJoinAnd(join == Join.AND).setDisplayName(displayName).setFieldName(fieldName).setWidgetType(widgetType).setOperator(operator).setDefaultValue(value).setDefaultValueTo(valueTo).setMandatory(// mandatory if there is no default value
value == null).setLookupDescriptor(lookupDescriptor));
} else {
filter.addInternalParameter(DocumentFilterParam.builder().setJoinAnd(join == Join.AND).setFieldName(fieldName).setOperator(operator).setValue(value).setValueTo(valueTo).build());
}
}
return filter.build();
}
use of de.metas.i18n.ITranslatableString in project metasfresh-webui-api by metasfresh.
the class HUEditorRowAttributesHelper method createLayoutElement.
private static final DocumentLayoutElementDescriptor createLayoutElement(final IAttributeValue attributeValue, final int warehouseId) {
final I_M_Attribute attribute = attributeValue.getM_Attribute();
final IModelTranslationMap attributeTrlMap = InterfaceWrapperHelper.getModelTranslationMap(attribute);
final ITranslatableString caption = attributeTrlMap.getColumnTrl(I_M_Attribute.COLUMNNAME_Name, attribute.getName());
final ITranslatableString description = attributeTrlMap.getColumnTrl(I_M_Attribute.COLUMNNAME_Description, attribute.getDescription());
final String attributeName = HUEditorRowAttributesHelper.extractAttributeName(attributeValue);
final DocumentFieldWidgetType widgetType = HUEditorRowAttributesHelper.extractWidgetType(attributeValue);
return DocumentLayoutElementDescriptor.builder().setCaption(caption).setDescription(description).setWidgetType(widgetType).addField(DocumentLayoutElementFieldDescriptor.builder(attributeName).setPublicField(true).addDevices(createDevices(attribute.getValue(), warehouseId))).build();
}
Aggregations