diff --git a/openslides/assignments/static/js/assignments/pdf.js b/openslides/assignments/static/js/assignments/pdf.js
index 24c4c95fa..f0f66b89c 100644
--- a/openslides/assignments/static/js/assignments/pdf.js
+++ b/openslides/assignments/static/js/assignments/pdf.js
@@ -9,16 +9,16 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf'])
'PdfPredefinedFunctions',
function(gettextCatalog, PdfPredefinedFunctions) {
- var createInstance = function(scope, polls) {
+ var createInstance = function(assignment) {
//use the Predefined Functions to create the title
var title = PdfPredefinedFunctions.createTitle(
- gettextCatalog.getString("Election") + ": " + scope.assignment.title);
+ gettextCatalog.getString("Election") + ": " + assignment.title);
//create the preamble
var createPreamble = function() {
var preambleText = gettextCatalog.getString("Number of posts to be elected") + ": ";
- var memberNumber = ""+scope.assignment.open_posts;
+ var memberNumber = ""+assignment.open_posts;
var preamble = {
text: [
{
@@ -37,7 +37,7 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf'])
//adds the description if present in the assignment
var createDescription = function() {
- if (scope.assignment.description) {
+ if (assignment.description) {
var descriptionText = gettextCatalog.getString("Description") + ":";
var description = [
{
@@ -46,7 +46,7 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf'])
style: 'textItem'
},
{
- text: scope.assignment.description,
+ text: assignment.description,
style: 'textItem',
margin: [10, 0, 0, 0]
}
@@ -59,11 +59,11 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf'])
//creates the candidate list in columns if the assignment phase is 'voting'
var createCandidateList = function() {
- if (scope.assignment.phase != 2) {
+ if (assignment.phase != 2) {
var candidatesText = gettextCatalog.getString("Candidates") + ": ";
var userList = [];
- angular.forEach(scope.assignment.assignment_related_users, function(assignmentsRelatedUser) {
+ angular.forEach(assignment.assignment_related_users, function(assignmentsRelatedUser) {
userList.push({
text: assignmentsRelatedUser.user.get_full_name(),
margin: [0, 0, 0, 10],
@@ -110,7 +110,7 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf'])
//creates the pull result table
var createPollResultTable = function() {
var resultBody = [];
- angular.forEach(polls, function(poll, pollIndex) {
+ angular.forEach(assignment.polls, function(poll, pollIndex) {
if (poll.published) {
var voteNrTotal = poll.votescast;
var voteNrValid = poll.votesvalid;
@@ -253,6 +253,10 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf'])
return resultBody;
};
+ var getTitle = function() {
+ return assignment.title;
+ };
+
var getContent = function() {
return [
title,
@@ -264,7 +268,8 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf'])
};
return {
- getContent: getContent
+ getContent: getContent,
+ getTitle: getTitle
};
};
@@ -440,7 +445,78 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf'])
return {
createInstance: createInstance
};
+}])
+.factory('AssignmentCatalogContentProvider', [
+ 'gettextCatalog',
+ 'PdfPredefinedFunctions',
+ function(gettextCatalog, PdfPredefinedFunctions) {
+
+ var createInstance = function(allAssignmnets, Config) {
+
+ var title = PdfPredefinedFunctions.createTitle(Config.get('assignments_pdf_title').value);
+
+ var createPreamble = function() {
+ var preambleText = Config.get('assignments_pdf_preamble').value;
+ if (preambleText) {
+ return {
+ text: preambleText,
+ style: "preamble"
+ };
+ } else {
+ return "";
+ }
+ };
+
+ var createTOContent = function(assignmentTitles) {
+ var heading = {
+ text: gettextCatalog.getString("Table of contents"),
+ style: "heading",
+ };
+
+ var toc = [];
+ angular.forEach(assignmentTitles, function(title, key) {
+ toc.push({
+ text: gettextCatalog.getString("Election") + " " + (key+1) + ": " + title,
+ style: "tableofcontent",
+ });
+ });
+
+ return [
+ heading,
+ toc,
+ PdfPredefinedFunctions.addPageBreak()
+ ];
+ };
+
+ var getContent = function() {
+ var content = [];
+ var assignmentContent = [];
+ var assignmentTitles = [];
+
+ angular.forEach(allAssignmnets, function(assignment, key) {
+ assignmentTitles.push(assignment.getTitle());
+ assignmentContent.push(assignment.getContent());
+ if (key < allAssignmnets.length - 1) {
+ assignmentContent.push(PdfPredefinedFunctions.addPageBreak());
+ }
+ });
+
+ content.push(title);
+ content.push(createPreamble());
+ content.push(createTOContent(assignmentTitles));
+ content.push(assignmentContent);
+ return content;
+ };
+
+ return {
+ getContent: getContent
+ };
+ };
+
+ return {
+ createInstance: createInstance
+ };
}]);
}());
diff --git a/openslides/assignments/static/js/assignments/site.js b/openslides/assignments/static/js/assignments/site.js
index ba17087ca..d271617c0 100644
--- a/openslides/assignments/static/js/assignments/site.js
+++ b/openslides/assignments/static/js/assignments/site.js
@@ -40,6 +40,9 @@ angular.module('OpenSlidesApp.assignments.site', [
assignments: function(Assignment) {
return Assignment.findAll();
},
+ users: function(User) { //TODO: Load only related users cause of better performance
+ return User.findAll();
+ },
tags: function(Tag) {
return Tag.findAll();
},
@@ -239,7 +242,13 @@ angular.module('OpenSlidesApp.assignments.site', [
'phases',
'Projector',
'ProjectionDefault',
- function($scope, ngDialog, AssignmentForm, Assignment, Tag, Agenda, phases, Projector, ProjectionDefault) {
+ 'gettextCatalog',
+ 'Config',
+ 'AssignmentContentProvider',
+ 'AssignmentCatalogContentProvider',
+ 'PdfMakeDocumentProvider',
+ function($scope, ngDialog, AssignmentForm, Assignment, Tag, Agenda, phases, Projector, ProjectionDefault,
+ gettextCatalog, Config, AssignmentContentProvider, AssignmentCatalogContentProvider, PdfMakeDocumentProvider) {
Assignment.bindAll({}, $scope, 'assignments');
Tag.bindAll({}, $scope, 'tags');
$scope.$watch(function () {
@@ -338,6 +347,20 @@ angular.module('OpenSlidesApp.assignments.site', [
$scope.delete = function (assignment) {
Assignment.destroy(assignment.id);
};
+ // create the PDF List
+ $scope.makePDF_assignmentList = function () {
+ var filename = gettextCatalog.getString("Elections") + ".pdf";
+ var assignmentContentProviderArray = [];
+
+ //convert the filtered assignments to content providers
+ angular.forEach($scope.assignmentsFiltered, function(assignment) {
+ assignmentContentProviderArray.push(AssignmentContentProvider.createInstance(assignment));
+ });
+
+ var assignmentCatalogContentProvider = AssignmentCatalogContentProvider.createInstance(assignmentContentProviderArray, Config);
+ var documentProvider = PdfMakeDocumentProvider.createInstance(assignmentCatalogContentProvider);
+ pdfMake.createPdf(documentProvider.getDocument()).download(filename);
+ };
}
])
@@ -525,7 +548,7 @@ angular.module('OpenSlidesApp.assignments.site', [
//creates the document as pdf
$scope.makePDF_singleAssignment = function() {
var filename = gettextCatalog.getString("Election") + " " + $scope.assignment.title + ".pdf";
- var assignmentContentProvider = AssignmentContentProvider.createInstance($scope, assignment.polls);
+ var assignmentContentProvider = AssignmentContentProvider.createInstance(assignment);
var documentProvider = PdfMakeDocumentProvider.createInstance(assignmentContentProvider);
pdfMake.createPdf(documentProvider.getDocument()).download(filename);
};
diff --git a/openslides/assignments/static/templates/assignments/assignment-list.html b/openslides/assignments/static/templates/assignments/assignment-list.html
index 7cd597e78..09998a214 100644
--- a/openslides/assignments/static/templates/assignments/assignment-list.html
+++ b/openslides/assignments/static/templates/assignments/assignment-list.html
@@ -9,7 +9,7 @@
Tags
-
+
PDF
diff --git a/openslides/core/static/js/core/pdf.js b/openslides/core/static/js/core/pdf.js
index 9dad545b8..f75288ac4 100644
--- a/openslides/core/static/js/core/pdf.js
+++ b/openslides/core/static/js/core/pdf.js
@@ -19,6 +19,16 @@ angular.module('OpenSlidesApp.core.pdf', [])
};
};
+ // function to apply a pagebreak-keyword
+ PdfPredefinedFunctions.addPageBreak = function() {
+ return [
+ {
+ text: '',
+ pageBreak: 'after'
+ }
+ ];
+ };
+
PdfPredefinedFunctions.flipTableRowStyle = function(currentTableSize) {
if (currentTableSize % 2 === 0) {
return "tableEven";
@@ -173,6 +183,10 @@ angular.module('OpenSlidesApp.core.pdf', [])
margin: [0,0,0,20],
bold: true
},
+ preamble: {
+ fontSize: 12,
+ margin: [0,0,0,10],
+ },
userDataTitle: {
fontSize: 26,
margin: [0,0,0,0],
diff --git a/openslides/motions/static/js/motions/pdf.js b/openslides/motions/static/js/motions/pdf.js
index 9f71700f7..d52db312e 100644
--- a/openslides/motions/static/js/motions/pdf.js
+++ b/openslides/motions/static/js/motions/pdf.js
@@ -283,7 +283,7 @@ angular.module('OpenSlidesApp.motions.pdf', ['OpenSlidesApp.core.pdf'])
return [
heading,
toc,
- addPageBreak()
+ PdfPredefinedFunctions.addPageBreak()
];
};
@@ -317,7 +317,7 @@ angular.module('OpenSlidesApp.motions.pdf', ['OpenSlidesApp.core.pdf'])
return [
heading,
toc,
- addPageBreak()
+ PdfPredefinedFunctions.addPageBreak()
];
} else {
// if there are no categories, return "empty string"
@@ -326,16 +326,6 @@ angular.module('OpenSlidesApp.motions.pdf', ['OpenSlidesApp.core.pdf'])
}
};
- // function to apply a pagebreak-keyword
- var addPageBreak = function() {
- return [
- {
- text: '',
- pageBreak: 'after'
- }
- ];
- };
-
// returns the pure content of the motion, parseable by makepdf
var getContent = function() {
var motionContent = [];
@@ -345,7 +335,7 @@ angular.module('OpenSlidesApp.motions.pdf', ['OpenSlidesApp.core.pdf'])
motionTitles.push(motion.getIdentifier() + ": " + motion.getTitle());
motionContent.push(motion.getContent());
if (key < allMotions.length - 1) {
- motionContent.push(addPageBreak());
+ motionContent.push(PdfPredefinedFunctions.addPageBreak());
}
});