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

Admin: JavaScript error in schedule template change #547

Closed
pitpalme opened this issue Apr 2, 2022 · 0 comments · Fixed by #579
Closed

Admin: JavaScript error in schedule template change #547

pitpalme opened this issue Apr 2, 2022 · 0 comments · Fixed by #579
Labels

Comments

@pitpalme
Copy link
Contributor

pitpalme commented Apr 2, 2022

Describe the bug
In schedule template change page there's a javascript error:

Uncaught TypeError: options is undefined

Maybe it originates from jQuery javascript

(function($) {
  $("#{{ inline_admin_formset.formset.prefix }}-group .tabular.inline-related tbody tr").tabularFormset({
    prefix: "{{ inline_admin_formset.formset.prefix }}",
    adminStaticPrefix: '{% static "admin/" %}',
    addText: "{% blocktranslate with inline_admin_formset.opts.verbose_name|capfirst as verbose_name %}Add another {{ verbose_name }}{% endblocktranslate %}",
    deleteText: "{% translate 'Remove' %}"
  });
})(django.jQuery);

in scheduletemplates/templates/admin/scheduletemplates/shifttemplate/shift_template_inline.html

To Reproduce
Steps to reproduce the behavior:

  1. Login as admin or manager with permission to edit schedule templates
  2. Make sure, at least one schedule template exists
  3. Start to edit schedule template
  4. Open Web Developer Tools or any other javascript console
  5. See error

Additional context
As it seems, the error is not new to this release, but undetected in currently productive version too.
If intended feature is not used (anymore), code could be cleaned up and simplified.

pitpalme added a commit to pitpalme/volunteer_planner that referenced this issue Apr 7, 2022
Django jQuery tabularFormset function exptects first parameter to be a
selector and second parameter to be options.
Seems it used to be different once upon a time and selector was not
required, because function is called on already selected object.
But ... an empty selector is good enough, so we make jQuery happy, for
jQuery being able to make us happy.

Now there's an "Add" link again show in inline tabular form. :)
@pitpalme pitpalme linked a pull request Apr 7, 2022 that will close this issue
pitpalme added a commit to pitpalme/volunteer_planner that referenced this issue Apr 8, 2022
Django jQuery tabularFormset function exptects first parameter to be a
selector and second parameter to be options.
Seems it used to be different once upon a time and selector was not
required, because function is called on already selected object.
But ... an empty selector is good enough, so we make jQuery happy, for
jQuery being able to make us happy.

Now there's an "Add" link again show in inline tabular form. :)
pitpalme added a commit that referenced this issue Apr 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant