<html py:extends="master.xhtml" py:strip="True">
<head py:block="head" py:strip="True">
  <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" py:if="False"/>
</head>

<body py:block="body" py:strip="True">
  <link rel="stylesheet" type="text/css" media="screen" href="${tg.url('/_pluggable/tgappcategories/css/style.css')}" />
  <div class="row categories-toolbar">
    <div class="col-md-10 col-md-offset-1">
      <a href="${tg.url(mount_point + '/new_category')}" class="pull-right btn btn-success">
        <span class="glyphicon glyphicon-plus" aria-hidden="true"/> Create
      </a>
    </div>
  </div>
  <div class="col-md-10 col-md-offset-1">
    <div class="tgappcategories-list">
      <table class="table table-striped">
        <thead>
          <tr>
            <th>Actions</th>
            <th>Small Image</th>
            <th>Name</th>
            <th>Description</th>
            <th>Big Image</th>
          </tr>
        </thead>
        <tbody>
          <tr py:for="cat in categories">
            <td>
              <a href="${tg.url(mount_point + '/edit_category/' +
                         h.tgappcategories.instance_primary_key(cat, True))}"
                 class="tgappcategories-edit btn btn-primary">
                <span class="glyphicon glyphicon-pencil"/>
              </a>
              <a href="${tg.url(mount_point + '/delete_category/' +
                         h.tgappcategories.instance_primary_key(cat, True))}"
                 class="tgappcategories-delete btn btn-danger col col-md1"
                 onclick="return confirm('Are you sure?')">
                <span class="glyphicon glyphicon-trash"/>
              </a>
            </td>
            <td>
              <img py:if="h.tgappcategories.content_of_first_small_image(cat)"
                   src="${h.tgappcategories.content_of_first_small_image(cat).url}"
                   class="small-image"/>
            </td>
            <td>
              <span class="col-xs-12">
		<py:for each="d in range(1, cat.depth)" strip="True">
		  <span style="padding-right: 12px" class="depth-marker">|</span>
		</py:for>
		<b>${cat.name}</b>
	      </span>
            </td>
            <td>
              <span class="col-md-5 col-xs-12">${cat.description}</span>
            </td>
            <td>
              <a py:if="h.tgappcategories.content_of_first_big_image(cat)"
                 href="${h.tgappcategories.content_of_first_big_image(cat).url}"
                 target="_blank">Open</a>
            </td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>
</body>
</html>
