From 3e1c1abe14f7dcaeec16f7b90f3e7601285f4901 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emanuel=20Sch=C3=BCtze?= Date: Wed, 21 Jun 2017 19:32:02 +0200 Subject: [PATCH 1/3] Added new logo placeholder for web interface header logo. --- CHANGELOG | 4 ++-- openslides/core/config_variables.py | 13 ++++++++++++- openslides/core/static/js/core/site.js | 1 + openslides/core/static/templates/index.html | 3 ++- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 5d047bdd0..03b7c8a40 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -51,8 +51,8 @@ Users: Core: - No reload on logoff. OpenSlides is now a full single page application [#3172]. -- Adding support for choosing image files as logos for projector and - PDF [#3184, #3207, #3208]. +- Adding support for choosing image files as logos for projector, + PDF and web interface header [#3184, #3207, #3208, #3310]. - Fixing error when clearing empty chat [#3199]. - Added notify system [#3212]. - Enhanced performance esp. for server restart and first connection of all diff --git a/openslides/core/config_variables.py b/openslides/core/config_variables.py index aeea09aba..c43354e8a 100644 --- a/openslides/core/config_variables.py +++ b/openslides/core/config_variables.py @@ -251,7 +251,8 @@ def get_config_variables(): 'logo_projector_main', 'logo_projector_header', 'logo_pdf_header', - 'logo_pdf_footer'], + 'logo_pdf_footer', + 'logo_web_header'], weight=300, group='Logo', hidden=True) @@ -296,3 +297,13 @@ def get_config_variables(): weight=311, group='Logo', hidden=True) + + yield ConfigVariable( + name='logo_web_header', + default_value={ + 'display_name': 'Web interface header logo', + 'path': ''}, + input_type='logo', + weight=311, + group='Logo', + hidden=True) diff --git a/openslides/core/static/js/core/site.js b/openslides/core/static/js/core/site.js index e369aa5ec..fb5ff3b28 100644 --- a/openslides/core/static/js/core/site.js +++ b/openslides/core/static/js/core/site.js @@ -1906,6 +1906,7 @@ angular.module('OpenSlidesApp.core.site', [ gettext('Projector header image'); gettext('PDF header logo'); gettext('PDF footer logo'); + gettext('Web interface header logo'); // Mark the string 'Default projector' here, because it does not appear in the templates. gettext('Default projector'); diff --git a/openslides/core/static/templates/index.html b/openslides/core/static/templates/index.html index bb613ef54..e1ff6f6e1 100644 --- a/openslides/core/static/templates/index.html +++ b/openslides/core/static/templates/index.html @@ -29,7 +29,8 @@
- Logo + OpenSlides Logo + Logo
From bf56067d175792c64c2b47d067c9b424b68cf05c Mon Sep 17 00:00:00 2001 From: FinnStutzenstein Date: Thu, 22 Jun 2017 08:44:59 +0200 Subject: [PATCH 2/3] poll and ballot paper logos --- .../assignments/static/js/assignments/pdf.js | 64 ++++++++++++--- openslides/core/config_variables.py | 30 ++++++- openslides/core/static/templates/index.html | 4 +- openslides/motions/static/js/motions/pdf.js | 80 ++++++++++++++----- 4 files changed, 143 insertions(+), 35 deletions(-) diff --git a/openslides/assignments/static/js/assignments/pdf.js b/openslides/assignments/static/js/assignments/pdf.js index 4f5df21c8..0e34b44b3 100644 --- a/openslides/assignments/static/js/assignments/pdf.js +++ b/openslides/assignments/static/js/assignments/pdf.js @@ -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); + }); }, }; } diff --git a/openslides/core/config_variables.py b/openslides/core/config_variables.py index c43354e8a..96e628d4b 100644 --- a/openslides/core/config_variables.py +++ b/openslides/core/config_variables.py @@ -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) diff --git a/openslides/core/static/templates/index.html b/openslides/core/static/templates/index.html index e1ff6f6e1..a57ef9f3e 100644 --- a/openslides/core/static/templates/index.html +++ b/openslides/core/static/templates/index.html @@ -29,8 +29,8 @@ diff --git a/openslides/motions/static/js/motions/pdf.js b/openslides/motions/static/js/motions/pdf.js index 3fa126ee3..e1061bf29 100644 --- a/openslides/motions/static/js/motions/pdf.js +++ b/openslides/motions/static/js/motions/pdf.js @@ -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); From 2c43bfee472e9c5cc3fac9592ec727338293f2e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emanuel=20Sch=C3=BCtze?= Date: Fri, 11 Aug 2017 12:46:59 +0200 Subject: [PATCH 3/3] Rework on ballot paper layout for using logos. --- .../assignments/static/js/assignments/pdf.js | 30 +++++++++---------- openslides/core/config_variables.py | 17 ++--------- openslides/core/static/js/core/pdf-worker.js | 6 ---- openslides/core/static/js/core/site.js | 1 + openslides/core/static/templates/index.html | 2 +- openslides/motions/static/js/motions/pdf.js | 25 +++++++++------- 6 files changed, 34 insertions(+), 47 deletions(-) diff --git a/openslides/assignments/static/js/assignments/pdf.js b/openslides/assignments/static/js/assignments/pdf.js index 0e34b44b3..ed83d19e8 100644 --- a/openslides/assignments/static/js/assignments/pdf.js +++ b/openslides/assignments/static/js/assignments/pdf.js @@ -276,33 +276,33 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf']) 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 logoBallotPaperUrl = Config.get('logo_pdf_ballot_paper').value.path; var imageMap = {}; // PDF header var header = function() { var columns = []; - var text = Config.get('general_event_name').value + // logo + if (logoBallotPaperUrl) { + columns.push({ + image: imageMap[logoBallotPaperUrl].data, + fit: [90,20], + width: '20%' + }); + } + var text = Config.get('general_event_name').value; columns.push({ text: text, fontSize: 8, - alignment: 'left', - width: '80%' + alignment: 'right', }); - // 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] + margin: [30, 10, 10, -10], // [left, top, right, bottom] columns: columns, - columnGap: 5 + columnGap: 10 }; }; @@ -384,7 +384,6 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf']) // with a one px width and a fixed top-margin return { columns: [ - header(), { width: 1, margin: [0, marginTop], @@ -393,6 +392,7 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf']) { width: '*', stack: [ + header(), createTitle(), createPollHint(), createSelectionField(), @@ -508,7 +508,7 @@ angular.module('OpenSlidesApp.assignments.pdf', ['OpenSlidesApp.core.pdf']) return $q(function (resolve) { var imageSources = [ - logoAssignmentBallotPaperUrl, + logoBallotPaperUrl, ]; ImageConverter.toBase64(imageSources).then(function (_imageMap) { imageMap = _imageMap; diff --git a/openslides/core/config_variables.py b/openslides/core/config_variables.py index 96e628d4b..a689054ff 100644 --- a/openslides/core/config_variables.py +++ b/openslides/core/config_variables.py @@ -253,8 +253,7 @@ def get_config_variables(): 'logo_web_header', 'logo_pdf_header', 'logo_pdf_footer', - 'logo_pdf_assignment_ballot_paper', - 'logo_pdf_motion_poll'], + 'logo_pdf_ballot_paper'], weight=300, group='Logo', hidden=True) @@ -311,21 +310,11 @@ def get_config_variables(): hidden=True) yield ConfigVariable( - name='logo_pdf_assignment_ballot_paper', + name='logo_pdf_ballot_paper', default_value={ - 'display_name': 'Election ballot paper', + 'display_name': 'PDF ballot paper logo', 'path': ''}, input_type='logo', 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) diff --git a/openslides/core/static/js/core/pdf-worker.js b/openslides/core/static/js/core/pdf-worker.js index 4d4d4b303..074035ed1 100644 --- a/openslides/core/static/js/core/pdf-worker.js +++ b/openslides/core/static/js/core/pdf-worker.js @@ -59,12 +59,6 @@ var replacePlaceholder = function (content) { hLineWidth: function(i, node) { if (i === 0){ return 0; - } else if (i === node.table.body.length) { - if (node.rowsperpage && node.rowsperpage > i) { - return 0.5; - } else { - return 0; - } } else { return 0.5; } diff --git a/openslides/core/static/js/core/site.js b/openslides/core/static/js/core/site.js index fb5ff3b28..009788923 100644 --- a/openslides/core/static/js/core/site.js +++ b/openslides/core/static/js/core/site.js @@ -1907,6 +1907,7 @@ angular.module('OpenSlidesApp.core.site', [ gettext('PDF header logo'); gettext('PDF footer logo'); gettext('Web interface header logo'); + gettext('PDF ballot paper logo'); // Mark the string 'Default projector' here, because it does not appear in the templates. gettext('Default projector'); diff --git a/openslides/core/static/templates/index.html b/openslides/core/static/templates/index.html index a57ef9f3e..68cf0bab0 100644 --- a/openslides/core/static/templates/index.html +++ b/openslides/core/static/templates/index.html @@ -29,7 +29,7 @@ diff --git a/openslides/motions/static/js/motions/pdf.js b/openslides/motions/static/js/motions/pdf.js index e1061bf29..16de80897 100644 --- a/openslides/motions/static/js/motions/pdf.js +++ b/openslides/motions/static/js/motions/pdf.js @@ -555,31 +555,34 @@ angular.module('OpenSlidesApp.motions.pdf', ['OpenSlidesApp.core.pdf']) */ var createInstance = function(title, id) { - var logoMotionPollUrl = Config.get('logo_pdf_motion_poll').value.path; + var logoBallotPaperUrl = Config.get('logo_pdf_ballot_paper').value.path; var imageMap = {}; // PDF header var header = function() { var columns = []; - var text = Config.get('general_event_name').value + var text = Config.get('general_event_name').value; columns.push({ text: text, fontSize: 8, alignment: 'left', - width: '80%' + width: '60%' }); // logo - columns.push({ - image: imageMap[logoMotionPollUrl].data, - fit: [90,25], - width: '20%' - }); + if (logoBallotPaperUrl) { + columns.push({ + image: imageMap[logoBallotPaperUrl].data, + fit: [90,25], + alignment: 'right', + width: '40%' + }); + } return { color: '#555', fontSize: 10, - margin: [30, 10, 10, 0], // [left, top, right, bottom] + margin: [30, 10, 10, -10], // [left, top, right, bottom] columns: columns, columnGap: 5 }; @@ -590,7 +593,7 @@ angular.module('OpenSlidesApp.motions.pdf', ['OpenSlidesApp.core.pdf']) * @function */ var createSection = function() { - var sheetend = 75; + var sheetend = 40; return { stack: [ header(), @@ -679,7 +682,7 @@ angular.module('OpenSlidesApp.motions.pdf', ['OpenSlidesApp.core.pdf']) return $q(function (resolve) { var imageSources = [ - logoMotionPollUrl, + logoBallotPaperUrl, ]; ImageConverter.toBase64(imageSources).then(function (_imageMap) { imageMap = _imageMap;