Skip to content

Commit

Permalink
Merge pull request #439 from collective/yurj_autofocus
Browse files Browse the repository at this point in the history
Add Advanced config to remove autofocus on first input
  • Loading branch information
yurj authored Dec 10, 2024
2 parents e1706b2 + 7c468d6 commit 4bbeeeb
Show file tree
Hide file tree
Showing 14 changed files with 542 additions and 429 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Changelog

- Pin version `Products.validation>=3.0.0`
[petschki]
- Add a checkbox to disable autofocus on the first input
[yurj]


4.2.1 (2024-10-08)
Expand Down
4 changes: 4 additions & 0 deletions src/collective/easyform/browser/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ def action(self):
def enable_form_tabbing(self):
return self.context.form_tabbing

@property
def enable_autofocus(self):
return self.context.autofocus

@property
def enable_unload_protection(self):
return self.context.unload_protection
Expand Down
8 changes: 8 additions & 0 deletions src/collective/easyform/interfaces/easyform.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ class IEasyForm(Schema):
"useCancelButton",
"resetLabel",
"form_tabbing",
"autofocus",
"nameAttribute",
"default_fieldset_label",
"method",
Expand Down Expand Up @@ -242,6 +243,13 @@ class IEasyForm(Schema):
default=True,
required=False,
)
directives.write_permission(autofocus=config.EDIT_ADVANCED_PERMISSION)
autofocus = zope.schema.Bool(
title=_(u"label_autofocus", default=u"Enable focus on the first input"),
description=_(u"help_autofocus", default=u""),
default=True,
required=False,
)
directives.write_permission(default_fieldset_label=config.EDIT_ADVANCED_PERMISSION)
default_fieldset_label = zope.schema.TextLine(
title=_(
Expand Down
87 changes: 48 additions & 39 deletions src/collective/easyform/locales/collective.easyform.pot
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2024-12-09 14:13+0000\n"
"POT-Creation-Date: 2024-12-09 14:39+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -181,7 +181,7 @@ msgid "No adapters available."
msgstr ""

#: ./collective/easyform/interfaces/actions.py:77
#: ./collective/easyform/interfaces/easyform.py:304
#: ./collective/easyform/interfaces/easyform.py:312
#: ./collective/easyform/interfaces/fields.py:117
msgid "Overrides"
msgstr ""
Expand All @@ -202,7 +202,7 @@ msgstr ""
msgid "Redirect to"
msgstr ""

#: ./collective/easyform/browser/view.py:220
#: ./collective/easyform/browser/view.py:224
msgid "Reset"
msgstr ""

Expand Down Expand Up @@ -299,15 +299,19 @@ msgid "extra_header"
msgstr ""

#. Default: "A TALES expression that will be called after the form issuccessfully validated, but before calling an action adapter (if any) or displaying a thanks page.Form input will be in the request.form dictionary.Leave empty if unneeded. The most common use of this field is to call a python scriptto clean up form input or to script an alternative action. Any value returned by the expression is ignored.PLEASE NOTE: errors in the evaluation of this expression willcause an error on form display."
#: ./collective/easyform/interfaces/easyform.py:398
#: ./collective/easyform/interfaces/easyform.py:406
msgid "help_AfterValidationOverride_text"
msgstr ""

#. Default: "A TALES expression that will be called when the form is displayed. Leave empty if unneeded. The most common use of this field is to call a python script that sets defaults for multiple fields by pre-populating request.form. Any value returned by the expression is ignored. PLEASE NOTE: errors in the evaluation of this expression will cause an error on form display."
#: ./collective/easyform/interfaces/easyform.py:378
#: ./collective/easyform/interfaces/easyform.py:386
msgid "help_OnDisplayOverride_text"
msgstr ""

#: ./collective/easyform/interfaces/easyform.py:249
msgid "help_autofocus"
msgstr ""

#. Default: "A TALES expression that will be evaluated to override any value otherwise entered for the BCC list. You are strongly cautioned against using unvalidated data from the request for this purpose. Leave empty if unneeded. Your expression should evaluate as a sequence of strings. PLEASE NOTE: errors in the evaluation of this expression will cause an error on form display."
#: ./collective/easyform/interfaces/mailer.py:498
msgid "help_bcc_override_text"
Expand All @@ -319,12 +323,12 @@ msgid "help_cc_override_text"
msgstr ""

#. Default: "Check this to employ Cross-Site Request Forgery protection. Note that only HTTP Post actions will be allowed."
#: ./collective/easyform/interfaces/easyform.py:276
#: ./collective/easyform/interfaces/easyform.py:284
msgid "help_csrf"
msgstr ""

#. Default: "This field allows you to change default fieldset label."
#: ./collective/easyform/interfaces/easyform.py:251
#: ./collective/easyform/interfaces/easyform.py:259
msgid "help_default_fieldset_label_text"
msgstr ""

Expand All @@ -343,16 +347,16 @@ msgid "help_field_widget"
msgstr ""

#. Default: "Check this to make the form redirect to an SSL-enabled version of itself (https://) if accessed via a non-SSL URL (http://). In order to function properly, this requires a web server that has been configured to handle the HTTPS protocol on port 443 and forward it to Zope."
#: ./collective/easyform/interfaces/easyform.py:288
#: ./collective/easyform/interfaces/easyform.py:296
msgid "help_force_ssl"
msgstr ""

#: ./collective/easyform/interfaces/easyform.py:241
#: ./collective/easyform/interfaces/easyform.py:242
msgid "help_form_tabbing"
msgstr ""

#. Default: "Use this field to override the form action attribute. Specify a URL to which the form will post. This will bypass form validation, success action adapter and thanks page."
#: ./collective/easyform/interfaces/easyform.py:364
#: ./collective/easyform/interfaces/easyform.py:372
msgid "help_formactionoverride_text"
msgstr ""

Expand Down Expand Up @@ -427,7 +431,7 @@ msgid "help_formmailer_to_extract"
msgstr ""

#. Default: "This override field allows you to insert content into the xhtml head. The typical use is to add custom CSS or JavaScript. Specify a TALES expression returning a string. The string will be inserted with no interpretation. PLEASE NOTE: errors in the evaluation of this expression will cause an error on form display."
#: ./collective/easyform/interfaces/easyform.py:418
#: ./collective/easyform/interfaces/easyform.py:426
msgid "help_headerInjection_text"
msgstr ""

Expand Down Expand Up @@ -456,12 +460,12 @@ msgstr ""
msgid "help_mailfields_text"
msgstr ""

#: ./collective/easyform/interfaces/easyform.py:261
#: ./collective/easyform/interfaces/easyform.py:269
msgid "help_method"
msgstr ""

#. Default: "optional, sets the name attribute on the form container. can be used for form analytics"
#: ./collective/easyform/interfaces/easyform.py:232
#: ./collective/easyform/interfaces/easyform.py:233
msgid "help_name_attribute"
msgstr ""

Expand All @@ -475,7 +479,7 @@ msgstr ""
msgid "help_recipient_override_text"
msgstr ""

#: ./collective/easyform/interfaces/easyform.py:226
#: ./collective/easyform/interfaces/easyform.py:227
msgid "help_reset_button"
msgstr ""

Expand Down Expand Up @@ -529,7 +533,7 @@ msgstr ""
msgid "help_showallfields_text"
msgstr ""

#: ./collective/easyform/interfaces/easyform.py:220
#: ./collective/easyform/interfaces/easyform.py:221
msgid "help_showcancel_text"
msgstr ""

Expand All @@ -543,12 +547,12 @@ msgstr ""
msgid "help_subject_override_text"
msgstr ""

#: ./collective/easyform/interfaces/easyform.py:214
#: ./collective/easyform/interfaces/easyform.py:215
msgid "help_submitlabel_text"
msgstr ""

#. Default: "This override field allows you to change submit button label. The typical use is to set label with request parameters. Specify a TALES expression returning a string. PLEASE NOTE: errors in the evaluation of this expression will cause an error on form display."
#: ./collective/easyform/interfaces/easyform.py:436
#: ./collective/easyform/interfaces/easyform.py:444
msgid "help_submitlabeloverride_text"
msgstr ""

Expand All @@ -573,12 +577,12 @@ msgid "help_thanksepilogue_text"
msgstr ""

#. Default: "Use this field in place of a thanks-page designation to determine final action after calling your action adapter (if you have one). You would usually use this for a custom success template or script. Leave empty if unneeded. Otherwise, specify as you would a CMFFormController action type and argument, complete with type of action to execute (e.g., \"redirect_to\" or \"traverse_to\") and a TALES expression. For example, \"Redirect to\" and \"string:thanks-page\" would redirect to \"thanks-page\"."
#: ./collective/easyform/interfaces/easyform.py:343
#: ./collective/easyform/interfaces/easyform.py:351
msgid "help_thankspageoverride_text"
msgstr ""

#. Default: "Use this field in place of a thanks-page designation to determine final action after calling your action adapter (if you have one). You would usually use this for a custom success template or script. Leave empty if unneeded. Otherwise, specify as you would a CMFFormController action type and argument, complete with type of action to execute (e.g., \"redirect_to\" or \"traverse_to\") and a TALES expression. For example, \"Redirect to\" and \"string:thanks-page\" would redirect to \"thanks-page\"."
#: ./collective/easyform/interfaces/easyform.py:322
#: ./collective/easyform/interfaces/easyform.py:330
msgid "help_thankspageoverrideaction_text"
msgstr ""

Expand All @@ -592,7 +596,7 @@ msgstr ""
msgid "help_tvalidator_text"
msgstr ""

#: ./collective/easyform/interfaces/easyform.py:269
#: ./collective/easyform/interfaces/easyform.py:277
msgid "help_unload_protection"
msgstr ""

Expand All @@ -616,15 +620,20 @@ msgid "import"
msgstr ""

#. Default: "After Validation Script"
#: ./collective/easyform/interfaces/easyform.py:395
#: ./collective/easyform/interfaces/easyform.py:403
msgid "label_AfterValidationOverride_text"
msgstr ""

#. Default: "Form Setup Script"
#: ./collective/easyform/interfaces/easyform.py:377
#: ./collective/easyform/interfaces/easyform.py:385
msgid "label_OnDisplayOverride_text"
msgstr ""

#. Default: "Enable focus on the first input"
#: ./collective/easyform/interfaces/easyform.py:248
msgid "label_autofocus"
msgstr ""

#. Default: "BCC Expression"
#: ./collective/easyform/interfaces/mailer.py:497
msgid "label_bcc_override_text"
Expand All @@ -636,7 +645,7 @@ msgid "label_cc_override_text"
msgstr ""

#. Default: "CSRF Protection"
#: ./collective/easyform/interfaces/easyform.py:275
#: ./collective/easyform/interfaces/easyform.py:283
msgid "label_csrf"
msgstr ""

Expand All @@ -646,7 +655,7 @@ msgid "label_customscript_action"
msgstr ""

#. Default: "Custom Default Fieldset Label"
#: ./collective/easyform/interfaces/easyform.py:247
#: ./collective/easyform/interfaces/easyform.py:255
msgid "label_default_fieldset_label_text"
msgstr ""

Expand All @@ -671,17 +680,17 @@ msgid "label_field_widget"
msgstr ""

#. Default: "Force SSL connection"
#: ./collective/easyform/interfaces/easyform.py:287
#: ./collective/easyform/interfaces/easyform.py:295
msgid "label_force_ssl"
msgstr ""

#. Default: "Turn fieldsets to tabs"
#: ./collective/easyform/interfaces/easyform.py:240
#: ./collective/easyform/interfaces/easyform.py:241
msgid "label_form_tabbing"
msgstr ""

#. Default: "Custom Form Action"
#: ./collective/easyform/interfaces/easyform.py:363
#: ./collective/easyform/interfaces/easyform.py:371
msgid "label_formactionoverride_text"
msgstr ""

Expand Down Expand Up @@ -761,7 +770,7 @@ msgid "label_hcaptcha_field"
msgstr ""

#. Default: "Header Injection"
#: ./collective/easyform/interfaces/easyform.py:417
#: ./collective/easyform/interfaces/easyform.py:425
msgid "label_headerInjection_text"
msgstr ""

Expand Down Expand Up @@ -806,12 +815,12 @@ msgid "label_mailfields_text"
msgstr ""

#. Default: "Form method"
#: ./collective/easyform/interfaces/easyform.py:260
#: ./collective/easyform/interfaces/easyform.py:268
msgid "label_method"
msgstr ""

#. Default: "Name attribute"
#: ./collective/easyform/interfaces/easyform.py:231
#: ./collective/easyform/interfaces/easyform.py:232
msgid "label_name_attribute"
msgstr ""

Expand All @@ -836,7 +845,7 @@ msgid "label_recipient_override_text"
msgstr ""

#. Default: "Reset Button Label"
#: ./collective/easyform/interfaces/easyform.py:225
#: ./collective/easyform/interfaces/easyform.py:226
msgid "label_reset_button"
msgstr ""

Expand Down Expand Up @@ -906,7 +915,7 @@ msgid "label_showallfields_text"
msgstr ""

#. Default: "Show Reset Button"
#: ./collective/easyform/interfaces/easyform.py:219
#: ./collective/easyform/interfaces/easyform.py:220
msgid "label_showcancel_text"
msgstr ""

Expand All @@ -921,12 +930,12 @@ msgid "label_subject_override_text"
msgstr ""

#. Default: "Submit Button Label"
#: ./collective/easyform/interfaces/easyform.py:213
#: ./collective/easyform/interfaces/easyform.py:214
msgid "label_submitlabel_text"
msgstr ""

#. Default: "Custom Submit Button Label"
#: ./collective/easyform/interfaces/easyform.py:433
#: ./collective/easyform/interfaces/easyform.py:441
msgid "label_submitlabeloverride_text"
msgstr ""

Expand All @@ -951,12 +960,12 @@ msgid "label_thanksepilogue_text"
msgstr ""

#. Default: "Custom Success Action"
#: ./collective/easyform/interfaces/easyform.py:342
#: ./collective/easyform/interfaces/easyform.py:350
msgid "label_thankspageoverride_text"
msgstr ""

#. Default: "Custom Success Action Type"
#: ./collective/easyform/interfaces/easyform.py:318
#: ./collective/easyform/interfaces/easyform.py:326
msgid "label_thankspageoverrideaction_text"
msgstr ""

Expand All @@ -976,7 +985,7 @@ msgid "label_tvalidator_text"
msgstr ""

#. Default: "Unload protection"
#: ./collective/easyform/interfaces/easyform.py:268
#: ./collective/easyform/interfaces/easyform.py:276
msgid "label_unload_protection"
msgstr ""

Expand All @@ -990,11 +999,11 @@ msgstr ""
msgid "label_xinfo_headers_text"
msgstr ""

#: ./collective/easyform/browser/view.py:448
#: ./collective/easyform/browser/view.py:452
msgid "msg_file_not_allowed"
msgstr ""

#: ./collective/easyform/browser/view.py:439
#: ./collective/easyform/browser/view.py:443
msgid "msg_file_too_big"
msgstr ""

Expand Down
Loading

0 comments on commit 4bbeeeb

Please sign in to comment.