{% extends "./layout/default" %}

{% block breadcrumbs %}
    {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, tag) }}
{% endblock %}

{% block content %}
    {{ Form.model(tag, {'class' : 'form-horizontal','id' : 'update','url' : route('tags.update',tag.id)}) }}

    <input type="hidden" name="id" value="{{ tag.id }}"/>

    <div class="row">
        <div class="col-lg-5 col-md-5 col-sm-12">
            <div class="box box-primary">
                <div class="box-header with-border">
                    <h3 class="box-title">{{ 'mandatoryFields'|_ }}</h3>
                </div>
                <div class="box-body">
                    {{ ExpandedForm.text('tag') }}
                    {{ ExpandedForm.multiRadio('tagMode',tagOptions) }}
                </div>
            </div>
        </div>

        <div class="col-lg-7 col-md-7 col-sm-12">

            <div class="box">
                <div class="box-header with-border">
                    <h3 class="box-title">{{ 'optionalFields'|_ }}</h3>
                </div>
                <div class="box-body">
                    {{ ExpandedForm.date('date', tag.date.format('Y-m-d')) }}
                    {{ ExpandedForm.textarea('description') }}
                    {{ ExpandedForm.location('tagPosition') }}
                </div>
            </div>

            <!-- panel for options -->
            <div class="box">
                <div class="box-header with-border">
                    <h3 class="box-title">{{ 'options'|_ }}</h3>
                </div>
                <div class="box-body">
                    {{ ExpandedForm.optionsList('update','tag') }}
                </div>
                <div class="box-footer">
                    <button type="submit" class="btn pull-right btn-success">
                        {{ 'update_tag'|_ }}
                    </button>
                </div>
            </div>

        </div>
    </div>

    {{ Form.close|raw }}

{% endblock %}
{% block scripts %}
    <script type="text/javascript">
        {% if Input.old('latitude') %}
        var latitude = {{ Input.old('latitude') }};
        {% else %}
        var latitude = {{ tag.latitude|default("52.3167") }};
        {% endif %}

        {% if (Input.old('latitude') and Input.old('longitude') and Input.old('zoomLevel'))
        or (tag.latitude and tag.longitude and tag.zoomLevel) %}
        var doPlaceMarker = true;
        {% else %}
        var doPlaceMarker = false;
        {% endif %}

        {% if Input.old('longitude') %}
        var longitude = "{{ Input.old('longitude') }}";
        {% else %}
        var longitude = {{ tag.longitude|default("5.5500") }};
        {% endif %}

        {% if Input.old('zoomLevel') %}
        var zoomLevel = {{ Input.old('zoomLevel') }};
        {% else %}
        var zoomLevel = {{ tag.zoomLevel|default("6") }};
        {% endif %}

        var apiKey = "{{ apiKey }}";

    </script>
    <script src="https://maps.googleapis.com/maps/api/js?v=3&amp;key={{ apiKey }}"></script>
    <script type="text/javascript" src="js/lib/modernizr-custom.js"></script>
    <script type="text/javascript" src="js/lib/jquery-ui.min.js"></script>
    <script src="js/ff/tags/create-edit.js"></script>
{% endblock %}
{% block styles %}
    <link href="css/jquery-ui/jquery-ui.structure.min.css" type="text/css" rel="stylesheet" media="all">
    <link href="css/jquery-ui/jquery-ui.theme.min.css" type="text/css" rel="stylesheet" media="all">
{% endblock %}
