Skip to content

Commit

Permalink
Merge pull request #216 from UUDigitalHumanitieslab/feature/export
Browse files Browse the repository at this point in the history
Export to Excel and CSV
  • Loading branch information
tijmenbaarda authored Sep 5, 2024
2 parents 5fd4d35 + 5026e26 commit 38ec5e5
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions frontend/vre/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/js/select2.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/backbone-min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/js/tabulator.min.js"></script>
<script src="https://cdn.sheetjs.com/xlsx-0.20.3/package/dist/xlsx.mini.min.js"></script>
<script src="/static/bundle.js"></script>
</body>
</html>
10 changes: 10 additions & 0 deletions frontend/vre/record/record.list.managing.view.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export var RecordListManagingView = CompositeView.extend({
this.vreCollectionsSelect.submitForm(event, selection);
},
'click .more-records': 'loadMore',
'click .download-xlsx': 'downloadXLSX',
'click .download-csv': 'downloadCSV',
},

initialize: function(options) {
Expand All @@ -39,4 +41,12 @@ export var RecordListManagingView = CompositeView.extend({
loadMore: function(event) {
this.collection.trigger('moreRequested', event);
},

downloadXLSX: function() {
this.recordListView.downloadXLSX();
},

downloadCSV: function() {
this.recordListView.downloadCSV();
},
});
6 changes: 5 additions & 1 deletion frontend/vre/record/record.list.managing.view.mustache
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
<h4 id="search-feedback"></h4>
<a href="#" class="more-records">Load more records</a>
<ul class="inline-list">
<li><a href="#" class="more-records">Load more records</a></li>
<li><a href="#" class="download-xlsx">Download XLSX</a></li>
<li><a href="#" class="download-csv">Download CSV</a></li>
</ul>
8 changes: 8 additions & 0 deletions frontend/vre/record/record.list.view.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,12 @@ export var RecordListView = Backbone.View.extend({
this.table.replaceData(data);
}
},

downloadXLSX: function() {
this.table.download("xlsx", "edpop.xlsx", {sheetName: "EDPOP"});
},

downloadCSV: function() {
this.table.download("csv", "edpop.csv");
},
});

0 comments on commit 38ec5e5

Please sign in to comment.