[ADD] reload file button next to the file input, as webkit browsers and MSIE don't trigger change when a file input is re-set to thee same file

Using other events (e.g. 'click') is not kosher as the event is
triggered long before the file is picked, the alternative is to use
the File API and regularly check the file in the input to see if it's
been altered (by storing a crc) and re-pushing it if the hash is
different. Of course this has other issues (risks catching the file
mid-edition...)

A third alternative is, once a file has been uploaded, to clear and
re-insert the corresponding file input. This means the file input will
*always* be empty

bzr revid: xmo@openerp.com-20121010101836-qtqmcc5n5zblgmcp
This commit is contained in:
Xavier Morel 2012-10-10 12:18:36 +02:00
parent f168998a49
commit 4dd9a0529e
3 changed files with 22 additions and 1 deletions

View File

@ -60,3 +60,22 @@
.oe_import_selector li {
margin: 0; padding: 0;
}
.oe_import .oe_import_file_reload {
font-size: 1px;
letter-spacing: -1px;
color: transparent;
font-weight: normal;
position: relative;
padding: 0;
height: 19px;
width: 20px;
}
.oe_import .oe_import_file_reload:before {
font: 26px "mnmliconsRegular";
content: "Q";
color: #4C4C4C;
position: absolute;
top: -6px;
left: 2px;
}

View File

@ -73,7 +73,8 @@ openerp.base_import = function (instance) {
],
events: {
// 'change .oe_import_grid input': 'import_dryrun',
'change input.oe_import_file': 'loaded_file',
'change .oe_import_file': 'loaded_file',
'click .oe_import_file_reload': 'loaded_file',
'change input.oe_import_has_header, .oe_import_options input': 'settings_changed',
'click a.oe_import_toggle': function (e) {
e.preventDefault();

View File

@ -24,6 +24,7 @@
<label t-attf-for="file_#{_id}" autofocus="autofocus">CSV File:</label>
<input type="file" id-attf-id="file_#{_id}"
name="file" class="oe_import_file"/>
<button type="button" class="oe_import_file_reload">Reload File</button>
<div class="oe_import_with_file">
<a href="#" class="oe_import_toggle">
File Format Options…</a>