{% extends "webclient/data/containers.html" %}
{% load i18n %}
{% load common_filters %}

{% comment %}
<!--
  Copyright (C) 2016 University of Dundee & Open Microscopy Environment.
  All rights reserved.

  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU Affero General Public License as
  published by the Free Software Foundation, either version 3 of the
  License, or (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU Affero General Public License for more details.

  You should have received a copy of the GNU Affero General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.

  Author: Aleksandra Tarkowska <A(dot)Tarkowska(at)dundee(dot)ac(dot)uk>,

  Version: 1.0
-->
{% endcomment %}

{% block link %}
    {{ block.super }}
    <link rel="stylesheet" href="{% static 'mapr/css/ome.mapr.css'|add:mapr_url_suffix %}" type="text/css" />
{% endblock %}

{% block script %}
    
    {{ block.super }}

    <script src="{% static 'mapr/javascript/ome.mapr.ui.autocomplete.js'|add:mapr_url_suffix %}" type="text/javascript"></script>
    <script src="{% static 'mapr/javascript/ome.mapr.js'|add:mapr_url_suffix %}" type="text/javascript"></script>
    <!-- include code to handle primary 'thumbs' middle plugin -->
    <script src="{% static 'mapr/javascript/center_plugin.thumbs.js'|add:mapr_url_suffix %}" type="text/javascript"></script>

{% endblock %}


{% block left %}

    <div id="left_panel_tabs" class="absolute_fill ui-tabs">

        <!-- toolbar above tree -->
        <div>

            <!-- Show Tags toolbar for tag page... -->
            <ul class="toolbar">

                <li><input id="refreshButton" class="button" type="image" src="{% static "webclient/image/icon_toolbar_refresh.png" %}" alt="Refresh" title="Refresh" /></li>

                <li class="seperator"></li>

                <li>
                    <div class="search filtersearch autocompletesearch" id="autocompletesearch">
                        <label for="id_autocomplete">Type {{ mapr_conf.menu_default|join:', ' }}...</label>
                        <input type="text" name="id_autocomplete" id="id_autocomplete" title="Search using a {{ mapr_conf.menu_default|join:', ' }} ({{ mapr_conf.menu_all|join:', ' }}).">
                    </div>
                </li>

                <li style="float:right">
                    <input type="image" class="button mapr_tooltip" src="{% static "webgateway/img/help16.png" %}" data-content="{% if mapr_conf.case_sensitive %}Please select 'Match case' or not as desired. {% endif %}Start typing to search for {{ mapr_conf.menu_all|join:' or ' }}. Select the desired item from the dropdown menu which appears after typing has started."/>
                </li>
                <li style="float:right;" >
                    <div class="case_sensitive"><input {% if map_ctx.case_sensitive %}checked{% endif %} {% if not mapr_conf.case_sensitive %}disabled{% endif %} id="id_case_sensitive" type="checkbox" name="case_sensitive" value="Case insensitive"><label for="id_case_sensitive">Match case</label></div>
                </li>

            </ul>

            <div class="clear"></div>

            <div id="tree_details" class="left_panel_inner">
                <div class="dataTree" id="dataTree"></div>
            </div>
        </div>

    </div>
    
    <script type="text/javascript">

        WEBCLIENT.UI.TREE.pagination_nodes = ["tagset", "image", "map"];

        WEBCLIENT.URLS.api_experimenter = "{% url 'mapannotations_api_experimenters' menu %}";

        WEBCLIENT.URLS.tree_top_level = "{% url 'mapannotations_api_mapannotations' menu %}";
        WEBCLIENT.URLS.tree_map_level = WEBCLIENT.URLS.tree_top_level;

        WEBCLIENT.URLS.api_tags_and_tagged = WEBCLIENT.URLS.tree_top_level;

        WEBCLIENT.URLS.api_datasets = "{% url 'mapannotations_api_datasets' menu %}";
        WEBCLIENT.URLS.api_images = "{% url 'mapannotations_api_images' menu %}";
        WEBCLIENT.URLS.api_plates = "{% url 'mapannotations_api_plates' menu %}";
        WEBCLIENT.URLS.api_plate_acquisitions = WEBCLIENT.URLS.api_images;

        WEBCLIENT.URLS.api_paths_to_object = "{% url 'mapannotations_api_paths_to_object' menu %}";

        var MAPANNOTATIONS = {}
        MAPANNOTATIONS.URLS = {'static_webclient': "{% static 'mapr' %}/"};
        MAPANNOTATIONS.URLS.maprindex = "{% url 'maprindex' %}";
        MAPANNOTATIONS.URLS.paths_to_object = "{% url 'mapannotations_api_paths_to_object' menu %}";
        MAPANNOTATIONS.URLS.autocomplete = "{% url 'mapannotations_autocomplete' menu %}";
        MAPANNOTATIONS.URLS.autocomplete_default = "{% url 'mapannotations_api_experimenters' menu %}";

        MAPANNOTATIONS.CTX = {{ map_ctx|json_dumps|safe }};

        payload = {};
        if (MAPANNOTATIONS.CTX.value.length > 0) {
            payload['value'] = MAPANNOTATIONS.CTX.value;
        }
        if (MAPANNOTATIONS.CTX.query) {
            payload['query'] = MAPANNOTATIONS.CTX.query;
        }
        if (MAPANNOTATIONS.CTX.case_sensitive) {
            payload['case_sensitive'] = MAPANNOTATIONS.CTX.case_sensitive;
            $('#id_case_sensitive').prop('checked', true);
        } else {
            $('#id_case_sensitive').prop('checked', false);
        }

        $("#dataTree").data('payload', payload);

    </script>
{% endblock %}
