fixes #149: export tickets in CSV format
This commit is contained in:
parent
a6d60a0e10
commit
f338da9078
7 changed files with 5748 additions and 11 deletions
|
@ -23,13 +23,23 @@
|
|||
</h1>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<form class="form-inline">
|
||||
<div class="form-group">
|
||||
<label for="query-tickets">{{'Search:' | translate}}</label>
|
||||
<input eventman-focus type="text" id="query-tickets" class="form-control" placeholder="{{'Name or email' | translate}}" ng-model="query" ng-model-options="{debounce: 350}">
|
||||
</div> <label> <input type="checkbox" ng-model="registeredFilterOptions.all" /> {{'Show cancelled tickets' | translate}}</label>
|
||||
</form>
|
||||
<uib-pagination ng-model="currentPage" total-items="filteredLength" items-per-page="itemsPerPage"
|
||||
<div>
|
||||
<div style="float:left;">
|
||||
<form class="form-inline">
|
||||
<div class="form-group">
|
||||
<label for="query-tickets">{{'Search:' | translate}}</label>
|
||||
<input eventman-focus type="text" id="query-tickets" class="form-control" placeholder="{{'Name or email' | translate}}" ng-model="query" ng-model-options="{debounce: 350}">
|
||||
</div> <label> <input type="checkbox" ng-model="registeredFilterOptions.all" /> {{'Show cancelled tickets' | translate}}</label>
|
||||
</form>
|
||||
</div>
|
||||
<div style="float:right;">
|
||||
<span style="color:#9e9e9e;">({{filteredLength}} {{'filtered item/s' | translate}})</span>
|
||||
<a download="eventman.csv" ng-href="{{downloadURL}}" class="btn btn-primary" ng-class="{disabled: !filteredLength}"><span class="fa fa-download"></span> {{'export CSV' | translate}}</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="clearfix"></div>
|
||||
<uib-pagination ng-model="currentPage" total-items="filteredLength" items-per-page="itemsPerPage"
|
||||
direction-links="false" boundary-links="true" boundary-link-numbers="true" max-size="maxPaginationSize">
|
||||
</uib-pagination>
|
||||
<table class="table table-striped">
|
||||
|
@ -73,7 +83,7 @@
|
|||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<uib-pagination ng-model="currentPage" total-items="filteredLength" items-per-page="itemsPerPage"
|
||||
<uib-pagination ng-model="currentPage" total-items="filteredLength" items-per-page="itemsPerPage"
|
||||
direction-links="false" boundary-links="true" boundary-link-numbers="true" max-size="maxPaginationSize">
|
||||
</uib-pagination>
|
||||
</div>
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
<script type="text/javascript" src="/static/js/api-check.min.js"></script>
|
||||
<script type="text/javascript" src="/static/js/formly.min.js"></script>
|
||||
<script type="text/javascript" src="/static/js/angular-formly-templates-bootstrap.min.js"></script>
|
||||
<script type="text/javascript" src="/static/js/json2csv.min.js"></script>
|
||||
|
||||
<script type="text/javascript" src="/static/js/eventman.js"></script>
|
||||
<script type="text/javascript" src="/js/app.js"></script>
|
||||
|
|
5
angular_app/js/app.js
vendored
5
angular_app/js/app.js
vendored
|
@ -105,8 +105,9 @@ eventManApp.run(['$rootScope', '$state', '$stateParams', '$log', 'Info',
|
|||
|
||||
|
||||
/* Configure the states. */
|
||||
eventManApp.config(['$stateProvider', '$urlRouterProvider',
|
||||
function($stateProvider, $urlRouterProvider) {
|
||||
eventManApp.config(['$stateProvider', '$urlRouterProvider', '$compileProvider',
|
||||
function($stateProvider, $urlRouterProvider, $compileProvider) {
|
||||
$compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|tel|file|blob):/);
|
||||
$urlRouterProvider.otherwise('/events');
|
||||
$stateProvider
|
||||
.state('events', {
|
||||
|
|
16
angular_app/js/controllers.js
vendored
16
angular_app/js/controllers.js
vendored
|
@ -202,6 +202,7 @@ eventManControllers.controller('EventTicketsCtrl', ['$scope', '$state', 'Event',
|
|||
$scope.shownItems = [];
|
||||
$scope.ticket = {}; // current ticket, for the event.ticket.* states
|
||||
$scope.tickets = []; // list of all tickets, for the 'tickets' state
|
||||
$scope.filteredTickets = [];
|
||||
$scope.formSchema = {};
|
||||
$scope.formData = {};
|
||||
$scope.guiOptions = {dangerousActionsEnabled: false};
|
||||
|
@ -221,9 +222,11 @@ eventManControllers.controller('EventTicketsCtrl', ['$scope', '$state', 'Event',
|
|||
tickets = $filter('splittedFilter')(tickets, $scope.query);
|
||||
tickets = $filter('registeredFilter')(tickets, $scope.registeredFilterOptions);
|
||||
tickets = $filter('orderBy')(tickets, $scope.ticketsOrder);
|
||||
$scope.filteredLength = tickets.length;
|
||||
$scope.filteredTickets = angular.copy(tickets);
|
||||
$scope.filteredLength = $scope.filteredTickets.length;
|
||||
tickets = $filter('pagination')(tickets, $scope.currentPage, $scope.itemsPerPage);
|
||||
$scope.shownItems = tickets;
|
||||
$scope.updateCSV();
|
||||
};
|
||||
|
||||
$scope.$watch('query', function() {
|
||||
|
@ -663,6 +666,17 @@ eventManControllers.controller('EventTicketsCtrl', ['$scope', '$state', 'Event',
|
|||
$scope.filterTickets();
|
||||
};
|
||||
|
||||
$scope.updateCSV = function() {
|
||||
if (!$scope.filteredTickets.length) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
var csv = json2csv({data: $scope.filteredTickets});
|
||||
var blob = new Blob([csv], {type: 'text/csv'});
|
||||
$scope.downloadURL = (window.URL || window.webkitURL).createObjectURL(blob);
|
||||
} catch(err) {}
|
||||
};
|
||||
|
||||
$scope.$on('$destroy', function() {
|
||||
$scope.EventUpdates && $scope.EventUpdates.close();
|
||||
});
|
||||
|
|
5707
static/js/json2csv.js
Normal file
5707
static/js/json2csv.js
Normal file
File diff suppressed because it is too large
Load diff
3
static/js/json2csv.min.js
vendored
Normal file
3
static/js/json2csv.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
static/js/json2csv.min.js.map
Normal file
1
static/js/json2csv.min.js.map
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue