<div class="tdy-table" ng-init="init.home()">
    <div class="page-title page-header">
        <h1 class="h3">Contests</h1>
    </div>

    <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 Contest" 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-play"></i></span>Create Contest</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="player-count">Players</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()" >Contests are empty.</a></td>
                </tr>
                <tr class="clickable" ng-if="!grid.isLoading" ng-repeat="contest in grid.items">
                    <td class="id" ng-bind="contest.row"></td>
                    <td class="name"><a ui-sref="contest({ con: contest.id })" ng-bind="contest.name"></a></td>
                    <td class="player-count" ng-click="modalEditActions.show(contest.id)">
                        {{ contest.joinedPlayers }}/{{ contest.maxPlayers }}
                    </td>
                    <td class="actions actions-lg">
                        <a type="button" bs-tooltip title="View" class="btn btn-labeled btn-xs btn-info" ui-sref="contest({ con: contest.id })" ><i class="fa fa-file"></i></a>
                        <button type="button" bs-tooltip title="Edit" ng-click="modalEditActions.show(contest.id)" class="btn btn-labeled btn-xs btn-info"><i class="fa fa-pencil"></i></button>
                        <button type="button" bs-tooltip title="Reset" ng-click="modalResetActions.show(contest.id)" class="btn btn-labeled btn-xs btn-warning"><i class="fa fa-refresh"></i></button>
                        <button type="button" bs-tooltip title="Delete" ng-click="modalDeleteActions.show(contest.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>
