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,44 +6,106 @@
|
||||||
{{'Edit' | translate}}
|
{{'Edit' | translate}}
|
||||||
</button>
|
</button>
|
||||||
</h1>
|
</h1>
|
||||||
<div class="panel panel-primary table-striped top5">
|
|
||||||
<div class="panel-heading">{{'Persons' | translate}}</div>
|
<div class="container">
|
||||||
<div class="panel-body">
|
<div class="row">
|
||||||
<form class="form-inline">
|
<div class="col-md-8">
|
||||||
<div class="form-group">
|
<div class="panel panel-primary table-striped top5">
|
||||||
<label for="query-persons">{{'Search:' | translate}}</label>
|
<div class="panel-heading">{{'Persons' | translate}}</div>
|
||||||
<input type="text" id="query-persons" class="form-control" placeholder="{{'Name or email' | translate}}" ng-model="query">
|
<div class="panel-body">
|
||||||
|
<form class="form-inline">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="query-persons">{{'Search:' | translate}}</label>
|
||||||
|
<input type="text" id="query-persons" class="form-control" placeholder="{{'Name or email' | translate}}" ng-model="query">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="persons-order">{{'Sort by:' | translate}}</label>
|
||||||
|
<select id="persons-order" class="form-control" ng-model="personsOrderProp">
|
||||||
|
<option value="name" ng-selected="selected">{{'Name' | translate}}</option>
|
||||||
|
<option value="-name" ng-selected="selected">{{'Name (descending)' | translate}}</option>
|
||||||
|
<option value="surname" ng-selected="selected">{{'Surname' | translate}}</option>
|
||||||
|
<option value="-surname" ng-selected="selected">{{'Surname (descending)' | translate}}</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<table class="table table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>{{'Person' | translate}}</th>
|
||||||
|
<th>{{'Email' | translate}}</th>
|
||||||
|
<th>{{'Attended' | translate}}</th>
|
||||||
|
<th>{{'Actions' | translate}}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<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>
|
||||||
|
<td>
|
||||||
|
<button ng-click="removeAttendee(person)" type="button" class="btn btn-link glyphicon glyphicon-trash"></button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
</div>
|
||||||
<label for="persons-order">{{'Sort by:' | translate}}</label>
|
|
||||||
<select id="persons-order" class="form-control" ng-model="personsOrderProp">
|
<div class="col-md-4">
|
||||||
<option value="name" ng-selected="selected">{{'Name' | translate}}</option>
|
|
||||||
<option value="-name" ng-selected="selected">{{'Name (descending)' | translate}}</option>
|
<div class="panel panel-info table-striped top5">
|
||||||
<option value="surname" ng-selected="selected">{{'Surname' | translate}}</option>
|
<div class="panel-heading">{{'Fast add' | translate}}</div>
|
||||||
<option value="-surname" ng-selected="selected">{{'Surname (descending)' | translate}}</option>
|
<div class="panel-body">
|
||||||
</select>
|
<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>
|
||||||
</form>
|
|
||||||
<table class="table table-striped">
|
<div class="panel panel-info table-striped top5">
|
||||||
<thead>
|
<div class="panel-heading">{{'Unregistered persons' | translate}}</div>
|
||||||
<tr>
|
<div class="panel-body" style="height:200px;overflow:auto;">
|
||||||
<th>{{'Person' | translate}}</th>
|
<table class="table table-striped table-condensed">
|
||||||
<th>{{'Attended' | translate}}</th>
|
<thead>
|
||||||
<th>{{'Actions' | translate}}</th>
|
<tr>
|
||||||
</tr>
|
<th>{{'Person' | translate}}</th>
|
||||||
</thead>
|
<th>{{'Add' | translate}}</th>
|
||||||
<tbody>
|
</tr>
|
||||||
<tr ng-repeat="person in event.persons | splittedFilter:query | orderBy:personsOrderProp">
|
</thead>
|
||||||
<td><strong><a ui-sref="person.info({id: person.person_id})">{{person.name}} {{person.surname}}</a></strong></td>
|
<tbody>
|
||||||
<td>
|
<tr ng-repeat="person in allPersons | splittedFilter:query">
|
||||||
<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>
|
||||||
</td>
|
<strong><a ui-sref="person.info({id: person.person_id})">{{person.name}} {{person.surname}}</a></strong>
|
||||||
<td>
|
<br />
|
||||||
<button ng-click="removeAttendee(person)" type="button" class="btn btn-link glyphicon glyphicon-trash"></button>
|
{{person.email}}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
<td>
|
||||||
</tbody>
|
<button ng-click="addAttendee(person)" type="button" class="btn btn-link glyphicon glyphicon-plus-sign"></button>
|
||||||
</table>
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</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',
|
eventManControllers.controller('EventDetailsCtrl', ['$scope', 'Event', 'Person', '$stateParams', '$log',
|
||||||
function ($scope, Event, $stateParams, $log) {
|
function ($scope, Event, Person, $stateParams, $log) {
|
||||||
$scope.personsOrderProp = 'name';
|
$scope.personsOrderProp = 'name';
|
||||||
$scope.eventsOrderProp = '-begin-date';
|
$scope.eventsOrderProp = '-begin-date';
|
||||||
if ($stateParams.id) {
|
if ($stateParams.id) {
|
||||||
$scope.event = Event.get($stateParams);
|
$scope.event = Event.get($stateParams);
|
||||||
|
$scope.allPersons = Person.all();
|
||||||
}
|
}
|
||||||
// store a new Event or update an existing one
|
// store a new Event or update an existing one
|
||||||
$scope.save = function() {
|
$scope.save = function() {
|
||||||
|
@ -75,6 +76,23 @@ eventManControllers.controller('EventDetailsCtrl', ['$scope', 'Event', '$statePa
|
||||||
$scope.eventForm.$dirty = false;
|
$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) {
|
$scope.updateAttendee = function(person, attended) {
|
||||||
$log.debug('EventDetailsCtrl.event_id: ' + $stateParams.id);
|
$log.debug('EventDetailsCtrl.event_id: ' + $stateParams.id);
|
||||||
$log.debug('EventDetailsCtrl.person_id: ' + person.person_id);
|
$log.debug('EventDetailsCtrl.person_id: ' + person.person_id);
|
||||||
|
|
Loading…
Reference in a new issue