From 2bdac9492bb99ea1be689b6731d8ced4b9506fa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 30 Aug 2018 15:57:43 +0200 Subject: [PATCH] Use tab name for CSV Export/Import issue7640 review48571002 --- CHANGELOG | 1 + src/common.js | 11 +++++++---- src/tab.js | 5 +++-- src/window.js | 20 ++++++++------------ 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index fd99aba55b..26b68daea9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Use tab name in CSV Export/Import * Add bus management * Load custom CSS and Javascript * New icons diff --git a/src/common.js b/src/common.js index 654f0ce1a2..1a802ca620 100644 --- a/src/common.js +++ b/src/common.js @@ -3362,10 +3362,13 @@ } }; - Sao.common.download_file = function(data, name) { - var type = Sao.common.guess_mimetype( - name ? name.split('.').pop() : undefined); - var blob = new Blob([data], {type: type}); + Sao.common.download_file = function(data, name, options) { + if (options === undefined) { + var type = Sao.common.guess_mimetype( + name ? name.split('.').pop() : undefined); + options = {type: type}; + } + var blob = new Blob([data], options); if (window.navigator && window.navigator.msSaveOrOpenBlob) { window.navigator.msSaveOrOpenBlob(blob, name); diff --git a/src/tab.js b/src/tab.js index 66accd8d6c..43570194ef 100644 --- a/src/tab.js +++ b/src/tab.js @@ -999,7 +999,8 @@ }.bind(this)); }, export: function(){ - new Sao.Window.Export(this.screen, + new Sao.Window.Export( + this.title.text(), this.screen, this.screen.current_view.selected_records().map(function(r) { return r.id; }), @@ -1007,7 +1008,7 @@ this.screen.context()); }, import: function(){ - new Sao.Window.Import(this.screen); + new Sao.Window.Import(this.title.text(), this.screen); }, get_url: function() { return this.screen.get_url(this.attributes.name); diff --git a/src/window.js b/src/window.js index 57821abbea..182de793b3 100644 --- a/src/window.js +++ b/src/window.js @@ -1011,13 +1011,14 @@ }); Sao.Window.Import = Sao.class_(Sao.Window.CSV, { - init: function(screen) { + init: function(name, screen) { + this.name = name; this.screen = screen; this.session = Sao.Session.current_session; this.fields_data = {}; // Ask before Removing this. this.fields_invert = {}; Sao.Window.Import._super.init.call(this, - Sao.i18n.gettext('Import from CSV')); + Sao.i18n.gettext('CSV Import: %1', name)); jQuery('