Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@eeacms/volto-object-widget

eea1.6kMIT8.0.0

volto-object-widget: Volto add-on

volto-addon, volto-widget, volto, plone, react

readme

volto-object-widget

Releases

Pipeline Lines of Code Coverage Bugs Duplicated Lines (%)

Pipeline Lines of Code Coverage Bugs Duplicated Lines (%)

Volto add-on: Various Volto schema-based widgets.

Features

This Volto addon provides several "abstract" widgets, to allow complex information to be editable by the schema-based forms. It centers around the concept: "we can create a form to edit a JSON object by using a schema" and so it provides, right now, widgets to edit "list of JSON objects", a "mapping of JSON objects" and a single "JSON object, but I choose the schema for it".

FlatListObject

Flat List object

This widget allows you to edit a list of objects by creating, editing and deleting instances of objects editable with the provided schema parameter. The list is sortable with drag&drop. You can also provide a schema extender, a function with signature (schema, data) => schema, which will adjust, per instance of object, its schema. To use this widget, in the schema, set the widget field to object_list_inline.

Example of how the data could look like for a block:

"a55c5053-ba81-4f73-ab29-7cdea74df20f": {
    "@type": "dataTable",
    "columns": [
        {
            "@id": "f899ca76-68be-4ded-aa0b-669c04c27309",
            "column": " PERC_HA_07\n(in %)",
            "renderer": "progress",
            "title": "21"
        },
        {
            "@id": "94315c5a-e031-4b7e-acb2-93887878a252",
            "column": " PERC_HA_07\n(in %)",
            "title": "12"
        }
    ],
}

The columns field, in this case, is data generated by the FlatListObject. The schema for this field could look like (ColumnSchema() just generates another instance of a schema, suitable for the column definition of our specific use case):

columns: {
  title: 'Columns',
  description: 'Leave empty to show all columns',
  schema: ColumnSchema(),
  widget: 'object_list_inline',
},

Mapping Widget

Mapping widget

This widget allows editing the properties of an object. For example, in the following block data, the row_colors value is generated by an instance of the MappingWidget.

"4430a32a-a266-497b-88e7-72fead5ab718": {
  "@type": "dottedTableChart",
  "column_data": "habitat_group",
  "row_colors": {
    "Bad": "#ed1834",
    "F - Heathland, scrub and tundra": "#88c24f",
    "Good": "#3c8000",
    "Poor": "#f2a70e",
    "Unknown": "#8d8d8d"
  },
  "row_data": "assessment",
  "size_data": "quantity"
},

