summaryrefslogtreecommitdiff
path: root/addons/website_mail/static
diff options
context:
space:
mode:
authorDenis Ledoux <dle@odoo.com>2014-07-23 13:16:59 +0200
committerDenis Ledoux <dle@odoo.com>2014-07-23 13:18:30 +0200
commita5f7891b689a325dd33e1d0ade0ea003f2785f60 (patch)
treeb94604a3bf144a33ac623c2552f7af962b383661 /addons/website_mail/static
parente7780ac97a6a45dcf295d4aa86509b00efdf618d (diff)
parent5739aebfb1711bb94c2f94bfb03ec12f17e9430d (diff)
[MERGE] forward port of branch saas-4 up to 5739aebfb1711bb94c2f94bfb03ec12f17e9430d
Diffstat (limited to 'addons/website_mail/static')
-rw-r--r--addons/website_mail/static/src/js/follow.js24
1 files changed, 14 insertions, 10 deletions
diff --git a/addons/website_mail/static/src/js/follow.js b/addons/website_mail/static/src/js/follow.js
index 18c36378328..a8b351efa6c 100644
--- a/addons/website_mail/static/src/js/follow.js
+++ b/addons/website_mail/static/src/js/follow.js
@@ -40,17 +40,21 @@
}
this.$target.removeClass('has-error');
- openerp.jsonRpc('/website_mail/follow', 'call', {
- 'id': +this.$target.data('id'),
- 'object': this.$target.data('object'),
- 'message_is_follower': this.$target.attr("data-follow") || "off",
- 'email': $email.length ? $email.val() : false,
- }).then(function (follow) {
- self.toggle_subscription(follow, self.email);
- });
+ var email = $email.length ? $email.val() : false;
+ if (email) {
+ openerp.jsonRpc('/website_mail/follow', 'call', {
+ 'id': +this.$target.data('id'),
+ 'object': this.$target.data('object'),
+ 'message_is_follower': this.$target.attr("data-follow") || "off",
+ 'email': email,
+ }).then(function (follow) {
+ self.toggle_subscription(follow, email);
+ });
+ }
},
toggle_subscription: function(follow, email) {
console.log(follow, email);
+ follow = follow || (!email && this.$target.attr('data-unsubscribe'));
if (follow) {
this.$target.find(".js_follow_btn").addClass("hidden");
this.$target.find(".js_unfollow_btn").removeClass("hidden");
@@ -60,8 +64,8 @@
this.$target.find(".js_unfollow_btn").addClass("hidden");
}
this.$target.find('input.js_follow_email')
- .val(email ? email : "")
- .attr("disabled", follow || (email.length && this.is_user) ? "disabled" : false);
+ .val(email || "")
+ .attr("disabled", email && (follow || this.is_user) ? "disabled" : false);
this.$target.attr("data-follow", follow ? 'on' : 'off');
},
});