diff options
| author | Fabien Meghazi <fme@openerp.com> | 2012-10-02 09:49:31 +0200 |
|---|---|---|
| committer | Fabien Meghazi <fme@openerp.com> | 2012-10-02 09:49:31 +0200 |
| commit | 4d2299adc4e9d7db2cb52a79cf4ab8ebaad707ae (patch) | |
| tree | 8a45a95b39d3b060fdef188f3da8a70fbfe20ad5 /addons/mail/static | |
| parent | 32d492acf9db0a57487a1c6c47e4311d842e99f7 (diff) | |
| parent | a5fac44994a5d2c0e20cdde0bf72ef152d2342dd (diff) | |
[MERGE] trunk
bzr revid: fme@openerp.com-20121002074931-845aiqhflw2rqrcn
Diffstat (limited to 'addons/mail/static')
| -rw-r--r-- | addons/mail/static/src/css/mail.css | 34 | ||||
| -rw-r--r-- | addons/mail/static/src/js/mail.js | 26 | ||||
| -rw-r--r-- | addons/mail/static/src/js/mail_followers.js | 66 | ||||
| -rw-r--r-- | addons/mail/static/src/xml/mail.xml | 4 | ||||
| -rw-r--r-- | addons/mail/static/src/xml/mail_followers.xml | 8 |
5 files changed, 75 insertions, 63 deletions
diff --git a/addons/mail/static/src/css/mail.css b/addons/mail/static/src/css/mail.css index 717d0439486..e69eaadbcdb 100644 --- a/addons/mail/static/src/css/mail.css +++ b/addons/mail/static/src/css/mail.css @@ -125,6 +125,14 @@ /* ------------------------------------------------------------ */ +/* Followers +/* ------------------------------------------------------------ */ + +.openerp div.oe_mail_recthread_aside h4 { + display: inline-block; +} + +/* ------------------------------------------------------------ */ /* Thread /* ------------------------------------------------------------ */ @@ -224,7 +232,7 @@ clear: both; } -.openerp .oe_mail_msg_content a { +.openerp .oe_chatter a { cursor: pointer; } @@ -258,30 +266,6 @@ display: none; } -/*--------------------------------------------------------------*/ -/* mail.vote -/*--------------------------------------------------------------*/ - -.openerp .oe_mail_msg_content button.oe_mail_msg_vote { - height:21px; - width: 30px; - padding: 1px; - background: #8A89BA; - margin-top: -4px; -} - -.openerp .oe_mail_msg_content button.oe_mail_msg_vote_true { - background:#DC5F59; -} - -.openerp .oe_mail_msg_content button.oe_mail_msg_vote span { - color: white; -} - -.openerp .oe_mail_msg_content span.oe_mail_vote_count{ - color: #807FB4; -} - /* ------------------------------------------------------------ */ /* mail.compose.message form view & OpenERP hacks diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index 57c777441e7..196c54c8296 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -56,11 +56,6 @@ openerp.mail = function(session) { return session.origin + '/web/binary/saveas?session_id=' + session.session_id + '&model=ir.attachment&field=datas&filename_field=datas_fname&id=' + attachment['id']; }, - /** Check if the current user is the message author */ - is_author: function (widget, message_user_id) { - return (widget.session && widget.session.uid != 0 && widget.session.uid == message_user_id); - }, - /** Replaces some expressions * - :name - shortcut to an image */ @@ -301,6 +296,7 @@ openerp.mail = function(session) { // TDE TODO: check for deferred, not sure it is correct this._super.apply(this, arguments); this.bind_events(); + this.display_user_avatar(); // fetch and display message, using message_ids if set var display_done = $.when(this.message_fetch(true, [], {})).then(this.proxy('do_customize_display')); // add message composition form view @@ -313,7 +309,6 @@ openerp.mail = function(session) { /** Customize the display * - show_header_compose: show the composition form in the header */ do_customize_display: function() { - this.display_user_avatar(); if (this.options.show_header_compose) { this.$el.find('div.oe_mail_thread_action').eq(0).show(); } @@ -349,7 +344,8 @@ openerp.mail = function(session) { // event: click on 'Reply by email' in msg side menu this.$el.on('click', 'a.oe_mail_msg_reply_by_email', function (event) { if (! self.compose_message_widget) return true; - var msg_id = event.srcElement.dataset.msg_id; + evt = event.target || event.srcElement; + var msg_id = evt.dataset.msg_id; if (! msg_id) return false; self.compose_message_widget.refresh({ 'default_composition_mode': 'reply', @@ -370,9 +366,10 @@ openerp.mail = function(session) { on_message_read: function (event) { //TDE: TODO - var msg_id = event.srcElement.dataset.id; + evt = event.target || event.srcElement; + var msg_id = evt.dataset.id; if (! msg_id) return false; - $(event.srcElement).parents('li.oe_mail_thread_msg').eq(0).remove(); + $(evt).parents('li.oe_mail_thread_msg').eq(0).remove(); return this.ds_notification.call('set_message_read', [parseInt(msg_id)]); }, @@ -489,8 +486,7 @@ openerp.mail = function(session) { * - record.date: formatting according to the user timezone * - record.timerelative: relative time givein by timeago lib * - record.avatar: image url - * - record.attachment_ids[].url: url of each attachment - * - record.is_author: is the current user the author of the record */ + * - record.attachment_ids[].url: url of each attachment */ display_record: function (record) { // formatting and additional fields record.date = session.web.format_value(record.date, {type:"datetime"}); @@ -504,7 +500,6 @@ openerp.mail = function(session) { var attach = record.attachment_ids[l]; attach['url'] = mail.ChatterUtils.get_attachment_url(this.session, attach); } - record.is_author = mail.ChatterUtils.is_author(this, record.author_user_id[0]); // add to internal storage this.records[record.id] = record; // render, add the expand feature @@ -647,12 +642,15 @@ openerp.mail = function(session) { // update domain var domain = this.options.domain.concat([['model', '=', this.view.model], ['res_id', '=', this.view.datarecord.id]]); // create and render Thread widget + var show_header_compose = this.view.is_action_enabled('edit') || + (this.getParent().fields.message_is_follower && this.getParent().fields.message_is_follower.get_value()); this.$el.find('div.oe_mail_recthread_main').empty(); var thread = new mail.Thread(self, domain, this.options.context, { 'thread_level': this.options.thread_level, - 'use_composer': true, + 'show_header_compose': show_header_compose, + 'use_composer': show_header_compose, 'show_dd_delete': true, - 'show_reply_by_email': true }); + 'show_reply_by_email': show_header_compose }); return thread.appendTo(this.$el.find('div.oe_mail_recthread_main')); }, }); diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index cf33bd64640..743c4704330 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -26,6 +26,8 @@ openerp_mail_followers = function(session, mail) { this._super.apply(this, arguments); this.options.image = this.node.attrs.image || 'image_small'; this.options.title = this.node.attrs.title || 'Followers'; + this.options.context = this.node.attrs.context; + this.options.comment = this.node.attrs.help || false; this.ds_model = new session.web.DataSetSearch(this, this.view.model); this.ds_follow = new session.web.DataSetSearch(this, this.field.relation); }, @@ -43,8 +45,8 @@ openerp_mail_followers = function(session, mail) { }, reinit: function() { - this.$el.find('button.oe_mail_button_follow').hide(); - this.$el.find('button.oe_mail_button_unfollow').hide(); + this.message_is_follower == undefined; + this.display_buttons(); }, bind_events: function() { @@ -53,7 +55,7 @@ openerp_mail_followers = function(session, mail) { .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) { + this.$el.on('click', 'a.oe_mail_invite', function(event) { action = { type: 'ir.actions.act_window', res_model: 'mail.wizard.invite', @@ -72,41 +74,65 @@ 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 results[0].message_follower_ids; - }).pipe(this.proxy('set_value')); + return this.ds_model.read_ids([this.view.datarecord.id], ['message_is_follower', 'message_follower_ids']).then(function (results) { + self.set_value(results[0].message_follower_ids, results[0].message_is_follower); + }); }, - set_value: function(value_) { + set_value: function(value_, message_is_follower) { this.reinit(); if (! this.view.datarecord.id || session.web.BufferedDataSet.virtual_id_regex.test(this.view.datarecord.id)) { - this.$el.find('div.oe_mail_recthread_aside').hide(); + this.$('div.oe_mail_recthread_aside').hide(); return; } - return this.fetch_followers(value_ || this.get_value()); + return this.fetch_followers(value_ || this.get_value(), message_is_follower); + }, + + fetch_followers: function (value_, message_is_follower) { + this.value = value_; + this.message_is_follower = message_is_follower || (this.getParent().fields.message_is_follower && this.getParent().fields.message_is_follower.get_value()); + return this.ds_follow.call('read', [value_, ['name', 'user_ids']]).pipe(this.proxy('display_followers'), this.proxy('display_generic')); }, - fetch_followers: function (value_) { - return this.ds_follow.call('read', [value_, ['name', 'user_ids']]).pipe(this.proxy('display_followers')); + + /* Display generic info about follower, for people not having access to res_partner */ + display_generic: function (error, event) { + event.preventDefault(); + var node_user_list = this.$('ul.oe_mail_followers_display').empty(); + // format content: Followers (You and 0 other) // Followers (3) + var content = this.options.title; + if (this.message_is_follower) { + content += ' (You and ' + (this.value.length-1) + ' other)'; + } + else { + content += ' (' + this.value.length + ')' + } + this.$('div.oe_mail_recthread_followers h4').html(content); + this.display_buttons(); + return $.when(); }, /** Display the followers, evaluate is_follower directly */ display_followers: function (records) { var self = this; - this.message_is_follower = _.indexOf(_.flatten(_.pluck(records, 'user_ids')), this.session.uid) != -1; - var node_user_list = this.$el.find('ul.oe_mail_followers_display').empty(); - this.$el.find('div.oe_mail_recthread_followers h4').html(this.options.title + ' (' + records.length + ')'); + var node_user_list = this.$('ul.oe_mail_followers_display').empty(); + this.$('div.oe_mail_recthread_followers h4').html(this.options.title + ' (' + records.length + ')'); _(records).each(function (record) { record.avatar_url = mail.ChatterUtils.get_image(self.session, 'res.partner', 'image_small', record.id); $(session.web.qweb.render('mail.followers.partner', {'record': record})).appendTo(node_user_list); }); - if (this.message_is_follower) { - this.$el.find('button.oe_mail_button_follow').hide(); - this.$el.find('button.oe_mail_button_unfollow').show(); } - else { - this.$el.find('button.oe_mail_button_follow').show(); - this.$el.find('button.oe_mail_button_unfollow').hide(); } + this.display_buttons(); + }, + + display_buttons: function () { + this.$('button.oe_mail_button_follow').hide(); + this.$('button.oe_mail_button_unfollow').hide(); + this.$('span.oe_mail_invite_wrapper').hide(); + if (! this.view.is_action_enabled('edit')) return; + this.$('span.oe_mail_invite_wrapper').show(); + if (this.message_is_follower) { this.$('button.oe_mail_button_unfollow').show(); } + else if (this.message_is_follower == false) { this.$('button.oe_mail_button_follow').show(); } }, do_follow: function () { diff --git a/addons/mail/static/src/xml/mail.xml b/addons/mail/static/src/xml/mail.xml index e3586e723e4..c54bd4dbb2d 100644 --- a/addons/mail/static/src/xml/mail.xml +++ b/addons/mail/static/src/xml/mail.xml @@ -140,7 +140,7 @@ <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}&id=#{record.res_id}"><t t-raw="record.record_name"/></a> </li> - <li><a t-attf-href="#model=res.partner&id=#{record.author_id[0]}"><t t-raw="record.author_id[1]"/></a></li> + <li t-if="record.author_id"><a t-attf-href="#model=res.partner&id=#{record.author_id[0]}"><t t-raw="record.author_id[1]"/></a></li> <li><span t-att-title="record.date"><t t-raw="record.timerelative"/></span></li> <t t-call="mail.thread.message.vote"/> <li t-if="options.show_reply"><a class="oe_mail_msg_reply">Reply</a></li> @@ -185,7 +185,7 @@ <t t-if='record.vote_user_ids.length > 0'> <span class="oe_left oe_mail_vote_count"><t t-esc="record.vote_user_ids.length"/> votes</span> </t> - <button t-attf-class="oe_mail_msg_vote oe_mail_msg_vote_#{record.has_voted}" t-attf-data-msg_id="{record.id}"> + <button t-attf-class="oe_mail_msg_vote oe_tag" t-attf-data-msg_id="{record.id}"> <t t-if="! record.has_voted"><span>+1</span></t> <t t-if="record.has_voted"><span>-1</span></t> </button> diff --git a/addons/mail/static/src/xml/mail_followers.xml b/addons/mail/static/src/xml/mail_followers.xml index 32ce34d48d1..203a7bce789 100644 --- a/addons/mail/static/src/xml/mail_followers.xml +++ b/addons/mail/static/src/xml/mail_followers.xml @@ -7,13 +7,17 @@ --> <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_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_grey"> + <t t-if="widget.options.comment"> + <h5><t t-raw="widget.options.comment"/></h5> + </t> + </div> <div class="oe_mail_recthread_followers"> <t t-if="widget.options.title"> - <h4><t t-raw="widget.options.title"/></h4> + <h4><t t-raw="widget.options.title"/></h4><span class="oe_mail_invite_wrapper"> ยท <a class="oe_mail_invite" >Invite partners</a></span> </t> <ul class="oe_mail_followers_display"></ul> </div> |
