<!-- show details of a Person -->
<div class="container">
    <h1>{{person.name}} {{person.surname}}
        <button ng-if="person._id" ng-click="$state.go('person.edit', {id: person._id})" class="btn btn-success">
            <span class="fa fa-pencil-square-o vcenter"></span>
            {{'Edit' | translate}}
        </button>
    </h1>
    <div class="panel panel-primary table-striped top5">
        <div class="panel-heading">Events</div>
        <div class="panel-body">
            <form class="form-inline">
                <div class="form-group">
                    <label for="query-persons">{{'Search:' | translate}}</label>
                    <input eventman-focus type="text" id="query-persons" class="form-control" placeholder="{{'Name or email' | translate}}" ng-model="query" ng-model-options="{debounce: 600}">
                </div>
                <div class="form-group">
                    <label for="events-order">{{'Sort by:' | translate}}</label>
                    <select id="events-order" class="form-control" ng-model="eventsOrderProp">
                        <option value="title">{{'Title' | translate}}</option>
                        <option value="-title">{{'Title (descending)' | translate}}</option>
                        <option value="begin_date">{{'Date' | translate}}</option>
                        <option value="-begin_date">{{'Date (descending)' | translate}}</option>
                    </select>
                </div>
            </form>
            <table class="table">
                <thead>
                    <tr>
                        <th>{{'Event' | translate}}</th>
                        <th class="text-center">{{'Registered' | translate}}</th>
                        <th class="text-center">{{'Attended' | translate}}</th>
                    </tr>
                </thead>
                <tbody>
                    <tr ng-repeat="event in events | splittedFilter:query | orderBy:eventsOrderProp">
                        <td><strong><a ui-sref="event.info({id: event._id})">{{event.title}}</a></strong></td>
                        <td class="text-center">
                            <button class="btn btn-link" name="switch-registered" ng-click="switchRegistered(event, person, !event.person_data.person_id)"><span class="fa fa-lg {{(event.person_data.person_id) && 'fa-check-circle text-success' || 'fa-times-circle text-danger'}}"></span></button>
                        </td>
                        <td class="text-center">
                            <button ng-disabled="!event.person_data.person_id" class="btn btn-link" name="switch-attended" ng-click="setPersonAttributeAtEvent(event, 'attended', !event.person_data.attended)"><span class="fa fa-lg {{(event.person_data.attended) && 'fa-check-circle text-success' || 'fa-times-circle text-danger'}}"></span></button>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
</div>

