Browse Source

Ajout d'un bout de js pour rechercher dans les utilisateurs

Nécessite un jquery plus récent

(patch de quota de février 2016)
Baptiste Jonglez 7 years ago
parent
commit
14b919c0e6
4 changed files with 27 additions and 9255 deletions
  1. 5 0
      static/js/jquery-1.12.0.min.js
  2. 0 9252
      static/js/jquery.js
  3. 2 2
      templates/admin_users.html
  4. 20 1
      templates/layout.html

File diff suppressed because it is too large
+ 5 - 0
static/js/jquery-1.12.0.min.js


File diff suppressed because it is too large
+ 0 - 9252
static/js/jquery.js


+ 2 - 2
templates/admin_users.html

@@ -6,6 +6,7 @@
   {% if not users %}
   <div class="alert">Il n'y a aucun utilisateur.</div>
   {% else %}
+  <input id="filter" type="text" class="form-control" placeholder="Rechercher...">
   <table class="table table-striped">
     <thead>
     <tr>
@@ -16,7 +17,7 @@
       <th>Actions</th>
     </tr>
     </thead>
-    <tbody>
+    <tbody class="searchable">
     {% for user in users %}
     <tr>
       <td>{{ user.email }}</td>
@@ -47,6 +48,5 @@
   <p>
   {% endif %}
   <a class="pull-right btn btn-primary btn-small" href="{{ url_for('admin_user_add') }}">+ Ajouter un utilisateur</a>
-
 {% endblock %}
 

+ 20 - 1
templates/layout.html

@@ -70,7 +70,26 @@
 </div>
 
 </div> <!-- container -->   
-  <script src="{{ url_for('static', filename='js/jquery.js') }}"></script>
+  <script src="{{ url_for('static', filename='js/jquery-1.12.0.min.js') }}"></script>
   <script src="{{ url_for('static', filename='js/bootstrap.js') }}"></script>
+  <script>
+$(document).ready(function () {
+
+    (function ($) {
+
+        $('#filter').keyup(function () {
+
+            var rex = new RegExp($(this).val(), 'i');
+            $('.searchable tr').hide();
+            $('.searchable tr').filter(function () {
+                return rex.test($(this).text());
+            }).show();
+
+        })
+
+    }(jQuery));
+
+});
+</script>
 </body>
 </html>