From 8d9fdcc3526f1aaaf394f571e5fed8169f459cd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20van=20der=20Essen?= Date: Wed, 24 Oct 2012 17:20:43 +0200 Subject: [PATCH] [IMP] mail: followers css + widget integration in inbox and formview bzr revid: fva@openerp.com-20121024152043-q5j7hpa4rur39k03 --- addons/mail/static/src/css/mail.css | 82 +++++++++++++++++-- addons/mail/static/src/js/mail.js | 4 +- addons/mail/static/src/js/mail_followers.js | 34 ++++---- addons/mail/static/src/xml/mail.xml | 14 +--- addons/mail/static/src/xml/mail_followers.xml | 46 +++++------ 5 files changed, 117 insertions(+), 63 deletions(-) diff --git a/addons/mail/static/src/css/mail.css b/addons/mail/static/src/css/mail.css index a1f2b5c4910..c4d1b6e2c28 100644 --- a/addons/mail/static/src/css/mail.css +++ b/addons/mail/static/src/css/mail.css @@ -1,6 +1,3 @@ -.oe_mail_wall_threads{ - padding: 16px; -} /* ------------ MAIL WIDGET --------------- */ .openerp .oe_mail, .openerp .oe_mail *{ @@ -9,7 +6,7 @@ .openerp .oe_mail { display: inline-block; position: relative; - width: 740px; + width: 720px; margin: 0px; } .openerp .oe_mail .oe_thread{ @@ -27,6 +24,7 @@ border-radius: 2px; margin-bottom: 2px; min-height: 40px; + border: solid 1px rgba(0,0,0,0.03); } .openerp .oe_mail .oe_msg_indented{ background: #FFF; @@ -58,7 +56,6 @@ margin-left: 40px; } .openerp .oe_mail .oe_msg .oe_msg_footer{ - height: 16px; padding-left: 4px; overflow: hidden; font-size: 11px; @@ -69,9 +66,6 @@ opacity: 1; -webkit-transition: opacity 0.2s linear; } -.openerp .oe_mail .oe_msg.oe_msg_composer .oe_msg_footer{ - height: auto; -} .openerp .oe_mail .oe_msg .oe_msg_content{ display: block; overflow: hidden; @@ -248,3 +242,75 @@ opacity: 1; -webkit-transition: opacity 0.2s linear; } + +/* ---------------- FOLLOWERS ------------------ */ + +.openerp .oe_followers{ + position: relative; + display: inline-block; + padding-top: 4px; + width: 120px; + float: right; +} + +/* a) THE FOLLOW BUTTON */ + +.openerp .oe_followers button.oe_follower{ + display: block; + text-align: center; + width:100%; +} +.openerp .oe_followers button.oe_follower.oe_following{ + background-color: #3465A4; + background-image: -webkit-linear-gradient(top, #729FCF, #3465A4); + color: white; +} + +.openerp .oe_followers button.oe_follower .oe_follow, +.openerp .oe_followers button.oe_follower .oe_unfollow, +.openerp .oe_followers button.oe_follower .oe_following{ + display: none; +} +/* a.1) when following, show 'following' */ +.openerp .oe_followers button.oe_follower.oe_following .oe_following{ + display: inline; +} +/* a.2) when following and hovering, show 'unfollow' */ +.openerp .oe_followers button.oe_follower.oe_following:hover .oe_following{ + display: none; +} +.openerp .oe_followers button.oe_follower.oe_following:hover .oe_unfollow{ + display: inline; +} +/* a.3) when not following show 'follow' */ +.openerp .oe_followers button.oe_follower.oe_notfollow .oe_follow{ + display: inline; +} + +.openerp .oe_followers .oe_subtype_list{ + margin-bottom: 4px; +} + +/* b) THE FOLLOWERS */ +.openerp .oe_followers .oe_follower_title{ + margin-top: 4px; +} +.openerp .oe_followers .oe_partner { + height: 32px; + overflow: hidden; +} +.openerp .oe_followers .oe_partner img{ + width: 32px; + margin-right:4px; + border-radius: 2px; +} + +/* ----------- FORM INTEGRATION ------------ */ + + /* Nothing to do yay! */ + +/* ----------- INBOX INTEGRATION ----------- */ + +.openerp .oe_mail_wall .oe_mail{ + margin: 16px; +} diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index 2890e9eda6e..888af67857a 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -1560,7 +1560,7 @@ openerp.mail = function(session) { } ); - return this.root.appendTo( this.$('.oe_mail_wall_threads:first') ); + return this.root.replace(this.$('.oe_mail-placeholder')); }, }); @@ -1658,7 +1658,7 @@ openerp.mail = function(session) { } ); - return this.root.appendTo( this.$('.oe_mail_wall_threads:first') ); + return this.root.replace(this.$('.oe_mail-placeholder')); }, bind_events: function(){ diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index f08991be2cc..bf913df0b04 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -24,10 +24,10 @@ openerp_mail_followers = function(session, mail) { init: function() { this._super.apply(this, arguments); - this.options.image = this.node.attrs.image || 'image_small'; - this.options.title = this.node.attrs.title || 'Followers'; - this.options.comment = this.node.attrs.help || false; - this.options.displayed_nb = this.node.attrs.displayed_nb || 10; + this.image = this.node.attrs.image || 'image_small'; + this.title = this.node.attrs.title || 'Followers'; + this.comment = this.node.attrs.help || false; + this.displayed_nb = this.node.attrs.displayed_nb || 10; this.ds_model = new session.web.DataSetSearch(this, this.view.model); this.ds_follow = new session.web.DataSetSearch(this, this.field.relation); this.ds_users = new session.web.DataSetSearch(this, 'res.users'); @@ -61,7 +61,7 @@ openerp_mail_followers = function(session, mail) { self.do_unfollow(); }); // event: click on a subtype, that (un)subscribe for this subtype - this.$el.on('click', 'ul.oe_subtypes input', self.do_update_subscription); + this.$el.on('click', '.oe_subtype_list input', self.do_update_subscription); // event: click on 'invite' button, that opens the invite wizard this.$('.oe_invite').on('click', function (event) { action = { @@ -119,16 +119,16 @@ openerp_mail_followers = function(session, mail) { /* Display generic info about follower, for people not having access to res_partner */ display_generic: function () { var self = this; - var node_user_list = this.$('ul.oe_mail_followers_display').empty(); + var node_user_list = this.$('.oe_follower_list').empty(); // format content: Followers (You and 0 other) // Followers (3) - var content = this.options.title; + var content = this.title; if (this.message_is_follower) { content += ' (You and ' + (this.get('value').length-1) + ' other)'; } else { content += ' (' + this.get('value').length + ')' } - this.$('div.oe_mail_recthread_followers h4').html(content); + this.$('.oe_follower_title').html(content); }, /** Display the followers */ @@ -137,16 +137,16 @@ openerp_mail_followers = function(session, mail) { records = records || []; this.message_is_follower = this.set_is_follower(records); // clean and display title - var node_user_list = this.$('ul.oe_mail_followers_display').empty(); - this.$('div.oe_mail_recthread_followers h4').html(this.options.title + ' (' + records.length + ')'); + var node_user_list = this.$('.oe_follower_list').empty(); + this.$('.oe_follower_title').html(this.title + ' (' + records.length + ')'); // truncate number of displayed followers - truncated = records.splice(0, this.options.displayed_nb); + truncated = records.splice(0, this.displayed_nb); _(truncated).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 (truncated.length < records.length) { - $('
  • And ' + (records.length - truncated.length) + ' more.
  • ').appendTo(node_user_list); + if (truncated.length < records.length) { //FIXME USE A TEMPLATE ! + $('
    And ' + (records.length - truncated.length) + ' more.
    ').appendTo(node_user_list); } }, @@ -172,7 +172,7 @@ openerp_mail_followers = function(session, mail) { /** Fetch subtypes, only if current user is follower */ fetch_subtypes: function () { - var subtype_list_ul = this.$('.oe_subtypes').empty(); + var subtype_list_ul = this.$('.oe_subtype_list').empty(); if (! this.message_is_follower) return; var context = new session.web.CompoundContext(this.build_context(), {}); this.ds_model.call('message_get_subscription_data', [[this.view.datarecord.id], context]).pipe(this.proxy('display_subtypes')); @@ -181,12 +181,12 @@ openerp_mail_followers = function(session, mail) { /** Display subtypes: {'name': default, followed} */ display_subtypes:function (data) { var self = this; - var subtype_list_ul = this.$('.oe_subtypes'); + var subtype_list_ul = this.$('.oe_subtype_list'); var records = data[this.view.datarecord.id || this.view.dataset.ids[0]].message_subtype_data; _(records).each(function (record, record_name) { record.name = record_name; record.followed = record.followed || undefined; - $(session.web.qweb.render('mail.followers.subtype', {'record': record})).appendTo( self.$('ul.oe_subtypes') ); + $(session.web.qweb.render('mail.followers.subtype', {'record': record})).appendTo( self.$('.oe_subtype_list') ); }); }, @@ -209,7 +209,7 @@ openerp_mail_followers = function(session, mail) { var self = this; var checklist = new Array(); - _(this.$('.oe_mail_recthread_actions input[type="checkbox"]')).each(function (record) { + _(this.$('.oe_actions input[type="checkbox"]')).each(function (record) { if ($(record).is(':checked')) { checklist.push(parseInt($(record).data('id'))); } diff --git a/addons/mail/static/src/xml/mail.xml b/addons/mail/static/src/xml/mail.xml index 125376deb57..e1e272f1dd4 100644 --- a/addons/mail/static/src/xml/mail.xml +++ b/addons/mail/static/src/xml/mail.xml @@ -153,11 +153,7 @@ - -
    -
    - -
    +
    -
    - -
    - + +
    -
    +
    diff --git a/addons/mail/static/src/xml/mail_followers.xml b/addons/mail/static/src/xml/mail_followers.xml index 87b49579100..02796c5d80a 100644 --- a/addons/mail/static/src/xml/mail_followers.xml +++ b/addons/mail/static/src/xml/mail_followers.xml @@ -5,51 +5,45 @@ followers main template Template used to display the followers, the actions and the subtypes in a record. --> -
    -
    -
    - -
    -
    -
      -
      +
      +
      + +
      - -
      + +
      -
      - - -

      -
      -
        -
        + + +

        +
        +
        -
      • +
        -
      • \ +
        -
      • - + +
        -
      • +