{% macro time_window_selector(details, number_sorted_columns) -%}
{% set days_1_checked = 'checked' if not details.is_request_valid or details.time_window == 'days_1' else '' %}
{% set days_7_checked = 'checked' if details.time_window == 'days_7' else '' %}
{% set days_30_checked = 'checked' if details.time_window == 'days_30' else '' %}
{% set unprocessed_checked = 'checked' if details.is_unprocessed_only == True else '' %}

<form data-form_initial_load="{{ 'true' if details.is_request_valid else 'false' }}" style="text-align: center" method="get" id="form_time_window">
    <label><input type="radio" name="time_window" id="days_1" value="days_1" {{ days_1_checked }} />Today</label>
    <label><input type="radio" name="time_window" id="days_7" value="days_7" {{ days_7_checked }} />Last 7 Days</label>
    <label><input type="radio" name="time_window" id="days_30" value="days_30" {{ days_30_checked }} />Last 30 Days</label>
    <br/>
    <label><input type="checkbox" name="unprocessed_only" id="unprocessed_only" {{ unprocessed_checked }} />Unprocessed only</label>
    <input type="submit" class="action_button fa-input" title="Refresh" value="&#xf021;&nbsp;Refresh"/>
</form>

{% set sorted_columns = [] %}
{%- for i in range(number_sorted_columns) %}
    {% do sorted_columns.append([i + 1, "asc"]) %}
{%- endfor %}

<script type="text/javascript">
    $(document).ready(function () {
        load_dataset('#form_time_window', 'form_initial_load', {{ sorted_columns|safe }});
    });
</script>
{%- endmacro %}
