{% extends "base.html" %}

{% block title %}Kategori{% endblock %}

{% block body %}
<main class="documentation">
    <section>
        <h1><a href="/posts/category">Kategori</a></h1>

        <div class="flex two-600 full grow">

            <div>
                <form method="post">
                    <h2>Tambah Kategori</h2>
                    <div class="flex three-600 two grow">
                        <div class="third-600 full">
                            <label for="category">Nama</label>
                        </div>
                        <div class="two-third-600 full">
                            <input type="text" name="category" value="{{ value.category }}">
                        </div>

                        <div class="third-600 full">
                            <label for="background">Background</label>
                        </div>
                        <div class="two-third-600 full">
                            <input type="color" name="background" value="{{ value.background }}">
                        </div>

                        <div class="third-600 full">
                            <label for="foreground">Teks</label>
                        </div>
                        <div class="two-third-600 full">
                            <input type="color" name="foreground" value="{{ value.foreground }}">
                        </div>

                        <input type="hidden" name="_method" value="{{ method }}">
                        <input type="hidden" name="_addon" value="kategori">
                        <input type="hidden" name="_token" value="{{ token }}">
                        <button type="submit" class="pseudo full">
                            {% if method == 'post' %}
                            <i class="fa fa-plus fa-fw" aria-hidden="true"></i>
                            <span style="font-size:smaller;">Tambah</span>
                            {% else %}
                            <i class="fa fa-edit fa-fw" aria-hidden="true"></i>
                            <span style="font-size:smaller;">Ubah</span>
                            {% endif %}
                        </button>
                    </div>
                </form>
            </div>

            <div>
                <h2>List</h2>
                <ul style="margin-top:0;">
                    {% for cat in categories %}
                    <li>
                        <div style="height:initial;text-align:center;border-radius:5px;background-color:{{ cat.background }};color:{{ cat.foreground }};">
                            <span>
                                {{ cat.category }}
                            </span>
                        </div>

                        <div class="flex two-600 full grow" style="margin:0;">
                            <div>
                                <a href="/posts/category/{{ cat.id }}" class="pseudo button full">
                                    <i class="fa fa-edit fa-fw"></i>
                                    <span style="font-size:smaller;">Ubah</span>
                                </a>
                            </div>
                            <div>
                                <form method="post">
                                    <input type="hidden" name="id" value="{{ cat.id }}">
                                    {% if cat.status == 1 %}
                                        <input type="hidden" name="status" value="0">
                                        <input type="hidden" name="_method" value="delete">
                                    {% elseif cat.status == 0 %}
                                    <input type="hidden" name="status" value="1">
                                        <input type="hidden" name="_method" value="put">
                                    {% endif %}

                                    <input type="hidden" name="_addon" value="kategori">
                                    <input type="hidden" name="_token" value="{{ token }}">

                                    <button type="submit" class="pseudo full" style="height:inherit;">

                                        {% if cat.status == 1 %}
                                        <i class="fa fa-times-circle-o fa-fw"></i>
                                        <span class="font-size:smaller;">Matikan</span>
                                        {% elseif cat.status == 0 %}
                                        <i class="fa fa-check fa-fw"></i>
                                        <span class="font-size:smaller;">Aktifkan</span>
                                        {% endif %}

                                    </button>
                                </form>
                            </div>
                        </div>

                        <div class="fourth-600 none"></div>
                    </li>
                    {% endfor %}
                </ul>
            </div>
        </div>
    </section>
</main>
{% endblock %}
