Skip to content

Refactor the store metadata handling

Metadata are currently stored as an attribute on elements in store.state.elements.elements[id].metadata. However, in backend!1128 (merged), the ListElementMetadata endpoint was introduced and the metadata attribute in the API turned from a list into a count of existing metadata, resulting in the metadata component sometimes disappearing or just not loading anything (#787 (closed)).

backend!1486 (merged) introduces a quickfix that just renames metadata to metadata_count, but this issue should never have occurred in the first place; the handling of metadata in the frontend should just never be handled in elements themselves, to make sure that there will not be any collisions with the API.

This can be handled by using this state:

{
  elements: {  },
  metadata: {
    [elementid]: [
      { id: '', name: '', type: '',  },
      { id: '', name: '', type: '',  }
    ]
  }
}