You need to provide the options, which is a list of objects with {id, title} and the field_props, which are parameters for the actual field that will be used to edit the values. In our case the schema definition that was used to edit the above value is (note, the options are empty, we're populating them in the edit component, before passing the schema to the form):

row_colors: {
  title: 'Colors',
  widget: 'option_mapping',
  field_props: {
    widget: 'simple_color',
    available_colors: settings.available_colors,
  },
  options: [],
}

To use this widget, in the schema, set the widget field to option_mapping.

Object by type

Object by type

With this widget you can choose the type of value that will be used, from a predefined list of schemas. A schema that would use this type of widget could look like:

const LinkEditSchema = {
  title: 'Link',
  fieldsets: [
    {
      id: 'default',
      title: 'Default',
      fields: ['link'],
    },
  ],
  properties: {
    link: {
      title: 'Link',
      widget: 'object_by_type',
      schemas: [
        {
          id: 'internal',
          icon: internalSVG,
          schema: InternalLinkSchema,
        },
        {
          id: 'external',
          icon: externalSVG,
          schema: ExternalLinkSchema,
        },
        {
          id: 'email',
          icon: emailSVG,
          schema: EmailLinkSchema,
        },
      ],
    },
  },
  required: [],
};

To use this widget, in the schema, set the widget field to object_by_type.

Getting started

Try volto-object-widget with Docker

  git clone https://github.com/eea/volto-object-widget.git
  cd volto-object-widget
  make
  make start

Go to http://localhost:3000

Add volto-object-widget to your Volto project

  1. Make sure you have a Plone backend up-and-running at http://localhost:8080/Plone

    docker compose up backend
  2. Start Volto frontend

  3. If you already have a volto project, just update package.json:

     "addons": [
         "@eeacms/volto-object-widget"
     ],
    
     "dependencies": {
         "@eeacms/volto-object-widget": "*"
     }
  4. If not, create one:

     npm install -g yo @plone/generator-volto
     yo @plone/volto my-volto-project --canary --addon @eeacms/volto-object-widget
     cd my-volto-project
  5. Install new add-ons and restart Volto:

    yarn
    yarn start
  6. Go to http://localhost:3000

  7. Happy editing!

Release

See RELEASE.md.

How to contribute

See DEVELOP.md.

The Initial Owner of the Original Code is European Environment Agency (EEA). All Rights Reserved.

See LICENSE.md for details.

Funding

European Environment Agency (EU)

changelog

Changelog

All notable changes to this project will be documented in this file. Dates are displayed in UTC.

Generated by auto-changelog.

8.0.0 - 3 July 2025

:boom: Breaking Change

  • breaking(attachedimage): Change attachedimage widget value so that it can be deserialized into uid #23 from eea/uid-deserialization [David Ichim - 476bc48]

:rocket: New Features

  • feat(attached-image): add cypress e2e tests for attached image widget [David Ichim - eec8a2a]
  • feat(attached-image): implement image existence check before upload [David Ichim - 25d5ea8]
  • feat(package.json): add @eeacms/volto-widgets-view as a dependency and addon [Miu Razvan - 3e6adce]

:bug: Bug Fixes

  • fix(attachedimage): widget value due to missing comparison for memo call [David Ichim - fd92965]
  • fix(volto-object-widget): improve state management and defer actions in AttachedImageWidget [David Ichim - a19a3b4]
  • fix(volto-object-widget): enable coverage and fix cypress ci [David Ichim - 263816d]
  • fix: AttachedImageWidget url and content handling [David Ichim - 0115df3]
  • fix: reset submitted urls [nileshgulia1 - 96f3957]
  • fix: url when string [nileshgulia1 - f4ccb9c]
  • fix:eslint [nileshgulia1 - 4fcd1e0]
  • fix: data structure of widget, use value instead of @id [nileshgulia1 - ecd6081]
  • fix: use getFieldURL [Miu Razvan - 4cd1cb6]

:nail_care: Enhancements

  • change(attached-image): widget to be functional component based from class based [David Ichim - 1726bdb]
  • change(attached-image): set url as an array of objects like object_browser widget [David Ichim - 4157f9c]

:house: Internal changes

  • chore: package.json [Alin Voinea - 0ad7583]
  • style: Automated code fix [eea-jenkins - 684a4f3]
  • style: Automated code fix [eea-jenkins - f188343]
  • chore(test): specs for flatListObject [nileshgulia1 - ac90d79]
  • chore: add tests to increase coverage [nileshgulia1 - 4fe4ec9]
  • chore: eslint . [nileshgulia1 - c2ba229]
  • chore: update makefile [nileshgulia1 - 999b17f]
  • chore: apply eslint . [nileshgulia1 - fe162f9]

:hammer_and_wrench: Others

  • removed volto 16 check and attempt to pass RAZZLE_CI also to start-ci plus switch to electron browser from chromium [David Ichim - b00f64a]
  • fix tests and test warning [David Ichim - 60ead51]
  • WIp adding cypress tests for attachedimage [David Ichim - 0a2b61f]
  • fix test since we don't return only uuid [David Ichim - 3dd2373]
  • update uuid mock to avoid complaint when method it's called more than once [David Ichim - 19153e4]
  • eslint fix, skip volto 16 check and bump package version to 8 to represent the major change [David Ichim - ec4d346]
  • Brought fixes and tests from volto-hero-block within volto-object-widget [David Ichim - 3d335ba]
  • Added info for image_field and image_scales as added by the new Volto ImageWidget [David Ichim - 47ec783]
  • Update package.json [dobri1408 - e15b893]
  • Update package.json [dobri1408 - 1a73ce2]
  • update snapshot [dobri1408 - 50a18be]
  • remove snapshot [dobri1408 - 316d2a7]
  • fix eslint [dobri1408 - d8aa577]
  • up to date [dobri1408 - 5e8b9db]
  • update [nileshgulia1 - 823b305]
  • update [nileshgulia1 - c6b7c9d]
  • fix [nileshgulia1 - 1a9666e]
  • add more tests [nileshgulia1 - 81885bf]
  • fix [nileshgulia1 - 6cf6227]
  • support custom content attr in objectbrowser, support for img scales refs#254622 [nileshgulia1 - ae1f1ac]

    7.0.0 - 22 April 2024

:rocket: New Features

  • feat: Release 7.0.0 - Volto 17 support [alin - 085cb98]
  • feat: Volto 17 support - refs #264527 [EEA Jenkins - 47612bf]

:hammer_and_wrench: Others

6.0.0 - 8 December 2023

:hammer_and_wrench: Others

  • Release 6.0.0 [Alin Voinea - 6eed79c]

    5.2.0 - 28 November 2023

:rocket: New Features

  • feat: Allow attachedImageWidget to use also object browser values for backwards compatibility - refs #258136 [dobri1408 - 031a597]

:house: Internal changes

:hammer_and_wrench: Others

  • Release 5.2.0 [Alin Voinea - 4429e99]

    5.1.5 - 22 October 2023

:house: Internal changes

  • chore: husky, lint-staged use fixed versions [valentinab25 - d0e591e]
  • chore:volto 16 in tests, update docs, fix stylelint overrides [valentinab25 - 80b57c0]

:hammer_and_wrench: Others

  • Update README.md [ana-oprea - ce96b03]

    5.1.4 - 29 September 2023

:house: Internal changes

  • style: lint-staged reorder in package.json [Alin Voinea - 608f4d9]

:house: Documentation changes

  • docs: Update README and DEVELOP [Alin Voinea - bcb0ca8]
  • docs: Cleanup Makefile, update DEVELOP documentation, i18n - refs #254894 [valentinab25 - 59c256f]

:hammer_and_wrench: Others

  • test: add unit tests - refs #254313 [ana-oprea - ec53971]
  • test: EN locales, pre-commit fix, feature PRs checks Refs #257193 [valentinab25 - fa47506]
  • i18n: Add en [Alin Voinea - e96fb5b]
  • test: Update Makefile and docker-compose to align it with Jenkinsfile [valentinab25 - 99817cd]

    5.1.3 - 24 July 2023

:hammer_and_wrench: Others

  • test: add unit tests for AttachedImageWidget, ObjectTypesWidget and delete unreachable branch - refs #253277 [ana-oprea - f46dd19]

    5.1.2 - 12 June 2023

:rocket: New Features

  • feat: File picker object browser - refs #253430 [dobri1408 - 62fb1d0]

:house: Internal changes

:hammer_and_wrench: Others

  • test: jest should look for addons in node_modules Refs #253277 [valentinab25 - 6a639c5]
  • test: Fix test config, coverage Refs #253277 [valentinab25 - 12f23fc]

    5.1.1 - 26 April 2023

:rocket: New Features

  • feat(package.json): add @eeacms/volto-widgets-view addon to dependencies [Miu Razvan - 845046f]
  • feat(package.json): add @eeacms/volto-widgets-view dependency [Miu Razvan - 9046117]

:house: Internal changes

  • chore(package.json): update version from 5.1.0 to 5.2.0 [Miu Razvan - 2ceff26]

:hammer_and_wrench: Others

  • Revert changes on AttachedImageWidget [Miu Razvan - 88eafeb]
  • Revert fc658b5 [Miu Razvan - 669d06f]

    5.1.0 - 27 March 2023

:hammer_and_wrench: Others

  • test(Jenkins): Run tests and cypress with latest canary @plone/volto [Alin Voinea - 33ab4d9]

    5.0.1 - 16 November 2022

:hammer_and_wrench: Others

  • test(estlint): Fix .project.eslintrc.js [Alin Voinea - 08d24ca]
  • fallback path [andreiggr - 0c58fc9]
  • check for widget before setting it [andreiggr - 561505f]

    5.0.0 - 27 October 2022

:hammer_and_wrench: Others

  • Typo [Miu Razvan - 0eac194]
  • Prepare 5.0.0 release [Miu Razvan - 2a12c37]
  • Update babel & jest config [Miu Razvan - 8269b4a]
  • update(jest): add @plone/volto-slate resolver refs- #153447 [nileshgulia1 - 6963a87]

    4.0.2 - 30 June 2022

:hammer_and_wrench: Others

4.0.1 - 20 May 2022

4.0.0 - 19 May 2022

:bug: Bug Fixes

  • fix(AttachedImageWidget): browsing mode: image [Alin Voinea - 4e27d20]

:hammer_and_wrench: Others

  • Release 4.0.0 [Alin Voinea - 553e4ab]
  • Improved style for attached image widget [Miu Razvan - 8c770cd]
  • Release 3.1.0 [Alin Voinea - 61dd13b]

    3.0.3 - 3 January 2022

3.0.2 - 18 December 2021

:hammer_and_wrench: Others

3.0.1 - 10 December 2021

:hammer_and_wrench: Others

  • Refs #142010 - Optimize Volto-addons gitflow pipelines [valentinab25 - 0598f50]

    3.0.0 - 3 September 2021

:hammer_and_wrench: Others

  • Fix ObjectListWidget tests [Alin Voinea - 149c3ae]
  • Remove DEPRECATED ObjectWidget. Moved to Volto core. [Alin Voinea - 415e7a9]

    2.2.3 - 4 June 2021

:hammer_and_wrench: Others

  • Bump version to 2.2.3 [Alin Voinea - dc122ce]
  • Cypress coverage [valentinab25 - d274f57]

    2.2.2 - 4 June 2021

2.2.1 - 14 May 2021

2.2.0 - 9 April 2021

:hammer_and_wrench: Others

  • Release 2.2.0 [Tiberiu Ichim - 3bf5ef4]
  • Rename object_list -> object_list_popup, as Volto now comes with ObjectList widget [Tiberiu Ichim - 6bde47a]

    2.1.0 - 8 March 2021

:hammer_and_wrench: Others

  • Release 2.1.0 [Alin Voinea - 59eee3c]
  • Cleanup Jenkinsfile [Alin Voinea - b7773c6]
  • Revert "Move addons dependencies to package.json" [Alin Voinea - b746230]
  • Move addons dependencies to package.json [Alin Voinea - 9249c71]
  • remove volto-blocks-form dependency [nileshgulia1 - 2c215bc]

    2.0.0 - 25 February 2021

:hammer_and_wrench: Others

  • Release 2.0.0 [Alin Voinea - fbbbd7c]
  • Update tests snapshots [Alin Voinea - b76e78f]

    1.0.4 - 14 January 2021

:hammer_and_wrench: Others

:hammer_and_wrench: Others

  • Release 1.0.3 [Alin Voinea - 65381d9]
  • Update package meta info [Alin Voinea - 3664282]

    1.0.2 - 9 November 2020

:hammer_and_wrench: Others

  • Release 1.0.2 [Alin Voinea - 2640312]
  • Fix dependency: @eeacms/volto-blocks-form [Alin Voinea - 5db6725]

    1.0.1 - 9 November 2020

:hammer_and_wrench: Others

  • Release 1.0.1 [Alin Voinea - a8c91f3]
  • Update docs [Alin Voinea - e06e4f4]
  • Package meta info [Alin Voinea - 7af4f64]
  • Update readme [Tiberiu Ichim - d074ac6]
  • Update readme [Tiberiu Ichim - b192262]

    1.0.0 - 7 November 2020

:hammer_and_wrench: Others

  • Release 1.0.0 [Tiberiu Ichim - de3d7fa]
  • Add dependency on volto-blocks-form; generate test snapshots [Tiberiu Ichim - 3408c49]
  • Add dependency on volto-blocks-form; generate test snapshots [Tiberiu Ichim - 419fc23]

    0.3.0 - 6 November 2020

:hammer_and_wrench: Others

  • Add schemaExtender support in ObjectListInlineWidget [Tiberiu Ichim - 02a00ce]

    0.2.3 - 14 October 2020

0.2.2 - 5 October 2020

:hammer_and_wrench: Others

  • Adjust readme [Tiberiu Ichim - 9290096]
  • Add images [Tiberiu Ichim - 88a36ae]
  • Add mappingwidget [Tiberiu Ichim - e7caa06]
  • Install ObjectByType, export it [Tiberiu Ichim - 3b8af77]
  • Add ObjectByTypeWidget [Tiberiu Ichim - d664eb9]
  • Pass down the object value to each field in an object widget [Tiberiu Ichim - 6117247]
  • Document dependencies: volto-blocks-form [Alin Voinea - f190351]

    0.2.1 - 30 September 2020

:hammer_and_wrench: Others

  • Add comments [Tiberiu Ichim - 08644af]
  • Fix moving the blocks [Tiberiu Ichim - 4eedc2f]
  • Add ObjectListInlineWidget [Tiberiu Ichim - cd583ef]

    0.2.0 - 19 September 2020

:hammer_and_wrench: Others

  • Improve UI of ObjectListWidget [Tiberiu Ichim - c3bb8cb]
  • Code cleanup [Tiberiu Ichim - 1436f40]
  • Remove divider; export components; fix required bug [Tiberiu Ichim - 1584807]

    0.1.2 - 14 September 2020

:hammer_and_wrench: Others

  • Add dividers for simple ObjectWidget [Tiberiu Ichim - 7ca0994]

    0.1.1 - 29 August 2020

:hammer_and_wrench: Others

  • Sync from development [Tiberiu Ichim - f4e7e87]
  • Solved some browser console errors [Silviu Bogan - 2342c1a]
  • Wrapped doc comments [Silviu Bogan - 8815b1d]
  • Cleanup + new & improved doc comments [Silviu Bogan - 4946c99]
  • Cleanup + new doc comments [Silviu Bogan - 7b7f710]
  • Cleanup + started using useIntl instead of HOC [Silviu Bogan - e63a7ce]
  • Added doc comments [Silviu Bogan - 2501cdd]
  • Improved style [Silviu Bogan - c004b9f]
  • Improved style + a bit of cleanup [Silviu Bogan - b190388]
  • Added a TODO comment [Silviu Bogan - 605cddf]
  • Improved style, cleanup, replaced class w/ func. component [Silviu Bogan - ae8002f]
  • Added CSS file so the animation works [Silviu Bogan - 1bf9f23]

    0.1.0 - 27 August 2020

:hammer_and_wrench: Others

  • Fix demo saving data [Tiberiu Ichim - dcd45e7]
  • Simplify Readme [Tiberiu Ichim - 82d939c]
  • Make demo work [Tiberiu Ichim - 4485cbf]
  • Add initial demo [Tiberiu Ichim - 7e288fa]
  • Add files from Silviu's branch [Tiberiu Ichim - 9e832ce]
  • Run bootstrap [Tiberiu Ichim - a0b7716]
  • Initial commit [Tiberiu Ichim - bb5cab8]