Class FieldsDictionaryMeta<T extends org.cxbox.api.data.dto.DataResponseDTO>

All Implemented Interfaces:
Iterable<org.cxbox.api.data.dto.rowmeta.FieldDTO>
Direct Known Subclasses:
FieldsGroupingHierarchyMeta

public class FieldsDictionaryMeta<T extends org.cxbox.api.data.dto.DataResponseDTO> extends FieldsDictionaryDeprecatedMeta<T>
  • Constructor Details

    • FieldsDictionaryMeta

      public FieldsDictionaryMeta(@Qualifier("cxboxObjectMapper") com.fasterxml.jackson.databind.ObjectMapper objectMapper, Optional<DictionaryProvider> dictionaryProvider)
  • Method Details

    • setDictionaryFilterValues

      public final <V extends Dictionary> void setDictionaryFilterValues(DtoField<? super T,V> field)


      Fills dictionary field filer drop-down (List widget field during filer editing) with all values from dictionary type
      Type Parameters:
      V - - dictionary class. Usually class name determines dictionary type, that is used to convert keys to values for UI (see Dictionary.getDictionaryType())
      Parameters:
      field - - widget dictionary field
    • setDictionaryFilterValues

      public final <V extends Dictionary> void setDictionaryFilterValues(@Nullable DtoField<? super T,V> field, @NonNull @NonNull Collection<V> variants)


      Type Parameters:
      V - - dictionary class. Usually class name determines dictionary type, that is used to convert keys to values for UI (see Dictionary.getDictionaryType())
      Parameters:
      field - - widget dictionary field
      variants - - variants to be shown in field filer drop-down (List widget field during filer editing)
    • setDictionaryIcons

      public final <V extends Dictionary> void setDictionaryIcons(@Nullable DtoField<? super T,V> field, @NonNull @NonNull Map<V,org.cxbox.api.data.dto.rowmeta.Icon> valueIconMap)


      Adds icons for fields having "type":"dictionary" in widget.json
      Usually one will provide mapping of ALL dictionary values to their icons here.
      Type Parameters:
      V - - dictionary class. Usually class name determines dictionary type, that is used to convert keys to values for UI (see Dictionary.getDictionaryType())
      Parameters:
      field - - widget dictionary field
      valueIconMap - <V, Icon> values, that one want to have icons in UI.
    • setEnumFilterValues

      public final <T extends org.cxbox.api.data.dto.DataResponseDTO, E extends Enum<?>> void setEnumFilterValues(@NonNull @NonNull FieldsMeta<T> fieldsMeta, @Nullable DtoField<? super T,E> field, @NonNull @NonNull E... values)
    • setEnumIcons

      public final <E extends Enum<?>> void setEnumIcons(@Nullable DtoField<? super T,E> field, @NonNull @NonNull Map<E,org.cxbox.api.data.dto.rowmeta.Icon> valueIconMap)
      Parameters:
      field - dto field
      valueIconMap - <extends Enum, Icon> Enum to icon mapping

      Example 1:
      
       @RequiredArgsConstructor
       @Getter
       public enum IconsEnum implements Icon {
        ARROW_UP("arrow-up #0cbfe9"),
        WATERMELON("watermelon"),
        DOWN("down");
      
       private final String icon;
       }
      
       @Getter
       @AllArgsConstructor
       public enum CustomFieldDictionaryEnum {
      
        HIGH("High", IconsEnum.ARROW_UP),
        MIDDLE("Middle", IconsEnum.DOWN),
        LOW("Low", IconsEnum.WATERMELON);
      
        @JsonValue
        private final String value;
      
        private final Icon icon;
      
        public static Map<CustomFieldDictionaryEnum, Icon> iconMap() {
            return Arrays.stream(CustomFieldDictionaryEnum.values())
            .filter(e -> e.icon != null)
            .collect(Collectors.toMap(e -> e, e -> e.icon));
        }
      
       }
      Add to buildIndependentMeta
      
        fields.setEnumIcons(MyExampleDTO_.customFieldDictionary, CustomFieldDictionaryEnum.iconMap());