<!DOCTYPE html>
<html lang="en"
      th:replace="~{admin/dashboard/layout:: parent(~{::#content},~{::title},~{::script})}">
<head>
    <title >View A Category</title>
</head>
<body>
<!-- Page content-->
<section class="content" id="content">

        <div class="row">
            <div class="col-md-12">
                <div class="card card-primary">
                    <div class="card-header">
                        <h3 class="card-title">View Category</h3>
                        <div class="card-tools">
                            <button type="button" class="btn btn-tool" data-card-widget="collapse" title="Collapse">
                                <i class="fas fa-minus"></i>
                            </button>
                        </div>
                    </div>
                    <div class="card-body">
                        <div class="card-header">
                            <div class="card-tools">
                                <div class="input-group input-group-sm" style="width: 150px;">
                                    <input type="text" name="table_search" class="form-control float-right" placeholder="Search">

                                    <div class="input-group-append">
                                        <button type="submit" class="btn btn-default">
                                            <i class="fas fa-search"></i>
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <table class="table table-striped projects display" id="myTable">
                            <thead>
                            <tr>
                                <th>Id</th>
                                <th style="width:15%"> Name</th >
                                <th style="width:30%">Description</th >
                                <th>Date</th>
                                <th class="text-center">Status</th>
                                <th class="text-center" >Admin Status </th>
                                <th class="text-center">Action</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr  th:each="category : ${categories}" >
                                <td th:text="${category.categoryId}"> </td>
                                <td th:text="${category.name}"></td>
                                <td>
                                    <span th:text="${#strings.length(category.desc) > 60
                                   ? #strings.substring(category.desc, 0, 60) + '...'
                                 : category.desc}"></span>

                                </td>
                                <td th:text="${category.createdAt}"></td>
                                <td>
                                     <span th:text="${category.activeStatus == T(com.codenetworkz.blog.models.Status).YES ? 'Active' : 'Inactive'}"
                                          th:classappend="${category.activeStatus == T(com.codenetworkz.blog.models.Status).YES ? 'badge badge-success' : 'badge badge-warning'}"></span>
                                </td>
                                <td class="project-state">
                                      <span th:text="${category.adminStatus == T(com.codenetworkz.blog.models.Status).YES ? 'Accept' :
                                             (category.adminStatus == T(com.codenetworkz.blog.models.Status).NO ? 'Denied' : 'Pending')}"
                                            th:class="${category.adminStatus == T(com.codenetworkz.blog.models.Status).YES ? 'badge badge-success' :
                                             (category.adminStatus == T(com.codenetworkz.blog.models.Status).NO ? 'badge badge-warning' :
                                            'badge badge-danger')}"> </span>
                                </td>
                                <td class="project-actions text-right">
                                    <a class="btn btn-primary btn-sm" th:href="@{'/admin/categories/view/'+${category.slug}}"  title="View Tag">
                                        <i class="fas fa-folder">
                                        </i>
                                        View
                                    </a>
                                    <a class="btn btn-info btn-sm" th:href="@{'/admin/categories/update/'+${category.slug}}"  title="Edit Category">
                                        <i class="fas fa-pencil-alt">
                                        </i>
                                        Edit
                                    </a>
                                    <form th:action="@{'/admin/categories/change-status/' + ${category.slug}}" method="post" style="display: inline;">
                                        <input type="hidden" name="slug" value="${category.slug}" />
                                        <button type="submit" class="btn btn-primary btn-sm" title="Active/Inactive">
                                            <i class="fas fa-user-shield"></i>
                                            Change Status
                                        </button>
                                    </form>
                                    <form th:action="@{'/admin/categories/admin-approve/' + ${category.slug}}" method="post" style="display: inline;">
                                        <input type="hidden" name="slug" value="${category.slug}" />
                                        <button type="submit" class="btn btn-primary btn-sm" title="Admin Approved">
                                            <i class="fas fa-user-shield"></i>
                                            Change Approved
                                        </button>
                                    </form>
                                    <form th:action="@{'/admin/categories/delete/' + ${category.slug}}" method="post" style="display: inline;">
                                        <input type="hidden" name="slug" value="${category.slug}" />
                                        <button type="submit" class="btn btn-danger btn-sm" title="delete">
                                            <i class="fas fa-trash" ></i>
                                            Delete
                                        </button>
                                    </form>
                                </td>
                            </tr>
                            <tr th:if="${#lists.isEmpty(categories)}">
                                <td colspan="7" class="text-center">No categories found.</td>
                            </tr>
                            </tbody>
                        </table>
                        <div class="card-footer clearfix" th:if="${!#lists.isEmpty(categories)}">
                        <ul class="pagination pagination-sm m-0 float-right">
                                <li class="page-item">
                                    <a class="page-link" th:if="${categories.hasPrevious()}" th:href="@{/admin/categories/list(page=${categories.number - 1}, size=${categories.size})}">«</a></li>
                                <li class="page-item" th:each="i : ${#numbers.sequence(0, categories.totalPages - 1)}">
                                    <a class="page-link" th:href="@{/admin/categories/list(page=${i}, size=${categories.size})}" th:text="${i + 1}">1</a></li>
                                <li class="page-item">
                                    <a class="page-link" th:if="${categories.hasNext()}" th:href="@{/admin/categories/list(page=${categories.number + 1}, size=${categories.size})}">»</a></li>
                            </ul>
                        </div>
                    </div>
                    <!-- /.card-body -->
                </div>
                <!-- /.card -->
            </div>
        </div>
</section>

</body>

</html>
