fast add of a person in the event info page
This commit is contained in:
parent
835667e32a
commit
484a543b4c
2 changed files with 118 additions and 38 deletions
|
@ -6,6 +6,10 @@
|
|||
{{'Edit' | translate}}
|
||||
</button>
|
||||
</h1>
|
||||
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<div class="panel panel-primary table-striped top5">
|
||||
<div class="panel-heading">{{'Persons' | translate}}</div>
|
||||
<div class="panel-body">
|
||||
|
@ -28,6 +32,7 @@
|
|||
<thead>
|
||||
<tr>
|
||||
<th>{{'Person' | translate}}</th>
|
||||
<th>{{'Email' | translate}}</th>
|
||||
<th>{{'Attended' | translate}}</th>
|
||||
<th>{{'Actions' | translate}}</th>
|
||||
</tr>
|
||||
|
@ -35,6 +40,7 @@
|
|||
<tbody>
|
||||
<tr ng-repeat="person in event.persons | splittedFilter:query | orderBy:personsOrderProp">
|
||||
<td><strong><a ui-sref="person.info({id: person.person_id})">{{person.name}} {{person.surname}}</a></strong></td>
|
||||
<td>{{person.email}}</td>
|
||||
<td>
|
||||
<button class="btn btn-link" name="switch-attended" ng-click="updateAttendee(person, !person.attended)"><span class="glyphicon {{(person.attended) && 'glyphicon-ok-sign text-success' || 'glyphicon-remove-sign text-danger'}}"></span></button>
|
||||
</td>
|
||||
|
@ -46,4 +52,60 @@
|
|||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
|
||||
<div class="panel panel-info table-striped top5">
|
||||
<div class="panel-heading">{{'Fast add' | translate}}</div>
|
||||
<div class="panel-body">
|
||||
<form>
|
||||
<div class="input-group input-group-sm">
|
||||
<span class="input-group-addon">{{'Name' | translate}}</span>
|
||||
<input type="text" class="form-control" placeholder="{{'Name' | translate}}" ng-model="newPerson.name" ng-required="1">
|
||||
</div>
|
||||
<div class="input-group input-group-sm top5">
|
||||
<span class="input-group-addon">{{'Surname' | translate}}</span>
|
||||
<input type="text" class="form-control" placeholder="{{'Surname' | translate}}" ng-model="newPerson.surname">
|
||||
</div>
|
||||
<div class="input-group top5">
|
||||
<span class="input-group-addon">{{'Email' | translate}}</span>
|
||||
<input type="email" name="email" class="form-control" placeholder="{{'name.surname@example.com' | translate}}" ng-model="newPerson.email">
|
||||
</div>
|
||||
<button ng-disabled="!(newPerson.name && newPerson.surname)" ng-click="fastAddPerson(newPerson)" class="btn btn-success top5">
|
||||
<span class="glyphicon glyphicon-plus-sign"></span>
|
||||
{{'Add' | translate}}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel panel-info table-striped top5">
|
||||
<div class="panel-heading">{{'Unregistered persons' | translate}}</div>
|
||||
<div class="panel-body" style="height:200px;overflow:auto;">
|
||||
<table class="table table-striped table-condensed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{'Person' | translate}}</th>
|
||||
<th>{{'Add' | translate}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="person in allPersons | splittedFilter:query">
|
||||
<td>
|
||||
<strong><a ui-sref="person.info({id: person.person_id})">{{person.name}} {{person.surname}}</a></strong>
|
||||
<br />
|
||||
{{person.email}}
|
||||
</td>
|
||||
<td>
|
||||
<button ng-click="addAttendee(person)" type="button" class="btn btn-link glyphicon glyphicon-plus-sign"></button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
22
angular_app/js/controllers.js
vendored
22
angular_app/js/controllers.js
vendored
|
@ -53,12 +53,13 @@ eventManControllers.controller('EventsListCtrl', ['$scope', 'Event',
|
|||
);
|
||||
|
||||
|
||||
eventManControllers.controller('EventDetailsCtrl', ['$scope', 'Event', '$stateParams', '$log',
|
||||
function ($scope, Event, $stateParams, $log) {
|
||||
eventManControllers.controller('EventDetailsCtrl', ['$scope', 'Event', 'Person', '$stateParams', '$log',
|
||||
function ($scope, Event, Person, $stateParams, $log) {
|
||||
$scope.personsOrderProp = 'name';
|
||||
$scope.eventsOrderProp = '-begin-date';
|
||||
if ($stateParams.id) {
|
||||
$scope.event = Event.get($stateParams);
|
||||
$scope.allPersons = Person.all();
|
||||
}
|
||||
// store a new Event or update an existing one
|
||||
$scope.save = function() {
|
||||
|
@ -75,6 +76,23 @@ eventManControllers.controller('EventDetailsCtrl', ['$scope', 'Event', '$statePa
|
|||
$scope.eventForm.$dirty = false;
|
||||
};
|
||||
|
||||
$scope.fastAddPerson = function(newPerson) {
|
||||
$log.debug('EventDetailsCtrl.fastAddPerson.newPerson:');
|
||||
$log.debug(newPerson);
|
||||
var person = new Person(newPerson);
|
||||
person.$save(function(p) {
|
||||
var data = angular.copy(p);
|
||||
data.person_id = data._id;
|
||||
data._id = $stateParams.id;
|
||||
data.attended = true;
|
||||
Event.addAttendee(data, function() {
|
||||
$scope.event = Event.get($stateParams);
|
||||
$scope.allPersons = Person.all();
|
||||
$scope.newPerson = {};
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.updateAttendee = function(person, attended) {
|
||||
$log.debug('EventDetailsCtrl.event_id: ' + $stateParams.id);
|
||||
$log.debug('EventDetailsCtrl.person_id: ' + person.person_id);
|
||||
|
|
Loading…
Reference in a new issue