summaryrefslogtreecommitdiff
path: root/addons/mail/static/src
diff options
context:
space:
mode:
authorRGA(OpenERP) <>2012-11-09 10:57:43 +0530
committerRGA(OpenERP) <>2012-11-09 10:57:43 +0530
commitaa8a73cebb4b0975b85e3d48024f41bb59bf031b (patch)
tree5a0f5e940a04d4c47cb726d68f6c8141c2ed44d8 /addons/mail/static/src
parent9accfe4e93409967756ec1a17c308017c82e482a (diff)
parent0528e00788a7cca36353a2996ab58568bdd8be78 (diff)
Merge with trunk
bzr revid: rgaopenerp-20121109052743-v8ts1k78k37dfgpx
Diffstat (limited to 'addons/mail/static/src')
-rw-r--r--addons/mail/static/src/js/mail.js51
-rw-r--r--addons/mail/static/src/js/mail_followers.js18
-rw-r--r--addons/mail/static/src/js/many2many_tags_email.js88
-rw-r--r--addons/mail/static/src/xml/mail.xml4
4 files changed, 127 insertions, 34 deletions
diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js
index bfda31119f2..7acebe9b1df 100644
--- a/addons/mail/static/src/js/mail.js
+++ b/addons/mail/static/src/js/mail.js
@@ -5,6 +5,7 @@ openerp.mail = function (session) {
var mail = session.mail = {};
openerp_mail_followers(session, mail); // import mail_followers.js
+ openerp_FieldMany2ManyTagsEmail(session); // import manyy2many_tags_email.js
/**
* ------------------------------------------------------------
@@ -356,7 +357,7 @@ openerp.mail = function (session) {
this.context.default_parent_id,
attachments,
this.parent_thread.context
- ]).then(function (record) {
+ ]).done(function (record) {
var thread = self.parent_thread;
// create object and attach to the thread object
thread.message_fetch(false, false, [record], function (arg, data) {
@@ -744,7 +745,7 @@ openerp.mail = function (session) {
}
// if this message is read, all childs message display is read
- this.ds_notification.call('set_message_read', [ [this.id].concat( this.get_child_ids() ) , this.to_read, this.context]).pipe(function () {
+ this.ds_notification.call('set_message_read', [ [this.id].concat( this.get_child_ids() ) , this.to_read, this.context]).then(function () {
self.$el.removeClass(self.to_read ? 'oe_msg_unread':'oe_msg_read').addClass(self.to_read ? 'oe_msg_read':'oe_msg_unread');
self.to_read = !self.to_read;
});
@@ -801,7 +802,7 @@ openerp.mail = function (session) {
on_vote: function (event) {
event.stopPropagation();
var self=this;
- return this.ds_message.call('vote_toggle', [[self.id]]).pipe(function (vote) {
+ return this.ds_message.call('vote_toggle', [[self.id]]).then(function (vote) {
self.has_voted = vote;
self.vote_nb += self.has_voted ? 1 : -1;
self.display_vote();
@@ -826,7 +827,7 @@ openerp.mail = function (session) {
event.stopPropagation();
var self=this;
var button = self.$('.oe_star:first');
- return this.ds_message.call('favorite_toggle', [[self.id]]).pipe(function (star) {
+ return this.ds_message.call('favorite_toggle', [[self.id]]).then(function (star) {
self.is_favorite=star;
if (self.is_favorite) {
button.addClass('oe_starred');
@@ -1111,7 +1112,7 @@ openerp.mail = function (session) {
var thread_level = this.options.display_indented_thread > this.thread_level ? this.options.display_indented_thread - this.thread_level : 0;
return this.ds_message.call('message_read', [ids, fetch_domain, message_loaded_ids, thread_level, fetch_context, this.context.default_parent_id || undefined])
- .then(callback ? _.bind(callback, this, arguments) : this.proxy('switch_new_message'));
+ .done(callback ? _.bind(callback, this, arguments) : this.proxy('switch_new_message'));
},
/**
@@ -1580,7 +1581,7 @@ openerp.mail = function (session) {
load_searchview: function (defaults, hidden) {
var self = this;
this.searchview = new session.web.SearchView(this, this.ds_msg, false, defaults || {}, hidden || false);
- return this.searchview.appendTo(this.$('.oe_view_manager_view_search')).then(function () {
+ return this.searchview.appendTo(this.$('.oe_view_manager_view_search')).done(function () {
self.searchview.on('search_data', self, self.do_searchview_search);
});
},
@@ -1598,7 +1599,7 @@ openerp.mail = function (session) {
domains: domains || [],
contexts: contexts || [],
group_by_seq: groupbys || []
- }).then(function (results) {
+ }).done(function (results) {
self.search_results['context'] = results.context;
self.search_results['domain'] = results.domain;
self.root.destroy();
@@ -1630,7 +1631,22 @@ openerp.mail = function (session) {
bind_events: function () {
var self=this;
- this.$(".oe_write_full").click(function(){ self.root.thread.compose_message.on_compose_fullmail(); });
+ this.$(".oe_write_full").click(function (event) {
+ event.stopPropagation();
+ var action = {
+ type: 'ir.actions.act_window',
+ res_model: 'mail.compose.message',
+ view_mode: 'form',
+ view_type: 'form',
+ action_from: 'mail.ThreadComposeMessage',
+ views: [[false, 'form']],
+ target: 'new',
+ context: {
+ 'default_content_subtype': 'html',
+ },
+ };
+ session.client.action_manager.do_action(action);
+ });
this.$(".oe_write_onwall").click(function(){ self.root.thread.on_compose_message(); });
}
});
@@ -1646,17 +1662,6 @@ openerp.mail = function (session) {
session.web.ComposeMessageTopButton = session.web.Widget.extend({
template:'mail.compose_message.button_top_bar',
- init: function (parent, options) {
- this._super.apply(this, options);
- this.options = this.options || {};
- this.options.domain = this.options.domain || [];
- this.options.context = {
- 'default_model': false,
- 'default_res_id': 0,
- 'default_content_subtype': 'html',
- };
- },
-
start: function (parent, params) {
var self = this;
this.$el.on('click', 'button', self.on_compose_message );
@@ -1673,11 +1678,11 @@ openerp.mail = function (session) {
action_from: 'mail.ThreadComposeMessage',
views: [[false, 'form']],
target: 'new',
- context: _.extend(this.options.context, {
- 'default_model': this.context.default_model,
- 'default_res_id': this.context.default_res_id,
+ context: {
+ 'default_model': '',
+ 'default_res_id': false,
'default_content_subtype': 'html',
- }),
+ },
};
session.client.action_manager.do_action(action);
},
diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js
index a13d2048bf3..a5a97f48d26 100644
--- a/addons/mail/static/src/js/mail_followers.js
+++ b/addons/mail/static/src/js/mail_followers.js
@@ -85,7 +85,7 @@ openerp_mail_followers = function(session, mail) {
read_value: function () {
var self = this;
- return this.ds_model.read_ids([this.view.datarecord.id], ['message_follower_ids']).pipe(function (results) {
+ return this.ds_model.read_ids([this.view.datarecord.id], ['message_follower_ids']).then(function (results) {
self.set_value(results[0].message_follower_ids);
});
},
@@ -98,9 +98,9 @@ openerp_mail_followers = function(session, mail) {
fetch_followers: function (value_) {
this.value = value_ || {};
return this.ds_follow.call('read', [this.value, ['name', 'user_ids']])
- .pipe(this.proxy('display_followers'), this.proxy('fetch_generic'))
- .pipe(this.proxy('display_buttons'))
- .pipe(this.proxy('fetch_subtypes'));
+ .then(this.proxy('display_followers'), this.proxy('fetch_generic'))
+ .then(this.proxy('display_buttons'))
+ .then(this.proxy('fetch_subtypes'));
},
/** Read on res.partner failed: fall back on a generic case
@@ -109,10 +109,10 @@ openerp_mail_followers = function(session, mail) {
fetch_generic: function (error, event) {
var self = this;
event.preventDefault();
- return this.ds_users.call('read', [this.session.uid, ['partner_id']]).pipe(function (results) {
+ return this.ds_users.call('read', [this.session.uid, ['partner_id']]).then(function (results) {
var pid = results['partner_id'][0];
self.message_is_follower = (_.indexOf(self.get('value'), pid) != -1);
- }).pipe(self.proxy('display_generic'));
+ }).then(self.proxy('display_generic'));
},
_format_followers: function(count){
// TDE note: why redefining _t ?
@@ -179,7 +179,7 @@ openerp_mail_followers = function(session, mail) {
var subtype_list_ul = this.$('.oe_subtype_list').empty();
if (! this.message_is_follower) return;
var context = new session.web.CompoundContext(this.build_context(), {});
- this.ds_model.call('message_get_subscription_data', [[this.view.datarecord.id], context]).pipe(this.proxy('display_subtypes'));
+ this.ds_model.call('message_get_subscription_data', [[this.view.datarecord.id], context]).then(this.proxy('display_subtypes'));
},
/** Display subtypes: {'name': default, followed} */
@@ -206,7 +206,7 @@ openerp_mail_followers = function(session, mail) {
$(record).attr('checked',false);
});
var context = new session.web.CompoundContext(this.build_context(), {});
- return this.ds_model.call('message_unsubscribe_users', [[this.view.datarecord.id], [this.session.uid], context]).pipe(this.proxy('read_value'));
+ return this.ds_model.call('message_unsubscribe_users', [[this.view.datarecord.id], [this.session.uid], context]).then(this.proxy('read_value'));
},
do_update_subscription: function (event) {
@@ -221,7 +221,7 @@ openerp_mail_followers = function(session, mail) {
var context = new session.web.CompoundContext(this.build_context(), {});
return this.ds_model.call('message_subscribe_users', [[this.view.datarecord.id], [this.session.uid], this.message_is_follower ? checklist:undefined, context])
- .pipe(this.proxy('read_value'));
+ .then(this.proxy('read_value'));
},
});
};
diff --git a/addons/mail/static/src/js/many2many_tags_email.js b/addons/mail/static/src/js/many2many_tags_email.js
new file mode 100644
index 00000000000..cc701e8a585
--- /dev/null
+++ b/addons/mail/static/src/js/many2many_tags_email.js
@@ -0,0 +1,88 @@
+openerp_FieldMany2ManyTagsEmail = function(instance) {
+var _t = instance.web._t;
+
+/**
+ * Extend of FieldMany2ManyTags widget method.
+ * When the user add a partner and the partner don't have an email, open a popup to purpose to add an email.
+ * The user can choose to add an email or cancel and close the popup.
+ */
+instance.web.form.FieldMany2ManyTagsEmail = instance.web.form.FieldMany2ManyTags.extend({
+
+ start: function() {
+ this.values = [];
+ this.values_checking = [];
+
+ this.on("change:value", this, this.on_change_value_check);
+ this.trigger("change:value");
+
+ this._super.apply(this, arguments);
+ },
+
+ on_change_value_check : function () {
+ this.values = _.uniq(this.values);
+
+ // filter for removed values
+ var values_removed = _.difference(this.values, this.get('value'));
+ if (values_removed.length) {
+ this.values = _.difference(this.values, values_removed);
+ this.set({'value': this.values});
+ return false;
+ }
+
+ // find not checked values that are not currently on checking
+ var not_checked = _.difference(this.get('value'), this.values, this.values_checking);
+ if (not_checked.length) {
+ // remember values on checking for cheked only one time
+ this.values_checking = this.values_checking.concat(not_checked);
+ // check values
+ this._check_email_popup(not_checked);
+ }
+ },
+
+ _check_email_popup: function (ids) {
+ var self = this;
+ new instance.web.Model('res.partner').call("search", [[
+ ["id", "in", ids],
+ ["email", "=", false],
+ ["notification_email_send", "in", ['all', 'comment']] ]],
+ {context: this.build_context()})
+ .then(function (record_ids) {
+ // valid partner
+ var valid_partner = _.difference(ids, record_ids);
+ self.values = self.values.concat(valid_partner);
+ self.values_checking = _.difference(self.values_checking, valid_partner);
+
+ // unvalid partner
+ _.each(record_ids, function (id) {
+ var pop = new instance.web.form.FormOpenPopup(self);
+ pop.show_element(
+ 'res.partner',
+ id,
+ self.build_context(),
+ {
+ title: _t("Please complete partner's informations and Email"),
+ }
+ );
+ pop.on('write_completed', self, function () {
+ this.values.push(id);
+ this.values_checking = _.without(this.values_checking, id);
+ this.set({'value': this.values});
+ });
+ pop.on('closed', self, function () {
+ this.values_checking = _.without(this.values_checking, id);
+ this.set({'value': this.values});
+ });
+ });
+ });
+ },
+});
+
+
+/**
+ * Registry of form fields
+ */
+instance.web.form.widgets = instance.web.form.widgets.extend({
+ 'many2many_tags_email' : 'instance.web.form.FieldMany2ManyTagsEmail',
+});
+
+};
diff --git a/addons/mail/static/src/xml/mail.xml b/addons/mail/static/src/xml/mail.xml
index caa85cd3deb..bfd0e4cd10f 100644
--- a/addons/mail/static/src/xml/mail.xml
+++ b/addons/mail/static/src/xml/mail.xml
@@ -197,8 +197,8 @@
<div class="oe_msg_center">
<div class='oe_msg_icons'>
- <span class='oe_read' t-if="widget.show_read_unread_button"><a title="Read" class="oe_e">X</a></span>
- <span class='oe_unread' t-if="widget.show_read_unread_button"><a title="Set back to unread" class="oe_e">v</a></span>
+ <span class='oe_read' t-if="widget.show_read_unread_button"><a title="Mark as read" class="oe_e">X</a></span>
+ <span class='oe_unread' t-if="widget.show_read_unread_button"><a title="Mark as unread" class="oe_e">v</a></span>
<span class='oe_reply' t-if="widget.show_reply_button"><a title="Reply" class="oe_e">(</a></span>
<span t-attf-class="oe_star #{widget.is_favorite?'oe_starred':''}"><a title="Add To Favorites" class="oe_e">7</a></span>
</div>