Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

In our case, we use this feature, for example, to differentiate between types of documents that we're displaying on data warehouses by using icons instead of displaying the whole category of the document in screen.

...

Schema Details

PropertyTypeDescriptionRequiredDefault
Descriptionmap_filestr-Path to the file that contains the mapping for this dynamic field.altOptional[str]'default'Alt option for display in case the specified mimetype does not exist in the map.

_MimeFieldUI Class

Enum
typestringThe type of field.Nomime_typemime_type
labelstring/nullLabel to show for this field.Nonull
css_styleobject/nullStyle to apply in the HTML of the UI.Nonull
css_classstring/nullCSS class to apply in the HTML component.Nonull
translatestring/nullTranslation key for the field.Nonull
translate_labelstring/nullTranslation key for the label.Nonull
analyticsobject/nullAnalytics configuration.Nonull
if_not_existstring/nullShow only if the specified field doesn't exist.Nonull
if_existstring/nullShow only if the specified field does exist.Nonull
only_on_highlightbooleanShow only when the value is highlighted.Nofalse
displayany/array/nullValue from the field.Nonull
fieldstringPath to field from which to retrieve the value (in JMESPath format).Yes

field_highlightstring/nullPath to highlight field from which to retrieve the value, in case it is not the same as the field parameter (in JMESPath format).Nonull
defaultanyDefault value to use in case no value was found for the field.Nonull
transformarray/string/nullList of transformations to apply to the displayed values.Nonull
suffixstring/nullSuffix to append to the value or values.Nonull
prefixstring/nullPrefix to append to the value or values.Nonull
suffix_labelstring/nullSuffix to append to the label of the field.Nonull
prefix_labelstring/nullPrefix to append to the label of the field.Nonull
sortstring/booleanSort order for values in an array.Nofalseasc, desc
uniquebooleanIf the values are in an array, remove the duplicates.Nofalse
show_blankbooleanIf there is no value, or value is null, and show_blank is true, keep the field.Nofalse
replacementstring/nullReplacement string for matches in the transformations Transformation.REPLACE_FIRST, Transformation.REPLACE_LAST, and Transformation.REPLACE_ALL.Nonull
patternstring/nullPattern used to look for matches in the transformations Transformation.REPLACE_FIRST, Transformation.REPLACE_LAST, and Transformation.REPLACE_ALL.Nonull
map_filestringPath to the file that contains the mapping for this dynamic field.Yes

altstring/nullThis is the alt option for display in case the specified MIME type does not exist in the map.Nodefault
PropertyTypeDefaultDescriptiontypeLiteral[DynamicFieldType.MIME_TYPE]DynamicFieldType.MIME_TYPEType of the field (Literal with value DynamicFieldType.MIME_TYPE).

Mapping

Since we have separated the front end from the backend, we made this field work with a map that maps the content of a field in the database (example Category) with it's corresponding Mime icon path in the UI. Our recommendation is to place the map at config/stages/fields/mimetype/ but you can give any path to the map_file property in the configuration.

...

Code Block
languagepy
themeDJango
{
    "Documentary": "src/assets/Icons/documento.svg",
    "default": "src/assets/Icons/filas-de-la-tabla.svg"
}

Example JSON Representation

Code Block
languagejs
themeDJango
{
  "type": "mime_type",
  "label": "Document Type",
  "css_style": null,
  "css_class": null,
  "translate": null,
  "translate_label": null,
  "analytics": null,
  "if_not_exist": null,
  "if_exist": null,
  "only_on_highlight": false,
  "display": "src/assets/Icons/documento.svg",
  "field": "file.mime_type",
  "field_highlight": null,
  "default": null,
  "transform": null,
  "suffix": null,
  "prefix": null,
  "suffix_label": null,
  "prefix_label": null,
  "sort": false,
  "unique": false,
  "show_blank": false,
  "replacement": null,
  "pattern": null,
  "map_file": "/path/to/mime_type_map.json",
  "alt": "default"
}

Code Example

...

of Usage


Code Block
languagepy
themeDJango
thumbnail=mime_field_example = MimeField(
	field='metadata.genres[0].name', 
	map_file='config/stages/fields/mimetype/mime_maps.json'
)