{% extends 'base.html' %}
{% load staticfiles %}
{% load cards %}

{% block header %}
    <link rel="stylesheet" type="text/css" href="{% static 'inventory/css/style.css' %}">
{% endblock header %}


{% block content %}

    <a class='dropdown-button btn' href='#' data-activates='dropdown1'
       style="position: absolute; width: 120px; margin-left: 10px; margin-top: 10px;">Valg</a>
    <ul id='dropdown1' class='dropdown-content'
        style="position: absolute; width: 120px; margin-left: 10px; margin-top: 45px;">

        {% if perms.inventory.add_tag %}
            <li><a href="{% url 'inventory:add_tag' tag.id %}">Endre tag</a></li>
        {% endif %}

    </ul>


    <div class="content">
        <h1>{{ tag.name }}</h1>

        <ul>
            {% for item in related_items %}

                {% card_item_detail item request perms False True %}

            {% endfor %}
        </ul>
    </div>
{% endblock content %}

{% extends 'base.html' %}
{% load staticfiles %}
{% load cards %}

{% block header %}
    <link rel="stylesheet" type="text/css" href="{% static 'inventory/css/style.css' %}">
    <script src="{% static 'inventory/js/utils.js' %}"></script>
{% endblock header %}


{% block content %}

    <a class='dropdown-button btn' href='#' data-activates='dropdown1'
       style="position: absolute; width: 120px; margin-left: 10px; margin-top: 10px;">Valg</a>
    <ul id='dropdown1' class='dropdown-content'
        style="position: absolute; width: 120px; margin-left: 10px; margin-top: 45px;">

        {% if perms.inventory.add_tag %}
            <li><a href="{% url 'inventory:add_tag' tag.id %}">Endre tag</a></li>
            <li><a onclick="deleteTag('{{ tag.id }}')">Slett tag</a></li>
        {% endif %}

    </ul>

    <div class="content">
        <h1>{{ tag.name }}</h1>

        <ul>
            {% for item in related_items %}

                {% card_item_detail item request perms False True %}


            {% endfor %}
        </ul>
    </div>

    {% csrf_token %}
    <script>
        var token = $('input[name="csrfmiddlewaretoken"]').attr('value');
        console.log(token);
        ajaxSetup(token);

        function deleteTag(tagID) {
            // TODO bør spørre: "er du sikker på at du vil slette" modal?
            console.log("hallspå dega");
            $.ajax({
                url: '{% url 'inventory:add_tag' tag.id %}',
                type: 'DELETE',
                success: function (result) {
                    window.location.replace('{% url 'inventory:index' %}');
                }
            });
        }

    </script>
{% endblock content %}


Create button for deleting tag.
Create button for deleting tag.
