<div class="modal-header">
    <div class="col md-12">
        <div class="row">
            <div class="col">
                 <h4 class="modal-title mt-1 mr-4">{% if task.id %} Task ID #{{ task.id }}{% else %} Add global task {% endif %}
                   {% if task.id %}
                    <i class="fas fa-info-circle ml-3" data-toggle="popover"
                        title="Task info"
                        data-content="Last updated {{ task.task_last_update }} by {{ user_name }}."></i>
                    {% endif %}
                 </h4>
                 <small><i class="text-muted">{% if task.task_uuid %}#{{ task.task_uuid }}{% endif %}</i></small>
            </div>
            <div class="col ">
                <div class="row float-right">
                    <button type="button" class="float-right btn bg-transparent" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true"><i class="fa fa-times"></i></span></button>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="modal-body">

    <div class="container col-md-12">

        <form method="post" action="" id="form_new_gtask">
            <div class="col-md-12 col-lg-12 col-sm-12">
                {{ form.hidden_tag() }}
                <div class="form-group mt-3">
                    <label for="task_assignee" class="placeholder">Assigned to</label>
                    {{ form.task_assignee_id(class="selectpicker pl--6  col-5") }}

                    <label for="task_status" class="placeholder">Status</label>
                    {{ form.task_status_id(class="selectpicker pl--6  col-5") }}
                </div>
                <div class="form-group">
                    <label for="task_title" class="placeholder">{{ form.task_title.label.text }} *</label>
                    {{ form.task_title(class='form-control col-md-12 col-sm-12',  autocomplete="off") }}
                </div>
                <div class="form-group mt-3">
                    <label for="task_description" class="placeholder">{{ form.task_description.label.text }}</label>
                    {{ form.task_description(class='form-control col-md-12 col-sm-12 sizable-textarea',  autocomplete="off") }}
                </div>
                <div class="form-group mt-3">
                    <label for="task_tags">Task tags
                    </label>
                    <input type="text" id="task_tags"
                        class="form-control col-md-12" {% if task.task_tags %} value="{{ task.task_tags }}" {% endif %}/>
                </div>
            </div>
            {% if task.id %}
                <button type="button" class="btn btn-outline-danger mt-5"
                onclick="delete_gtask({{ task.id }});">Delete</button>

                <button type="button" class="btn btn-outline-success ml-4 mt-5 float-right"
                onclick="update_gtask({{ task.id }});">Update</button>

            {% else %}

                <button type="button" class="btn btn-outline-success ml-4 mt-5 float-right"
                id="submit_new_gtask">Save</button>

            {% endif %}
        </form>
    </div>

</div>

<script>
    set_suggest_tags('task_tags');

    $('#task_assignee_id').selectpicker({
        liveSearch: true,
        title: "None",
        style: "Bootstrap 4: 'btn-outline-primary'",
    });
    $('#task_status_id').selectpicker({
        liveSearch: true,
        title: "None",
        style: "Bootstrap 4: 'btn-outline-primary'",
    });
    {% if uid %}
        $('#task_assignee_id').selectpicker('val', '{{uid}}');
    {% endif %}

    {% if task.task_status_id %}
        $('#task_status_id').selectpicker('val', '{{task.task_status_id}}');
     {% else %}
        $('#task_status_id').selectpicker('val', '1');
    {% endif %}
    $('[data-toggle="popover"]').popover();
</script>

