|
| 1 | +{% extends "admin/base_site.html" %} |
| 2 | +{% load i18n admin_urls static admin_list %} |
| 3 | + |
| 4 | +{% block extrastyle %} |
| 5 | +{{ block.super }} |
| 6 | +<link rel="stylesheet" type="text/css" href="{% static "admin/css/changelists.css" %}"> |
| 7 | +{% if cl.formset %} |
| 8 | +<link rel="stylesheet" type="text/css" href="{% static "admin/css/forms.css" %}"> |
| 9 | +{% endif %} |
| 10 | +{% if cl.formset or action_form %} |
| 11 | +<script type="text/javascript" src="{% url 'admin:jsi18n' %}"></script> |
| 12 | +{% endif %} |
| 13 | +{{ media.css }} |
| 14 | +{% if not actions_on_top and not actions_on_bottom %} |
| 15 | +<style> |
| 16 | + #changelist table thead th:first-child {width: inherit} |
| 17 | +</style> |
| 18 | +{% endif %} |
| 19 | +{% endblock %} |
| 20 | + |
| 21 | +{% block extrahead %} |
| 22 | +{{ block.super }} |
| 23 | +{{ media.js }} |
| 24 | +{% endblock %} |
| 25 | + |
| 26 | +{% block bodyclass %}{{ block.super }} app-{{ opts.app_label }} model-{{ opts.model_name }} change-list{% endblock %} |
| 27 | + |
| 28 | +{% if not is_popup %} |
| 29 | +{% block breadcrumbs %} |
| 30 | +<ol class="breadcrumb"> |
| 31 | + <li><a href="{% url 'admin:index' %}"><i class="fa fa-dashboard"></i> {% trans 'Home' %}</a></li> |
| 32 | + <li><a href="javascript:void(0)">{{ cl.opts.app_config.verbose_name }}</a></li> |
| 33 | + <li class="active">{{ cl.opts.verbose_name_plural|capfirst }}</li> |
| 34 | +</ol> |
| 35 | +{% endblock %} |
| 36 | +{% endif %} |
| 37 | + |
| 38 | +{% block coltype %}flex{% endblock %} |
| 39 | + |
| 40 | +{% block content %} |
| 41 | +<div id="content-main"> |
| 42 | + {% block object-tools %} |
| 43 | + <ul class="object-tools"> |
| 44 | + {% block object-tools-items %} |
| 45 | + {% change_list_object_tools %} |
| 46 | + {% endblock %} |
| 47 | + </ul> |
| 48 | + {% endblock %} |
| 49 | + {% if cl.formset and cl.formset.errors %} |
| 50 | + <p class="errornote"> |
| 51 | + {% if cl.formset.total_error_count == 1 %}{% trans "Please correct the error below." %}{% else %}{% trans "Please correct the errors below." %}{% endif %} |
| 52 | + </p> |
| 53 | + {{ cl.formset.non_form_errors }} |
| 54 | + {% endif %} |
| 55 | + <div class="module{% if cl.has_filters %} filtered{% endif %}" id="changelist"> |
| 56 | + <div class="row"> |
| 57 | + {% block date_hierarchy %}{% if cl.date_hierarchy %}{% date_hierarchy cl %}{% endif %}{% endblock %} |
| 58 | + |
| 59 | + {% block search %}{% search_form cl %}{% endblock %} |
| 60 | + |
| 61 | + </div> |
| 62 | + |
| 63 | + <form id="changelist-form" method="post"{% if cl.formset and cl.formset.is_multipart %} enctype="multipart/form-data"{% endif %} novalidate>{% csrf_token %} |
| 64 | + {% if cl.formset %} |
| 65 | + <div>{{ cl.formset.management_form }}</div> |
| 66 | + {% endif %} |
| 67 | + |
| 68 | + {% block result_list %} |
| 69 | + {% if action_form and actions_on_top and cl.show_admin_actions %}{% admin_actions %}{% endif %} |
| 70 | + {% result_list cl %} |
| 71 | + {% if action_form and actions_on_bottom and cl.show_admin_actions %}{% admin_actions %}{% endif %} |
| 72 | + {% endblock %} |
| 73 | + {% block pagination %}{% pagination cl %}{% endblock %} |
| 74 | + </form> |
| 75 | + </div> |
| 76 | +</div> |
| 77 | +{% endblock %} |
| 78 | + |
| 79 | +{% block custom_js %} |
| 80 | + |
| 81 | +<script> |
| 82 | + var selectors = document.querySelector('#changelist-search').querySelectorAll('select'); |
| 83 | + for (var i in selectors) { |
| 84 | + selectors[i].onchange = function() { |
| 85 | + var $field = $(this); |
| 86 | + var $option = $field.find('option:selected'); |
| 87 | + var select_name = $option.data('name'); |
| 88 | + console.log(select_name); |
| 89 | + if (select_name) { |
| 90 | + $field.attr('name', select_name); |
| 91 | + } else { |
| 92 | + $field.removeAttr('name'); |
| 93 | + } |
| 94 | + // Handle additional values for date filters |
| 95 | + // var additional = $option.data('additional'); |
| 96 | + // if (additional) { |
| 97 | + // var hidden_id = $field.data('name') + '_add'; |
| 98 | + // var $hidden = $('#' + hidden_id); |
| 99 | + // if (!$hidden.length) { |
| 100 | + // $hidden = $('<input/>').attr('type', 'hidden').attr('id', hidden_id); |
| 101 | + // $field.after($hidden); |
| 102 | + // } |
| 103 | + // additional = additional.split('='); |
| 104 | + // $hidden.attr('name', additional[0]).val(additional[1]) |
| 105 | + // } |
| 106 | + |
| 107 | + // remove the hidden input of select_name |
| 108 | + var input = document.querySelector('#search_group').querySelector('input[name="' + select_name + '"]'); |
| 109 | + input.parentNode.removeChild(input) |
| 110 | + } |
| 111 | + } |
| 112 | + |
| 113 | +</script> |
| 114 | + |
| 115 | +{% endblock %} |
0 commit comments