1 parent
dba33cbb64
commit
4e37fb2039
4 files changed
+28
-18
No files matched your search
@@ -1,3 +1,4 @@
|
||||
* Keep CSV export window opened
|
||||
* Remove favorite management
|
||||
* Retry JSON-RPC requests on Service Unavailable
|
||||
* Allow resizing the attachment preview panel
|
||||
|
||||
+8
-5
@@ -1757,6 +1757,10 @@
|
||||
this.session = Sao.Session.current_session;
|
||||
Sao.Window.Export._super.init.call(this,
|
||||
Sao.i18n.gettext('CSV Export: %1',name));
|
||||
|
||||
this.info_bar = new Sao.Window.InfoBar();
|
||||
this.dialog.body.append(this.info_bar.el);
|
||||
|
||||
var fields = this.screen.model.fields;
|
||||
for (const name of names) {
|
||||
var type = fields[name].description.type;
|
||||
@@ -2201,6 +2205,7 @@
|
||||
).appendTo(this.fields_selected);
|
||||
},
|
||||
response: function(response_id) {
|
||||
this.info_bar.clear();
|
||||
if(response_id == 'RESPONSE_OK') {
|
||||
var fields = [];
|
||||
this.fields_selected.children('li').each(function(i, field) {
|
||||
@@ -2251,9 +2256,7 @@
|
||||
}, this.session);
|
||||
}
|
||||
prm.then(data => {
|
||||
this.export_csv(data, paths, header).then(() => {
|
||||
this.destroy();
|
||||
});
|
||||
this.export_csv(data, paths, header);
|
||||
});
|
||||
} else {
|
||||
this.destroy();
|
||||
@@ -2281,9 +2284,9 @@
|
||||
if (header) {
|
||||
size -= 1;
|
||||
}
|
||||
return Sao.common.message.run(
|
||||
this.info_bar.add(
|
||||
Sao.i18n.ngettext(
|
||||
"%1 record saved", "%1 records saved", size));
|
||||
"%1 record saved", "%1 records saved", size), 'info');
|
||||
},
|
||||
set_url: function() {
|
||||
var path = [this.session.database, 'data', this.screen.model_name];
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
* Keep CSV export window opened
|
||||
* Remove favorite management
|
||||
* Retry JSON-RPC requests on Service Unavailable
|
||||
* Set focus on search entry after search
|
||||
|
||||
@@ -20,10 +20,12 @@ from tryton.gui.window.win_csv import WinCSV
|
||||
from tryton.jsonrpc import JSONEncoder
|
||||
from tryton.rpc import CONNECTION, clear_cache
|
||||
|
||||
from .infobar import InfoBar
|
||||
|
||||
_ = gettext.gettext
|
||||
|
||||
|
||||
class WinExport(WinCSV):
|
||||
class WinExport(WinCSV, InfoBar):
|
||||
"Window export"
|
||||
|
||||
def __init__(self, name, screen):
|
||||
@@ -32,6 +34,8 @@ class WinExport(WinCSV):
|
||||
self.fields = {}
|
||||
super(WinExport, self).__init__()
|
||||
self.dialog.set_title(_('CSV Export: %s') % name)
|
||||
self.dialog.vbox.pack_start(
|
||||
self.create_info_bar(), expand=False, fill=True, padding=0)
|
||||
# Hide as selected record is the default
|
||||
self.ignore_search_limit.hide()
|
||||
|
||||
@@ -341,6 +345,7 @@ class WinExport(WinCSV):
|
||||
self.model2.append((string_, name))
|
||||
|
||||
def response(self, dialog, response):
|
||||
self.info_bar_clear()
|
||||
if response == Gtk.ResponseType.OK:
|
||||
fields = []
|
||||
iter = self.model2.get_iter_first()
|
||||
@@ -393,15 +398,15 @@ class WinExport(WinCSV):
|
||||
else:
|
||||
fileno, fname = tempfile.mkstemp(
|
||||
'.csv', common.slugify(self.name) + '_')
|
||||
if self.export_csv(
|
||||
fname, data, paths, popup=False, header=header):
|
||||
if self.export_csv(fname, data, paths, header=header):
|
||||
os.close(fileno)
|
||||
common.file_open(fname, 'csv')
|
||||
else:
|
||||
os.close(fileno)
|
||||
self.destroy()
|
||||
else:
|
||||
self.destroy()
|
||||
|
||||
def export_csv(self, fname, data, paths, popup=True, header=False):
|
||||
def export_csv(self, fname, data, paths, header=False):
|
||||
encoding = self.csv_enc.get_active_text() or 'utf_8_sig'
|
||||
locale_format = self.csv_locale.get_active()
|
||||
|
||||
@@ -415,14 +420,14 @@ class WinExport(WinCSV):
|
||||
if row:
|
||||
writer.writerow(self.format_row(
|
||||
row, indent=indent, locale_format=locale_format))
|
||||
if popup:
|
||||
size = len(data)
|
||||
if header:
|
||||
size -= 1
|
||||
if size <= 1:
|
||||
common.message(_('%d record saved.') % size)
|
||||
else:
|
||||
common.message(_('%d records saved.') % size)
|
||||
size = len(data)
|
||||
if header:
|
||||
size -= 1
|
||||
if size <= 1:
|
||||
message = _('%d record saved.') % size
|
||||
else:
|
||||
message = _('%d records saved.') % size
|
||||
self.info_bar_add(message, Gtk.MessageType.INFO)
|
||||
return True
|
||||
except (IOError, UnicodeEncodeError, csv.Error) as exception:
|
||||
common.warning(str(exception), _('Export failed'))
|
||||
|
||||
Reference in new issue
Block a user