closes #26: sort by columns, in the event details page
This commit is contained in:
parent
0d8f443ac7
commit
64930ef7c2
2 changed files with 24 additions and 16 deletions
|
@ -35,29 +35,20 @@
|
||||||
<label for="query-persons">{{'Search:' | translate}}</label>
|
<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">
|
<input eventman-focus type="text" id="query-persons" class="form-control" placeholder="{{'Name or email' | translate}}" ng-model="query">
|
||||||
</div>
|
</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>
|
</form>
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>{{'Person' | translate}}</th>
|
<th>{{'Person' | translate}} <a ng-click="updateOrded('name')" href=""><i class="fa fa-caret-up"></i></a>{{'Name' | translate}}<a ng-click="updateOrded('-name')" href=""><i class="fa fa-caret-down"></i></a> <a ng-click="updateOrded('surname')" href=""><i class="fa fa-caret-up"></i></a>{{'Surname' | translate}}<a ng-click="updateOrded('-surname')" href=""><i class="fa fa-caret-down"></i></a></th>
|
||||||
<th>{{'Attended' | translate}}</th>
|
<th><a ng-click="updateOrded('-attended')" href=""><i class="fa fa-caret-up"></i></a>{{'Attended' | translate}}<a ng-click="updateOrded('attended')" href=""><i class="fa fa-caret-down"></i></a></th>
|
||||||
<th ng-repeat="col in customFields">
|
<th ng-repeat="col in customFields">
|
||||||
<strong>{{col.label | translate}}</strong>
|
<a ng-click="updateOrded(col.key)" href=""><i class="fa fa-caret-up"></i></a>{{col.label | translate}}<a ng-click="updateOrded('-' + col.key)" href=""><i class="fa fa-caret-down"></i></a>
|
||||||
</th>
|
</th>
|
||||||
<th>{{'Delete' | translate}}</th>
|
<th>{{'Delete' | translate}}</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr ng-repeat="person in event.persons | splittedFilter:query | orderBy:personsOrderProp">
|
<tr ng-repeat="person in event.persons | splittedFilter:query | orderBy:personsOrder">
|
||||||
<td>
|
<td>
|
||||||
<span><strong><a ui-sref="person.info({id: person.person_id})"><span>{{person.name}}</span> <span>{{person.surname}}</span></a></strong></span><span ng-if="person.email"> <{{person.email}}></span>
|
<span><strong><a ui-sref="person.info({id: person.person_id})"><span>{{person.name}}</span> <span>{{person.surname}}</span></a></strong></span><span ng-if="person.email"> <{{person.email}}></span>
|
||||||
<p ng-if="person.company || person.job_title"><i ng-if="person.job_title">{{person.job_title}}</i><span ng-if="person.company && person.job_title"> @ </span><i ng-if="person.company">{{person.company}}</i></p>
|
<p ng-if="person.company || person.job_title"><i ng-if="person.job_title">{{person.job_title}}</i><span ng-if="person.company && person.job_title"> @ </span><i ng-if="person.company">{{person.company}}</i></p>
|
||||||
|
|
23
angular_app/js/controllers.js
vendored
23
angular_app/js/controllers.js
vendored
|
@ -55,8 +55,7 @@ eventManControllers.controller('EventsListCtrl', ['$scope', 'Event',
|
||||||
|
|
||||||
eventManControllers.controller('EventDetailsCtrl', ['$scope', 'Event', 'Person', 'EventUpdates', '$stateParams', 'Setting', '$log',
|
eventManControllers.controller('EventDetailsCtrl', ['$scope', 'Event', 'Person', 'EventUpdates', '$stateParams', 'Setting', '$log',
|
||||||
function ($scope, Event, Person, EventUpdates, $stateParams, Setting, $log) {
|
function ($scope, Event, Person, EventUpdates, $stateParams, Setting, $log) {
|
||||||
$scope.personsOrderProp = 'name';
|
$scope.personsOrder = ["name", "surname"];
|
||||||
$scope.eventsOrderProp = '-begin-date';
|
|
||||||
$scope.countAttendees = 0;
|
$scope.countAttendees = 0;
|
||||||
$scope.message = {};
|
$scope.message = {};
|
||||||
$scope.event = {};
|
$scope.event = {};
|
||||||
|
@ -89,6 +88,25 @@ eventManControllers.controller('EventDetailsCtrl', ['$scope', 'Event', 'Person',
|
||||||
$scope.allPersons = Person.all();
|
$scope.allPersons = Person.all();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$scope.updateOrded = function(key) {
|
||||||
|
var new_order = [key];
|
||||||
|
var inv_key;
|
||||||
|
if (key && key[0] === '-') {
|
||||||
|
inv_key = key.substring(1);
|
||||||
|
} else {
|
||||||
|
inv_key = '-' + key;
|
||||||
|
}
|
||||||
|
angular.forEach($scope.personsOrder,
|
||||||
|
function(value, idx) {
|
||||||
|
if (value !== key && value !== inv_key) {
|
||||||
|
new_order.push(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
$scope.personsOrder = new_order;
|
||||||
|
$log.debug(new_order);
|
||||||
|
};
|
||||||
|
|
||||||
// store a new Event or update an existing one
|
// store a new Event or update an existing one
|
||||||
$scope.save = function() {
|
$scope.save = function() {
|
||||||
// avoid override of event.persons list.
|
// avoid override of event.persons list.
|
||||||
|
@ -202,7 +220,6 @@ eventManControllers.controller('EventDetailsCtrl', ['$scope', 'Event', 'Person',
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.$on('$destroy', function() {
|
$scope.$on('$destroy', function() {
|
||||||
$log.debug('destroying controller');
|
|
||||||
$scope.EventUpdates && $scope.EventUpdates.close();
|
$scope.EventUpdates && $scope.EventUpdates.close();
|
||||||
});
|
});
|
||||||
}]
|
}]
|
||||||
|
|
Loading…
Reference in a new issue