<script type="text/ng-template" id="todoItemTemplate">
  <div ui-tree-handle class="tree-node tree-node-content">
    <input type="checkbox"
           ng-hide="showSkipped"
           ng-model="todo.completed"
           ng-change="updateTodo(todo)">
    <label ng-class="{'text-danger': isInDanger(todo)}">
      <span ng-click="toggleTodo(todo, this)">
        <i aria-hidden="true" ng-if="todo.items && todo.items.length > 0" data-nodrag
          class="fa"
          ng-class="{
            'skipped-todos': showSkipped,
            'fa-caret-right': collapsed,
            'fa-caret-down': !collapsed
          }"></i>
        <i class="fa fa-circle-o" aria-hidden="true" ng-if="(!todo.items || todo.items.length === 0) && showSkipped" data-nodrag></i>
        <span ng-hide="!todo.items || todo.items.length < 1 || showSkipped">[{{ ( filterTodoList(todo.items, showSkipped) | filter: { completed: true } ).length }}/{{ filterTodoList(todo.items, showSkipped).length }}] </span>
        <span class="todo__role">{{steps[todo.step].name}}:&nbsp;</span>
        <span class="todo__description" ng-bind-html="todo.title" linkify></span>
        <span ng-class="{'todo__dates': true, 'todo__dates-danger': isInDanger(todo)}">
          <span ng-if="isNonEmptyString(todo.start_by_datetime)">
            Start <datetime-display datetime="todo.start_by_datetime" show-time="true"/>
          </span>
          <span ng-if="isNonEmptyString(todo.start_by_datetime) && isNonEmptyString(todo.due_datetime)" class="todo__dates-separator">|</span>
          <span ng-if="isNonEmptyString(todo.due_datetime)">
            Due <datetime-display datetime="todo.due_datetime" show-time="true"/></span>
        </span>
      </span>
      <span ng-if="templates.length > 0">
        &nbsp;&nbsp;
        <a href="#" ng-hide="!showSkipped" ng-click="unskipTodo(todo)">[relevant]</a>
        <a href="#" ng-hide="showSkipped" ng-click="skipTodo(todo)">[not relevant]</a>
        <a href="#" ng-hide="todo.parent_todo" ng-click="removeTodo(todo)">[remove]</a>
      </span>
    </label>
    <div class="todo-qa panel panel-default" ng-if="todoQas[todo.title] && todoQas[todo.title].comment">
      <div class="panel-body">
        <span>{{todoQas[todo.title].todo === todo.id?"Feedback on this project":"Feedback from previous project"}}:</span>
        <strong>{{todoQas[todo.title].comment}}</strong>
      </div>
    </div>
  </div>
  <ol ui-tree-nodes ng-model="todo.items" ng-class="{hidden: collapsed}" ng-if="!collapsed">
    <li ng-repeat="todo in filterTodoList(todo.items, showSkipped)" ui-tree-node data-collapsed="isCollapsed(todo, showSkipped)" ng-include="'todoItemTemplate'"></li>
  </ol>
</script>


<div class="list-by-status" ng-if="todos.length > 0">
  <div class="todo">
    <div ui-tree data-drag-enabled="false" id="tree-root">
      <ol ui-tree-nodes ng-model="todos">
        <li ng-repeat="todo in filterTodoList(todos, showSkipped)" ui-tree-node data-collapsed="isCollapsed(todo, showSkipped)" ng-include="'todoItemTemplate'"></li>
      </ol>
    </div>
  </div>
</div>
