<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:py="http://genshi.edgewall.org/"
      xmlns:xi="http://www.w3.org/2001/XInclude">

  <xi:include href="master.html" />
  <xi:include href="lib.html" />

  <?python from pyforge.lib.security import has_project_access ?>

  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="content-type" py:replace="''"/>
    <title>Project Homepage for $c.project._id</title>
    <link rel="stylesheet" type="text/css" 
          href="${g.app_static('css/project_home.css')}"/>
  </head>
  
  <body>
    <h1 class="title">Configure Dashboard for $c.project.name</h1>
    <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" selected="${layout_class=='onecol' or None}">
            One Column</option>
          <option value="twocol" selected="${layout_class=='twocol' or None}">
            Two Column</option>
        </select>
      </div>
      <div class="span-5 last">
        <input type="submit" value="Update Layout" class="ui-state-default ui-button ui-button-text"/>
      </div>
      <div py:for="i, div in enumerate(layout)" style="margin-bottom: 1em; border: 1px solid #ddd" class="span-18 last">
        <div class="span-3 clear"><label for="divs-${i}.name">Div Name</label></div>
        <div class="span-14 last">
          <input name="divs-${i}.name" id="divs-${i}.name" value="$div.name" class="title span-10"/> &nbsp;
          <input type="submit" name="divs-${i}.del" value="Remove Div" class="ui-state-default ui-button ui-button-text"/>
        </div>
        <div class="span-3 clear"><label>Widgets</label></div>
        <div class="span-14 last">
          <span py:if="not len(div.content)">No widgets have been added.</span>
          <table py:if="len(div.content)">
            <thead>
              <tr>
                <th>Widget</th>
                <th>Remove</th>
              </tr>
            </thead>
            <tbody>
              <tr py:for="j, w in enumerate(div.content)" class="${j%2 and 'even' or ''}">
                <td>
                  <select name="divs-${i}.content-${j}.widget" id="divs-${i}.content-${j}">
                    <option py:for="wt in widget_types"
                            value="$wt.mount_point/$wt.widget_name"
                            selected="${wt==w or None}">$wt.mount_point / $wt.widget_name</option>
                  </select>
                </td>
                <td>
                  <input type="submit" name="divs-${i}.content-${j}.del"
                         value="Remove Widget" class="ui-state-default ui-button ui-button-text"/>
                </td>
              </tr>
            </tbody>
          </table>
        </div>
        <div class="push-3 span-14 clear last">
          <input type="submit" name="divs-${i}.new_widget" value="Add new widget" class="ui-state-default ui-button ui-button-text"/>
        </div>
      </div>
      <div class="clear">
        <input type="submit" name="new_div" value="Add new div" class="ui-state-default ui-button ui-button-text"/>
      </div>
    </form>
  </body>
</html>
