[FIX] mail: scroll, avatar, delete attachments, print
bzr revid: chm@openerp.com-20121109101628-4e8cnjr1lcmt0tdv
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<!-- <data noupdate="1"> -->
|
||||
<data>
|
||||
<data noupdate="1">
|
||||
|
||||
<!-- Pushed to all employees -->
|
||||
<record id="message_blogpost0" model="mail.message">
|
||||
|
||||
@@ -408,7 +408,6 @@ class mail_message(osv.Model):
|
||||
ancestors and expandables
|
||||
:return list: list of message structure for the Chatter widget
|
||||
"""
|
||||
# print '\n>>>>message_read begin', ids, domain, thread_level, parent_id, '\n'
|
||||
assert thread_level in [0, 1], 'message_read() thread_level should be 0 (flat) or 1 (1 level of thread); given %s.' % thread_level
|
||||
domain = domain if domain is not None else []
|
||||
message_unload_ids = message_unload_ids if message_unload_ids is not None else []
|
||||
@@ -491,7 +490,6 @@ class mail_message(osv.Model):
|
||||
- uid have read access to the related document is model, res_id
|
||||
- otherwise: remove the id
|
||||
"""
|
||||
# print '\n>>>>>_search on mail.message', uid, args, '\n'
|
||||
# Rules do not apply to administrator
|
||||
if uid == SUPERUSER_ID:
|
||||
return super(mail_message, self)._search(cr, uid, args, offset=offset, limit=limit, order=order,
|
||||
@@ -526,7 +524,6 @@ class mail_message(osv.Model):
|
||||
allowed_ids |= set([message_id for allowed_doc_id in allowed_doc_ids for message_id in doc_dict[allowed_doc_id]])
|
||||
|
||||
final_ids = author_ids | partner_ids | allowed_ids
|
||||
# print '\n>>>>>end _search on mail.message\n'
|
||||
if count:
|
||||
return len(final_ids)
|
||||
else:
|
||||
@@ -551,7 +548,6 @@ class mail_message(osv.Model):
|
||||
- uid has write access on the related document if model, res_id
|
||||
- Otherwise: raise
|
||||
"""
|
||||
# print '\n>>>>>check_access_rule on mail.message', uid, ids, operation, '\n'
|
||||
if uid == SUPERUSER_ID:
|
||||
return
|
||||
if isinstance(ids, (int, long)):
|
||||
@@ -623,7 +619,6 @@ class mail_message(osv.Model):
|
||||
|
||||
# Calculate remaining ids: if not void, raise an error
|
||||
other_ids = other_ids - set(document_related_ids)
|
||||
# print '\n>>>>>end check_access_rule on mail.message\n'
|
||||
if not other_ids:
|
||||
return
|
||||
raise orm.except_orm(_('Access Denied'),
|
||||
|
||||
@@ -114,6 +114,69 @@ openerp.mail = function (session) {
|
||||
return domain;
|
||||
},
|
||||
|
||||
// inserts zero width space between each letter of a string so that
|
||||
// the word will correctly wrap in html boxes smaller than the text
|
||||
breakword: function(str){
|
||||
var out = '';
|
||||
if (!str) {
|
||||
return str;
|
||||
}
|
||||
for(var i = 0, len = str.length; i < len; i++){
|
||||
out += _.str.escapeHTML(str[i]) + '​';
|
||||
}
|
||||
return out;
|
||||
},
|
||||
|
||||
// returns the file type of a file based on its extension
|
||||
// As it only looks at the extension it is quite approximative.
|
||||
filetype: function(url){
|
||||
url = url.filename || url;
|
||||
var tokens = url.split('.');
|
||||
if(tokens.length <= 1){
|
||||
return 'unknown';
|
||||
}
|
||||
var extension = tokens[tokens.length -1];
|
||||
if(extension.length === 0){
|
||||
return 'unknown';
|
||||
}else{
|
||||
extension = extension.toLowerCase();
|
||||
}
|
||||
var filetypes = {
|
||||
'webimage': ['png','jpg','jpeg','jpe','gif'], // those have browser preview
|
||||
'image': ['tif','tiff','tga',
|
||||
'bmp','xcf','psd','ppm','pbm','pgm','pnm','mng',
|
||||
'xbm','ico','icon','exr','webp','psp','pgf','xcf',
|
||||
'jp2','jpx','dng','djvu','dds'],
|
||||
'vector': ['ai','svg','eps','vml','cdr','xar','cgm','odg','sxd'],
|
||||
'print': ['dvi','pdf','ps'],
|
||||
'document': ['doc','docx','odm','odt'],
|
||||
'presentation': ['key','keynote','odp','pps','ppt'],
|
||||
'font': ['otf','ttf','woff','eot'],
|
||||
'archive': ['zip','7z','ace','apk','bzip2','cab','deb','dmg','gzip','jar',
|
||||
'rar','tar','gz','pak','pk3','pk4','lzip','lz','rpm'],
|
||||
'certificate': ['cer','key','pfx','p12','pem','crl','der','crt','csr'],
|
||||
'audio': ['aiff','wav','mp3','ogg','flac','wma','mp2','aac',
|
||||
'm4a','ra','mid','midi'],
|
||||
'video': ['asf','avi','flv','mkv','m4v','mpeg','mpg','mpe','wmv','mp4','ogm'],
|
||||
'text': ['txt','rtf','ass'],
|
||||
'html': ['html','xhtml','xml','htm','css'],
|
||||
'disk': ['iso','nrg','img','ccd','sub','cdi','cue','mds','mdx'],
|
||||
'script': ['py','js','c','cc','cpp','cs','h','java','bat','sh',
|
||||
'd','rb','pl','as','cmd','coffee','m','r','vbs','lisp'],
|
||||
'spreadsheet': ['123','csv','ods','numbers','sxc','xls','vc','xlsx'],
|
||||
'binary': ['exe','com','bin','app'],
|
||||
};
|
||||
for(filetype in filetypes){
|
||||
var ext_list = filetypes[filetype];
|
||||
for(var i = 0, len = ext_list.length; i < len; i++){
|
||||
if(extension === ext_list[i]){
|
||||
return filetype;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 'unknown';
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -211,87 +274,29 @@ openerp.mail = function (session) {
|
||||
this.date = session.web.format_value(this._date, {type:"datetime"});
|
||||
this.timerelative = $.timeago(this.date);
|
||||
}
|
||||
if (this.type == 'email') {
|
||||
if (this.type == 'email' && !this.author_id) {
|
||||
this.avatar = ('/mail/static/src/img/email_icon.png');
|
||||
} else if (this.author_id) {
|
||||
this.avatar = mail.ChatterUtils.get_image(this.session, 'res.partner', 'image_small', this.author_id[0]);
|
||||
} else {
|
||||
this.avatar = mail.ChatterUtils.get_image(this.session, 'res.users', 'image_small', this.session.uid);
|
||||
}
|
||||
for (var l in this.attachment_ids) {
|
||||
var attach = this.attachment_ids[l];
|
||||
attach['url'] = mail.ChatterUtils.get_attachment_url(this.session, attach);
|
||||
|
||||
if (attach.filename.match(/[.](jpg|jpg|gif|png|tif|svg)$/i)) {
|
||||
attach.is_image = true;
|
||||
attach['url'] = mail.ChatterUtils.get_image(this.session, 'ir.attachment', 'datas', attach.id);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// inserts zero width space between each letter of a string so that
|
||||
// the word will correctly wrap in html boxes smaller than the text
|
||||
breakword: function(str){
|
||||
var out = '';
|
||||
for(var i = 0, len = str.length; i < len; i++){
|
||||
out += _.str.escapeHTML(str[i]) + '​';
|
||||
}
|
||||
return out;
|
||||
},
|
||||
|
||||
// returns the file type of a file based on its extension
|
||||
// As it only looks at the extension it is quite approximative.
|
||||
filetype: function(url){
|
||||
url = url.name || url.filename || url;
|
||||
var tokens = url.split('.');
|
||||
if(tokens.length <= 1){
|
||||
return 'unknown';
|
||||
}
|
||||
var extension = tokens[tokens.length -1];
|
||||
if(extension.length === 0){
|
||||
return 'unknown';
|
||||
}else{
|
||||
extension = extension.toLowerCase();
|
||||
}
|
||||
var filetypes = {
|
||||
'webimage': ['png','jpg','jpeg','jpe','gif'], // those have browser preview
|
||||
'image': ['tif','tiff','tga',
|
||||
'bmp','xcf','psd','ppm','pbm','pgm','pnm','mng',
|
||||
'xbm','ico','icon','exr','webp','psp','pgf','xcf',
|
||||
'jp2','jpx','dng','djvu','dds'],
|
||||
'vector': ['ai','svg','eps','vml','cdr','xar','cgm','odg','sxd'],
|
||||
'print': ['dvi','pdf','ps'],
|
||||
'document': ['doc','docx','odm','odt'],
|
||||
'presentation': ['key','keynote','odp','pps','ppt'],
|
||||
'font': ['otf','ttf','woff','eot'],
|
||||
'archive': ['zip','7z','ace','apk','bzip2','cab','deb','dmg','gzip','jar',
|
||||
'rar','tar','gz','pak','pk3','pk4','lzip','lz','rpm'],
|
||||
'certificate': ['cer','key','pfx','p12','pem','crl','der','crt','csr'],
|
||||
'audio': ['aiff','wav','mp3','ogg','flac','wma','mp2','aac',
|
||||
'm4a','ra','mid','midi'],
|
||||
'video': ['asf','avi','flv','mkv','m4v','mpeg','mpg','mpe','wmv','mp4','ogm'],
|
||||
'text': ['txt','rtf','ass'],
|
||||
'html': ['html','xhtml','xml','htm','css'],
|
||||
'disk': ['iso','nrg','img','ccd','sub','cdi','cue','mds','mdx'],
|
||||
'script': ['py','js','c','cc','cpp','cs','h','java','bat','sh',
|
||||
'd','rb','pl','as','cmd','coffee','m','r','vbs','lisp'],
|
||||
'spreadsheet': ['123','csv','ods','numbers','sxc','xls','vc','xlsx'],
|
||||
'binary': ['exe','com','bin','app'],
|
||||
};
|
||||
for(filetype in filetypes){
|
||||
var ext_list = filetypes[filetype];
|
||||
for(var i = 0, len = ext_list.length; i < len; i++){
|
||||
if(extension === ext_list[i]){
|
||||
return filetype;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 'unknown';
|
||||
},
|
||||
|
||||
/* upload the file on the server, add in the attachments list and reload display
|
||||
*/
|
||||
display_attachments: function () {
|
||||
for (var l in this.attachment_ids) {
|
||||
var attach = this.attachment_ids[l];
|
||||
if (!attach.formating) {
|
||||
attach.url = mail.ChatterUtils.get_attachment_url(this.session, attach);
|
||||
attach.filetype = mail.ChatterUtils.filetype(attach.filename);
|
||||
attach.name = mail.ChatterUtils.breakword(attach.name || attach.filename);
|
||||
attach.formating = true;
|
||||
}
|
||||
}
|
||||
this.$(".oe_msg_attachment_list").html( session.web.qweb.render('mail.thread.message.attachments', {'widget': this}) );
|
||||
},
|
||||
|
||||
@@ -437,6 +442,7 @@ openerp.mail = function (session) {
|
||||
*/
|
||||
on_attachment_delete: function (event) {
|
||||
event.stopPropagation();
|
||||
console.log(event);
|
||||
var attachment_id=$(event.target).data("id");
|
||||
if (attachment_id) {
|
||||
var attachments=[];
|
||||
@@ -476,7 +482,7 @@ openerp.mail = function (session) {
|
||||
this.$('textarea:not(.oe_compact)').on('blur', _.bind( this.on_compose_expandable, this));
|
||||
|
||||
// event: delete child attachments off the oe_msg_attachment_list box
|
||||
this.$(".oe_msg_attachment_list").off('click').on('click', '.oe_mail_attachment_delete', this.on_attachment_delete);
|
||||
this.$(".oe_msg_attachment_list").on('click', '.oe_delete', this.on_attachment_delete);
|
||||
},
|
||||
|
||||
on_compose_fullmail: function (default_composition_mode) {
|
||||
@@ -1043,7 +1049,7 @@ openerp.mail = function (session) {
|
||||
*/
|
||||
on_scroll: function () {
|
||||
var expandables =
|
||||
_.each( _.filter(this.messages, function (val) {return val.id == -1;}), function (val) {
|
||||
_.each( _.filter(this.messages, function (val) {return val.max_limit && !val.parent_id;}), function (val) {
|
||||
var pos = val.$el.position();
|
||||
if (pos.top) {
|
||||
/* bottom of the screen */
|
||||
|
||||
@@ -72,21 +72,21 @@
|
||||
-->
|
||||
<t t-name="mail.thread.message.attachments">
|
||||
<t t-foreach='widget.attachment_ids' t-as='attachment'>
|
||||
<t t-if="widget.filetype(attachment) !== 'webimage'">
|
||||
<t t-if="attachment.filetype !== 'webimage'">
|
||||
<div class='oe_attachment'>
|
||||
<a t-att-href='attachment.url'><img t-att-src="'/mail/static/src/img/mimetypes/' + widget.filetype(attachment) + '.png'"></img></a>
|
||||
<a t-att-href='attachment.url'><img t-att-src="'/mail/static/src/img/mimetypes/' + attachment.filetype + '.png'"></img></a>
|
||||
<div class='oe_delete oe_e' title="Delete this attachment" t-attf-data-id="{attachment.id}">[</div>
|
||||
<div class='oe_name'><t t-raw='widget.breakword(attachment.name || attachment.filename)' /></div>
|
||||
<div class='oe_name'><t t-raw='attachment.name' /></div>
|
||||
<div class='oe_progress_bar'>
|
||||
uploading
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
<t t-if="widget.filetype(attachment) === 'webimage'">
|
||||
<t t-if="attachment.filetype === 'webimage'">
|
||||
<div class='oe_attachment oe_preview'>
|
||||
<a t-att-href='attachment.url'><img t-att-src="widget.attachments_resize_image(attachment.id, [100,100])"></img></a>
|
||||
<div class='oe_delete oe_e'>[</div>
|
||||
<div class='oe_name'><t t-raw='widget.breakword(attachment.name || attachment.filename)' /></div>
|
||||
<div class='oe_name'><t t-raw='attachment.name' /></div>
|
||||
<div class='oe_progress_bar'>
|
||||
uploading
|
||||
</div>
|
||||
|
||||
@@ -8,11 +8,11 @@
|
||||
<form string="Compose Email" version="7.0">
|
||||
<group>
|
||||
<!-- truly invisible fields for control and options -->
|
||||
<field name="composition_mode" invisible="0"/>
|
||||
<field name="model" invisible="0"/>
|
||||
<field name="res_id" invisible="0"/>
|
||||
<field name="parent_id" invisible="0"/>
|
||||
<field name="content_subtype" invisible="0"/>
|
||||
<field name="composition_mode" invisible="1"/>
|
||||
<field name="model" invisible="1"/>
|
||||
<field name="res_id" invisible="1"/>
|
||||
<field name="parent_id" invisible="1"/>
|
||||
<field name="content_subtype" invisible="1"/>
|
||||
<!-- visible wizard -->
|
||||
<field name="partner_ids" widget="many2many_tags_email" placeholder="Add contacts to notify..."
|
||||
context="{'force_email':True}" required="1"/>
|
||||
|
||||
Reference in New Issue
Block a user