list.html.j2 4.57 KB
Newer Older
Nicolas Joyard's avatar
Nicolas Joyard committed
1 2
{% extends "_base.html.j2" %}

3 4 5 6
{% block header %}
  <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='bootstrap-sortable.css') }}">
{% endblock %}

Nicolas Joyard's avatar
Nicolas Joyard committed
7 8
{% block content %}
  <section class="panel panel-default">
Nicolas Joyard's avatar
Nicolas Joyard committed
9 10 11
    {% if full_list %}

      <header class="panel-heading">
12
        <b>Liste des {{ parlementaires|length }} parlementaires (élus entre 2012 et 2017)</b>
Nicolas Joyard's avatar
Nicolas Joyard committed
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
      </header>

      <article class="panel-body">
        <div class="input-group">
          <span class="input-group-addon" id="search-header">Filtrer les parlementaires</span>
          <input type="search" autocomplete="off" autofocus="autofocus" class="form-control" id="search" placeholder="Nom, groupe, circonscription..." value="{{ request.args.q|e }}" aria-describedby="search-header">
          <span class="input-group-btn">
            <button class="btn btn-primary" type="button" id="search-clear" style="display: none;">Effacer le filtre</button>
          </span>
        </div>
      </article>

    {% else %}

      <header class="panel-heading">
        <b>Mes actions</b>
      </header>

31 32 33 34 35 36 37
      <article class="panel-body" style="text-align: center;">
        Vous souhaitez solliciter un autre parlementaire ?<br>

        <a class="btn btn-sm btn-primary" href="/parlementaires">Trouver un parlementaire à solliciter</a>
        <a class="btn btn-sm btn-primary" href="/hasard">Solliciter un parlementaire au hasard</a>
      </article>

Nicolas Joyard's avatar
Nicolas Joyard committed
38
    {% endif %}
39 40

    <table class="table table-condensed table-striped sortable searchable">
41
      <thead>
Nicolas Joyard's avatar
Nicolas Joyard committed
42
        <tr>
43
          <th colspan="2" data-defaultsort="asc" data-mainsort="1">Parlementaire</th>
44
          <th class="col-center">Groupe</th>
45
          <th>Circonscription</th>
Benjamin Ooghe-Tabanou's avatar
Benjamin Ooghe-Tabanou committed
46
          <th class="col-center">Étape</th>
47
          <th></th>
Nicolas Joyard's avatar
Nicolas Joyard committed
48
        </tr>
49 50 51
      </thead>
      <tbody>
        {% for parl in parlementaires %}
Nicolas Joyard's avatar
Nicolas Joyard committed
52

53
          <tr>
54
            <td class="col-center">
Nicolas Joyard's avatar
Nicolas Joyard committed
55
              <a data-toggle="tooltip" title="Accéder à la page du parlementaire ({{ chambres[parl.chambre] }})" target="_blank" href="{{ parl.url_off }}">
Nicolas Joyard's avatar
Nicolas Joyard committed
56 57
                <img class="chamber-icon" src="{{ url_for('static', filename=parl.chambre|lower+'.png') }}">
              </a>
58
              <span class="search-vector">{{ parl.nom_complet }} {{ parl.nom_circo }} {{ parl.num_deptmt }} {{ parl.groupe.sigle }} {{ parl.groupe.nom }} {{ etapes_by_ordre[parl.etape].label }}</span>
59
            </td>
60
            <td data-value="{{ parl.nom }} {{ parl.prenom }}">
Nicolas Joyard's avatar
Nicolas Joyard committed
61
              <a href="{{ url_for('parlementaire', id=parl.id) }}">{{ parl.nom_complet }}</a>
62 63 64 65
              {% if not parl.adresse %}
                <span class="label label-danger">Adresse manquante !</span>
              {% endif %}
            </td>
66
            <td class="col-center">{{ parl.groupe|label_groupe }}</td>
67
            <td data-value="{{ parl.num_deptmt }} {{ parl.num_circo }}">{{ parl.nom_circo }} n°{{ parl.num_circo }}</td>
Nicolas Joyard's avatar
Nicolas Joyard committed
68
            <td data-value="{{ parl.etape }}" class="col-center">
69
              {{ parl.etape|label_etape }}
70 71
            </td>
            <td class="col-right">
Nicolas Joyard's avatar
Nicolas Joyard committed
72
              {% if parl.etape == 10 %}
73 74
                <a class="btn btn-primary btn-sm" href="{{ url_for('parlementaire', id=parl.id) }}" role="button">Envoyer la demande</a>
              {% else %}
Nicolas Joyard's avatar
Nicolas Joyard committed
75
                <a class="btn btn-default btn-sm" href="{{ url_for('parlementaire', id=parl.id) }}" role="button">Voir</a>
76 77
              {% endif %}
            </td>
78
          </tr>
Nicolas Joyard's avatar
Nicolas Joyard committed
79

80
        {% else %}
Nicolas Joyard's avatar
Nicolas Joyard committed
81

82
          <tr>
83
            <td class="warning" colspan="6">
84 85 86 87 88 89
              <em>Aucun parlementaire trouvé :(</em>
            </td>
          </tr>

        {% endfor %}
      </tbody>
Nicolas Joyard's avatar
Nicolas Joyard committed
90 91 92
    </table>
  </section>
{% endblock %}
93 94 95 96

{% block scripts %}
  <script src="{{ url_for('static', filename='moment.min.js') }}"></script>
  <script src="{{ url_for('static', filename='bootstrap-sortable.js') }}"></script>
97 98

  <script>
99 100 101 102 103 104 105 106 107 108 109
    $(document).ready(function() {
      var search = $('#search');
      var clear = $('#search-clear');

      clear.hide();

      function filterRows() {
        if (search.val()) {
          clear.show();

          var rex = new RegExp(search.val(), 'i');
110 111 112 113
          $('.searchable tbody tr').hide();
          $('.searchable tbody tr').filter(function () {
            return rex.test($(this).find('.search-vector').text());
          }).show();
114 115 116 117 118 119 120 121 122 123 124 125 126
        } else {
          $('.searchable tbody tr').show();
          clear.hide();
        }
      }

      clear.click(function() {
        search.val('');
        filterRows();
      });

      search.keyup(filterRows);
      filterRows();
127 128
    });
  </script>
129
{% endblock %}