Switch to unified view

a b/qiita_pet/templates/user_messages.html
1
{% extends sitebase.html %}
2
{% block head %}
3
<script type="text/javascript">
4
  function checkbox_action(action) {
5
    var boxes = $('.msg-checkbox');
6
    if(action == 'check') { boxes.prop('checked',true); }
7
    else if(action == 'uncheck') { boxes.prop('checked',false); }
8
    else if(action='invert') { boxes.each( function() {
9
      $(this).is(':checked') ? $(this).prop('checked',false) : $(this).prop('checked',true);
10
    });}
11
    show_hide_actions();
12
    return false;
13
  }
14
15
  function submit_form(action) {
16
    $('#action').val(action);
17
    if($("input:checked").length == 0) {
18
      return false;
19
    }
20
    document.msgform.submit();
21
  }
22
23
  function show_hide_actions() {
24
    if($('input:checked').length > 0) { $('#message-actions').show(); }
25
    else { $('#message-actions').hide(); }
26
  }
27
28
  $(document).ready(function() {
29
    $('#message-actions').hide();
30
  });
31
</script>
32
{% end %}
33
34
{% block content%}
35
<h2 style="text-decoration: underline;">System Messages</h2>
36
<form method="POST" action="{% raw qiita_config.portal_dir %}/user/messages/" name="msgform">
37
<div class="row">
38
  <div class="col-sm-6"><a href="#" onclick="checkbox_action('check')">Select all</a> | <a href="#" onclick="checkbox_action('uncheck')">Select None</a> | <a href="#" onclick="checkbox_action('invert')">Select Inverse</a></div>
39
  <input type="hidden" name="action" id="action" value="">
40
  <div class="col-sm-6" style="text-align:right" id="message-actions"><a href="#" onclick="return submit_form('read')">Mark as Read</a> | <a href="#" onclick="return submit_form('unread')">Mark as Unread</a> | <a href="#" onclick="return submit_form('delete')">Delete</a></div>
41
</div>
42
  {% set user_messages = current_user.messages() %}
43
    {% if user_messages %}
44
    <table class="table">
45
      <thead>
46
        <td class="col-sm-1"></td class="col-md-9"><td>Message</td><td class="col-md-2">Timestamp</td></tr>
47
      </thead>
48
      <tbody>
49
        {% for m_id, message, ts, read, _ in user_messages %}
50
          <tr><td>
51
          <input type="checkbox" class="msg-checkbox" name="messages" value="{{m_id}}" onchange="show_hide_actions()">
52
          </td><td {% if not read %}style="font-weight:bold"{% end %}>{% raw message %}</td><td>{{ts}}</td></tr>
53
        {% end %}
54
      </tbody>
55
    </table>
56
</form>
57
    {% else %}
58
      <h3>You have no messages</h3>
59
    {% end %}
60
{% end %}