<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>
        Features
    </title>

    {% include 'admin/includes/imports.top.html' %}

</head>

<body class="g-sidenav-show  bg-gray-100">
    {% include 'admin/includes/part.menu.html' %}
    <script>
        $('.vehicle-utilities').addClass('active');
        $('.features').addClass('active');
    </script>
    <main class="main-content position-relative max-height-vh-100 h-100 border-radius-lg ">
        <!-- Navbar -->
        {% include 'admin/includes/part.header.html' %}
        <!-- End Navbar -->
        <div class="container-fluid py-4">
            <div class="row g-1">
                <div class="col-md-12">
                    <div class="card">
                        <div class="card-header pb-0 px-3">
                            <div class="d-flex justify-content-between">
                                <h6 class="mb-0">Vehicle Features</h6>
                                <!-- <a href="{{url_for('admin_news_add')}}" class="btn btn-sm btn-info">Add a Make</a> -->
                                <button class="btn btn-sm btn-info" type="button" data-bs-toggle="offcanvas"
                                    data-bs-target="#add_a_feature" aria-controls="add_a_feature">Add a Feature</button>
                            </div>
                        </div>


                        <div class="offcanvas offcanvas-end" data-bs-scroll="true" tabindex="-1" id="add_a_feature"
                            aria-labelledby="add_a_featureLabel">
                            <div class="offcanvas-header">
                                <h5 class="offcanvas-title" id="add_a_featureLabel">Add a Feature
                                </h5>
                                <button type="button" class="btn-close" data-bs-dismiss="offcanvas"
                                    aria-label="Close"></button>
                            </div>
                            <div class="offcanvas-body">
                                <div>
                                    <form id="make-form" method="post">
                                        {{form.csrf_token}}
                                        <div>
                                            <label for="name">{{form.name.label}}</label>
                                            <div class="mb-3">
                                                {{form.name(class_="form-control", id="name", placeholder="Name",
                                                aria_label="name", aria_describedby="name-addon")}}
                                                {% for error in form.name.errors %}
                                                <span class='text-danger text-sm text-gradient'>{{ error }}</span>
                                                {% endfor %}
                                            </div>
                                        </div>
                                        <div>
                                            <label for="description">{{form.description.label}}</label>
                                            <div class="mb-3">
                                                {{form.description(class_="form-control", id="description",
                                                placeholder="Description", cols='10')}}
                                                {% for error in form.description.errors %}
                                                <span class='text-danger text-sm text-gradient'>{{ error }}</span>
                                                {% endfor %}
                                            </div>
                                        </div>
                                        <div class="text-center">
                                            <button type="submit" form="make-form"
                                                class="submit-form btn btn-sm bg-gradient-info w-100 mt-4 mb-0">
                                                Submit</button>
                                        </div>

                                    </form>
                                </div>
                            </div>
                        </div>
                        <div class="card-body p-3" style="overflow: visible !important;">
                            <div class="table-responsive p-0" style="overflow: visible !important;">
                                <table class="table table-responsive align-items-center justify-content-center mb-0"
                                    style="overflow: visible !important;">
                                    <thead>
                                        <tr>
                                            <th
                                                class="text-uppercase text-secondary text-xxs text-black font-weight-bolder opacity-7 ps-2">
                                                Features
                                            </th>
                                            <th
                                                class="text-uppercase text-secondary text-xxs text-black font-weight-bolder opacity-7 ps-2">
                                                Description
                                            </th>
                                            <th
                                                class="text-uppercase text-secondary text-xxs text-black font-weight-bolder opacity-7 ps-2">
                                                Publish
                                            </th>
                                            <th
                                                class="text-uppercase text-secondary text-xxs text-black font-weight-bolder opacity-7 ps-2">
                                                Status</th>
                                            <th
                                                class="text-uppercase text-secondary text-xxs text-black font-weight-bolder opacity-7 ps-2">
                                                Action</th>

                                        </tr>
                                    </thead>
                                    <tbody>
                                        {% for feature in features %}
                                        <tr>

                                            <td>
                                                <p class="text-sm text-black font-weight-bold mb-0">{{feature.name}}</p>
                                            </td>
                                            <td>
                                                <p class="text-sm text-black font-weight-bold mb-0">{{feature.description}}
                                                </p>
                                            </td>
                                            <td>
                                                <p class="text-sm text-black font-weight-bold mb-0">
                                                    {{feature.date.strftime('%c')}}</p>
                                            </td>
                                            <td>
                                                <p class="text-sm text-black font-weight-bold mb-0">
                                                    {% if feature.active %}
                                                    <span class="badge bg-gradient-success">Active</span>
                                                    {% else %}
                                                    <span class="badge bg-gradient-danger">Inactive</span>
                                                    {% endif %}
                                                </p>
                                            </td>
                                            <td class="px-1">
                                                <div class="btn-group my-auto mx-1">
                                                    <button id="menu-1" type="button"
                                                        class="py-1 border-secondary badge badge-sm bg-secondary dropdown-toggle"
                                                        data-bs-toggle="dropdown" aria-haspopup="true"
                                                        aria-expanded="false">
                                                        Action
                                                    </button>
                                                    <div class="dropdown-menu dropdown-menu-dark border shadow-3"
                                                        style="z-index: 2500 !important;" aria-labelledby="menu-1">
                                                        <a class="dropdown-item" href="#">View</a>
                                                        <!-- <a class="dropdown-item" href="#">Edit</a> -->
                                                        <a class="dropdown-item text-danger" data-bs-toggle="modal"
                                                        data-bs-target="#delete" href="#delete" onclick="Delete('{{url_for('delete_feature', id=feature.id)}}')">Delete</a>
                                                    </div>
                                                </div>
                                            </td>
                                        </tr>
                                        {% endfor %}
                                    </tbody>
                                </table>
                            </div>
                            <!-- Modal -->
                            <div class="modal fade" id="delete" data-bs-backdrop="static"
                                data-bs-keyboard="false" tabindex="-1" aria-labelledby="deleteLabel"
                                aria-hidden="true">
                                <div class="modal-dialog modal-dialog-centered">
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <h1 class="modal-title fs-5" id="deleteLabel">Delete Item</h1>
                                            <button type="button" class="btn-close" data-bs-dismiss="modal"
                                                aria-label="Close"></button>
                                        </div>
                                        <div class="modal-body">
                                            Are you sure you want to proceed with this operation?
                                        </div>
                                        <div class="modal-footer py-2 d-flex justify-content-between">
                                            <button type="button" class="btn btn-sm btn-secondary"
                                                data-bs-dismiss="modal">Cancel</button>
                                            <a title="Proceed with Deletion" id="delete_it_button" href="" class="btn btn-sm btn-danger">Proceed</a>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            {% include 'admin/includes/part.footer.html' %}
        </div>
    </main>

    <!--   Core JS Files   -->
    {% include 'admin/includes/imports.bottom.html' %}
    <script>
        var win = navigator.platform.indexOf('Win') > -1;
        if (win && document.querySelector('#sidenav-scrollbar')) {
            var options = {
                damping: '0.5'
            }
            Scrollbar.init(document.querySelector('#sidenav-scrollbar'), options);
        }
    </script>
</body>

</html>