{#
This file is part of EC-CUBE

Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.

http://www.ec-cube.co.jp/

For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends '@admin/default_frame.twig' %}

{% set menus = ['content', 'news'] %}


{% block title %}{{ 'admin.content.news_management'|trans }}{% endblock %}
{% block sub_title %}{{ 'admin.content.contents_management'|trans }}{% endblock %}

{% block stylesheet %}
    <style type="text/css">
        li.list-group-item {
            z-index: inherit !important;
        }
    </style>
{% endblock %}

{% block main %}
    <div class="c-contentsArea__cols">
        <div class="c-contentsArea__primaryCol">
            <div class="c-primaryCol">
                <div class="d-block mb-3">
                    <a id="addNew" class="btn btn-ec-regular"
                       href="{{ url('admin_content_news_new') }}">{{ 'admin.common.create__new'|trans }}</a>
                </div>
                <div class="card rounded border-0 mb-4">
                    <div class="card-body p-0">
                        <ul class="list-group list-group-flush mb-4 sortable-container">
                            <li class="list-group-item">
                                <div class="row justify-content-around">
                                    <div class="col-2"><strong>{{ 'admin.content.news.publish_date'|trans }}</strong>
                                    </div>
                                    <div class="col-1"><strong>{{ 'admin.content.news.display_status'|trans }}</strong>
                                    </div>
                                    <div class="col"><strong>{{ 'admin.content.news.title'|trans }}</strong></div>
                                </div>
                            </li>
                            {% for News in pagination %}
                                <li class="list-group-item sortable-item" data-id="{{ News.id }}">
                                    <div class="row justify-content-around">
                                        <div class="col-2 d-flex align-items-center">
                                            <span>{{ News.publishDate|date_min }}</span></div>
                                        <div class="col-1 d-flex align-items-center">{{ News.visible ? 'admin.content.news.display_status__show'|trans : 'admin.content.news.display_status__hide'|trans }}</div>
                                        <div class="col d-flex align-items-center"><a
                                                    href="{{ url('admin_content_news_edit', {id: News.id}) }}">{{ News.title }}</a>
                                        </div>
                                        <div class="col-2">
                                            <div class="row">
                                                <div class="col px-0 text-center">
                                                    <a class="btn btn-ec-actionIcon"
                                                       href="{{ url('admin_content_news_edit', {id: News.id}) }}"
                                                       data-toggle="tooltip" data-placement="top"
                                                       title="{{ 'admin.common.edit'|trans }}">
                                                        <i class="fa fa-pencil fa-lg text-secondary"></i>
                                                    </a>
                                                </div>
                                                <div class="col pl-0 text-center" data-toggle="tooltip"
                                                     data-placement="top" title="{{ 'admin.common.delete'|trans }}">
                                                    <a class="btn btn-ec-actionIcon" data-toggle="modal"
                                                       data-target="#delete_{{ News.id }}">
                                                        <i class="fa fa-close fa-lg text-secondary"
                                                           aria-hidden="true"></i>
                                                    </a>
                                                    <div class="modal fade" id="delete_{{ News.id }}" tabindex="-1"
                                                         role="dialog"
                                                         aria-labelledby="delete_{{ News.id }}" aria-hidden="true">
                                                        <div class="modal-dialog" role="document">
                                                            <div class="modal-content">
                                                                <div class="modal-header">
                                                                    <h5 class="modal-title font-weight-bold">{{ 'admin.common.delete_modal__title'|trans }}</h5>
                                                                    <button class="close" type="button"
                                                                            data-dismiss="modal"
                                                                            aria-label="Close"><span
                                                                                aria-hidden="true">×</span>
                                                                    </button>
                                                                </div>
                                                                <div class="modal-body text-left">
                                                                    <p class="text-left">{{ 'admin.common.delete_modal__message'|trans({'%name%': News.title}) }}</p>
                                                                </div>
                                                                <div class="modal-footer">
                                                                    <button class="btn btn-ec-sub" type="button"
                                                                            data-dismiss="modal">{{ 'admin.common.cancel'|trans }}</button>
                                                                    <a class="btn btn-ec-delete"
                                                                       href="{{ url('admin_content_news_delete', {id: News.id}) }}" {{ csrf_token_for_anchor() }}
                                                                       data-method="delete"
                                                                       data-confirm="false">{{ 'admin.common.delete'|trans }}</a>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </li>
                            {% endfor %}
                        </ul>

                        {% if pagination.paginationData.pageCount > 1 %}
                            <div class="row justify-content-md-center mb-4">
                                {% include "@admin/pager.twig" with { 'pages' : pagination.paginationData, 'routes' : 'admin_content_news_page' } %}
                            </div>
                        {% endif %}
                    </div>
                </div>
            </div>
        </div>
    </div>
{% endblock %}
