summaryrefslogtreecommitdiff
path: root/addons/mail/static/src
diff options
context:
space:
mode:
authorAmit Patel <apa@tinyerp.com>2012-09-14 10:37:33 +0530
committerAmit Patel <apa@tinyerp.com>2012-09-14 10:37:33 +0530
commit4eac135e0859b70d7e87d92478ff5a609eaef6ed (patch)
tree55aaa3d2c0eb1c463a15dff97483a430d5273677 /addons/mail/static/src
parent23951e1e0d86fe86732928a143c9029e2fcf6862 (diff)
parent9df7381ced04b44e470fe0a060b6b82773f20c84 (diff)
[MERGE]:trunk
bzr revid: apa@tinyerp.com-20120914050733-9euo3vftm8fee6sq
Diffstat (limited to 'addons/mail/static/src')
-rw-r--r--addons/mail/static/src/css/mail.css4
-rw-r--r--addons/mail/static/src/js/mail_followers.js57
-rw-r--r--addons/mail/static/src/xml/mail.xml6
-rw-r--r--addons/mail/static/src/xml/mail_followers.xml3
4 files changed, 43 insertions, 27 deletions
diff --git a/addons/mail/static/src/css/mail.css b/addons/mail/static/src/css/mail.css
index 92ead6f2432..48a178732b0 100644
--- a/addons/mail/static/src/css/mail.css
+++ b/addons/mail/static/src/css/mail.css
@@ -96,10 +96,6 @@
width: 120px;
}
-.openerp button.oe_mail_button_followers {
- display: inline;
-}
-
.openerp button.oe_mail_button_mouseout {
color: white;
background-color: #8a89ba;
diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js
index 34976269285..cf33bd64640 100644
--- a/addons/mail/static/src/js/mail_followers.js
+++ b/addons/mail/static/src/js/mail_followers.js
@@ -31,33 +31,52 @@ openerp_mail_followers = function(session, mail) {
},
start: function() {
- var self = this;
- // NB: all the widget should be modified to check the actual_mode property on view, not use
- // any other method to know if the view is in create mode anymore
+ // use actual_mode property on view to know if the view is in create mode anymore
this.view.on("change:actual_mode", this, this._check_visibility);
this._check_visibility();
- this.$el.find('button.oe_mail_button_follow').click(function () { self.do_follow(); })
- .mouseover(function () { $(this).html('Follow').removeClass('oe_mail_button_mouseout').addClass('oe_mail_button_mouseover'); })
- .mouseleave(function () { $(this).html('Not following').removeClass('oe_mail_button_mouseover').addClass('oe_mail_button_mouseout'); });
- this.$el.find('button.oe_mail_button_unfollow').click(function () { self.do_unfollow(); })
- .mouseover(function () { $(this).html('Unfollow').removeClass('oe_mail_button_mouseout').addClass('oe_mail_button_mouseover'); })
- .mouseleave(function () { $(this).html('Following').removeClass('oe_mail_button_mouseover').addClass('oe_mail_button_mouseout'); });
this.reinit();
+ this.bind_events();
},
_check_visibility: function() {
this.$el.toggle(this.view.get("actual_mode") !== "create");
},
- destroy: function () {
- this._super.apply(this, arguments);
- },
-
reinit: function() {
this.$el.find('button.oe_mail_button_follow').hide();
this.$el.find('button.oe_mail_button_unfollow').hide();
},
+ bind_events: function() {
+ var self = this;
+ this.$('button.oe_mail_button_unfollow').on('click', function () { self.do_unfollow(); })
+ .mouseover(function () { $(this).html('Unfollow').removeClass('oe_mail_button_mouseout').addClass('oe_mail_button_mouseover'); })
+ .mouseleave(function () { $(this).html('Following').removeClass('oe_mail_button_mouseover').addClass('oe_mail_button_mouseout'); });
+ this.$el.on('click', 'button.oe_mail_button_follow', function () { self.do_follow(); });
+ this.$el.on('click', 'button.oe_mail_button_invite', function(event) {
+ action = {
+ type: 'ir.actions.act_window',
+ res_model: 'mail.wizard.invite',
+ view_mode: 'form',
+ view_type: 'form',
+ views: [[false, 'form']],
+ target: 'new',
+ context: {
+ 'default_res_model': self.view.dataset.model,
+ 'default_res_id': self.view.datarecord.id
+ },
+ }
+ self.do_action(action, function() { self.read_value(); });
+ });
+ },
+
+ read_value: function() {
+ var self = this;
+ return this.ds_model.read_ids([this.view.datarecord.id], ['message_follower_ids']).pipe(function (results) {
+ return results[0].message_follower_ids;
+ }).pipe(this.proxy('set_value'));
+ },
+
set_value: function(value_) {
this.reinit();
if (! this.view.datarecord.id ||
@@ -65,11 +84,11 @@ openerp_mail_followers = function(session, mail) {
this.$el.find('div.oe_mail_recthread_aside').hide();
return;
}
- return this.fetch_followers(value_);
+ return this.fetch_followers(value_ || this.get_value());
},
fetch_followers: function (value_) {
- return this.ds_follow.call('read', [value_ || this.get_value(), ['name', 'user_ids']]).then(this.proxy('display_followers'));
+ return this.ds_follow.call('read', [value_, ['name', 'user_ids']]).pipe(this.proxy('display_followers'));
},
/** Display the followers, evaluate is_follower directly */
@@ -91,13 +110,13 @@ openerp_mail_followers = function(session, mail) {
},
do_follow: function () {
- var context = new session.web.CompoundContext(this.build_context(), {'read_back': true});
- return this.ds_model.call('message_subscribe_users', [[this.view.datarecord.id], undefined, context]).pipe(this.proxy('set_value'));
+ var context = new session.web.CompoundContext(this.build_context(), {});
+ return this.ds_model.call('message_subscribe_users', [[this.view.datarecord.id], undefined, context]).pipe(this.proxy('read_value'));
},
do_unfollow: function () {
- var context = new session.web.CompoundContext(this.build_context(), {'read_back': true});
- return this.ds_model.call('message_unsubscribe_users', [[this.view.datarecord.id], undefined, context]).pipe(this.proxy('set_value'));
+ var context = new session.web.CompoundContext(this.build_context(), {});
+ return this.ds_model.call('message_unsubscribe_users', [[this.view.datarecord.id], undefined, context]).pipe(this.proxy('read_value'));
},
});
};
diff --git a/addons/mail/static/src/xml/mail.xml b/addons/mail/static/src/xml/mail.xml
index 4d3b56cf62f..bf339f21f1c 100644
--- a/addons/mail/static/src/xml/mail.xml
+++ b/addons/mail/static/src/xml/mail.xml
@@ -114,7 +114,7 @@
<!-- dropdown menu with message options and actions -->
<span class="oe_dropdown_toggle oe_dropdown_arrow">
<ul class="oe_dropdown_menu">
- <li t-if="record.is_author &amp; options.show_dd_delete"><a class="oe_mail_msg_delete" t-attf-data-id='{record.id}'>Delete</a></li>
+ <li t-if="record.is_author and options.show_dd_delete"><a class="oe_mail_msg_delete" t-attf-data-id='{record.id}'>Delete</a></li>
<li t-if="options.show_dd_hide"><a class="oe_mail_msg_hide" t-attf-data-id='{record.id}'>Remove notification</a></li>
<!-- Uncomment when adding subtype hiding
<li t-if="display['show_hide']">
@@ -130,14 +130,14 @@
<t t-raw="record.subject"/>
</h1>
<div class="oe_mail_msg_body">
- <t t-if="options.show_record_name &amp; (!record.subject) &amp; (options.thread_level > 0)">
+ <t t-if="options.show_record_name and record.record_name and (!record.subject) and (options.thread_level > 0)">
<a t-attf-href="#model=#{record.model}&amp;id=#{record.res_id}"><t t-raw="record.record_name"/></a>
</t>
<t t-raw="record.body"/>
</div>
<div class="oe_clear"/>
<ul class="oe_mail_msg_footer">
- <li t-if="options.show_record_name &amp; record.subject &amp; options.thread_level > 0">
+ <li t-if="options.show_record_name and record.record_name and record.subject and options.thread_level > 0">
<a t-attf-href="#model=#{record.model}&amp;id=#{record.res_id}"><t t-raw="record.record_name"/></a>
</li>
<li><a t-attf-href="#model=res.partner&amp;id=#{record.author_id[0]}"><t t-raw="record.author_id[1]"/></a></li>
diff --git a/addons/mail/static/src/xml/mail_followers.xml b/addons/mail/static/src/xml/mail_followers.xml
index 39622f42abf..32ce34d48d1 100644
--- a/addons/mail/static/src/xml/mail_followers.xml
+++ b/addons/mail/static/src/xml/mail_followers.xml
@@ -7,7 +7,8 @@
-->
<div t-name="mail.followers" class="oe_mail_recthread_aside oe_semantic_html_override">
<div class="oe_mail_recthread_actions">
- <button type="button" class="oe_mail_button_follow oe_mail_button_mouseout">Not following</button>
+ <button type="button" class="oe_mail_button_invite">Invite</button>
+ <button type="button" class="oe_mail_button_follow">Follow</button>
<button type="button" class="oe_mail_button_unfollow oe_mail_button_mouseout">Following</button>
</div>
<div class="oe_mail_recthread_followers">