summaryrefslogtreecommitdiff
path: root/addons/mail/static/src
diff options
context:
space:
mode:
authorChristophe Matthieu <chm@openerp.com>2012-10-09 10:08:58 +0200
committerChristophe Matthieu <chm@openerp.com>2012-10-09 10:08:58 +0200
commit7a41798d7014adca2c2e91d6eac14e8f6562bc4f (patch)
tree999fa319c7e9f8a2a3512115ecf8cca6312244e3 /addons/mail/static/src
parentaff7e6d16106e473745159d47f842fa0d9c6f27c (diff)
[IMP] mail, document: don't check duplication of file for attachment mail
bzr revid: chm@openerp.com-20121009080858-gnpf1893m12jd3mp
Diffstat (limited to 'addons/mail/static/src')
-rw-r--r--addons/mail/static/src/css/mail.css1
-rw-r--r--addons/mail/static/src/js/mail.js26
-rw-r--r--addons/mail/static/src/xml/mail.xml9
3 files changed, 21 insertions, 15 deletions
diff --git a/addons/mail/static/src/css/mail.css b/addons/mail/static/src/css/mail.css
index 9133078d433..c2abc6a5882 100644
--- a/addons/mail/static/src/css/mail.css
+++ b/addons/mail/static/src/css/mail.css
@@ -245,6 +245,7 @@
.openerp .oe_mail_msg_email {
padding: 8px;
background: white;
+ position: relative;
}
.openerp .oe_mail_msg_notification:after,
diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js
index 599241e598f..8fab771fcc0 100644
--- a/addons/mail/static/src/js/mail.js
+++ b/addons/mail/static/src/js/mail.js
@@ -104,12 +104,13 @@ openerp.mail = function(session) {
this.res_id = options.parameters.res_id;
this.is_private = options.parameters.is_private;
this.partner_ids = options.parameters.partner_ids;
- this.show_header_compose = options.parameters.options.thread.show_header_compose;
- this.display_on_flat = options.parameters.options.thread.display_on_flat;
+ this.options={thread:{}};
+ this.options.thread.show_header_compose = options.parameters.options.thread.show_header_compose;
+ this.options.thread.display_on_flat = options.parameters.options.thread.display_on_flat;
this.attachment_ids = [];
- this.show_attachment_delete = true;
- this.show_attachment_link = true;
+ this.options.thread.show_attachment_delete = true;
+ this.options.thread.show_attachment_link = true;
this.parent_thread= parent.messages!= undefined ? parent : false;
@@ -147,12 +148,17 @@ openerp.mail = function(session) {
var $target = $(event.target);
if ($target.val() !== '') {
+ // if the files exits for this answer, delete the file before upload
+ var attachments=[];
for(var i in this.attachment_ids){
if(this.attachment_ids[i].url == $target.val()){
var ds_attachment = new session.web.DataSetSearch(this, 'ir.attachment');
- ds_attachment.unlink(this.attachment_ids.id);
+ ds_attachment.unlink([this.attachment_ids.id]);
+ } else {
+ attachments.push(this.attachment_ids[i]);
}
}
+ this.attachment_ids = attachments;
// submit file
session.web.blockUI();
@@ -186,7 +192,7 @@ openerp.mail = function(session) {
this.display_attachments();
var ds_attachment = new session.web.DataSetSearch(this, 'ir.attachment');
- ds_attachment.unlink(attachment_id);
+ ds_attachment.unlink([attachment_id]);
}
},
@@ -231,7 +237,7 @@ openerp.mail = function(session) {
this.$('input[data-id]').remove();
this.attachment_ids=[];
this.display_attachments();
- if(!this.show_header_compose || !this.display_on_flat){
+ if(!this.options.thread.show_header_compose || !this.options.thread.display_on_flat){
this.$el.hide();
}
},
@@ -455,10 +461,10 @@ openerp.mail = function(session) {
* in the function. */
bind_events: function() {
var self = this;
+
// event: click on 'Attachment(s)' in msg
- this.$el.on('click', 'a.oe_mail_msg_view_attachments', function (event) {
- var act_dom = $(this).parent().parent().parent().find('.oe_mail_msg_attachments');
- act_dom.toggle();
+ this.$('a.oe_mail_msg_view_attachments:first').on('click', function (event) {
+ self.$('.oe_mail_msg_attachments:first').toggle();
});
// event: click on icone 'Read' in header
this.$el.on('click', 'a.oe_read', this.on_message_read_unread);
diff --git a/addons/mail/static/src/xml/mail.xml b/addons/mail/static/src/xml/mail.xml
index db6935d7af8..cd14632ec6c 100644
--- a/addons/mail/static/src/xml/mail.xml
+++ b/addons/mail/static/src/xml/mail.xml
@@ -55,14 +55,14 @@
Template used to display attachments in a mail.message
-->
<t t-name="mail.thread.message.attachments">
- <ul t-attf-class="oe_mail_msg_attachments #{widget.attachment_ids[0]?'':'oe_hidden'}">
+ <ul t-attf-class="oe_mail_msg_attachments #{widget.attachment_ids[0] and widget.options.thread.show_attachment_link?'':'oe_hidden'}">
<t t-foreach="widget.attachment_ids" t-as="attachment">
<li>
- <a t-if="widget.show_attachment_link" t-att-href="attachment.url"><t t-raw="attachment.name || attachment.filename"/></a>
- <span t-if="!widget.show_attachment_link"><t t-raw="attachment.name || attachment.filename"/></span>
- <t t-if="widget.show_attachment_delete">
+ <a t-att-href="attachment.url"><t t-raw="attachment.name || attachment.filename"/></a>
+ <t t-if="widget.options.thread.show_attachment_delete">
<a class="oe_right oe_mail_attachment_delete" title="Delete this attachmentt" t-attf-data-id="{attachment.id}">x</a>
</t>
+
</li>
</t>
</ul>
@@ -214,7 +214,6 @@
<ul class="oe_mail_msg_footer">
<li t-if="widget.author_id"><a t-attf-href="#model=res.partner&amp;id=#{widget.author_id[0]}"><t t-raw="widget.author_id[1]"/></a></li>
<li><span t-att-title="widget.date"><t t-raw="widget.timerelative"/></span></li>
-
<li t-if="widget.attachment_ids.length > 0">
<a class="oe_mail_msg_view_attachments">
<t t-if="widget.attachment_ids.length == 1">1 Attachment</t>