From 706932665512c710d19026a4e5e991d3bfb4fbf9 Mon Sep 17 00:00:00 2001 From: Sean Engelhardt Date: Thu, 3 Nov 2016 14:32:20 +0100 Subject: [PATCH 1/2] ElectionList over PdfMake --- .../assignments/static/js/assignments/pdf.js | 94 +++++++++++++++++-- .../assignments/static/js/assignments/site.js | 27 +++++- .../assignments/assignment-list.html | 2 +- openslides/core/static/js/core/pdf.js | 14 +++ openslides/motions/static/js/motions/pdf.js | 16 +--- 5 files changed, 128 insertions(+), 25 deletions(-) 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()); } }); From ff359ea629e391ce96f1c92a889603555ee421e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emanuel=20Sch=C3=BCtze?= Date: Wed, 9 Nov 2016 22:18:44 +0100 Subject: [PATCH 2/2] Improved assignments and motions pdf. Load all users in pdfmake function - not in state resolver of assignment list. --- .../assignments/static/js/assignments/pdf.js | 83 ++++++++++--------- .../assignments/static/js/assignments/site.js | 29 +++---- openslides/core/config.py | 1 + openslides/motions/static/js/motions/pdf.js | 61 ++++++++++---- openslides/utils/search.py | 1 + 5 files changed, 104 insertions(+), 71 deletions(-) diff --git a/openslides/assignments/static/js/assignments/pdf.js b/openslides/assignments/static/js/assignments/pdf.js index f0f66b89c..5c8012447 100644 --- a/openslides/assignments/static/js/assignments/pdf.js +++ b/openslides/assignments/static/js/assignments/pdf.js @@ -12,8 +12,7 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf']) var createInstance = function(assignment) { //use the Predefined Functions to create the title - var title = PdfPredefinedFunctions.createTitle( - gettextCatalog.getString("Election") + ": " + assignment.title); + var title = PdfPredefinedFunctions.createTitle(assignment.title); //create the preamble var createPreamble = function() { @@ -121,7 +120,7 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf']) text: gettextCatalog.getString("Ballot") + " " + (pollIndex+1), bold: true, style: 'textItem', - margin: [0,15,0,0] + margin: [0, 15, 0, 0] }); pollTableBody.push([ @@ -150,17 +149,18 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf']) ]); } else if (poll.pollmethod == 'yn') { pollTableBody.push([ - { - text: candidateName, - style: PdfPredefinedFunctions.flipTableRowStyle(pollTableBody.length) - }, + electedCandidateLine(candidateName, pollOption, pollTableBody), { text: [ { - text: votes[0].label + ": " + votes[0].value + " " + votes[0].percentStr + "\n" + text: votes[0].label + ": " + + votes[0].value + " " + + votes[0].percentStr + "\n" }, { - text: votes[1].label + ": " + votes[1].value + " " + votes[1].percentStr + text: votes[1].label + ": " + + votes[1].value + " " + + votes[1].percentStr } ], style: PdfPredefinedFunctions.flipTableRowStyle(pollTableBody.length) @@ -168,20 +168,23 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf']) ]); } else if (poll.pollmethod == 'yna') { pollTableBody.push([ - { - text: candidateName, - style: PdfPredefinedFunctions.flipTableRowStyle(pollTableBody.length) - }, + electedCandidateLine(candidateName, pollOption, pollTableBody), { text: [ { - text: votes[0].label + ": " + votes[0].value + " " + votes[0].percentStr + "\n" + text: votes[0].label + ": " + + votes[0].value + " " + + votes[0].percentStr + "\n" }, { - text: votes[1].label + ": " + votes[1].value + " " + votes[1].percentStr + "\n" + text: votes[1].label + ": " + + votes[1].value + " " + + votes[1].percentStr + "\n" }, { - text: votes[2].label + ": " + votes[2].value + " " + votes[2].percentStr + text: votes[2].label + ": " + + votes[2].value + " " + + votes[2].percentStr } ], style: PdfPredefinedFunctions.flipTableRowStyle(pollTableBody.length) @@ -199,7 +202,7 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf']) style: 'tableConclude' }, { - text: ""+voteNrValid, + text: "" + voteNrValid, style: 'tableConclude' }, ]); @@ -212,7 +215,7 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf']) style: 'tableConclude' }, { - text: ""+voteNrInVal, + text: "" + voteNrInVal, style: 'tableConclude' }, ]); @@ -225,7 +228,7 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf']) style: 'tableConclude' }, { - text: ""+voteNrTotal, + text: "" + voteNrTotal, style: 'tableConclude' }, ]); @@ -244,19 +247,17 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf']) } }); - //Add the Legend to the result body - resultBody.push({ - text: "* = " + gettextCatalog.getString("is elected"), - margin: [0,5,0,0], - }); + //Add the legend to the result body + if (assignment.polls.length > 0) { + resultBody.push({ + text: "* = " + gettextCatalog.getString("is elected"), + margin: [0, 5, 0, 0], + }); + } return resultBody; }; - var getTitle = function() { - return assignment.title; - }; - var getContent = function() { return [ title, @@ -269,7 +270,7 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf']) return { getContent: getContent, - getTitle: getTitle + title: assignment.title }; }; @@ -288,15 +289,16 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf']) // use the Predefined Functions to create the title var createTitle = function() { return { - text: gettextCatalog.getString("Election") + ": " + scope.assignment.title, + text: scope.assignment.title, style: 'title', }; }; //function to create the poll hint var createPollHint = function() { + var description = poll.description ? ': ' + poll.description : ''; return { - text: gettextCatalog.getString("Ballot") + " " + pollNumber + ": " + poll.description, + text: gettextCatalog.getString("Ballot") + " " + pollNumber + description, style: 'description', }; }; @@ -364,7 +366,7 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf']) columns : [ { width: 1, - margin: [0,marginTop], + margin: [0, marginTop], text: "" }, { @@ -450,11 +452,14 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf']) .factory('AssignmentCatalogContentProvider', [ 'gettextCatalog', 'PdfPredefinedFunctions', - function(gettextCatalog, PdfPredefinedFunctions) { + 'Config', + function(gettextCatalog, PdfPredefinedFunctions, Config) { - var createInstance = function(allAssignmnets, Config) { + var createInstance = function(allAssignmnets) { - var title = PdfPredefinedFunctions.createTitle(Config.get('assignments_pdf_title').value); + var title = PdfPredefinedFunctions.createTitle( + gettextCatalog.getString(Config.get('assignments_pdf_title').value) + ); var createPreamble = function() { var preambleText = Config.get('assignments_pdf_preamble').value; @@ -475,10 +480,10 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf']) }; var toc = []; - angular.forEach(assignmentTitles, function(title, key) { + angular.forEach(assignmentTitles, function(title) { toc.push({ - text: gettextCatalog.getString("Election") + " " + (key+1) + ": " + title, - style: "tableofcontent", + text: title, + style: "tableofcontent" }); }); @@ -495,7 +500,7 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf']) var assignmentTitles = []; angular.forEach(allAssignmnets, function(assignment, key) { - assignmentTitles.push(assignment.getTitle()); + assignmentTitles.push(assignment.title); assignmentContent.push(assignment.getContent()); if (key < allAssignmnets.length - 1) { assignmentContent.push(PdfPredefinedFunctions.addPageBreak()); diff --git a/openslides/assignments/static/js/assignments/site.js b/openslides/assignments/static/js/assignments/site.js index d271617c0..cef4bf1f5 100644 --- a/openslides/assignments/static/js/assignments/site.js +++ b/openslides/assignments/static/js/assignments/site.js @@ -40,9 +40,6 @@ 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(); }, @@ -243,12 +240,12 @@ angular.module('OpenSlidesApp.assignments.site', [ 'Projector', 'ProjectionDefault', 'gettextCatalog', - 'Config', 'AssignmentContentProvider', 'AssignmentCatalogContentProvider', 'PdfMakeDocumentProvider', + 'User', function($scope, ngDialog, AssignmentForm, Assignment, Tag, Agenda, phases, Projector, ProjectionDefault, - gettextCatalog, Config, AssignmentContentProvider, AssignmentCatalogContentProvider, PdfMakeDocumentProvider) { + gettextCatalog, AssignmentContentProvider, AssignmentCatalogContentProvider, PdfMakeDocumentProvider, User) { Assignment.bindAll({}, $scope, 'assignments'); Tag.bindAll({}, $scope, 'tags'); $scope.$watch(function () { @@ -349,17 +346,21 @@ angular.module('OpenSlidesApp.assignments.site', [ }; // create the PDF List $scope.makePDF_assignmentList = function () { - var filename = gettextCatalog.getString("Elections") + ".pdf"; - var assignmentContentProviderArray = []; + User.findAll().then( function(users) { + 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)); + //convert the filtered assignments to content providers + angular.forEach($scope.assignmentsFiltered, function(assignment) { + assignmentContentProviderArray.push(AssignmentContentProvider.createInstance(assignment)); + }); + + var assignmentCatalogContentProvider = + AssignmentCatalogContentProvider.createInstance(assignmentContentProviderArray); + var documentProvider = + PdfMakeDocumentProvider.createInstance(assignmentCatalogContentProvider); + pdfMake.createPdf(documentProvider.getDocument()).download(filename); }); - - var assignmentCatalogContentProvider = AssignmentCatalogContentProvider.createInstance(assignmentContentProviderArray, Config); - var documentProvider = PdfMakeDocumentProvider.createInstance(assignmentCatalogContentProvider); - pdfMake.createPdf(documentProvider.getDocument()).download(filename); }; } ]) diff --git a/openslides/core/config.py b/openslides/core/config.py index 3ea38db27..3eaab937a 100644 --- a/openslides/core/config.py +++ b/openslides/core/config.py @@ -157,6 +157,7 @@ class ConfigHandler: """ return ConfigStore.get_collection_string() + config = ConfigHandler() """ Final entry point to get an set config variables. To get a config variable diff --git a/openslides/motions/static/js/motions/pdf.js b/openslides/motions/static/js/motions/pdf.js index d52db312e..01b3b7619 100644 --- a/openslides/motions/static/js/motions/pdf.js +++ b/openslides/motions/static/js/motions/pdf.js @@ -15,8 +15,9 @@ angular.module('OpenSlidesApp.motions.pdf', ['OpenSlidesApp.core.pdf']) var createInstance = function(converter, motion, $scope, User) { - var header = PdfPredefinedFunctions.createTitle(gettextCatalog.getString("Motion") + " " + - motion.identifier + ": " + motion.getTitle($scope.version)); + var identifier = motion.identifier ? ' ' + motion.identifier : ''; + var header = PdfPredefinedFunctions.createTitle(gettextCatalog.getString("Motion") + identifier + + ': ' + motion.getTitle($scope.version)); // generates the text of the motion. Also septerates between line-numbers var textContent = function() { @@ -142,7 +143,7 @@ angular.module('OpenSlidesApp.motions.pdf', ['OpenSlidesApp.core.pdf']) }; var getIdentifier = function() { - return motion.identifier; + return motion.identifier ? motion.identifier : ''; }; var getCategory = function() { @@ -252,7 +253,8 @@ angular.module('OpenSlidesApp.motions.pdf', ['OpenSlidesApp.core.pdf']) .factory('MotionCatalogContentProvider', [ 'gettextCatalog', 'PdfPredefinedFunctions', - function(gettextCatalog, PdfPredefinedFunctions) { + 'Config', + function(gettextCatalog, PdfPredefinedFunctions, Config) { /** * Constructor @@ -263,21 +265,46 @@ angular.module('OpenSlidesApp.motions.pdf', ['OpenSlidesApp.core.pdf']) */ var createInstance = function(allMotions, $scope, User, Category) { - var title = PdfPredefinedFunctions.createTitle("Motions"); + var title = PdfPredefinedFunctions.createTitle( + gettextCatalog.getString(Config.get('motions_export_title').value) + ); - var createTOContent = function(motionTitles) { + var createPreamble = function() { + var preambleText = Config.get('motions_export_preamble').value; + if (preambleText) { + return { + text: preambleText, + style: "preamble" + }; + } else { + return ""; + } + }; + var createTOContent = function() { var heading = { text: gettextCatalog.getString("Table of contents"), - style: "heading", + style: "heading" }; var toc = []; - angular.forEach(motionTitles, function(title) { - toc.push({ - text: gettextCatalog.getString("Motion") + " " + title, - style: "tableofcontent", - }); + angular.forEach(allMotions, function(motion) { + var identifier = motion.getIdentifier() ? motion.getIdentifier() : ''; + toc.push( + { + columns: [ + { + text: identifier, + style: 'tableofcontent', + width: 30 + }, + { + text: motion.getTitle(), + style: 'tableofcontent' + } + ] + } + ); }); return [ @@ -288,7 +315,7 @@ angular.module('OpenSlidesApp.motions.pdf', ['OpenSlidesApp.core.pdf']) }; // function to create the table of catergories (if any) - var createTOCatergories = function() { + var createTOCategories = function() { if (Category.getAll().length > 0) { var heading = { text: gettextCatalog.getString("Categories"), @@ -329,10 +356,7 @@ angular.module('OpenSlidesApp.motions.pdf', ['OpenSlidesApp.core.pdf']) // returns the pure content of the motion, parseable by makepdf var getContent = function() { var motionContent = []; - var motionTitles = []; - var motionCategories = []; angular.forEach(allMotions, function(motion, key) { - motionTitles.push(motion.getIdentifier() + ": " + motion.getTitle()); motionContent.push(motion.getContent()); if (key < allMotions.length - 1) { motionContent.push(PdfPredefinedFunctions.addPageBreak()); @@ -341,8 +365,9 @@ angular.module('OpenSlidesApp.motions.pdf', ['OpenSlidesApp.core.pdf']) return [ title, - createTOCatergories(), - createTOContent(motionTitles), + createPreamble(), + createTOCategories(), + createTOContent(), motionContent ]; }; diff --git a/openslides/utils/search.py b/openslides/utils/search.py index 9d1156d1b..0da9b4f63 100644 --- a/openslides/utils/search.py +++ b/openslides/utils/search.py @@ -76,6 +76,7 @@ class Index: return open_dir(path) return self.create_index() + index = Index()