]> git.0d.be Git - django-panik-nonstop.git/blob - nonstop/templates/nonstop/tracks_metadata.html
templates: improve metadata sync between instru and language
[django-panik-nonstop.git] / nonstop / templates / nonstop / tracks_metadata.html
1 {% extends "base.html" %}
2 {% load i18n %}
3
4 {% block appbar %}
5 <h2>Nonstop - {{ view.page_title }}</h2>
6 {% endblock %}
7
8 {% block more-user-links %}
9 {{ block.super }}
10 <a href="{% url 'nonstop-quick-links' %}">Gestion nonstop</a>
11 {% endblock %}
12
13 {% block content %}
14 <form method="post">
15 {% csrf_token %}
16 <table id="edit-metadata">
17 <thead>
18  <tr><th>{% trans "Title" %}</th><th>{% trans "Artist" %}</th>
19      <th class="en">EN</th><th class="fr">FR</th><th class="nl">NL</th><th class="other">Other</th><th class="na">n.a.</th>
20      <th class="instru">Instru</th><th class="sabam">Sabam</th><th class="cfwb">CFWB</th></tr>
21 </thead>
22 <tbody>
23 {% for track in object_list %}
24 <tr>
25  <td><input type="hidden" name="track" value="{{track.id}}">
26          <a href="{% url 'track-view' pk=track.id %}">{{track.title}}</a></td><td>{{track.artist.name|default:"-"}}</td>
27  <td class="en"><input type="radio" name="lang-{{track.id}}" value="en" {% if track.language == "en" %}checked{% endif %}></td>
28  <td class="fr"><input type="radio" name="lang-{{track.id}}" value="fr" {% if track.language == "fr" %}checked{% endif %}></td>
29  <td class="nl"><input type="radio" name="lang-{{track.id}}" value="nl" {% if track.language == "nl" %}checked{% endif %}></td>
30  <td class="other"><input type="radio" name="lang-{{track.id}}" value="other" {% if track.language == "other" %}checked{% endif %}></td>
31  <td class="na"><input type="radio" name="lang-{{track.id}}" value="na" {% if track.language == "na" %}checked{% endif %}></td>
32  <td class="instru"><input type="checkbox" name="instru-{{track.id}}" {% if track.instru %}checked{% endif %}></td>
33  <td class="sabam"><input type="checkbox" name="sabam-{{track.id}}" {% if track.sabam %}checked{% endif %}></td>
34  <td class="cfwb"><input type="checkbox" name="cfwb-{{track.id}}" {% if track.cfwb %}checked{% endif %}></td>
35 </tr>
36 {% endfor %}
37 </tbody>
38 </table>
39
40   <div class="buttons">
41     <button class="submit-button">{% trans "Save" %}</button>
42   </div>
43 </form>
44
45 <script>
46 $('table#edit-metadata th').on('click', function() {
47   var propvalue = true;
48   if ($(this)[0].className == 'sabam') propvalue = false;
49   $('tbody').find('.' + $(this)[0].className + ' input').prop('checked', propvalue);
50 });
51
52 $('input[type=radio][name^=lang-]').on('change', function() {
53   var $instru = $(this).parents('tr').find('input[type=checkbox][name^=instru]');
54   if (($(this).val() == 'na' && ! $instru.is(':checked')) ||
55       ($(this).val() != 'na' && $instru.is(':checked'))) {
56     $instru.trigger('click');
57   }
58 });
59
60 $('input[type=checkbox][name^=instru]').on('change', function() {
61   if ($(this).is(':checked')) {
62     $(this).parents('tr').find('input[name^=lang][value=na]').trigger('click');
63   } else {
64     $(this).parents('tr').find('input[name^=lang]').prop('checked', false);
65   }
66 });
67 </script>
68
69 {% endblock %}