{% extends g.theme.master %}

{% block title %}{{c.project.name}} / Configure Dashboard{% endblock %}

{% block header %}Configure Dashboard for {{c.project.name}}{% endblock %}

{% block extra_css %}
    <link rel="stylesheet" type="text/css"  
          href="{{g.app_static('css/project_home.css')}}"/>
{% endblock %}


{% block content %}
          <form method="post" action="update_configuration">
            <div class="span-3 clear"><label for="layout_class">Layout Class</label></div>
            <div class="span-10">
              <select name="layout_class" id="layout_class" class="title">
                <option value="onecol" {% if layout_class=='onecol' %}selected="selected"{% endif %}>
                  One Column</option>
                <option value="twocol" {% if layout_class=='twocol' %}selected="selected"{% endif %}>
                  Two Column</option>
              </select>
            </div>
            <div class="span-5 last">
              <input type="submit" value="Update Layout"/>
            </div>
            
            {% for div in layout %}
            <div style="margin-bottom: 1em; border: 1px solid #ddd" class="span-18 last">
              <div class="span-3 clear"><label for="divs-{{loop.index0}}.name">Div Name</label></div>
              <div class="span-14 last">
                <input type="text" name="divs-{{loop.index0}}.name" id="divs-{{loop.index0}}.name" value="{{div.name}}" class="title span-10"/> &nbsp;
                <input type="submit" name="divs-{{loop.index0}}.del" value="Remove Div"/>
              </div>
              <div class="span-3 clear"><label>Widgets</label></div>
              <div class="span-14 last">
                {% if not div.content %}
                <span">No widgets have been added.</span>
                {% else %}
                <table>
                  <thead>
                    <tr>
                      <th>Widget</th>
                      <th>Remove</th>
                    </tr>
                  </thead>
                  <tbody>
                    {% set i = loop.index0 %}
                    {% for w in div.content %}
                    <tr class="{{loop.cycle('even', '')}}">
                      <td>
                        <select name="divs-{{i}}.content-{{loop.index0}}.widget" id="divs-{{i}}.content-{{loop.index0}}">
                          {% for wt in widget_types %}
                            <option value="{{wt.mount_point}}/{{wt.widget_name}}"
                                  {% if wt==w %}selected="selected"{% endif %}>{{wt.mount_point}} / {{wt.widget_name}}</option>
                          {% endfor %}
                        </select>
                      </td>
                      <td>
                        <input type="submit" name="divs-{{i}}.content-{{loop.index0}}.del"
                               value="Remove Widget"/>
                      </td>
                    </tr>
                    {% endfor %}
                  </tbody>
                </table>
                {% endif %}
              </div>
              <div class="push-3 span-14 clear last">
                <input type="submit" name="divs-{{loop.index0}}.new_widget" value="Add new widget"/>
              </div>
            </div>
            {% endfor %}
            
            <div class="clear">
              <input type="submit" name="new_div" value="Add new div"/>
            </div>
          </form>
{% endblock %}
