Allow to attach multiple files
issue7735 review56391002
This commit is contained in:
1 parent
c748e07c71
commit
f2be833feb
3 files changed
+23
-20
No files matched your search
+14
-10
@@ -3418,16 +3418,20 @@
|
||||
};
|
||||
|
||||
Sao.common.get_input_data = function(input, callback, char_) {
|
||||
var reader = new FileReader(),
|
||||
file = input[0].files[0];
|
||||
reader.onload = function() {
|
||||
var value = new Uint8Array(reader.result);
|
||||
if (char_) {
|
||||
value = String.fromCharCode.apply(null, value);
|
||||
}
|
||||
callback(value, file.name);
|
||||
};
|
||||
reader.readAsArrayBuffer(file);
|
||||
function read(file) {
|
||||
var reader = new FileReader();
|
||||
reader.onload = function() {
|
||||
var value = new Uint8Array(reader.result);
|
||||
if (char_) {
|
||||
value = String.fromCharCode.apply(null, value);
|
||||
}
|
||||
callback(value, file.name);
|
||||
};
|
||||
reader.readAsArrayBuffer(file);
|
||||
}
|
||||
for (var i = 0; i < input[0].files.length; i++) {
|
||||
read(input[0].files[i]);
|
||||
}
|
||||
};
|
||||
|
||||
Sao.common.ellipsize = function(string, length) {
|
||||
|
||||
+3
-1
@@ -992,11 +992,13 @@
|
||||
}).append(jQuery('<input/>', {
|
||||
'type': 'file',
|
||||
'role': 'menuitem',
|
||||
'multiple': true,
|
||||
'tabindex': -1,
|
||||
}).change(function() {
|
||||
var attachment = window_();
|
||||
Sao.common.get_input_data(
|
||||
jQuery(this), function(data, filename) {
|
||||
window_().add_data(data, filename);
|
||||
attachment.add_data(data, filename);
|
||||
});
|
||||
})).append(jQuery('<a/>', {
|
||||
'role': 'menuitem',
|
||||
|
||||
+6
-9
@@ -443,15 +443,12 @@
|
||||
add_data: function(data, filename) {
|
||||
var screen = this.screen;
|
||||
this.switch_prm.then(function() {
|
||||
screen.set_current_record(null);
|
||||
screen.switch_view('form').then(function() {
|
||||
screen.new_().then(function(record) {
|
||||
var data_field = record.model.fields.data;
|
||||
record.field_set_client(
|
||||
data_field.description.filename, filename);
|
||||
record.field_set_client('data', data);
|
||||
screen.display();
|
||||
});
|
||||
screen.new_().then(function(record) {
|
||||
var data_field = record.model.fields.data;
|
||||
record.field_set_client(
|
||||
data_field.description.filename, filename);
|
||||
record.field_set_client('data', data);
|
||||
screen.display();
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user