[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
This commit is contained in:
parent
1bc3f0cec4
commit
6671d25523
|
@ -31,7 +31,7 @@
|
|||
}
|
||||
|
||||
.oe_mail_button_follow, .oe_mail_button_unfollow, .oe_mail_button_followers {
|
||||
width: 100px;
|
||||
width: 120px;
|
||||
}
|
||||
|
||||
.oe_mail_button_comment {
|
||||
|
|
|
@ -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) {
|
||||
$('<div>').html(
|
||||
'<img src="' + this.thread_get_mini('res.users', 'avatar_mini', records[0].id) + '" title="' + records[0].name + '" alt="' + 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();
|
||||
},
|
||||
|
||||
|
|
|
@ -4,13 +4,15 @@
|
|||
<div t-name="ThreadView" class="oe_mail_main">
|
||||
<div class="separator horizontal">OpenSocial</div>
|
||||
<div class="oe_mail_main_left">
|
||||
<div class="oe_mail_actions">
|
||||
<button type="button" class="oe_mail_button_follow">Follow</button>
|
||||
<button type="button" class="oe_mail_button_unfollow">Unfollow</button>
|
||||
</div>
|
||||
<div class="oe_mail_post_comment">
|
||||
<textarea class="oe_mail_action_textarea" onfocus="this.value='';">Enter your comment here...</textarea><br />
|
||||
<button type="button" class="oe_mail_button_comment">Post comment</button>
|
||||
<div class="oe_mail_comment">
|
||||
<div class="oe_mail_msg_image">
|
||||
</div>
|
||||
<div class="oe_mail_msg_content">
|
||||
<div class="oe_mail_post_comment">
|
||||
<textarea class="oe_mail_action_textarea" onfocus="this.value='';">Enter your comment here...</textarea><br />
|
||||
<button type="button" class="oe_mail_button_comment">Post comment</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="oe_mail_msg">
|
||||
<div class="oe_mail_comment">
|
||||
|
@ -18,8 +20,12 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="oe_mail_main_right">
|
||||
<div class="oe_mail_actions">
|
||||
<button type="button" class="oe_mail_button_follow">Follow</button>
|
||||
<button type="button" class="oe_mail_button_unfollow">Unfollow</button>
|
||||
</div>
|
||||
<div class="oe_mail_followers_actions">
|
||||
<button type="button" class="oe_mail_button_followers">See followers</button>
|
||||
<button type="button" class="oe_mail_button_followers">Hide followers</button>
|
||||
</div>
|
||||
<div class="oe_mail_followers">
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue