2016-12-05 16:22:58 +01:00
|
|
|
(function () {
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
angular.module('OpenSlidesApp.agenda.csv', [])
|
|
|
|
|
|
|
|
.factory('AgendaCsvExport', [
|
2016-12-19 14:41:18 +01:00
|
|
|
'HumanTimeConverter',
|
2017-01-06 12:21:37 +01:00
|
|
|
'gettextCatalog',
|
2017-01-20 15:03:45 +01:00
|
|
|
'CsvDownload',
|
|
|
|
function (HumanTimeConverter, gettextCatalog, CsvDownload) {
|
2017-01-06 12:21:37 +01:00
|
|
|
var makeHeaderline = function () {
|
|
|
|
var headerline = ['Title', 'Text', 'Duration', 'Comment', 'Internal item'];
|
|
|
|
return _.map(headerline, function (entry) {
|
|
|
|
return gettextCatalog.getString(entry);
|
2016-12-05 16:22:58 +01:00
|
|
|
});
|
2017-01-06 12:21:37 +01:00
|
|
|
};
|
|
|
|
return {
|
2017-02-07 12:44:51 +01:00
|
|
|
export: function (agenda) {
|
2017-01-06 12:21:37 +01:00
|
|
|
var csvRows = [
|
|
|
|
makeHeaderline()
|
|
|
|
];
|
|
|
|
_.forEach(agenda, function (item) {
|
|
|
|
var row = [];
|
|
|
|
var duration = item.duration ? HumanTimeConverter.secondsToHumanTime(item.duration*60,
|
|
|
|
{ seconds: 'disabled',
|
|
|
|
hours: 'enabled' }) : '';
|
|
|
|
row.push('"' + (item.title || '') + '"');
|
2017-02-14 19:33:56 +01:00
|
|
|
row.push('"' + (item.getCSVExportText() || '') + '"');
|
2017-01-06 12:21:37 +01:00
|
|
|
row.push('"' + duration + '"');
|
|
|
|
row.push('"' + (item.comment || '') + '"');
|
|
|
|
row.push('"' + (item.is_hidden ? '1' : '') + '"');
|
|
|
|
csvRows.push(row);
|
|
|
|
});
|
2018-03-19 11:58:16 +01:00
|
|
|
CsvDownload(csvRows, gettextCatalog.getString('Agenda') + '.csv');
|
2017-01-06 12:21:37 +01:00
|
|
|
},
|
2016-12-05 16:22:58 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
]);
|
|
|
|
|
|
|
|
}());
|