diff --git a/openslides/agenda/static/js/agenda/csv.js b/openslides/agenda/static/js/agenda/csv.js new file mode 100644 index 000000000..3af602796 --- /dev/null +++ b/openslides/agenda/static/js/agenda/csv.js @@ -0,0 +1,31 @@ +(function () { + +'use strict'; + +angular.module('OpenSlidesApp.agenda.csv', []) + +.factory('AgendaCsvExport', [ + function () { + return function (element, agenda) { + var csvRows = [ + ['title', 'text', 'duration', 'comment', 'is_hidden'], + ]; + _.forEach(agenda, function (item) { + var row = []; + row.push('"' + (item.title || '') + '"'); + row.push('"' + (item.text || '') + '"'); + row.push('"' + (item.duration || '') + '"'); + row.push('"' + (item.comment || '') + '"'); + row.push('"' + (item.is_hidden ? '1' : '') + '"'); + csvRows.push(row); + }); + + var csvString = csvRows.join("%0A"); + element.href = 'data:text/csv;charset=utf-8,' + csvString; + element.download = 'agenda-export.csv'; + element.target = '_blank'; + }; + } +]); + +}()); diff --git a/openslides/agenda/static/js/agenda/site.js b/openslides/agenda/static/js/agenda/site.js index 52b375a18..de8fd82f8 100644 --- a/openslides/agenda/static/js/agenda/site.js +++ b/openslides/agenda/static/js/agenda/site.js @@ -5,7 +5,8 @@ angular.module('OpenSlidesApp.agenda.site', [ 'OpenSlidesApp.agenda', 'OpenSlidesApp.core.pdf', - 'OpenSlidesApp.agenda.pdf' + 'OpenSlidesApp.agenda.pdf', + 'OpenSlidesApp.agenda.csv', ]) .config([ diff --git a/openslides/motions/static/js/motions/base.js b/openslides/motions/static/js/motions/base.js index 49d289db3..b50bd592e 100644 --- a/openslides/motions/static/js/motions/base.js +++ b/openslides/motions/static/js/motions/base.js @@ -6,7 +6,6 @@ angular.module('OpenSlidesApp.motions', [ 'OpenSlidesApp.motions.motionBlock', 'OpenSlidesApp.motions.lineNumbering', 'OpenSlidesApp.motions.diff', - 'OpenSlidesApp.motions.DOCX', 'OpenSlidesApp.poll.majority', 'OpenSlidesApp.users', ]) diff --git a/openslides/motions/static/js/motions/csv.js b/openslides/motions/static/js/motions/csv.js new file mode 100644 index 000000000..5e621f958 --- /dev/null +++ b/openslides/motions/static/js/motions/csv.js @@ -0,0 +1,35 @@ +(function () { + +'use strict'; + +angular.module('OpenSlidesApp.motions.csv', []) + +.factory('MotionCsvExport', [ + function () { + return function (element, motions) { + var csvRows = [ + ['identifier', 'title', 'text', 'reason', 'submitter', 'category', 'origin'], + ]; + _.forEach(motions, function (motion) { + var row = []; + row.push('"' + motion.identifier + '"'); + row.push('"' + motion.getTitle() + '"'); + row.push('"' + motion.getText() + '"'); + row.push('"' + motion.getReason() + '"'); + var submitter = motion.submitters[0] ? motion.submitters[0].get_full_name() : ''; + row.push('"' + submitter + '"'); + var category = motion.category ? motion.category.name : ''; + row.push('"' + category + '"'); + row.push('"' + motion.origin + '"'); + csvRows.push(row); + }); + + var csvString = csvRows.join("%0A"); + element.href = 'data:text/csv;charset=utf-8,' + csvString; + element.download = 'motions-export.csv'; + element.target = '_blank'; + }; + } +]); + +}()); diff --git a/openslides/motions/static/js/motions/docx.js b/openslides/motions/static/js/motions/docx.js index 6b3b7ef97..a02d5bb9d 100644 --- a/openslides/motions/static/js/motions/docx.js +++ b/openslides/motions/static/js/motions/docx.js @@ -2,7 +2,7 @@ 'use strict'; -angular.module('OpenSlidesApp.motions.DOCX', []) +angular.module('OpenSlidesApp.motions.docx', []) .factory('MotionDocxExport', [ '$http', diff --git a/openslides/motions/static/js/motions/site.js b/openslides/motions/static/js/motions/site.js index ec21c8152..ec0cd25e3 100644 --- a/openslides/motions/static/js/motions/site.js +++ b/openslides/motions/static/js/motions/site.js @@ -7,7 +7,9 @@ angular.module('OpenSlidesApp.motions.site', [ 'OpenSlidesApp.motions.motionservices', 'OpenSlidesApp.poll.majority', 'OpenSlidesApp.core.pdf', - 'OpenSlidesApp.motions.pdf' + 'OpenSlidesApp.motions.docx', + 'OpenSlidesApp.motions.pdf', + 'OpenSlidesApp.motions.csv', ]) .config([ @@ -716,33 +718,6 @@ angular.module('OpenSlidesApp.motions.site', [ } ]) -.factory('MotionCsvExport', [ - function () { - return function (element, motions) { - var csvRows = [ - ['identifier', 'title', 'text', 'reason', 'submitter', 'category', 'origin'], - ]; - _.forEach(motions, function (motion) { - var row = []; - row.push('"' + motion.identifier + '"'); - row.push('"' + motion.getTitle() + '"'); - row.push('"' + motion.getText() + '"'); - row.push('"' + motion.getReason() + '"'); - row.push('"' + motion.submitters[0].get_full_name() + '"'); - var category = motion.category ? motion.category.name : ''; - row.push('"' + category + '"'); - row.push('"' + motion.origin + '"'); - csvRows.push(row); - }); - - var csvString = csvRows.join("%0A"); - element.href = 'data:text/csv;charset=utf-8,' + csvString; - element.download = 'motions-export.csv'; - element.target = '_blank'; - }; - } -]) - // Cache for MotionPollDetailCtrl so that users choices are keeped during user actions (e. g. save poll form). .value('MotionPollDetailCtrlCache', {}) diff --git a/openslides/motions/static/templates/motions/motion-list.html b/openslides/motions/static/templates/motions/motion-list.html index c170f45b6..eb1090d77 100644 --- a/openslides/motions/static/templates/motions/motion-list.html +++ b/openslides/motions/static/templates/motions/motion-list.html @@ -369,7 +369,7 @@ -