{% extends "bijoe/base.html" %}
{% load i18n staticfiles bijoe %}

{% block extrascripts %}
  {% import_django_select2_js_css %}
  {{ block.super }}
  <script src="{% static "js/jquery.form.js" %}"></script>
  <script src="{% static "js/addclear.js" %}"></script>
  <script src="{% static "xstatic/ChartNew.js" %}"></script>
  <script src="{% static "js/bijoe.js" %}"></script>
  {{ form.media.css }}
  {{ form.media.js }}
{% endblock %}


{% block breadcrumb %}
  {% url 'homepage' as homepage_url %}
  {% url 'warehouse' warehouse=warehouse.name as warehouse_url %}

  <a href="{{ homepage_url }}">{% trans "Homepage" %}</a>
  <a href="{{ warehouse_url }}">{{ warehouse.label }}</a>
  <a>{{ cube.label }}</a>

{% endblock %}

{% block content %}
  <form class="cube-form" method="post" action=".">
    {% csrf_token %}
    <h3>Représentation</h3>
    {% include "bijoe/field.html" with field=form.representation %}
    <h3>Répétition</h3>
    {% include "bijoe/field.html" with field=form.loop %}
    <h3>Mesure</h3>
    {% include "bijoe/field.html" with field=form.measure %}
    <h3>Regroupement horizontal</h3>
    {% include "bijoe/field.html" with field=form.drilldown_x %}
    <h3>Regroupement vertical</h3>
    {% include "bijoe/field.html" with field=form.drilldown_y %}
    <h3>Filtre(s)</h3>
    {% for field in form %}
      {% if not field.is_hidden and field.name != "loop" and field.name != "measure" and field.name != "drilldown_x" and field.name != "drilldown_y" and field.name != "representation" %}
        {% include "bijoe/filter_field.html" with field=field %}
      {% endif %}

    {% endfor %}
    {% block buttons %}
      <input type="submit" name="visualize" value="{% trans "Visualiser" %}">
    {% endblock %}
  </form>
  <div id="data" {% if visualization %}class="visualization-{{visualization.representation}}"{% endif %}>
  {% if visualization %}
    {% if visualization.representation == 'table' %}
      {% include "bijoe/cube_table.html" %}
    {% else %}
      {% include "bijoe/cube_chart.html" %}
    {% endif %}
    {% block actions %}
      <a href="?{% firstof view.request.POST.urlencode view.request.GET.urlencode %}" title="{{
        visualization.title }}" class="button">URL</a>

      <a href="iframe/?{% firstof view.request.POST.urlencode view.request.GET.urlencode %}"
         title="{{ visualization.title }}" class="button">{% trans "URL for IFRAME" %}</a>
      <a rel="popup" href="{% url "create-visualization" warehouse=warehouse.name cube=cube.name %}?{% firstof view.request.POST.urlencode view.request.GET.urlencode %}"
         title="{{ visualization.title }}" class="button">{% trans "Save" %}</a>
    {% endblock %}
  {% else %}
    <div class="big-msg-info">{% trans "Please choose some measures and groupings." %}</div>
  {% endif %}
  </div>
{% endblock %}
