From 6671d25523af5fdb9b9da08bacce7033772a1af4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 22 Feb 2012 15:48:35 +0100 Subject: [PATCH] [IMP] ThreadView: moved follow/unfollow action on the right; see followers now has its value toggling when choosing to display or hide followers; comment textare now displays as a comment, i.e. it has user avatar on the left and is aligned with comments bzr revid: tde@openerp.com-20120222144835-w8jfscffigaggr6p --- addons/mail/static/src/css/mail.css | 2 +- addons/mail/static/src/js/mail.js | 26 ++++++++++++++++++++++---- addons/mail/static/src/xml/mail.xml | 22 ++++++++++++++-------- 3 files changed, 37 insertions(+), 13 deletions(-) diff --git a/addons/mail/static/src/css/mail.css b/addons/mail/static/src/css/mail.css index 9f4d8440205..ed824071f0f 100644 --- a/addons/mail/static/src/css/mail.css +++ b/addons/mail/static/src/css/mail.css @@ -31,7 +31,7 @@ } .oe_mail_button_follow, .oe_mail_button_unfollow, .oe_mail_button_followers { - width: 100px; + width: 120px; } .oe_mail_button_comment { diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index daf15e41d35..fe29fd8d139 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -14,10 +14,12 @@ openerp.mail = function(session) { form_template: 'ThreadView', init: function() { - this.follow_state = 0; + this.is_sub = 0; + this.see_sub = 1; this._super.apply(this, arguments); /* DataSets */ this.ds = new session.web.DataSet(this, this.view.model); + this.ds_users = new session.web.DataSet(this, 'res.users'); }, start: function() { @@ -46,14 +48,21 @@ openerp.mail = function(session) { if (! this.view.datarecord.id) { return; } /* find wich (un)follow buttons to show */ var call_res = this.ds.call('message_is_subscriber', [[this.view.datarecord.id]]).then(function (records) { - if (records == true) { self.follow_state = 1; self.$element.find('button.oe_mail_button_unfollow').show(); } - else { self.follow_state = 0; self.$element.find('button.oe_mail_button_follow').show(); } + if (records == true) { self.is_sub = 1; self.$element.find('button.oe_mail_button_unfollow').show(); } + else { self.is_sub = 0; self.$element.find('button.oe_mail_button_follow').show(); } }); + console.log(this); /* fetch comments and subscribers */ + this.fetch_current_user(); this.fetch_subscribers(); return this.fetch_comments(); }, + fetch_current_user: function () { + return this.ds_users.read_ids([this.session.uid], ['id', 'name', 'avatar_mini']).then( + this.proxy('display_current_user')); + }, + fetch_comments: function () { var load_res = this.ds.call('message_load', [[this.view.datarecord.id]]).then( this.proxy('display_comments')); @@ -66,6 +75,12 @@ openerp.mail = function(session) { return follow_res; }, + display_current_user: function (records) { + $('
').html( + '' + records[0].name + '' + ).appendTo(this.$element.find('div.oe_mail_msg_image')); + }, + display_comments: function (records) { this.$element.find('div.oe_mail_msg').empty(); var self = this; @@ -106,12 +121,15 @@ openerp.mail = function(session) { }, do_toggle_follow: function () { - this.follow_state = 1 - this.follow_state; + this.is_sub = 1 - this.is_sub; this.$element.find('button.oe_mail_button_unfollow').toggle(); this.$element.find('button.oe_mail_button_follow').toggle(); }, do_toggle_followers: function () { + this.see_sub = 1 - this.see_sub; + if (this.see_sub == 1) { this.$element.find('button.oe_mail_button_followers').html('Hide followers'); } + else { this.$element.find('button.oe_mail_button_followers').html('Display followers'); } this.$element.find('div.oe_mail_followers').toggle(); }, diff --git a/addons/mail/static/src/xml/mail.xml b/addons/mail/static/src/xml/mail.xml index 755357b7da3..79e421cc559 100644 --- a/addons/mail/static/src/xml/mail.xml +++ b/addons/mail/static/src/xml/mail.xml @@ -4,13 +4,15 @@
OpenSocial
-
- - -
-
-
- +
+
+
+
+
+
+ +
+
@@ -18,8 +20,12 @@
+
+ + +
- +