Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RelationList Widget #3355

Closed
arky opened this issue May 11, 2022 · 12 comments
Closed

RelationList Widget #3355

arky opened this issue May 11, 2022 · 12 comments

Comments

@arky
Copy link
Contributor

arky commented May 11, 2022

If your content type uses 'Relation List' then there a not usable since there is dedicated widget to handle this type. I think current placeholder refers to Object Browser Widget. I think Relation Choice might also suffer from limited functionality.

Is your feature request related to a problem? Please describe.
This lack of widget makes selection and adding of relations in Volto impossible.

Describe the solution you'd like
Add a new widget based on existing volto list widgets.

factory: {
'Relation List': ObjectBrowserWidget,
'Relation Choice': ReferenceWidget,
},

@arky
Copy link
Contributor Author

arky commented May 23, 2022

There is some work done by @nileshgulia1 in this source tree https://github.com/plone/volto/tree/relations-volto

Some work needs to be done based on new plone.restapi endpoint @relations https://github.com/plone/plone.restapi/tree/relations-documentation-etc

@arky
Copy link
Contributor Author

arky commented May 23, 2022

@ksuess @nileshgulia1 This bug is quite critical to enable users to select and add relations in Volto. It is my understanding that the blocker in plone.restapi has now been resolved by new proposal by @pbauer https://github.com/plone/plone.restapi/tree/relations-documentation-etc

Really appreciate your continue support and contributions in making relations work out of box in Volto! Thank you.

@nileshgulia1
Copy link
Member

Katja drafted a PR for relations controlpanel: #3382

@ksuess
Copy link
Member

ksuess commented May 23, 2022

A bug fix is needed to feed the ObjectBrowserWidget with the vocabulary of the field.
This is not related to a @relations endpoint.
This bug fix could also be accompanied with a replacement of the widget for the RelationChoice field by ObjectBrowserWidget (single mode).

@ericof
Copy link
Sponsor Member

ericof commented Jun 30, 2022

So, it seems there is a simple way to make this work as expected. Passing pattern_options and frontendOptions via directives.widget turns the current ObjectBrowserWidget more friendly to relations.

Take a look at the implementation bellow

from plone.autoform import directives
from z3c.relationfield.schema import RelationChoice
from z3c.relationfield.schema import RelationList
from plone.app.z3cform.widget import RelatedItemsFieldWidget

...

    campus2 = RelationList(
        title=_("person_campus", default="Campus"),
        required=False,
        default=list(),
        value_type=RelationChoice(
            title=_("person_campus", default="Campus"),
            vocabulary="plone.app.vocabularies.Catalog",
        ),
    )
    directives.widget(
        "campus",
        RelatedItemsFieldWidget,
        pattern_options={
            "selectableTypes": ['campus']
        },
        frontendOptions={
            "widget": "object_browser",
            "widgetProps": {"mode": "multiple", "return": "multiple"},
        },
    )

To be honest, the only thing I would like to have more was a way to pass a start point for the ObjectBrowserWidget start the search tree.

@arky, @ksuess, @nileshgulia1, what do you think?

@ksuess
Copy link
Member

ksuess commented Jul 1, 2022

Unfortunatly this does not work for me:

  • No selection possible on new document in Volto
  • No display of related items in Volto on document with related items selected in backend.

I think ObjectBrowserWidget needs some attention.

  • bug fix: this.props.mode === 'multiple' ? [...(this.props.value || [])] : [];
  • bug fix for the return value on 'multiple'

BTW your frontendOptions is the default for factory Relation List which is the case for RelatedItemsFieldWidget

@ksuess
Copy link
Member

ksuess commented Jul 1, 2022

Also still open:

  • Support for StaticCatalogVocabulary

@sneridagh sneridagh added this to the 16.x.x milestone Aug 30, 2022
@sneridagh
Copy link
Member

@arky added to the 16 Milestone.

@arky
Copy link
Contributor Author

arky commented Aug 30, 2022

Thank you @sneridagh for including this in the release milestone.The ability to add multiple relationships in Volto would make relations first class citizen in Plone 6.

@sneridagh
Copy link
Member

@arky I think this is solved already thanks to the work done in #4614 Please feel free to re-open if it's not the case.

@arky
Copy link
Contributor Author

arky commented Sep 27, 2023

Thank you! \o/

@ksuess
Copy link
Member

ksuess commented Sep 27, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants