Merge pull request #2610 from tsiegleauq/electionListPdfMake
ElectionList over PdfMake
This commit is contained in:
commit
18accc58ae
@ -9,16 +9,15 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf'])
|
|||||||
'PdfPredefinedFunctions',
|
'PdfPredefinedFunctions',
|
||||||
function(gettextCatalog, PdfPredefinedFunctions) {
|
function(gettextCatalog, PdfPredefinedFunctions) {
|
||||||
|
|
||||||
var createInstance = function(scope, polls) {
|
var createInstance = function(assignment) {
|
||||||
|
|
||||||
//use the Predefined Functions to create the title
|
//use the Predefined Functions to create the title
|
||||||
var title = PdfPredefinedFunctions.createTitle(
|
var title = PdfPredefinedFunctions.createTitle(assignment.title);
|
||||||
gettextCatalog.getString("Election") + ": " + scope.assignment.title);
|
|
||||||
|
|
||||||
//create the preamble
|
//create the preamble
|
||||||
var createPreamble = function() {
|
var createPreamble = function() {
|
||||||
var preambleText = gettextCatalog.getString("Number of posts to be elected") + ": ";
|
var preambleText = gettextCatalog.getString("Number of posts to be elected") + ": ";
|
||||||
var memberNumber = ""+scope.assignment.open_posts;
|
var memberNumber = ""+assignment.open_posts;
|
||||||
var preamble = {
|
var preamble = {
|
||||||
text: [
|
text: [
|
||||||
{
|
{
|
||||||
@ -37,7 +36,7 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf'])
|
|||||||
|
|
||||||
//adds the description if present in the assignment
|
//adds the description if present in the assignment
|
||||||
var createDescription = function() {
|
var createDescription = function() {
|
||||||
if (scope.assignment.description) {
|
if (assignment.description) {
|
||||||
var descriptionText = gettextCatalog.getString("Description") + ":";
|
var descriptionText = gettextCatalog.getString("Description") + ":";
|
||||||
var description = [
|
var description = [
|
||||||
{
|
{
|
||||||
@ -46,7 +45,7 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf'])
|
|||||||
style: 'textItem'
|
style: 'textItem'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: scope.assignment.description,
|
text: assignment.description,
|
||||||
style: 'textItem',
|
style: 'textItem',
|
||||||
margin: [10, 0, 0, 0]
|
margin: [10, 0, 0, 0]
|
||||||
}
|
}
|
||||||
@ -59,11 +58,11 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf'])
|
|||||||
|
|
||||||
//creates the candidate list in columns if the assignment phase is 'voting'
|
//creates the candidate list in columns if the assignment phase is 'voting'
|
||||||
var createCandidateList = function() {
|
var createCandidateList = function() {
|
||||||
if (scope.assignment.phase != 2) {
|
if (assignment.phase != 2) {
|
||||||
var candidatesText = gettextCatalog.getString("Candidates") + ": ";
|
var candidatesText = gettextCatalog.getString("Candidates") + ": ";
|
||||||
var userList = [];
|
var userList = [];
|
||||||
|
|
||||||
angular.forEach(scope.assignment.assignment_related_users, function(assignmentsRelatedUser) {
|
angular.forEach(assignment.assignment_related_users, function(assignmentsRelatedUser) {
|
||||||
userList.push({
|
userList.push({
|
||||||
text: assignmentsRelatedUser.user.get_full_name(),
|
text: assignmentsRelatedUser.user.get_full_name(),
|
||||||
margin: [0, 0, 0, 10],
|
margin: [0, 0, 0, 10],
|
||||||
@ -110,7 +109,7 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf'])
|
|||||||
//creates the pull result table
|
//creates the pull result table
|
||||||
var createPollResultTable = function() {
|
var createPollResultTable = function() {
|
||||||
var resultBody = [];
|
var resultBody = [];
|
||||||
angular.forEach(polls, function(poll, pollIndex) {
|
angular.forEach(assignment.polls, function(poll, pollIndex) {
|
||||||
if (poll.published) {
|
if (poll.published) {
|
||||||
var voteNrTotal = poll.votescast;
|
var voteNrTotal = poll.votescast;
|
||||||
var voteNrValid = poll.votesvalid;
|
var voteNrValid = poll.votesvalid;
|
||||||
@ -121,7 +120,7 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf'])
|
|||||||
text: gettextCatalog.getString("Ballot") + " " + (pollIndex+1),
|
text: gettextCatalog.getString("Ballot") + " " + (pollIndex+1),
|
||||||
bold: true,
|
bold: true,
|
||||||
style: 'textItem',
|
style: 'textItem',
|
||||||
margin: [0,15,0,0]
|
margin: [0, 15, 0, 0]
|
||||||
});
|
});
|
||||||
|
|
||||||
pollTableBody.push([
|
pollTableBody.push([
|
||||||
@ -150,17 +149,18 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf'])
|
|||||||
]);
|
]);
|
||||||
} else if (poll.pollmethod == 'yn') {
|
} else if (poll.pollmethod == 'yn') {
|
||||||
pollTableBody.push([
|
pollTableBody.push([
|
||||||
{
|
electedCandidateLine(candidateName, pollOption, pollTableBody),
|
||||||
text: candidateName,
|
|
||||||
style: PdfPredefinedFunctions.flipTableRowStyle(pollTableBody.length)
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
text: [
|
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)
|
style: PdfPredefinedFunctions.flipTableRowStyle(pollTableBody.length)
|
||||||
@ -168,20 +168,23 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf'])
|
|||||||
]);
|
]);
|
||||||
} else if (poll.pollmethod == 'yna') {
|
} else if (poll.pollmethod == 'yna') {
|
||||||
pollTableBody.push([
|
pollTableBody.push([
|
||||||
{
|
electedCandidateLine(candidateName, pollOption, pollTableBody),
|
||||||
text: candidateName,
|
|
||||||
style: PdfPredefinedFunctions.flipTableRowStyle(pollTableBody.length)
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
text: [
|
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)
|
style: PdfPredefinedFunctions.flipTableRowStyle(pollTableBody.length)
|
||||||
@ -199,7 +202,7 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf'])
|
|||||||
style: 'tableConclude'
|
style: 'tableConclude'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: ""+voteNrValid,
|
text: "" + voteNrValid,
|
||||||
style: 'tableConclude'
|
style: 'tableConclude'
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
@ -212,7 +215,7 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf'])
|
|||||||
style: 'tableConclude'
|
style: 'tableConclude'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: ""+voteNrInVal,
|
text: "" + voteNrInVal,
|
||||||
style: 'tableConclude'
|
style: 'tableConclude'
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
@ -225,7 +228,7 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf'])
|
|||||||
style: 'tableConclude'
|
style: 'tableConclude'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: ""+voteNrTotal,
|
text: "" + voteNrTotal,
|
||||||
style: 'tableConclude'
|
style: 'tableConclude'
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
@ -244,11 +247,13 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf'])
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//Add the Legend to the result body
|
//Add the legend to the result body
|
||||||
resultBody.push({
|
if (assignment.polls.length > 0) {
|
||||||
text: "* = " + gettextCatalog.getString("is elected"),
|
resultBody.push({
|
||||||
margin: [0,5,0,0],
|
text: "* = " + gettextCatalog.getString("is elected"),
|
||||||
});
|
margin: [0, 5, 0, 0],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return resultBody;
|
return resultBody;
|
||||||
};
|
};
|
||||||
@ -264,7 +269,8 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf'])
|
|||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
getContent: getContent
|
getContent: getContent,
|
||||||
|
title: assignment.title
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -283,15 +289,16 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf'])
|
|||||||
// use the Predefined Functions to create the title
|
// use the Predefined Functions to create the title
|
||||||
var createTitle = function() {
|
var createTitle = function() {
|
||||||
return {
|
return {
|
||||||
text: gettextCatalog.getString("Election") + ": " + scope.assignment.title,
|
text: scope.assignment.title,
|
||||||
style: 'title',
|
style: 'title',
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
//function to create the poll hint
|
//function to create the poll hint
|
||||||
var createPollHint = function() {
|
var createPollHint = function() {
|
||||||
|
var description = poll.description ? ': ' + poll.description : '';
|
||||||
return {
|
return {
|
||||||
text: gettextCatalog.getString("Ballot") + " " + pollNumber + ": " + poll.description,
|
text: gettextCatalog.getString("Ballot") + " " + pollNumber + description,
|
||||||
style: 'description',
|
style: 'description',
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -359,7 +366,7 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf'])
|
|||||||
columns : [
|
columns : [
|
||||||
{
|
{
|
||||||
width: 1,
|
width: 1,
|
||||||
margin: [0,marginTop],
|
margin: [0, marginTop],
|
||||||
text: ""
|
text: ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -440,7 +447,81 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf'])
|
|||||||
return {
|
return {
|
||||||
createInstance: createInstance
|
createInstance: createInstance
|
||||||
};
|
};
|
||||||
|
}])
|
||||||
|
|
||||||
|
.factory('AssignmentCatalogContentProvider', [
|
||||||
|
'gettextCatalog',
|
||||||
|
'PdfPredefinedFunctions',
|
||||||
|
'Config',
|
||||||
|
function(gettextCatalog, PdfPredefinedFunctions, Config) {
|
||||||
|
|
||||||
|
var createInstance = function(allAssignmnets) {
|
||||||
|
|
||||||
|
var title = PdfPredefinedFunctions.createTitle(
|
||||||
|
gettextCatalog.getString(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) {
|
||||||
|
toc.push({
|
||||||
|
text: 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.title);
|
||||||
|
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
|
||||||
|
};
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
@ -239,7 +239,13 @@ angular.module('OpenSlidesApp.assignments.site', [
|
|||||||
'phases',
|
'phases',
|
||||||
'Projector',
|
'Projector',
|
||||||
'ProjectionDefault',
|
'ProjectionDefault',
|
||||||
function($scope, ngDialog, AssignmentForm, Assignment, Tag, Agenda, phases, Projector, ProjectionDefault) {
|
'gettextCatalog',
|
||||||
|
'AssignmentContentProvider',
|
||||||
|
'AssignmentCatalogContentProvider',
|
||||||
|
'PdfMakeDocumentProvider',
|
||||||
|
'User',
|
||||||
|
function($scope, ngDialog, AssignmentForm, Assignment, Tag, Agenda, phases, Projector, ProjectionDefault,
|
||||||
|
gettextCatalog, AssignmentContentProvider, AssignmentCatalogContentProvider, PdfMakeDocumentProvider, User) {
|
||||||
Assignment.bindAll({}, $scope, 'assignments');
|
Assignment.bindAll({}, $scope, 'assignments');
|
||||||
Tag.bindAll({}, $scope, 'tags');
|
Tag.bindAll({}, $scope, 'tags');
|
||||||
$scope.$watch(function () {
|
$scope.$watch(function () {
|
||||||
@ -338,6 +344,24 @@ angular.module('OpenSlidesApp.assignments.site', [
|
|||||||
$scope.delete = function (assignment) {
|
$scope.delete = function (assignment) {
|
||||||
Assignment.destroy(assignment.id);
|
Assignment.destroy(assignment.id);
|
||||||
};
|
};
|
||||||
|
// create the PDF List
|
||||||
|
$scope.makePDF_assignmentList = function () {
|
||||||
|
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));
|
||||||
|
});
|
||||||
|
|
||||||
|
var assignmentCatalogContentProvider =
|
||||||
|
AssignmentCatalogContentProvider.createInstance(assignmentContentProviderArray);
|
||||||
|
var documentProvider =
|
||||||
|
PdfMakeDocumentProvider.createInstance(assignmentCatalogContentProvider);
|
||||||
|
pdfMake.createPdf(documentProvider.getDocument()).download(filename);
|
||||||
|
});
|
||||||
|
};
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
|
|
||||||
@ -525,7 +549,7 @@ angular.module('OpenSlidesApp.assignments.site', [
|
|||||||
//creates the document as pdf
|
//creates the document as pdf
|
||||||
$scope.makePDF_singleAssignment = function() {
|
$scope.makePDF_singleAssignment = function() {
|
||||||
var filename = gettextCatalog.getString("Election") + " " + $scope.assignment.title + ".pdf";
|
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);
|
var documentProvider = PdfMakeDocumentProvider.createInstance(assignmentContentProvider);
|
||||||
pdfMake.createPdf(documentProvider.getDocument()).download(filename);
|
pdfMake.createPdf(documentProvider.getDocument()).download(filename);
|
||||||
};
|
};
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
<i class="fa fa-tags fa-lg"></i>
|
<i class="fa fa-tags fa-lg"></i>
|
||||||
<translate>Tags</translate>
|
<translate>Tags</translate>
|
||||||
</a>
|
</a>
|
||||||
<a ui-sref="assignments_pdf" target="_blank" class="btn btn-default btn-sm">
|
<a href="" ng-click="makePDF_assignmentList()" class="btn btn-default btn-sm">
|
||||||
<i class="fa fa-file-pdf-o fa-lg"></i>
|
<i class="fa fa-file-pdf-o fa-lg"></i>
|
||||||
<translate>PDF</translate>
|
<translate>PDF</translate>
|
||||||
</a>
|
</a>
|
||||||
|
@ -157,6 +157,7 @@ class ConfigHandler:
|
|||||||
"""
|
"""
|
||||||
return ConfigStore.get_collection_string()
|
return ConfigStore.get_collection_string()
|
||||||
|
|
||||||
|
|
||||||
config = ConfigHandler()
|
config = ConfigHandler()
|
||||||
"""
|
"""
|
||||||
Final entry point to get an set config variables. To get a config variable
|
Final entry point to get an set config variables. To get a config variable
|
||||||
|
@ -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) {
|
PdfPredefinedFunctions.flipTableRowStyle = function(currentTableSize) {
|
||||||
if (currentTableSize % 2 === 0) {
|
if (currentTableSize % 2 === 0) {
|
||||||
return "tableEven";
|
return "tableEven";
|
||||||
@ -173,6 +183,10 @@ angular.module('OpenSlidesApp.core.pdf', [])
|
|||||||
margin: [0,0,0,20],
|
margin: [0,0,0,20],
|
||||||
bold: true
|
bold: true
|
||||||
},
|
},
|
||||||
|
preamble: {
|
||||||
|
fontSize: 12,
|
||||||
|
margin: [0,0,0,10],
|
||||||
|
},
|
||||||
userDataTitle: {
|
userDataTitle: {
|
||||||
fontSize: 26,
|
fontSize: 26,
|
||||||
margin: [0,0,0,0],
|
margin: [0,0,0,0],
|
||||||
|
@ -15,8 +15,9 @@ angular.module('OpenSlidesApp.motions.pdf', ['OpenSlidesApp.core.pdf'])
|
|||||||
|
|
||||||
var createInstance = function(converter, motion, $scope, User) {
|
var createInstance = function(converter, motion, $scope, User) {
|
||||||
|
|
||||||
var header = PdfPredefinedFunctions.createTitle(gettextCatalog.getString("Motion") + " " +
|
var identifier = motion.identifier ? ' ' + motion.identifier : '';
|
||||||
motion.identifier + ": " + motion.getTitle($scope.version));
|
var header = PdfPredefinedFunctions.createTitle(gettextCatalog.getString("Motion") + identifier +
|
||||||
|
': ' + motion.getTitle($scope.version));
|
||||||
|
|
||||||
// generates the text of the motion. Also septerates between line-numbers
|
// generates the text of the motion. Also septerates between line-numbers
|
||||||
var textContent = function() {
|
var textContent = function() {
|
||||||
@ -142,7 +143,7 @@ angular.module('OpenSlidesApp.motions.pdf', ['OpenSlidesApp.core.pdf'])
|
|||||||
};
|
};
|
||||||
|
|
||||||
var getIdentifier = function() {
|
var getIdentifier = function() {
|
||||||
return motion.identifier;
|
return motion.identifier ? motion.identifier : '';
|
||||||
};
|
};
|
||||||
|
|
||||||
var getCategory = function() {
|
var getCategory = function() {
|
||||||
@ -252,7 +253,8 @@ angular.module('OpenSlidesApp.motions.pdf', ['OpenSlidesApp.core.pdf'])
|
|||||||
.factory('MotionCatalogContentProvider', [
|
.factory('MotionCatalogContentProvider', [
|
||||||
'gettextCatalog',
|
'gettextCatalog',
|
||||||
'PdfPredefinedFunctions',
|
'PdfPredefinedFunctions',
|
||||||
function(gettextCatalog, PdfPredefinedFunctions) {
|
'Config',
|
||||||
|
function(gettextCatalog, PdfPredefinedFunctions, Config) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@ -263,32 +265,57 @@ angular.module('OpenSlidesApp.motions.pdf', ['OpenSlidesApp.core.pdf'])
|
|||||||
*/
|
*/
|
||||||
var createInstance = function(allMotions, $scope, User, Category) {
|
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 = {
|
var heading = {
|
||||||
text: gettextCatalog.getString("Table of contents"),
|
text: gettextCatalog.getString("Table of contents"),
|
||||||
style: "heading",
|
style: "heading"
|
||||||
};
|
};
|
||||||
|
|
||||||
var toc = [];
|
var toc = [];
|
||||||
angular.forEach(motionTitles, function(title) {
|
angular.forEach(allMotions, function(motion) {
|
||||||
toc.push({
|
var identifier = motion.getIdentifier() ? motion.getIdentifier() : '';
|
||||||
text: gettextCatalog.getString("Motion") + " " + title,
|
toc.push(
|
||||||
style: "tableofcontent",
|
{
|
||||||
});
|
columns: [
|
||||||
|
{
|
||||||
|
text: identifier,
|
||||||
|
style: 'tableofcontent',
|
||||||
|
width: 30
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: motion.getTitle(),
|
||||||
|
style: 'tableofcontent'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
return [
|
return [
|
||||||
heading,
|
heading,
|
||||||
toc,
|
toc,
|
||||||
addPageBreak()
|
PdfPredefinedFunctions.addPageBreak()
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
// function to create the table of catergories (if any)
|
// function to create the table of catergories (if any)
|
||||||
var createTOCatergories = function() {
|
var createTOCategories = function() {
|
||||||
if (Category.getAll().length > 0) {
|
if (Category.getAll().length > 0) {
|
||||||
var heading = {
|
var heading = {
|
||||||
text: gettextCatalog.getString("Categories"),
|
text: gettextCatalog.getString("Categories"),
|
||||||
@ -317,7 +344,7 @@ angular.module('OpenSlidesApp.motions.pdf', ['OpenSlidesApp.core.pdf'])
|
|||||||
return [
|
return [
|
||||||
heading,
|
heading,
|
||||||
toc,
|
toc,
|
||||||
addPageBreak()
|
PdfPredefinedFunctions.addPageBreak()
|
||||||
];
|
];
|
||||||
} else {
|
} else {
|
||||||
// if there are no categories, return "empty string"
|
// if there are no categories, return "empty string"
|
||||||
@ -326,33 +353,21 @@ 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
|
// returns the pure content of the motion, parseable by makepdf
|
||||||
var getContent = function() {
|
var getContent = function() {
|
||||||
var motionContent = [];
|
var motionContent = [];
|
||||||
var motionTitles = [];
|
|
||||||
var motionCategories = [];
|
|
||||||
angular.forEach(allMotions, function(motion, key) {
|
angular.forEach(allMotions, function(motion, key) {
|
||||||
motionTitles.push(motion.getIdentifier() + ": " + motion.getTitle());
|
|
||||||
motionContent.push(motion.getContent());
|
motionContent.push(motion.getContent());
|
||||||
if (key < allMotions.length - 1) {
|
if (key < allMotions.length - 1) {
|
||||||
motionContent.push(addPageBreak());
|
motionContent.push(PdfPredefinedFunctions.addPageBreak());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return [
|
return [
|
||||||
title,
|
title,
|
||||||
createTOCatergories(),
|
createPreamble(),
|
||||||
createTOContent(motionTitles),
|
createTOCategories(),
|
||||||
|
createTOContent(),
|
||||||
motionContent
|
motionContent
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
@ -76,6 +76,7 @@ class Index:
|
|||||||
return open_dir(path)
|
return open_dir(path)
|
||||||
return self.create_index()
|
return self.create_index()
|
||||||
|
|
||||||
|
|
||||||
index = Index()
|
index = Index()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user