{% extends 'aasrp/base.html' %}

{% load i18n %}
{% load static %}
{% load aasrp_versioned_static %}
{% load humanize %}

{% block aasrp_header %}
    {% translate "SRP Requests" as translated_header %}
    {% include 'aasrp/partials/header/h1.html' with header_text=translated_header %}
{% endblock %}

{% block aasrp_body %}
    {% include 'aasrp/partials/view_requests/overview.html' %}
    {% include 'aasrp/partials/view_requests/requests.html' %}
    {% include 'aasrp/modals/view_requests/request_details.html' %}
    {% include 'aasrp/modals/view_requests/mark_complete_modal.html' %}
    {% include 'aasrp/modals/view_requests/accept_request.html' %}
    {% include 'aasrp/modals/view_requests/reject_request.html' %}
    {% include 'aasrp/modals/view_requests/remove_request.html' %}
{% endblock %}

{% block extra_css %}
    {% include 'bundles/datatables-css.html' %}
    {% include 'aasrp/bundles/bootstrap3-editable-css.html' %}

    <link rel="stylesheet" href="{% aasrp_static 'aasrp/css/aa-bootstrap-fix.min.css' %}" type="text/css">
    <link rel="stylesheet" href="{% aasrp_static 'aasrp/css/aa-srp.min.css' %}" type="text/css">
    <link rel="stylesheet" href="{% aasrp_static 'aasrp/css/aa-srp-form.min.css' %}" type="text/css">
{% endblock %}

{% block extra_javascript %}
    {% include 'bundles/datatables-js.html' %}
    {% include 'bundles/moment-js.html' with locale=True %}
    {% include 'aasrp/bundles/bootstrap3-editable-js.html' %}
    {% include 'bundles/clipboard-js.html' %}

    <script type="application/javascript">
        let clipboard = new ClipboardJS('.copy-text-fa-icon');

        clipboard.on('success', function (e) {
            e.clearSelection();
        });

        clipboard.on('error', function (e) {
            console.error('Action:', e.action);
            console.error('Trigger:', e.trigger);
        });
    </script>

    <script type="application/javascript" src="{% static 'aasrp/libs/datatables/plugins/dataTables.rowGroup.min.js' %}"></script>
    <script type="application/javascript" src="{% static 'aasrp/libs/datatables/plugins/datetime.min.js' %}"></script>
    <script type="application/javascript" src="{% static 'js/filterDropDown/filterDropDown.min.js' %}"></script>

    <script type="application/javascript">
        /**
         * passing some settings to our JS
         */
        let urlRequestsForSrpLink = '{% url "aasrp:ajax_srp_link_view_requests_data" srp_link.srp_code %}';
        let urlChangeSrpAmount = '{% url "aasrp:ajax_srp_request_change_payout" srp_link.srp_code 'SRP_REQUEST_CODE' %}';

        let aaSrpSettings = {
            datetimeFormat: 'YYYY-MM-DD HH:mm',
            srpCode: '{{ srp_link.srp_code }}',
            csrfToken: '{{ csrf_token }}',
            url: {
                requestsForSrpLink: urlRequestsForSrpLink,
                changeSrpAmount: urlChangeSrpAmount
            },
            translation: {
                filter: {
                    requestStatus: '{% translate "Request Status" %}',
                    ship: '{% translate "Ship" %}',
                    character: '{% translate "Character" %}',
                },
                changeSrpPayoutHeader: '{% translate "Enter SRP payout value" %}',
                editableValidate: '{% translate "Empty values are not allowed" %}',
                modal: {
                    srpDetails: {
                        body: {
                            requestor: '{% translate "Requestor" %}',
                            character: '{% translate "Character" %}',
                            ship: '{% translate "Ship" %}',
                            insurance: '{% translate "Insurance Payout" %}',
                            additionalInformation: '{% translate "Additional Information" %}',
                            rejectInformation: '{% translate "Reject Information" %}'
                        }
                    },
                    rejectRequest: {
                        body: {
                            fieldRequired: '{% translate "This field is required." %}'
                        }
                    }
                }
            }
        };
    </script>
    <script type="application/javascript" src="{% aasrp_static 'aasrp/javascript/aa-srp-view-requests.min.js' %}"></script>
{% endblock %}
