diff options
| -rw-r--r-- | changelog/en/changelog_2022-06-15.md | 6 | ||||
| -rw-r--r-- | changelog/fr/changelog_2023-01-25.md | 6 | ||||
| -rw-r--r-- | ishtar_common/forms.py | 4 | ||||
| -rw-r--r-- | ishtar_common/static/js/ishtar.js | 5 | ||||
| -rw-r--r-- | ishtar_common/templates/blocks/JQueryAutocomplete.js | 2 | ||||
| -rw-r--r-- | ishtar_common/templates/ishtar/wizard/default_wizard.html | 1 | ||||
| -rw-r--r-- | ishtar_common/widgets.py | 3 | ||||
| -rw-r--r-- | ishtar_common/wizards.py | 3 | 
8 files changed, 26 insertions, 4 deletions
| diff --git a/changelog/en/changelog_2022-06-15.md b/changelog/en/changelog_2022-06-15.md index 766ace589..257529eb7 100644 --- a/changelog/en/changelog_2022-06-15.md +++ b/changelog/en/changelog_2022-06-15.md @@ -1,3 +1,9 @@ +v4.0.53 - 2999-12-31 +-------------------- + +### Bug fixes ### +- wizards: fix autofocus of first field +  v4.0.52 - 2023-07-06  -------------------- diff --git a/changelog/fr/changelog_2023-01-25.md b/changelog/fr/changelog_2023-01-25.md index a53b80746..80aeb3df0 100644 --- a/changelog/fr/changelog_2023-01-25.md +++ b/changelog/fr/changelog_2023-01-25.md @@ -1,3 +1,9 @@ +v4.0.53 - 2999-12-31 +-------------------- + +### Corrections de dysfonctionnements ### +- correction de l'autofocus du premier champ +  v4.0.52 - 2023-07-06  -------------------- diff --git a/ishtar_common/forms.py b/ishtar_common/forms.py index 338c49bfc..b0bf64b46 100644 --- a/ishtar_common/forms.py +++ b/ishtar_common/forms.py @@ -919,8 +919,8 @@ class TableSelect(IshtarForm):                  cls += " search-vector"              self.fields[k].widget.attrs["class"] = cls              self.fields[k].alt_name = alt_names[k].search_key if k in alt_names else k -        key = list(self.fields.keys())[0] -        self.fields[key].widget.attrs["autofocus"] = "autofocus" +        if "search_vector" in self.fields.keys(): +            self.fields["search_vector"].widget.attrs["autofocus"] = True      def get_input_ids(self):          return list(self.fields.keys()) diff --git a/ishtar_common/static/js/ishtar.js b/ishtar_common/static/js/ishtar.js index 56f4e157d..97fdaf13a 100644 --- a/ishtar_common/static/js/ishtar.js +++ b/ishtar_common/static/js/ishtar.js @@ -83,6 +83,7 @@ var current_modal;  var default_search_vector;  var pin_search_url;  var static_path = '/static/'; +var autofocus_field;  var datatables_default = {      "processing": true, @@ -364,6 +365,10 @@ var load_alerts = function(){                  html += '</a> ';              }              $("#alert-list").html(html); +            if (autofocus_field) { +                $(autofocus_field).focus(); +                autofocus_field = null; +            }          },          error:function(XMLHttpRequest, textStatus, errorThrows){              close_wait(); diff --git a/ishtar_common/templates/blocks/JQueryAutocomplete.js b/ishtar_common/templates/blocks/JQueryAutocomplete.js index 54b0cb645..47ff687e0 100644 --- a/ishtar_common/templates/blocks/JQueryAutocomplete.js +++ b/ishtar_common/templates/blocks/JQueryAutocomplete.js @@ -20,6 +20,8 @@ $(function() {          {{options}}          {% endif %}      }); +    {% if autofocus %}autofocus_field = "#id_select_{{field_id}}"; +    {% endif %}      $(document).on("click", '#id_select_{{field_id}}', function(){          $('#id_{{field_id}}').val(null); diff --git a/ishtar_common/templates/ishtar/wizard/default_wizard.html b/ishtar_common/templates/ishtar/wizard/default_wizard.html index 50e0662ae..405c52965 100644 --- a/ishtar_common/templates/ishtar/wizard/default_wizard.html +++ b/ishtar_common/templates/ishtar/wizard/default_wizard.html @@ -65,6 +65,7 @@ $(document).ready(function(){      {% if open_url %}load_window("{{open_url}}");{% endif %}      {% block "js_extra_ready" %}      {% endblock %} +    if ($("[autofocus]").length > 0) autofocus_field = "#" + $($("[autofocus]")[0]).attr('id');  });  {% endlocalize %}</script>  {% endblock %} diff --git a/ishtar_common/widgets.py b/ishtar_common/widgets.py index 2bcc598bf..131051077 100644 --- a/ishtar_common/widgets.py +++ b/ishtar_common/widgets.py @@ -757,7 +757,6 @@ class JQueryAutoComplete(forms.TextInput):                  )              else:                  dynamic_limit.append("id_" + lim.replace("_", "")) -          dct = {              "source": mark_safe(source),              "field_id": field_id, @@ -765,6 +764,8 @@ class JQueryAutoComplete(forms.TextInput):              "modify": self.modify,              "dynamic_limit": dynamic_limit,          } +        if self.attrs.get("autofocus", False): +            dct["autofocus"] = True          if self.associated_model:              model_name = self.associated_model._meta.object_name.lower()              dct["model_name"] = model_name diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py index 475c426bb..aa5e1804d 100644 --- a/ishtar_common/wizards.py +++ b/ishtar_common/wizards.py @@ -1227,7 +1227,8 @@ class Wizard(IshtarWizard):              first_field = None              for key in frm.fields:                  field = frm.fields[key] -                if not field.widget.input_type == "hidden": +                if not hasattr(field.widget, "input_type") \ +                        or not field.widget.input_type == "hidden":                      first_field = field                      break              if first_field: | 
