{% extends "admin_base.html" %}
{% load i18n %}
{% block nav_notificationadmin_class %}class="cur"{% endblock %}

{% block left_panel %}
<div class="info-item">
    <h3 class="info-item-top">{% trans "Operations" %}</h3>
    <ul class="info-item-bottom op-list">
        <li><a href="#" id="add-n">{% trans "Add new notification" %}</a></li>
    </ul>
</div>
<form action="{% url 'notification_add' %}" method="post" class="hide" id="add-n-form">{% csrf_token %}
    <h3>{% trans "Add new notification" %}</h3>
    <textarea name="message" class="textarea"></textarea><br />
    <input type="submit" value="{% trans "Submit" %}" class="submit" />
</form>

{% endblock %}

{% block right_panel %}
<h3>{% trans "All Notifications" %}</h3>
{% if notes %}
<table>
    <tr>
        <th width="75%">{% trans "Notification Detail" %}</th>
        <th width="25%">{% trans "Operations" %}</th>
    </tr>
    {% for note in notes %}
    <tr>
        <td>{{ note.message }}
        {% if note.primary == 1 %}
        <span class="cur-note">{% trans "(current notification)" %}</span>
        {% endif %}
        <td>
          {% if note.primary != 1 %}
          <a href="#" data="{{ SITE_ROOT }}notification/set-primary/{{ note.id }}/" class="note-change-btn op vh">{% trans "Set to current" %}</a>
          {% endif %}
          <a href="#" data-url="{{ SITE_ROOT }}notification/delete/{{ note.id }}/" data-target="{{ note.message }}" class="note-delete-btn op vh">{% trans "Delete" %}</a>
        </td>
    </tr>
    {% endfor %}
</table>
{% else %}
<p>{% trans "Empty" %}</p>
{% endif %}
{% endblock %}

{% block extra_script %}
<script type="text/javascript">
$('#add-n').click(function() {
    $('#add-n-form').modal();
    $('#simplemodal-container').css({'height':'auto'});
    return false;
});
addConfirmTo($('.note-delete-btn'), {
        'title':'{% trans "Delete Notification" %}',
        'con':'{% trans "Are you sure you want to delete %s ?" %}'
});

$('.note-change-btn').click(function() {
    window.location = $(this).attr('data');
})
</script>
{% endblock %}
 
