poll and ballot paper logos

This commit is contained in:
FinnStutzenstein 2017-06-22 08:44:59 +02:00 committed by Emanuel Schütze
parent 3e1c1abe14
commit bf56067d17
4 changed files with 143 additions and 35 deletions

View File

@ -266,14 +266,46 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf'])
]) ])
.factory('BallotContentProvider', [ .factory('BallotContentProvider', [
'$q',
'$filter', '$filter',
'gettextCatalog', 'gettextCatalog',
'PDFLayout', 'PDFLayout',
'Config', 'Config',
'User', 'User',
function($filter, gettextCatalog, PDFLayout, Config, User) { 'ImageConverter',
function($q, $filter, gettextCatalog, PDFLayout, Config, User, ImageConverter) {
var createInstance = function(assignment, poll, pollNumber) { var createInstance = function(assignment, poll, pollNumber) {
var logoAssignmentBallotPaperUrl = Config.get('logo_pdf_assignment_ballot_paper').value.path;
var imageMap = {};
// PDF header
var header = function() {
var columns = [];
var text = Config.get('general_event_name').value
columns.push({
text: text,
fontSize: 8,
alignment: 'left',
width: '80%'
});
// logo
columns.push({
image: imageMap[logoAssignmentBallotPaperUrl].data,
fit: [90,25],
width: '20%'
});
return {
color: '#555',
fontSize: 10,
margin: [30, 10, 10, 0], // [left, top, right, bottom]
columns: columns,
columnGap: 5
};
};
// page title // page title
var createTitle = function() { var createTitle = function() {
return { return {
@ -351,11 +383,12 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf'])
// since it is not possible to give a column a fixed height, we draw an "empty" column // since it is not possible to give a column a fixed height, we draw an "empty" column
// with a one px width and a fixed top-margin // with a one px width and a fixed top-margin
return { return {
columns : [ columns: [
header(),
{ {
width: 1, width: 1,
margin: [0, marginTop], margin: [0, marginTop],
text: "" text: '',
}, },
{ {
width: '*', width: '*',
@ -363,8 +396,8 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf'])
createTitle(), createTitle(),
createPollHint(), createPollHint(),
createSelectionField(), createSelectionField(),
] ],
} },
] ]
}; };
}; };
@ -473,9 +506,17 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf'])
return createContentTable(); return createContentTable();
}; };
return { return $q(function (resolve) {
getContent: getContent var imageSources = [
}; logoAssignmentBallotPaperUrl,
];
ImageConverter.toBase64(imageSources).then(function (_imageMap) {
imageMap = _imageMap;
resolve({
getContent: getContent
});
});
});
}; };
return { return {
@ -610,9 +651,10 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf'])
} }
}); });
var filename = gettextCatalog.getString('Ballot') + '_' + pollNumber + '_' + assignment.title + '.pdf'; var filename = gettextCatalog.getString('Ballot') + '_' + pollNumber + '_' + assignment.title + '.pdf';
var ballotContentProvider = BallotContentProvider.createInstance(assignment, thePoll, pollNumber); BallotContentProvider.createInstance(assignment, thePoll, pollNumber).then(function (ballotContentProvider) {
var documentProvider = PdfMakeBallotPaperProvider.createInstance(ballotContentProvider); var documentProvider = PdfMakeBallotPaperProvider.createInstance(ballotContentProvider);
PdfCreate.download(documentProvider.getDocument(), filename); PdfCreate.download(documentProvider.getDocument(), filename);
});
}, },
}; };
} }

View File

@ -250,9 +250,11 @@ def get_config_variables():
default_value=[ default_value=[
'logo_projector_main', 'logo_projector_main',
'logo_projector_header', 'logo_projector_header',
'logo_web_header',
'logo_pdf_header', 'logo_pdf_header',
'logo_pdf_footer', 'logo_pdf_footer',
'logo_web_header'], 'logo_pdf_assignment_ballot_paper',
'logo_pdf_motion_poll'],
weight=300, weight=300,
group='Logo', group='Logo',
hidden=True) hidden=True)
@ -277,6 +279,16 @@ def get_config_variables():
group='Logo', group='Logo',
hidden=True) hidden=True)
yield ConfigVariable(
name='logo_web_header',
default_value={
'display_name': 'Web interface header logo',
'path': ''},
input_type='logo',
weight=303,
group='Logo',
hidden=True)
# PDF logos # PDF logos
yield ConfigVariable( yield ConfigVariable(
name='logo_pdf_header', name='logo_pdf_header',
@ -299,11 +311,21 @@ def get_config_variables():
hidden=True) hidden=True)
yield ConfigVariable( yield ConfigVariable(
name='logo_web_header', name='logo_pdf_assignment_ballot_paper',
default_value={ default_value={
'display_name': 'Web interface header logo', 'display_name': 'Election ballot paper',
'path': ''}, 'path': ''},
input_type='logo', input_type='logo',
weight=311, weight=312,
group='Logo',
hidden=True)
yield ConfigVariable(
name='logo_pdf_motion_poll',
default_value={
'display_name': 'Motion poll',
'path': ''},
input_type='logo',
weight=313,
group='Logo', group='Logo',
hidden=True) hidden=True)

