<div growl></div>
<nav class="navbar navbar-inverse" role="navigation">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-collapsable">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand strong" href="#">Task Dashboard - Users</a>
        </div>
        <div class="collapse navbar-collapse" id="navbar-collapsable">
            <ul class="nav navbar-nav navbar-right">
                <li>
                    <a href="#">{{ username }}</a>
                    </li>
                    <li>
                    <a href="" ng-click="logout()">Logout</a>
                    </li>
            </ul>
        </div>
</nav>


<table class="table table-condensed ng-table-resizable-columns table-striped" ng-table="vm.tableParams">
    <tr ng-repeat="task in userData">
        <td data-title="'#ID'" class="text-center">{{ task.id }}</td>
        <td data-title="'Task'" class="text-center">{{ task.title | limitTo: 25 }}{{task.title.length > 25 ? '...' : ''}}</td>
        <td data-title="'Description'" class="text-center">{{ task.description | limitTo: 40 }}{{task.description.length > 40 ? '...' : ''}}</td>
        <td data-title="'Status'" class="text-center">
            <span ng-show="task.closed" class="label label-success">Completed</span>
            <span ng-show="!task.closed" class="label label-warning">In Progress</span>
        </td>
        <td data-title="'Operations'" class="text-center">
            <button ng-click="update(task)" class="btn btn-default">Edit</button>
            <button ng-click="remove(task)" class="btn btn-default">Delete</button>
            <span ng-show="task.closed">
                <button ng-click="toggleTask(task)" class="btn btn-default">Mark In Progress</button>
            </span>
            <span ng-show="!task.closed">
                <button ng-click="toggleTask(task)" class="btn btn-default">Mark Completed</button>
            </span>
        </td>
    </tr>
</table>

<button class="btn btn-primary" ng-click="open()">Add Task</button>

<script type="text/ng-template" id="myModalContent.html">
    <div class="modal-header">
        <h3>Add Task</h3>
    </div>
    <div class="modal-body">
        <form class="form-horizontal"> <!--ng-submit="submit()" -->
            <div class="form-group">
                <label for="task" class="col-sm-2 control-label">Task</label>
                <div class="col-sm-10">
                    <input id="task" class="form-control" placeholder="Enter Task Name" type="text" ng-model="task.name" />
                </div>
            </div>
            <div class="form-group">
                <label for="desc" class="col-sm-2 control-label">Description</label>
                <div class="col-sm-10">
                    <input id="desc" class="form-control" placeholder="Enter Description" type="text" ng-model="task.description" />
                </div>
            </div>
        </form>
    </div>
    <div class="modal-footer">
        <button class="btn btn-primary" type="button" ng-click="submitTask()">Add Task</button>
        <button class="btn btn-warning" ng-click="cancel()" aria-hidden="true">Cancel</button>
    </div>
</script>

<script type="text/ng-template" id="myModalUpdate.html">
    <div class="modal-header">
        <h3>Update Task</h3>
    </div>
    <div class="modal-body">
        <form class="form-horizontal"> <!--ng-submit="submit()" -->
            <div class="form-group">
                <label for="task" class="col-sm-2 control-label">Task</label>
                <div class="col-sm-10">
                    <input id="task" class="form-control" placeholder="Enter Task Name" type="text" ng-model="task.title" />
                </div>
            </div>
            <div class="form-group">
                <label for="desc" class="col-sm-2 control-label">Description</label>
                <div class="col-sm-10">
                    <input id="desc" class="form-control" placeholder="Enter Description" type="text" ng-model="task.description" />
                </div>
            </div>
        </form>
    </div>
    <div class="modal-footer">
        <button class="btn btn-primary" type="button" ng-click="updateTask()">Update Task</button>
        <button class="btn btn-warning" ng-click="cancel()" aria-hidden="true">Cancel</button>
    </div>
</script>

<script type="text/ng-template" id="myModalRemove.html">
    <div>
      <div class="modal-header">
        <h3 class="modal-title">Confirm task deletion</h3>
      </div>
      <div class="modal-body">
        <p>Would you wish to delete task "{{ task.title }}" ?</p>
      </div>
      <div class="modal-footer">
        <button class="btn btn-warning" ng-click="deleteTask()">Yes</button>
        <button class="btn btn-primary" ng-click="cancel()">Cancel</button>
      </div>
    </div>
</script>
