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 does not get populated without specifying form.widget. #5

Closed
fulv opened this issue Nov 29, 2015 · 9 comments
Closed

Comments

@fulv
Copy link
Member

fulv commented Nov 29, 2015

@pbauer got any idea why the slider_relation widget comes up empty if I don't use the form.widget directive?

    form.widget('slider_relation', RelatedItemsFieldWidget,
                vocabulary='plone.app.vocabularies.Catalog')
    slider_relation = RelationList(
        title=_(u"Slider Banners"),
        description=_(u"These banners will be used in the slider"),
        default=[],
        value_type=RelationChoice(
            title=_(u'Target'),
            source=ObjPathSourceBinder(
                object_provides=IBanner.__identifier__,
            )),
        required=False,
    )

Without form.widget, the widget gets rendered fine, but it's empty. The key piece making it work is the vocabulary.

Somehow, the ObjPathSourceBinder does not seem to do its job. I tried using a portal_type filter, instead of object_provides, does not make a difference. The portal_catalog has plenty of objects indexed with object_provides=IBanner.__identifier__.
Basically, this is the same as http://docs.plone.org/external/plone.app.dexterity/docs/advanced/references.html, and it doesn't work.

I also tried stepping via /pdb, creating an ObjPathSourceBinder by hand:

(Pdb) foo = ObjPathSourceBinder(object_provides=IBanner.__identifier__)
(Pdb) foo(self.context).selectable_filter.criteria
{'object_provides': ['collective.behavior.banner.banner.IBanner']}
(Pdb) [i.title for i in foo(self.context).search('')]

And it returns plenty of items.

Also:
http://stackoverflow.com/questions/24638057/how-to-make-a-dexterity-reference-field

@pbauer
Copy link
Member

pbauer commented Nov 30, 2015

I observed the same behavior in some other cases but was not able (or too busy) to track down the reason. For Plone 5 setting the widget is not necessary anyway so I removed that and replaced ObjPathSourceBinder with plone.app.vocabularies.catalog.CatalogSource

@davilima6
Copy link

Related: 4ea3cd8 and plone/plone.app.dexterity#200

@fulv
Copy link
Member Author

fulv commented Nov 30, 2015

sweet!

@fulv
Copy link
Member Author

fulv commented Nov 30, 2015

As a further refinement, I'd like to figure out if there's a way to filter on items that actually have a banner image, not just that they provide IBanner.

@pbauer
Copy link
Member

pbauer commented Nov 30, 2015

@fulv good point. My first guess would be that this can only be achieved with a new boolean-index and a custom indexer that stores True if there is a banner-image.

@pbauer
Copy link
Member

pbauer commented Dec 3, 2015

@fulv ... or with a custom vocabulary. It would be cool if the widget could show a preview of the banner-image if there is one.
But you can use banners without a image (text only) so the vocabulary (or index) should have to test for any field in the banner-behavior, not only the image. That would not work well with a preview-image...
Pull-requests are welcome 😃

@fulv
Copy link
Member Author

fulv commented Dec 3, 2015

I'm using this for a client project, so I will definitely add the index.
PR by next week at the latest.

I noticed that the TinyMCE image picker shows thumbnails (see screenshot).
Any idea if that is easy to do, or if it's too closely tied to Tiny?

At this point, this is mostly out of curiosity, because a) I agree that it
would be odd to have some thumbnails, and some without thumbnails, if the
banner has only text and no image, and b) I just want to do this quickly.

screen shot 2015-12-03 at 11 13 38 am

On Thu, Dec 3, 2015 at 7:04 AM Philip Bauer notifications@github.com
wrote:

@fulv https://github.com/fulv ... or with a custom vocabulary. It would
be cool if the widget could show a preview of the banner-image if there is
one.
But you can use banners without a image (text only) so the vocabulary (or
index) should have to test for any field in the banner-behavior, not only
the image. That would not work well with a preview-image...
Pull-requests are welcome [image: 😃]


Reply to this email directly or view it on GitHub
#5 (comment)
.

@fulv
Copy link
Member Author

fulv commented Dec 20, 2015

@pbauer I didn't realize you reordered the commits in branch video, so my branch fulv-video could no longer be rebased. So I created yet another branch fulv-video2, and a PR #10.
Hopefully after this we can delete all these branches.

@fulv
Copy link
Member Author

fulv commented Dec 21, 2015

Done!

@fulv fulv closed this as completed Dec 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants