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', [
'$q',
'$filter',
'gettextCatalog',
'PDFLayout',
'Config',
'User',
function($filter, gettextCatalog, PDFLayout, Config, User) {
'ImageConverter',
function($q, $filter, gettextCatalog, PDFLayout, Config, User, ImageConverter) {
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
var createTitle = function() {
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
// with a one px width and a fixed top-margin
return {
columns : [
columns: [
header(),
{
width: 1,
margin: [0, marginTop],
text: ""
text: '',
},
{
width: '*',
@ -363,8 +396,8 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf'])
createTitle(),
createPollHint(),
createSelectionField(),
]
}
],
},
]
};
};
@ -473,9 +506,17 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf'])
return createContentTable();
};
return {
getContent: getContent
};
return $q(function (resolve) {
var imageSources = [
logoAssignmentBallotPaperUrl,
];
ImageConverter.toBase64(imageSources).then(function (_imageMap) {
imageMap = _imageMap;
resolve({
getContent: getContent
});
});
});
};
return {
@ -610,9 +651,10 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf'])
}
});
var filename = gettextCatalog.getString('Ballot') + '_' + pollNumber + '_' + assignment.title + '.pdf';
var ballotContentProvider = BallotContentProvider.createInstance(assignment, thePoll, pollNumber);
var documentProvider = PdfMakeBallotPaperProvider.createInstance(ballotContentProvider);
PdfCreate.download(documentProvider.getDocument(), filename);
BallotContentProvider.createInstance(assignment, thePoll, pollNumber).then(function (ballotContentProvider) {
var documentProvider = PdfMakeBallotPaperProvider.createInstance(ballotContentProvider);
PdfCreate.download(documentProvider.getDocument(), filename);
});
},
};
}

View File

@ -250,9 +250,11 @@ def get_config_variables():
default_value=[
'logo_projector_main',
'logo_projector_header',
'logo_web_header',
'logo_pdf_header',
'logo_pdf_footer',
'logo_web_header'],
'logo_pdf_assignment_ballot_paper',
'logo_pdf_motion_poll'],
weight=300,
group='Logo',
hidden=True)
@ -277,6 +279,16 @@ def get_config_variables():
group='Logo',
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
yield ConfigVariable(
name='logo_pdf_header',
@ -299,11 +311,21 @@ def get_config_variables():
hidden=True)
yield ConfigVariable(
name='logo_web_header',
name='logo_pdf_assignment_ballot_paper',
default_value={
'display_name': 'Web interface header logo',
'display_name': 'Election ballot paper',
'path': ''},
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',
hidden=True)

View File

@ -29,8 +29,8 @@
<!-- Logo -->
<div class="title">
<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" ng-src="{{ config('logo_web_header').path }}" alt="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="OpenSlides Logo" height="35">
</a>
</div>

View File

@ -540,11 +540,13 @@ angular.module('OpenSlidesApp.motions.pdf', ['OpenSlidesApp.core.pdf'])
])
.factory('PollContentProvider', [
'$q',
'PDFLayout',
'gettextCatalog',
'Config',
'User',
function(PDFLayout, gettextCatalog, Config, User) {
'ImageConverter',
function($q, PDFLayout, gettextCatalog, Config, User, ImageConverter) {
/**
* Generates a content provider for polls
* @constructor
@ -553,6 +555,36 @@ angular.module('OpenSlidesApp.motions.pdf', ['OpenSlidesApp.core.pdf'])
*/
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
* @function
@ -560,18 +592,21 @@ angular.module('OpenSlidesApp.motions.pdf', ['OpenSlidesApp.core.pdf'])
var createSection = function() {
var sheetend = 75;
return {
stack: [{
text: gettextCatalog.getString("Motion") + " " + id,
style: 'title',
}, {
text: title,
style: 'description'
},
PDFLayout.createBallotEntry(gettextCatalog.getString("Yes")),
PDFLayout.createBallotEntry(gettextCatalog.getString("No")),
PDFLayout.createBallotEntry(gettextCatalog.getString("Abstain")),
stack: [
header(),
{
text: gettextCatalog.getString('Motion') + ' ' + id,
style: 'title',
},
{
text: title,
style: 'description'
},
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 {
getContent: getContent,
};
return $q(function (resolve) {
var imageSources = [
logoMotionPollUrl,
];
ImageConverter.toBase64(imageSources).then(function (_imageMap) {
imageMap = _imageMap;
resolve({
getContent: getContent
});
});
});
};
return {
createInstance: createInstance
@ -944,9 +987,10 @@ angular.module('OpenSlidesApp.motions.pdf', ['OpenSlidesApp.core.pdf'])
var id = motion.identifier.replace(' ', '');
var title = motion.getTitle(version);
var filename = gettextCatalog.getString('Motion') + '-' + id + '-' + gettextCatalog.getString('ballot-paper') + '.pdf';
var pollContentProvider = PollContentProvider.createInstance(title, id);
var documentProvider = PdfMakeBallotPaperProvider.createInstance(pollContentProvider);
PdfCreate.download(documentProvider.getDocument(), filename);
PollContentProvider.createInstance(title, id).then(function (pollContentProvider) {
var documentProvider = PdfMakeBallotPaperProvider.createInstance(pollContentProvider);
PdfCreate.download(documentProvider.getDocument(), filename);
});
},
exportPersonalNote: function (motion, filename) {
var personalNote = PersonalNoteManager.getNote(motion);