collective / collective.easyform

Forms for Plone
https://pypi.org/project/collective.easyform
13 stars 28 forks source link

Date and Datetime fields do not work for anonymous #203

Open pbauer opened 4 years ago

pbauer commented 4 years ago

The pickadate-pattern is only part of the of the bundles plone-editor-tools and plone-tinymce which are only available for logged-in users. Is there a way to work around this?

tkimnguyen commented 4 years ago

Copy them into the add-on?

pbauer commented 4 years ago

Copy what into the addon? The bundle, the pattern or only the registration?

thet commented 4 years ago

May we should peel out the pickadate pattern from plone-editor-tools and make it available as a seperate bundle? That's to be done in plone.staticresources. Then collective.easyform could just enable that bundle via the registry. /cc @agitator

agitator commented 4 years ago

I'm open for further splitting of bundles @pbauer remind me at the sprint ;-) But please no generic auto-enable from easyform ...

tkimnguyen commented 4 years ago

Copy what into the addon? The bundle, the pattern or only the registration?

I meant the pattern, but @thet ‘s idea is much better

tkimnguyen commented 4 years ago

Actually, if the pattern isn’t heavy, why not move it into the non logged in bundle?

agitator commented 4 years ago

one can always extend the condition for the bundle to something like python: member is not None or context.portal_type in ('EasyForm')

Depending on the usecase putting "everything" into a bundle doesn't make sense because it adds unnecessary load and therefore slows down the experience. We did that wrong with Plone for too long!

tkimnguyen commented 4 years ago

Is it ok to mention a non core content type? That dredges up the question: why not include EasyForm in Plone buildout.cfg but commented out, as used to be the case with PloneFormGen (maybe in the unified installer)

davide-targa commented 4 years ago

Maybe I misunderstood the issue (is it a datepicker problem?) but I just tried on a clean Plone 5.2 buildout with Python 3.7.3: Date and Datetime fields work as expected.

thet commented 4 years ago

@davide-targa probably only if you're logged-in, as the pickadate pattern is part of the plone-editor-tools bundle, which itself is only available to logged in users?

https://github.com/plone/plone.staticresources/blob/a3149d90ffe7ff8c0875bbb278243ae9cf02ae6a/src/plone/staticresources/static/plone-logged-in.js#L21

https://github.com/plone/plone.staticresources/blob/a3149d90ffe7ff8c0875bbb278243ae9cf02ae6a/src/plone/staticresources/profiles/default/registry/bundles.xml#L152

davide-targa commented 4 years ago

@thet I was not logged-in.

davide-targa commented 4 years ago

Check out this public test form for exmple: https://bit.ly/2vOBRGb I have no issue filling the Date and DateTime fields.

Plone 5.2.0 (5207)
CMF 2.4.0
Zope 4.1.1
Python 3.7.3 (default, Apr 3 2019, 05:39:12) [GCC 8.3.0]
PIL 6.1.0 (Pillow)
WSGI: On
Server: waitress 1.3.0
pbauer commented 4 years ago

@davide-targa That's weird. Can you try to do the same for 5.2.1? Maybe it it still worked in 5.2.0.

thet commented 4 years ago

@pbauer @davide-targa yes, 5.2.0 is probably the reason why it's working for you. We did the bundle-splitting @ ploneconf in Ferrara, where 5.2.0 was out since some months: https://github.com/plone/plone.staticresources/pull/46

... not the best semantic versioning scheme for cmfplone here ;)

pbauer commented 4 years ago

I just confirmed this. In Plone 5.2 the date and datetime fields still work for anonymous users. After upgrading to 5.2.1 they stop working. I can also confirm that you can work around that by changing the condition of the bundle plone-logged-in in /@@resourceregistry-controlpanel to python: member is not None or context.portal_type in ('EasyForm')

davide-targa commented 4 years ago

@thet @pbauer I confirm that in Plone 5.2.1 Date and DateTime fields don't work for anonymous users. Sorry for the noise.

mactrash commented 4 years ago

