Merge pull request #2899 from FinnStutzenstein/IssueCsvIE
Csv export for IE (closes #2898)
This commit is contained in:
commit
fb047fc5b9
@ -7,7 +7,8 @@ angular.module('OpenSlidesApp.agenda.csv', [])
|
||||
.factory('AgendaCsvExport', [
|
||||
'HumanTimeConverter',
|
||||
'gettextCatalog',
|
||||
function (HumanTimeConverter, gettextCatalog) {
|
||||
'CsvDownload',
|
||||
function (HumanTimeConverter, gettextCatalog, CsvDownload) {
|
||||
var makeHeaderline = function () {
|
||||
var headerline = ['Title', 'Text', 'Duration', 'Comment', 'Internal item'];
|
||||
return _.map(headerline, function (entry) {
|
||||
@ -31,11 +32,7 @@ angular.module('OpenSlidesApp.agenda.csv', [])
|
||||
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';
|
||||
CsvDownload(csvRows, element, 'agenda-export.csv');
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ img {
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
max-height: 356px;
|
||||
max-height: 340px;
|
||||
z-index: 1000;
|
||||
}
|
||||
#spinner-container div {
|
||||
|
25
openslides/core/static/js/core/csv.js
Normal file
25
openslides/core/static/js/core/csv.js
Normal file
@ -0,0 +1,25 @@
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
angular.module('OpenSlidesApp.core.csv', [])
|
||||
|
||||
.factory('CsvDownload', [
|
||||
function () {
|
||||
return function (contentRows, element, fileName) {
|
||||
if (navigator.msSaveBlob && typeof navigator.msSaveBlob === 'function') {
|
||||
// Bad browsers
|
||||
var blob = new Blob([contentRows.join('\r\n')]);
|
||||
navigator.msSaveBlob(blob, fileName);
|
||||
} else { // Good browsers
|
||||
// %0A is the url encoded linefeed character. Needed to be
|
||||
// percentage encoded for the data url.
|
||||
element.href = 'data:text/csv;charset=utf-8,' + contentRows.join('%0A');
|
||||
element.download = fileName;
|
||||
element.target = '_blank';
|
||||
}
|
||||
};
|
||||
}
|
||||
]);
|
||||
|
||||
}());
|
@ -6,6 +6,7 @@
|
||||
angular.module('OpenSlidesApp.core.site', [
|
||||
'OpenSlidesApp.core',
|
||||
'OpenSlidesApp.core.start',
|
||||
'OpenSlidesApp.core.csv',
|
||||
'OpenSlidesApp.poll.majority',
|
||||
'ui.router',
|
||||
'colorpicker.module',
|
||||
|
@ -6,7 +6,8 @@ angular.module('OpenSlidesApp.motions.csv', [])
|
||||
|
||||
.factory('MotionCsvExport', [
|
||||
'gettextCatalog',
|
||||
function (gettextCatalog) {
|
||||
'CsvDownload',
|
||||
function (gettextCatalog, CsvDownload) {
|
||||
var makeHeaderline = function () {
|
||||
var headerline = ['Identifier', 'Title', 'Text', 'Reason', 'Submitter', 'Category', 'Origin'];
|
||||
return _.map(headerline, function (entry) {
|
||||
@ -31,11 +32,7 @@ angular.module('OpenSlidesApp.motions.csv', [])
|
||||
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';
|
||||
CsvDownload(csvRows, element, 'motions-export.csv');
|
||||
},
|
||||
downloadExample: function (element) {
|
||||
var csvRows = [makeHeaderline(),
|
||||
@ -44,10 +41,7 @@ angular.module('OpenSlidesApp.motions.csv', [])
|
||||
['B1', 'Title 2', 'Text 2', 'Reason 2', 'Submitter B', 'Category B', '' ],
|
||||
['' , 'Title 3', 'Text 3', '' , '' , '' , '' ],
|
||||
];
|
||||
var csvString = csvRows.join("%0A");
|
||||
element.href = 'data:text/csv;charset=utf-8,' + csvString;
|
||||
element.download = 'motions-example.csv';
|
||||
element.target = '_blank';
|
||||
CsvDownload(csvRows, element, 'motions-example.csv');
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@ -6,7 +6,8 @@ angular.module('OpenSlidesApp.topics.csv', [])
|
||||
|
||||
.factory('TopicsCsvExample', [
|
||||
'gettextCatalog',
|
||||
function (gettextCatalog) {
|
||||
'CsvDownload',
|
||||
function (gettextCatalog, CsvDownload) {
|
||||
var makeHeaderline = function () {
|
||||
var headerline = ['Title', 'Text', 'Duration', 'Comment', 'Internal item'];
|
||||
return _.map(headerline, function (entry) {
|
||||
@ -22,11 +23,7 @@ angular.module('OpenSlidesApp.topics.csv', [])
|
||||
['Demo 2', 'Demo text 2', '1:30', '', '']
|
||||
|
||||
];
|
||||
var csvString = csvRows.join("%0A");
|
||||
element.href = 'data:text/csv;charset=utf-8,' + csvString;
|
||||
element.download = 'agenda-example.csv';
|
||||
element.target = '_blank';
|
||||
|
||||
CsvDownload(csvRows, element, 'agenda-example.csv');
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@ -7,7 +7,8 @@ angular.module('OpenSlidesApp.users.csv', [])
|
||||
.factory('UserCsvExport', [
|
||||
'Group',
|
||||
'gettextCatalog',
|
||||
function (Group, gettextCatalog) {
|
||||
'CsvDownload',
|
||||
function (Group, gettextCatalog, CsvDownload) {
|
||||
var makeHeaderline = function () {
|
||||
var headerline = ['Title', 'Given name', 'Surname', 'Structure level', 'Participant number', 'Groups',
|
||||
'Comment', 'Is active', 'Is present', 'Is a committee'];
|
||||
@ -21,24 +22,23 @@ angular.module('OpenSlidesApp.users.csv', [])
|
||||
makeHeaderline()
|
||||
];
|
||||
_.forEach(users, function (user) {
|
||||
var groups = _.map(user.groups_id, function (id) {
|
||||
return gettextCatalog.getString(Group.get(id).name);
|
||||
}).join(',');
|
||||
var row = [];
|
||||
row.push('"' + user.title + '"');
|
||||
row.push('"' + user.first_name + '"');
|
||||
row.push('"' + user.last_name + '"');
|
||||
row.push('"' + user.structure_level + '"');
|
||||
row.push('"' + user.number + '"');
|
||||
row.push('"' + user.groups_id.join(',') + '"');
|
||||
row.push('"' + groups + '"');
|
||||
row.push('"' + user.comment + '"');
|
||||
row.push(user.is_active ? '1' : '0');
|
||||
row.push(user.is_present ? '1' : '0');
|
||||
row.push(user.is_committee ? '1' : '0');
|
||||
csvRows.push(row);
|
||||
});
|
||||
|
||||
var csvString = csvRows.join("%0A");
|
||||
element.href = 'data:text/csv;charset=utf-8,' + csvString;
|
||||
element.download = 'users-export.csv';
|
||||
element.target = '_blank';
|
||||
CsvDownload(csvRows, element, 'users-export.csv');
|
||||
},
|
||||
|
||||
downloadExample: function (element) {
|
||||
@ -62,10 +62,7 @@ angular.module('OpenSlidesApp.users.csv', [])
|
||||
['', '', 'Executive Board', '', '', '', '', '', '', '1'],
|
||||
|
||||
];
|
||||
var csvString = csvRows.join("%0A");
|
||||
element.href = 'data:text/csv;charset=utf-8,' + csvString;
|
||||
element.download = 'users-example.csv';
|
||||
element.target = '_blank';
|
||||
CsvDownload(csvRows, element, 'users-example.csv');
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user