Add the option to sort categories different in motion export.

This commit is contained in:
FinnStutzenstein 2017-07-26 15:21:49 +02:00 committed by Emanuel Schütze
parent a44b84e836
commit a32b046fa5
5 changed files with 38 additions and 14 deletions

View File

@ -30,7 +30,9 @@ Motions:
- Reworked DOCX export parser and added comments to DOCX [#3258].
- New PDF export for personal note and comments [#3239].
- Bugfix: Creating colliding change recommendation is now prevented
on server side [#3304]
on server side [#3304].
- Added config value for customize sorting of category list in
pdf/docx export [#3329].
Users:
- User without permission to see users can now see agenda item speakers,

View File

@ -253,3 +253,15 @@ def get_config_variables():
weight=375,
group='Motions',
subgroup='Export')
yield ConfigVariable(
name='motions_export_category_sorting',
default_value='prefix',
input_type='choice',
label='Sort categories by',
choices=(
{'value': 'prefix', 'display_name': 'Prefix'},
{'value': 'name', 'display_name': 'Name'}),
weight=385,
group='Motions',
subgroup='Export')

View File

@ -22,7 +22,6 @@ angular.module('OpenSlidesApp.motions.docx', ['OpenSlidesApp.core.docx'])
var getData = function (motions, params) {
var data = {};
var categories = Category.getAll();
// header
var headerline1 = [
Config.translate(Config.get('general_event_name').value),
@ -39,9 +38,10 @@ angular.module('OpenSlidesApp.motions.docx', ['OpenSlidesApp.core.docx'])
data.preamble = Config.get('motions_export_preamble').value;
// categories
var categories = getCategoriesData(motions);
data.has_categories = categories.length === 0 ? false : true;
data.categories_translation = gettextCatalog.getString('Categories');
data.categories = getCategoriesData(categories);
data.categories = categories;
data.no_categories = gettextCatalog.getString('No categories available.');
data.pagebreak_main = categories.length === 0 ? '' : PAGEBREAK;
@ -58,13 +58,21 @@ angular.module('OpenSlidesApp.motions.docx', ['OpenSlidesApp.core.docx'])
});
};
var getCategoriesData = function (categories) {
return _.map(categories, function (category) {
var getCategoriesData = function (motions) {
var categories = _.map(motions, function (motion) {
if (motion.category) {
return {
prefix: category.prefix,
name: category.name,
prefix: motion.category.prefix,
name: motion.category.name,
};
}
});
// clear out 'undefined' and make the categories unique.
categories = _.uniqBy(_.filter(categories, function(category) {
return category;
}), 'prefix');
var sortKey = Config.get('motions_export_category_sorting').value;
return _.orderBy(categories, [sortKey]);
};
var getMotionShortData = function (motions) {

View File

@ -718,15 +718,16 @@ angular.module('OpenSlidesApp.motions.pdf', ['OpenSlidesApp.core.pdf'])
categories.push(category);
}
});
categories = _.uniqBy(categories, 'id');
var sortKey = Config.get('motions_export_category_sorting').value;
categories = _.orderBy(_.uniqBy(categories, 'id'), [sortKey]);
if (categories.length > 1) {
var heading = {
text: gettextCatalog.getString("Categories"),
style: "heading2"
text: gettextCatalog.getString('Categories'),
style: 'heading2',
};
var toc = [];
angular.forEach(_.orderBy(categories, ['prefix']), function(cat) {
angular.forEach(categories, function(cat) {
toc.push(
{
columns: [

View File

@ -2260,6 +2260,7 @@ angular.module('OpenSlidesApp.motions.site', [
// subgroup PDF
gettext('Title for PDF and DOCX documents (all motions)');
gettext('Preamble text for PDF and DOCX documents (all motions)');
gettext('Sort categories by');
// misc strings (used dynamically in templates by translate filter)
gettext('needed');