+1 same issue

parruc commented 3 years ago

We had this issue and solved it extending (in our own product ATM) the existing easyform bundle as follows:

If this other solution can work for collective.easyform too we would be happy to create a pull request.

agitator commented 3 years ago

@parruc have you tried changing the condition for the bundle to check on EasyForm as well?

If you want to help other users, you could create a separate bundle for the datepicker in staticresources and extend it's condition in the profile.xml of the EasyForm. So no need to include the datepicker bundle in Easyform as well.

parruc commented 3 years ago

We did not need to change the condition because we included the mockup-patterns-pickadate needed by EasyForm into the easyform bundle along with other js and css we needed.

If the idea here is to move datepicker to its own bundle inside staticresources it makes absolutly sense and I will gladly share the minimal code to do it as soon as possible.

agitator commented 3 years ago

At least it would allow the datepicker to be enabled through the resource registry without loading the whole logged-in-bundle. As we did that for datatables https://github.com/plone/plone.staticresources/blob/master/src/plone/staticresources/static/plone-datatables.js

@thet what do you think?

parruc commented 3 years ago

In the meantime I opened a ticket in plone.staticresources: https://github.com/plone/plone.staticresources/issues/96 given that the needed changes are to be done there, ok?

vanne commented 3 years ago

It's not only date/time fields/pickers that are not working. All other JS that validates fields on blur is also missing.

For instance logged in users see a "Required input is missing." (when blurring a mandatory field, leaving it empty) while logged out users see nothing.

mactrash commented 3 years ago

Just test clean install Plone 5.2.3 the date/time fields/pickers that are not working.

mactrash commented 3 years ago

Also test clean install Plone 5.2.4rc the date/time fields/pickers that are not working.

mactrash commented 3 years ago

5.2.4 by changing the condition of the bundle plone-logged-in in /@@resourceregistry-controlpanel to python: member is not None still not working any idea?

fredvd commented 3 years ago

I have created an add'on that should include the date picker pattern and also inline validation to public views.

https://github.com/collective/collective.anonymouseditpatterns

It is a first attempt that seems to work for me locally in a plain Plone 5.2.4 coredev plone site. I first tried to get the add'on working in a customer project, but I ran into strange issues of missing resources in the compiling bundle stage.

The anonymouseditpatterns imports the pickadate patterns' less code, but in the mockup pattern these imports failed until I changed bootstrap to bootstrap3:

https://github.com/plone/mockup/blob/2ec35e1bf556b76a4b1584cd11b82ebf2c93dd40/mockup/patterns/pickadate/pattern.pickadate.less#L4-L5

when I added the add'on to a 5.2 coredev checkout, the paths worked again for /bootstrap/ :-S

I've tried to reduce the bundle size by adding js stubs, but the pickadate pattern pulls in select2. Maybe it doesn't add more js if I also add pat-select2 to collective.anonymouseditpatterns.

agitator commented 3 years ago

how about adding a profile to change the condition for that bundle to python: member is not None or context.portal_type in ('EasyForm') within easyform?

fredvd commented 3 years ago

And what happens to the condition for that bundle when it is merged into the meta-bundle?

agitator commented 3 years ago

imho it's will be merged...

@thet ping?

we're sprinting tomorrow, as every Wednesday, join us if you need some pointers

oxygenius commented 2 years ago

What's the status on this issue?

fredvd commented 2 years ago

What's the status on this issue?

@oxygenius I think the status is what you see here on github. Do you have the same problem? Which Plone versions. Did you try collective.anonymouseditpatterns?

oxygenius commented 2 years ago

Okay. So the workaround with the anonymouseditpatterns is still the way to go. I'll try collective.anonymouseditpatterns.

oxygenius commented 2 years ago

Hi @fredvd, works like a charm!

pbauer commented 1 year ago

In Plone 6 there is still no datepicker for anonymous users. You have to enter the date manually.

witsch commented 11 months ago

Hi @fredvd, works like a charm!

Same here (on 5.2.13). Thank you! 🙌