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

Calendar icon not loading in admin panel #264

Open
mobinghoveoud opened this issue Oct 25, 2024 · 1 comment
Open

Calendar icon not loading in admin panel #264

mobinghoveoud opened this issue Oct 25, 2024 · 1 comment

Comments

@mobinghoveoud
Copy link
Contributor

Hi,

First, thank you for maintaining and improving this library.
I encountered an issue in the admin panel. In my project, static files are served from a separate subdomain, which prevents the calendar icon image from loading correctly.

I noticed that in main.js (link to code), the url for the calendar icon is hardcoded, which causes the static url to be generated incorrectly.

For example, if the admin panel is hosted at:

admin.example.com

It tries to load the calendar icon from this url, which is incorrect:

admin.example.com/static/admin/jquery.ui.datepicker.jalali/themes/base/images/icon-calendar.svg

This issue arises when the static files are served from a different base url or subdomain.
Thanks.

Configurations

  • Python version: python 3.11
  • Django version: django 4.2
  • django_jalali version: django_jalali 7.2.0
  • OS: Debian
  • Database: PostgreSQL
@mobinghoveoud
Copy link
Contributor Author

Since django template tags cannot be used directly in css or js files, I had to override admin/base.html and save the icon path in a variable like this and use in main.js file:

<script>
    var calendarIcon = "{% static 'static/admin/jquery.ui.datepicker.jalali/themes/base/images/icon-calendar.svg' %}";
</script>

However, this approach doesn’t seem suitable for a fix within the library itself.

An alternative approach might be to follow django style by using a <span> tag instead of an <img> tag (datepicker-cc.js) and defining the icon path in the css file:

/* admin/main.css */
span.ui-datepicker-trigger {
    background: url("../jquery.ui.datepicker.jalali/themes/base/images/icon-calendar.svg") 0 0 no-repeat;
}

This would require changes in jquery.ui.datepicker-cc.js or jquery.ui.datepicker-cc-fa.js. However, I’m unsure if modifying these files would be the best approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants