[IMP]mail chatter: wizard liked
bzr revid: chm@openerp.com-20121005122741-a0hwb656ww61qcro
This commit is contained in:
parent
df5071c896
commit
9ca47b7f99
|
@ -313,7 +313,7 @@ class mail_message(osv.Model):
|
||||||
record = None
|
record = None
|
||||||
|
|
||||||
# select ids
|
# select ids
|
||||||
if ids:
|
if ids and ids!=[None]:
|
||||||
for msg in self.browse(cr, uid, ids, context=context):
|
for msg in self.browse(cr, uid, ids, context=context):
|
||||||
result.append(self._message_dict_get(cr, uid, msg, context=context))
|
result.append(self._message_dict_get(cr, uid, msg, context=context))
|
||||||
return result
|
return result
|
||||||
|
|
|
@ -160,7 +160,6 @@
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
|
||||||
.openerp div.oe_mail_thread_action {
|
.openerp div.oe_mail_thread_action {
|
||||||
display: none;
|
|
||||||
white-space: normal;
|
white-space: normal;
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
z-index:5;
|
z-index:5;
|
||||||
|
|
|
@ -10,12 +10,27 @@
|
||||||
float: left;
|
float: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.openerp .oe_mail .oe_mail_compose_textarea
|
||||||
|
{
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
.openerp .oe_mail .oe_mail_compose_textarea .oe_mail_post_header,
|
.openerp .oe_mail .oe_mail_compose_textarea .oe_mail_post_header,
|
||||||
.openerp .oe_mail .oe_mail_compose_textarea .oe_mail_post_footer,
|
.openerp .oe_mail .oe_mail_compose_textarea .oe_mail_post_footer,
|
||||||
{
|
{
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.openerp .oe_mail .oe_mail_compose_textarea a.oe_cancel {
|
||||||
|
position: absolute;
|
||||||
|
right: -8px;
|
||||||
|
top: -8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.openerp .oe_mail .oe_mail_compose_textarea button.oe_full {
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
/* mail.compose.message : list_recipients
|
/* mail.compose.message : list_recipients
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ -82,6 +97,10 @@
|
||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.openerp .oe_mail .oe_mail_compose_attachment_list {
|
||||||
|
clear: both;
|
||||||
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
/* mail.compose.message
|
/* mail.compose.message
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ -90,7 +109,7 @@
|
||||||
/* default textarea (oe_mail_compose_textarea), and body textarea for compose form view */
|
/* default textarea (oe_mail_compose_textarea), and body textarea for compose form view */
|
||||||
.openerp .oe_mail.oe_semantic_html_override .oe_mail_compose_textarea textarea.field_text,
|
.openerp .oe_mail.oe_semantic_html_override .oe_mail_compose_textarea textarea.field_text,
|
||||||
.openerp .oe_mail div.oe_mail_compose_message_body textarea.field_text {
|
.openerp .oe_mail div.oe_mail_compose_message_body textarea.field_text {
|
||||||
width: 474px;
|
width: 100%;
|
||||||
min-height: 120px;
|
min-height: 120px;
|
||||||
height: auto;
|
height: auto;
|
||||||
padding: 4px;
|
padding: 4px;
|
||||||
|
|
|
@ -100,10 +100,8 @@ openerp.mail = function(session) {
|
||||||
var self = this;
|
var self = this;
|
||||||
this._super(parent);
|
this._super(parent);
|
||||||
this.attachment_ids = [];
|
this.attachment_ids = [];
|
||||||
// options
|
|
||||||
this.options = options || {};
|
this.context = options.context || {};
|
||||||
this.options.context = options.context || {};
|
|
||||||
this.options.show_attachment_delete = options.show_attachment_delete || false;
|
|
||||||
|
|
||||||
this.id = options.parameters.id;
|
this.id = options.parameters.id;
|
||||||
this.model = options.parameters.model;
|
this.model = options.parameters.model;
|
||||||
|
@ -113,6 +111,8 @@ openerp.mail = function(session) {
|
||||||
this.attachment_ids = [];
|
this.attachment_ids = [];
|
||||||
this.show_attachment_delete = true;
|
this.show_attachment_delete = true;
|
||||||
this.show_attachment_link = false;
|
this.show_attachment_link = false;
|
||||||
|
|
||||||
|
this.parent_thread= parent.messages!= undefined ? parent : false;
|
||||||
},
|
},
|
||||||
|
|
||||||
start: function(){
|
start: function(){
|
||||||
|
@ -153,7 +153,10 @@ openerp.mail = function(session) {
|
||||||
});
|
});
|
||||||
|
|
||||||
// set the function called when attachments are added
|
// set the function called when attachments are added
|
||||||
this.$el.on('change', 'input.oe_insert_file', self.on_attachment_change);
|
this.$el.on('change', 'input.oe_insert_file', self.on_attachment_change );
|
||||||
|
this.$el.on('click', 'a.oe_cancel', self.on_cancel );
|
||||||
|
this.$el.on('click', 'button.oe_post', function(){self.on_message_post()} );
|
||||||
|
this.$el.on('click', 'button.oe_full', function(){self.on_open_wizard()} );
|
||||||
},
|
},
|
||||||
|
|
||||||
on_attachment_change: function (event) {
|
on_attachment_change: function (event) {
|
||||||
|
@ -170,12 +173,43 @@ openerp.mail = function(session) {
|
||||||
$newfield = $target.clone();
|
$newfield = $target.clone();
|
||||||
$newfield.insertAfter($target);
|
$newfield.insertAfter($target);
|
||||||
$target.hide();
|
$target.hide();
|
||||||
$target.attr("id",id);
|
$target.attr("data-id",id);
|
||||||
|
|
||||||
this.display_attachments();
|
this.display_attachments();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
on_open_wizard: function(){
|
||||||
|
var action = {
|
||||||
|
type: 'ir.actions.act_window',
|
||||||
|
res_model: 'mail.compose.message',
|
||||||
|
view_mode: 'form',
|
||||||
|
view_type: 'form',
|
||||||
|
views: [[false, 'form']],
|
||||||
|
target: 'new',
|
||||||
|
context: {
|
||||||
|
'default_res_model': this.model,
|
||||||
|
'default_res_id': this.res_id,
|
||||||
|
'default_content_subtype': 'html',
|
||||||
|
'default_is_private': true,
|
||||||
|
'default_parent_id': this.id,
|
||||||
|
'default_body': this.$('textarea').val().replace(/[\n\r]/g,'<br>'),
|
||||||
|
'default_attachment_ids': this.attachment_ids
|
||||||
|
|
||||||
|
},
|
||||||
|
};
|
||||||
|
this.do_action(action);
|
||||||
|
},
|
||||||
|
|
||||||
|
on_cancel: function(){
|
||||||
|
event.stopPropagation();
|
||||||
|
this.$('textarea').val("");
|
||||||
|
this.$('input[data-id]').remove();
|
||||||
|
this.attachment_ids=[];
|
||||||
|
this.display_attachments();
|
||||||
|
this.$el.hide();
|
||||||
|
},
|
||||||
|
|
||||||
on_attachment_delete: function (event) {
|
on_attachment_delete: function (event) {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
var id=$(event.target).data("id");
|
var id=$(event.target).data("id");
|
||||||
|
@ -186,7 +220,7 @@ openerp.mail = function(session) {
|
||||||
attachments.push(this.attachment_ids[i]);
|
attachments.push(this.attachment_ids[i]);
|
||||||
}
|
}
|
||||||
this.attachment_ids = attachments;
|
this.attachment_ids = attachments;
|
||||||
this.$("input#"+id).remove();
|
this.$("input[data-id='"+id+"'").remove();
|
||||||
/*
|
/*
|
||||||
var attachment_id = parseInt(event.target.dataset.id);
|
var attachment_id = parseInt(event.target.dataset.id);
|
||||||
var idx = _.pluck(this.attachment_ids, 'id').indexOf(attachment_id);
|
var idx = _.pluck(this.attachment_ids, 'id').indexOf(attachment_id);
|
||||||
|
@ -198,6 +232,25 @@ openerp.mail = function(session) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
/*post a message and fletch the message*/
|
||||||
|
on_message_post: function (body) {
|
||||||
|
var self = this;
|
||||||
|
if (! body) {
|
||||||
|
var comment_node = this.$('textarea');
|
||||||
|
var body = comment_node.val();
|
||||||
|
comment_node.val('');
|
||||||
|
}
|
||||||
|
if(body.match(/\S+/)) {
|
||||||
|
this.parent_thread.ds_thread.call('message_post_api', [
|
||||||
|
[this.context.default_res_id], body, false, 'comment', false, this.context.default_parent_id, undefined])
|
||||||
|
.then(this.parent_thread.proxy('switch_new_message'));
|
||||||
|
this.on_cancel();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -654,13 +707,7 @@ openerp.mail = function(session) {
|
||||||
this.display_user_avatar();
|
this.display_user_avatar();
|
||||||
var display_done = compose_done = false;
|
var display_done = compose_done = false;
|
||||||
|
|
||||||
// add message composition form view
|
this.instantiate_ComposeMessage();
|
||||||
this.ComposeMessage = new mail.ComposeMessage(this,{
|
|
||||||
'context': this.context,
|
|
||||||
'parameters': this,
|
|
||||||
'show_attachment_delete': true,
|
|
||||||
});
|
|
||||||
this.ComposeMessage.appendTo(this.$(".oe_mail_thread_action:first"));
|
|
||||||
|
|
||||||
this.bind_events();
|
this.bind_events();
|
||||||
|
|
||||||
|
@ -671,6 +718,16 @@ openerp.mail = function(session) {
|
||||||
return display_done && compose_done;
|
return display_done && compose_done;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
instantiate_ComposeMessage: function(){
|
||||||
|
// add message composition form view
|
||||||
|
this.ComposeMessage = new mail.ComposeMessage(this,{
|
||||||
|
'context': this.context,
|
||||||
|
'parameters': this,
|
||||||
|
'show_attachment_delete': true,
|
||||||
|
});
|
||||||
|
this.ComposeMessage.appendTo(this.$(".oe_mail_thread_action:first"));
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Override-hack of do_action: automatically load message on the chatter.
|
* Override-hack of do_action: automatically load message on the chatter.
|
||||||
* Normally it should be called only when clicking on 'Post/Send'
|
* Normally it should be called only when clicking on 'Post/Send'
|
||||||
|
@ -691,6 +748,8 @@ openerp.mail = function(session) {
|
||||||
|
|
||||||
$(document).scroll( self.on_scroll );
|
$(document).scroll( self.on_scroll );
|
||||||
window.setTimeout( self.on_scroll, 500 );
|
window.setTimeout( self.on_scroll, 500 );
|
||||||
|
|
||||||
|
this.ComposeMessage.$el.show();
|
||||||
},
|
},
|
||||||
|
|
||||||
/* When the expandable object is visible on screen (with scrolling)
|
/* When the expandable object is visible on screen (with scrolling)
|
||||||
|
@ -711,20 +770,11 @@ openerp.mail = function(session) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
on_attachment_change: function (event) {
|
|
||||||
var $target = $(event.target);
|
|
||||||
if ($target.val() !== '') {
|
|
||||||
this.$('form.oe_form_binary_form').submit();
|
|
||||||
session.web.blockUI();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bind events in the widget. Each event is slightly described
|
* Bind events in the widget. Each event is slightly described
|
||||||
* in the function. */
|
* in the function. */
|
||||||
bind_events: function() {
|
bind_events: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
self.$('.oe_mail_compose_textarea:first button.post').click(function () {return self.message_post();});
|
|
||||||
self.$('.oe_mail_compose_textarea .oe_more').click(function () { var p=$(this).parent(); p.find('.oe_more_hidden, .oe_hidden').show(); p.find('.oe_more').hide(); });
|
self.$('.oe_mail_compose_textarea .oe_more').click(function () { var p=$(this).parent(); p.find('.oe_more_hidden, .oe_hidden').show(); p.find('.oe_more').hide(); });
|
||||||
self.$('.oe_mail_compose_textarea .oe_more_hidden').click(function () { var p=$(this).parent(); p.find('.oe_more_hidden, .oe_hidden').hide(); p.find('.oe_more').show(); });
|
self.$('.oe_mail_compose_textarea .oe_more_hidden').click(function () { var p=$(this).parent(); p.find('.oe_more_hidden, .oe_hidden').hide(); p.find('.oe_more').show(); });
|
||||||
},
|
},
|
||||||
|
@ -792,7 +842,7 @@ openerp.mail = function(session) {
|
||||||
/* this function is launch when a user click on "Reply" button
|
/* this function is launch when a user click on "Reply" button
|
||||||
*/
|
*/
|
||||||
on_compose_message: function(){
|
on_compose_message: function(){
|
||||||
this.$('div.oe_mail_thread_action:first').toggle();
|
this.ComposeMessage.$el.toggle();
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -802,24 +852,6 @@ openerp.mail = function(session) {
|
||||||
self.message_fletch();
|
self.message_fletch();
|
||||||
},
|
},
|
||||||
|
|
||||||
/*post a message and fletch the message*/
|
|
||||||
message_post: function (body) {
|
|
||||||
var self = this;
|
|
||||||
if (! body) {
|
|
||||||
var comment_node = this.$('textarea');
|
|
||||||
var body = comment_node.val();
|
|
||||||
comment_node.val('');
|
|
||||||
}
|
|
||||||
if(body.match(/\S+/)) {
|
|
||||||
this.ds_thread.call('message_post_api', [
|
|
||||||
[this.context.default_res_id], body, false, 'comment', false, this.context.default_parent_id, undefined])
|
|
||||||
.then(this.proxy('switch_new_message'));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/** Fetch messages
|
/** Fetch messages
|
||||||
* @param {Bool} initial_mode: initial mode: try to use message_data or
|
* @param {Bool} initial_mode: initial mode: try to use message_data or
|
||||||
* message_ids, if nothing available perform a message_read; otherwise
|
* message_ids, if nothing available perform a message_read; otherwise
|
||||||
|
|
|
@ -16,11 +16,13 @@
|
||||||
<!-- default content: old basic textarea -->
|
<!-- default content: old basic textarea -->
|
||||||
<div class="oe_mail_post_header">
|
<div class="oe_mail_post_header">
|
||||||
<t t-call="mail.thread.list_recipients"/>
|
<t t-call="mail.thread.list_recipients"/>
|
||||||
|
<a class="oe_cancel oe_e">X</a>
|
||||||
</div>
|
</div>
|
||||||
<textarea class="field_text" placeholder="Add your comment here..."/>
|
<textarea class="field_text" placeholder="Add your comment here..."/>
|
||||||
<div class="oe_mail_post_footer">
|
<div class="oe_mail_post_footer">
|
||||||
<span class="oe_mail_compose_attachment_list"/>
|
<div class="oe_mail_compose_attachment_list"/>
|
||||||
<button class="post">Post message</button>
|
<button class="oe_full">Full mail message</button>
|
||||||
|
<button class="oe_post">Post message</button>
|
||||||
<t t-call="mail.compose_message.add_attachment"/>
|
<t t-call="mail.compose_message.add_attachment"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -63,7 +65,7 @@
|
||||||
<t t-name="mail.thread.message.private">
|
<t t-name="mail.thread.message.private">
|
||||||
<div>
|
<div>
|
||||||
<span class="oe_placeholder_checkbox_private"/>
|
<span class="oe_placeholder_checkbox_private"/>
|
||||||
<span class="oe_send_private">This email is private and don't send to all my followers.</span>
|
<span class="oe_send_private">This email is private.</span>
|
||||||
<span class="oe_send_public">I wrote for contacts and all my followers.</span>
|
<span class="oe_send_public">I wrote for contacts and all my followers.</span>
|
||||||
</div>
|
</div>
|
||||||
</t>
|
</t>
|
||||||
|
@ -92,12 +94,6 @@
|
||||||
Template used to display the communication history in the wall.
|
Template used to display the communication history in the wall.
|
||||||
-->
|
-->
|
||||||
<div t-name="mail.wall" class="oe_view_manager oe_mail_wall oe_view_manager_current">
|
<div t-name="mail.wall" class="oe_view_manager oe_mail_wall oe_view_manager_current">
|
||||||
|
|
||||||
<!--button string="Send Reminder Email" name="%(mail.action_email_compose_message_wizard)d" type="action"
|
|
||||||
states="waiting_answer"
|
|
||||||
context="{'default_body_text': 'Hello,\n\n',
|
|
||||||
'default_subject': '' }"/-->
|
|
||||||
|
|
||||||
<table class="oe_view_manager_header">
|
<table class="oe_view_manager_header">
|
||||||
<colgroup>
|
<colgroup>
|
||||||
<col width="33%"/>
|
<col width="33%"/>
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
<field name="partner_ids" widget="many2many_tags" placeholder="Add contacts to notify..."
|
<field name="partner_ids" widget="many2many_tags" placeholder="Add contacts to notify..."
|
||||||
context="{'force_email':True}"
|
context="{'force_email':True}"
|
||||||
on_change="onchange_partner_ids(partner_ids)"/>
|
on_change="onchange_partner_ids(partner_ids)"/>
|
||||||
|
<field name="is_private" help="If this message is not private, this message will send to all your followers or all followers of the parented message."/>
|
||||||
</group>
|
</group>
|
||||||
<notebook>
|
<notebook>
|
||||||
<page string="Body">
|
<page string="Body">
|
||||||
|
|
Loading…
Reference in New Issue