Generate example csv import files (Fixes #1761)

- agenda csv file
- motions csv file
- users csv file
This commit is contained in:
Emanuel Schuetze 2015-12-30 21:56:03 +01:00
parent 9a6ebdb2cf
commit 98cd4301a6
6 changed files with 53 additions and 9 deletions

View File

@ -342,6 +342,22 @@ angular.module('OpenSlidesApp.agenda.site', ['OpenSlidesApp.agenda'])
$scope.clear = function () {
$scope.csv.result = null;
};
// download CSV example file
$scope.downloadCSVExample = function () {
var element = document.getElementById('downloadLink');
var csvRows = [
// column header line
['title', 'text'],
// example entries
['Demo 1', 'Demo text 1'],
['Demo 2', 'Demo text 2']
];
var csvString = csvRows.join("%0A");
element.href = 'data:text/csv;charset=utf-8,' + csvString;
element.download = 'agenda-example.csv';
element.target = '_blank';
}
}
]);

View File

@ -69,9 +69,7 @@ Keep each item in a single line.</p>
<code>'title, text'</code>
<li translate>Text is optional and may be empty.
<li translate>Only double quotes are accepted as text delimiter (no single quotes).
<li><a href="https://github.com/OpenSlides/OpenSlides/wiki/CSV-Import" translate>
Use the CSV example file from OpenSlides Wiki.
</a>
<li><a id="downloadLink" href="" ng-click="downloadCSVExample()" translate>Download CSV example file</a>
</ul>
<div ng-if="csv.result">

View File

@ -720,6 +720,23 @@ angular.module('OpenSlidesApp.motions.site', ['OpenSlidesApp.motions'])
$scope.clear = function () {
$scope.csv.result = null;
};
// download CSV example file
$scope.downloadCSVExample = function () {
var element = document.getElementById('downloadLink');
var csvRows = [
// column header line
['identifier', 'title', 'text', 'reason', 'submitter', 'category'],
// example entries
['A1', 'title 1', 'text 1', 'reason 1', 'Submitter A', 'Category A'],
['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';
}
}
])

View File

@ -41,9 +41,7 @@
<code>'identifier, title, text, reason, submitter, category'</code>
<li translate>Identifier, reason, submitter and category are optional and may be empty.
<li translate>Only double quotes are accepted as text delimiter (no single quotes).
<li><a href="https://github.com/OpenSlides/OpenSlides/wiki/CSV-Import" translate>
Use the CSV example file from OpenSlides Wiki.
</a>
<li><a id="downloadLink" href="" ng-click="downloadCSVExample()" translate>Download CSV example file</a>
</ul>
<div ng-if="csv.result">

View File

@ -712,6 +712,23 @@ angular.module('OpenSlidesApp.users.site', ['OpenSlidesApp.users'])
$scope.clear = function () {
$scope.csv.result = null;
};
// download CSV example file
$scope.downloadCSVExample = function () {
var element = document.getElementById('downloadLink');
var csvRows = [
// column header line
['title', 'first_name', 'last_name', 'structure_level', 'groups', 'comment', 'is_active'],
// example entries
['Dr.', 'Max', 'Mustermann', 'Berlin', '"3,4"', 'xyz', '1'],
['', 'John', 'Doe', 'Washington', '3', 'abc', '1'],
['', 'Fred', 'Bloggs', 'London', '', '', ''],
];
var csvString = csvRows.join("%0A");
element.href = 'data:text/csv;charset=utf-8,' + csvString;
element.download = 'users-example.csv';
element.target = '_blank';
}
}
])

View File

@ -74,9 +74,7 @@
<li translate>At least first name or last name have to be filled in. All
other fields are optional and may be empty.
<li translate>Only double quotes are accepted as text delimiter (no single quotes).
<li><a href="https://github.com/OpenSlides/OpenSlides/wiki/CSV-Import" translate>
Use the CSV example file from OpenSlides Wiki.
</a>
<li><a id="downloadLink" href="" ng-click="downloadCSVExample()" translate>Download CSV example file</a>
</ul>
<div ng-if="csv.result">