<div class="tdy-table" ng-init="init.home()">
    <div class="section section-top">
        <div class="row">
            <div class="col-sm-6">
                <form method="get" ng-submit="grid.call()" class="form">
                    <div class="form-group">
                        <div class="input-group col-sm-8">
                            <input type="text" class="input-search form-control" name="q" placeholder="Search Team" value="" ng-model="grid.queryString.q">
                            <span class="input-group-btn">
                                <button type="submit" class="btn btn-default btn-clear"><i class="fa fa-search"></i></button>
                                <button type="button" class="btn btn-default btn-clear" ng-click="grid.refresh()"><i class="fa fa-refresh"></i></button>
                            </span>
                        </div>
                    </div>
                </form>
            </div>
            <div class="col-sm-6 text-right">
                <button type="button" ng-click="modalAddActions.show()" class="btn btn-labeled btn-primary"><span class="btn-label"><i class="fa fa-plus"></i></span>Add Team</button>
            </div>
        </div>
    </div>
    <div class="tdy-table-container">
        <div class="tdy-table-wrapper">
            <table class="table table-bordered table-striped table-hover" fsa-table>
                <thead>
                <tr>
                    <th class="id">#</th>
                    <th class="name">Name</th>
                    <th class="collection">Sport</th>
                    <th class="collection">League</th>
                    <th class="collection">Group</th>
                    <th class="actions actions-md">Actions</th>
                </tr>
                </thead>
                <tbody class="overflowable">
                <tr ng-if="grid.isLoading">
                    <td colspan="10">Loading, please wait...</td>
                </tr>
                <tr ng-if="!grid.isLoading && grid.results.totalItems == 0 && grid.results.totalItems != null">
                    <td colspan="10">
                        No results found. <a href="#" ng-if="grid.queryString.q == ''" ng-click="modalAddActions.show()" >Add at least one team.</a></td>
                </tr>
                <tr class="clickable" ng-if="!grid.isLoading" ng-repeat="team in grid.items">
                    <td class="id" ng-click="modalEditActions.show(team.id)" ng-bind="team.row"></td>
                    <td class="name" ng-click="modalEditActions.show(team.id)" ng-bind="team.name"></td>
                    <td class="collection" ng-click="modalEditActions.show(team.id)" ng-bind="team.sport.name"></td>
                    <td class="collection" ng-click="modalEditActions.show(team.id)" ng-bind="team.league.name"></td>
                    <td class="collection" ng-click="modalEditActions.show(team.id)" ng-bind="team.group.name"></td>
                    <td class="actions actions-md">
                        <button type="button" data-title="Edit" bs-tooltip ng-click="modalEditActions.show(team.id)" class="btn btn-labeled btn-xs btn-info"><i class="fa fa-pencil"></i></button>
                        <button type="button" data-title="Delete" ng-click="modalDeleteActions.show(team.id)" class="btn btn-labeled btn-xs btn-danger"><i class="fa fa-trash-o"></i></button>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>
    </div>
    <div class="section section-btm">
        <uib-pagination
                class="pull-right pagination"
                ng-model="grid.pagination.currentPage"
                total-items="grid.results.totalItems"
                items-per-page="grid.pagination.pageSize"
                max-size="5"
                boundary-links="true"
                ng-change="grid.selectPage()"
                previous-text="&lsaquo;"
                next-text="&rsaquo;"
                first-text="&laquo;"
                last-text="&raquo;">
        </uib-pagination>
    </div>
</div>
