Merge pull request #2508 from tsiegleauq/userListPdfMake
Create the user list over pdfmake
This commit is contained in:
commit
447339ec33
@ -129,6 +129,15 @@ angular.module('OpenSlidesApp.core.pdf', [])
|
||||
listChild: {
|
||||
fontSize: 11,
|
||||
margin: [0,5]
|
||||
},
|
||||
tableHeader: {
|
||||
bold: true
|
||||
},
|
||||
tableEven: {
|
||||
fillColor: 'white'
|
||||
},
|
||||
tableOdd: {
|
||||
fillColor: '#e7e7e7'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
116
openslides/users/static/js/users/pdf.js
Normal file
116
openslides/users/static/js/users/pdf.js
Normal file
@ -0,0 +1,116 @@
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
angular.module('OpenSlidesApp.users.pdf', ['OpenSlidesApp.core.pdf'])
|
||||
|
||||
.factory('UserListContentProvider', [
|
||||
'gettextCatalog',
|
||||
'PdfPredefinedFunctions',
|
||||
function(gettextCatalog, PdfPredefinedFunctions) {
|
||||
|
||||
var createInstance = function(userList, groups) {
|
||||
|
||||
//use the Predefined Functions to create the title
|
||||
var title = PdfPredefinedFunctions.createTitle(gettextCatalog.getString("List of participants"));
|
||||
|
||||
//function to generate the user list
|
||||
var createUserList = function() {
|
||||
var userJsonList = [];
|
||||
|
||||
angular.forEach(userList, function (user, counter) {
|
||||
|
||||
//check if the row is even or odd
|
||||
var rowStyle = [];
|
||||
if (counter % 2 === 0) {
|
||||
rowStyle = 'tableEven';
|
||||
} else {
|
||||
rowStyle = 'tableOdd';
|
||||
}
|
||||
|
||||
//parse for the group names
|
||||
var userGroups = [];
|
||||
angular.forEach(user.groups_id, function (id) {
|
||||
if (id) {
|
||||
angular.forEach(groups, function(group) {
|
||||
if (id == group.id) {
|
||||
userGroups.push(gettextCatalog.getString(group.name));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
var userJsonObj = [
|
||||
{
|
||||
text: "" + (counter+1),
|
||||
style: rowStyle
|
||||
},
|
||||
{
|
||||
text: user.short_name,
|
||||
style: rowStyle
|
||||
},
|
||||
{
|
||||
text: user.structure_level,
|
||||
style: rowStyle
|
||||
},
|
||||
{
|
||||
text: userGroups.join(" "),
|
||||
style: rowStyle
|
||||
}
|
||||
];
|
||||
userJsonList.push(userJsonObj);
|
||||
});
|
||||
|
||||
var userTableBody = [
|
||||
[
|
||||
{
|
||||
text: '#',
|
||||
style: 'tableHeader'
|
||||
},
|
||||
{
|
||||
text: gettextCatalog.getString("Name"),
|
||||
style: 'tableHeader'
|
||||
},
|
||||
{
|
||||
text: gettextCatalog.getString("Structure level"),
|
||||
style: 'tableHeader'
|
||||
},
|
||||
{
|
||||
text: gettextCatalog.getString("Groups"),
|
||||
style: 'tableHeader'
|
||||
}
|
||||
]
|
||||
];
|
||||
userTableBody = userTableBody.concat((userJsonList));
|
||||
|
||||
var userTableJsonString = {
|
||||
table: {
|
||||
widths: ['auto', '*', 'auto', 'auto'],
|
||||
headerRows: 1,
|
||||
body: userTableBody
|
||||
},
|
||||
layout: 'headerLineOnly'
|
||||
};
|
||||
|
||||
return userTableJsonString;
|
||||
};
|
||||
|
||||
var getContent = function() {
|
||||
return [
|
||||
title,
|
||||
createUserList()
|
||||
];
|
||||
};
|
||||
|
||||
return {
|
||||
getContent: getContent
|
||||
};
|
||||
};
|
||||
|
||||
return {
|
||||
createInstance: createInstance
|
||||
};
|
||||
|
||||
}]);
|
||||
|
||||
}());
|
@ -2,7 +2,11 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
angular.module('OpenSlidesApp.users.site', ['OpenSlidesApp.users'])
|
||||
angular.module('OpenSlidesApp.users.site', [
|
||||
'OpenSlidesApp.users',
|
||||
'OpenSlidesApp.core.pdf',
|
||||
'OpenSlidesApp.users.pdf'
|
||||
])
|
||||
|
||||
.config([
|
||||
'mainMenuProvider',
|
||||
@ -423,7 +427,11 @@ angular.module('OpenSlidesApp.users.site', ['OpenSlidesApp.users'])
|
||||
'PasswordGenerator',
|
||||
'Projector',
|
||||
'ProjectionDefault',
|
||||
function($scope, $state, $http, ngDialog, UserForm, User, Group, PasswordGenerator, Projector, ProjectionDefault) {
|
||||
'UserListContentProvider',
|
||||
'PdfMakeDocumentProvider',
|
||||
'gettextCatalog',
|
||||
function($scope, $state, $http, ngDialog, UserForm, User, Group, PasswordGenerator, Projector, ProjectionDefault,
|
||||
UserListContentProvider, PdfMakeDocumentProvider, gettextCatalog) {
|
||||
User.bindAll({}, $scope, 'users');
|
||||
Group.bindAll({where: {id: {'>': 1}}}, $scope, 'groups');
|
||||
$scope.$watch(function () {
|
||||
@ -548,6 +556,13 @@ angular.module('OpenSlidesApp.users.site', ['OpenSlidesApp.users'])
|
||||
$scope.isSelectMode = false;
|
||||
$scope.uncheckAll();
|
||||
};
|
||||
|
||||
$scope.makePDF_userList = function () {
|
||||
var filename = gettextCatalog.getString("List of participants")+".pdf";
|
||||
var userListContentProvider = UserListContentProvider.createInstance($scope.users, $scope.groups);
|
||||
var documentProvider = PdfMakeDocumentProvider.createInstance(userListContentProvider);
|
||||
pdfMake.createPdf(documentProvider.getDocument()).download(filename);
|
||||
};
|
||||
}
|
||||
])
|
||||
|
||||
|
@ -21,7 +21,8 @@
|
||||
<span class="caret"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu" uib-dropdown-menu aria-labelledby="user-pdf-dropdown">
|
||||
<li><a ui-sref="user_listpdf" target="_blank">
|
||||
<li>
|
||||
<a ng-click="makePDF_userList()" class="btn">
|
||||
<i class="fa fa-list fa-fw"></i>
|
||||
<translate>List of participants</translate>
|
||||
</a>
|
||||
|
Loading…
Reference in New Issue
Block a user