diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2023-07-06 11:34:33 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2023-07-06 11:46:39 +0200 |
commit | 04834bbea2984400b3a3d33ed4e32fc04affff1f (patch) | |
tree | d0baf37b61616ac0455eccc95214289088ce6396 | |
parent | e15763bbcee86bf867c43586d32a59acef30daa0 (diff) | |
download | Ishtar-04834bbea2984400b3a3d33ed4e32fc04affff1f.tar.bz2 Ishtar-04834bbea2984400b3a3d33ed4e32fc04affff1f.zip |
🚧 work on autofocus fix
-rw-r--r-- | archaeological_operations/widgets.py | 5 | ||||
-rw-r--r-- | ishtar_common/forms.py | 2 | ||||
-rw-r--r-- | ishtar_common/wizards.py | 15 |
3 files changed, 17 insertions, 5 deletions
diff --git a/archaeological_operations/widgets.py b/archaeological_operations/widgets.py index f2a2d3d66..7519bf0a8 100644 --- a/archaeological_operations/widgets.py +++ b/archaeological_operations/widgets.py @@ -66,6 +66,11 @@ class OAWidget(forms.TextInput): def render(self, name, value, attrs=None, renderer=None): if not value: value = "" + attrs.update(self.attrs) + if "class" not in attrs: + attrs["class"] = "widget-oa" + else: + attrs["class"] += " widget-oa" final_attrs = flatatt(self.build_attrs(attrs, {"name": name, "value": value})) oa_prefix = get_current_profile(force=False).operation_prefix or "" dct = { diff --git a/ishtar_common/forms.py b/ishtar_common/forms.py index 5a2e14b02..338c49bfc 100644 --- a/ishtar_common/forms.py +++ b/ishtar_common/forms.py @@ -191,7 +191,7 @@ class CustomForm(BSForm): self.current_user = kwargs.pop("user").ishtaruser except AttributeError: pass - super(CustomForm, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) if not self._explicit_ordering: self.custom_form_ordering() diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py index 2cf7a1b9c..475c426bb 100644 --- a/ishtar_common/wizards.py +++ b/ishtar_common/wizards.py @@ -1224,10 +1224,17 @@ class Wizard(IshtarWizard): frm = form.forms[0] if frm: # autofocus on first field - first_field = frm.fields[list(frm.fields.keys())[0]] - attrs = first_field.widget.attrs - attrs.update({"autofocus": "autofocus"}) - first_field.widget.attrs = attrs + first_field = None + for key in frm.fields: + field = frm.fields[key] + if not field.widget.input_type == "hidden": + first_field = field + break + if first_field: + attrs = first_field.widget.attrs + attrs.update({"autofocus": True}) + first_field.widget.attrs = attrs + if not step: step = self.steps.current if self.filter_owns_items and self.filter_owns and step in self.filter_owns: |