View File

@ -29,8 +29,8 @@
<!-- Logo --> <!-- Logo -->
<div class="title"> <div class="title">
<a ui-sref="home"> <a ui-sref="home">
<img src="/static/img/openslides-logo-dark.png" alt="OpenSlides Logo" height="35"> <img ng-if="!config('logo_web_header').path" src="/static/img/openslides-logo-dark.png" alt="OpenSlides Logo" height="35">
<img ng-if="config('logo_web_header').path" ng-src="{{ config('logo_web_header').path }}" alt="Logo" height="35"> <img ng-if="config('logo_web_header').path" ng-src="{{ config('logo_web_header').path }}" alt="OpenSlides Logo" height="35">
</a> </a>
</div> </div>

View File

@ -540,11 +540,13 @@ angular.module('OpenSlidesApp.motions.pdf', ['OpenSlidesApp.core.pdf'])
]) ])
.factory('PollContentProvider', [ .factory('PollContentProvider', [
'$q',
'PDFLayout', 'PDFLayout',
'gettextCatalog', 'gettextCatalog',
'Config', 'Config',
'User', 'User',
function(PDFLayout, gettextCatalog, Config, User) { 'ImageConverter',
function($q, PDFLayout, gettextCatalog, Config, User, ImageConverter) {
/** /**
* Generates a content provider for polls * Generates a content provider for polls
* @constructor * @constructor
@ -553,6 +555,36 @@ angular.module('OpenSlidesApp.motions.pdf', ['OpenSlidesApp.core.pdf'])
*/ */
var createInstance = function(title, id) { var createInstance = function(title, id) {
var logoMotionPollUrl = Config.get('logo_pdf_motion_poll').value.path;
var imageMap = {};
// PDF header
var header = function() {
var columns = [];
var text = Config.get('general_event_name').value
columns.push({
text: text,
fontSize: 8,
alignment: 'left',
width: '80%'
});
// logo
columns.push({
image: imageMap[logoMotionPollUrl].data,
fit: [90,25],
width: '20%'
});
return {
color: '#555',
fontSize: 10,
margin: [30, 10, 10, 0], // [left, top, right, bottom]
columns: columns,
columnGap: 5
};
};
/** /**
* Returns a single section on the ballot paper * Returns a single section on the ballot paper
* @function * @function
@ -560,18 +592,21 @@ angular.module('OpenSlidesApp.motions.pdf', ['OpenSlidesApp.core.pdf'])
var createSection = function() { var createSection = function() {
var sheetend = 75; var sheetend = 75;
return { return {
stack: [{ stack: [
text: gettextCatalog.getString("Motion") + " " + id, header(),
style: 'title', {
}, { text: gettextCatalog.getString('Motion') + ' ' + id,
text: title, style: 'title',
style: 'description' },
}, {
PDFLayout.createBallotEntry(gettextCatalog.getString("Yes")), text: title,
PDFLayout.createBallotEntry(gettextCatalog.getString("No")), style: 'description'
PDFLayout.createBallotEntry(gettextCatalog.getString("Abstain")), },
PDFLayout.createBallotEntry(gettextCatalog.getString('Yes')),
PDFLayout.createBallotEntry(gettextCatalog.getString('No')),
PDFLayout.createBallotEntry(gettextCatalog.getString('Abstain')),
], ],
margin: [0, 0, 0, sheetend] margin: [0, 0, 0, sheetend],
}; };
}; };
@ -642,9 +677,17 @@ angular.module('OpenSlidesApp.motions.pdf', ['OpenSlidesApp.core.pdf'])
return content; return content;
}; };
return { return $q(function (resolve) {
getContent: getContent, var imageSources = [
}; logoMotionPollUrl,
];
ImageConverter.toBase64(imageSources).then(function (_imageMap) {
imageMap = _imageMap;
resolve({
getContent: getContent
});
});
});
}; };
return { return {
createInstance: createInstance createInstance: createInstance
@ -944,9 +987,10 @@ angular.module('OpenSlidesApp.motions.pdf', ['OpenSlidesApp.core.pdf'])
var id = motion.identifier.replace(' ', ''); var id = motion.identifier.replace(' ', '');
var title = motion.getTitle(version); var title = motion.getTitle(version);
var filename = gettextCatalog.getString('Motion') + '-' + id + '-' + gettextCatalog.getString('ballot-paper') + '.pdf'; var filename = gettextCatalog.getString('Motion') + '-' + id + '-' + gettextCatalog.getString('ballot-paper') + '.pdf';
var pollContentProvider = PollContentProvider.createInstance(title, id); PollContentProvider.createInstance(title, id).then(function (pollContentProvider) {
var documentProvider = PdfMakeBallotPaperProvider.createInstance(pollContentProvider); var documentProvider = PdfMakeBallotPaperProvider.createInstance(pollContentProvider);
PdfCreate.download(documentProvider.getDocument(), filename); PdfCreate.download(documentProvider.getDocument(), filename);
});
}, },
exportPersonalNote: function (motion, filename) { exportPersonalNote: function (motion, filename) {
var personalNote = PersonalNoteManager.getNote(motion); var personalNote = PersonalNoteManager.getNote(motion);