diff --git a/CHANGELOG b/CHANGELOG index c74dfd0ee..7147a3a80 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -66,6 +66,7 @@ Motions: - Save pagination sate to session storage [#3569]. - Split up 'can_see_and_manage_comments' permission in two seperate ones [#3565]. +- Added (shortened) motion title to motion block slide [#3700]. Elections: - Added pagination for list view [#3393]. diff --git a/openslides/motions/static/js/motions/motion-block-projector.js b/openslides/motions/static/js/motions/motion-block-projector.js index e1e791b0c..5db18429c 100644 --- a/openslides/motions/static/js/motions/motion-block-projector.js +++ b/openslides/motions/static/js/motions/motion-block-projector.js @@ -26,6 +26,33 @@ angular.module('OpenSlidesApp.motions.motionBlockProjector', []) // class. var id = $scope.element.id; MotionBlock.bindOne(id, $scope, 'motionBlock'); + + // Returns a shortened motion title. If the title is longer then maxLength, it is + // split at the last whitespace that is in maxLength. Three dots are added then. + $scope.getShortTitle = function (motion) { + var maxLength = 40; + var title = motion.getTitle(); + + if (title.length <= maxLength) { + return title; + } + + // Find last whitespace that is before maxLength. Split the title + // there and append dots. + var whitespaceIndex = -1; + for (var i = 0; i < maxLength+1; i++) { + if (title[i] === ' ') { + whitespaceIndex = i; + } + } + + if (whitespaceIndex === -1) { + // just one long word.. split it :/ + return title.substr(0, maxLength) + '...'; + } else { + return title.substr(0, whitespaceIndex) + '...'; + } + }; } ]); diff --git a/openslides/motions/static/templates/motions/slide_motion_block.html b/openslides/motions/static/templates/motions/slide_motion_block.html index f6bac20e3..6ccdc555c 100644 --- a/openslides/motions/static/templates/motions/slide_motion_block.html +++ b/openslides/motions/static/templates/motions/slide_motion_block.html @@ -8,7 +8,8 @@
- {{ motion.identifier }} + {{ motion.identifier }}: + {{ getShortTitle(motion) }}
{{ motion.getRecommendationName() }}