diff options
| author | Martin Trigaux <mat@openerp.com> | 2013-09-11 13:07:55 +0200 |
|---|---|---|
| committer | Martin Trigaux <mat@openerp.com> | 2013-09-11 13:07:55 +0200 |
| commit | c48504fdba1ef68033c5e6c3b7929ea4e153d4b7 (patch) | |
| tree | 471c4c37f5b76a4f034b5de805655d5fc5dcf867 /addons/mail/static/src | |
| parent | 9349ba848497b9c5b7ded809a4db6b1e3b26b6a6 (diff) | |
| parent | 3fa90321e11d28df4e2b874ddfa450dc73e8e0af (diff) | |
[MERGE] sync with trunk (state -> stage removed some test)
bzr revid: mat@openerp.com-20130911110755-zf3ytf9m27im6x9k
Diffstat (limited to 'addons/mail/static/src')
| -rw-r--r-- | addons/mail/static/src/css/mail.css | 22 | ||||
| -rw-r--r-- | addons/mail/static/src/js/mail.js | 45 | ||||
| -rw-r--r-- | addons/mail/static/src/js/mail_followers.js | 112 | ||||
| -rw-r--r-- | addons/mail/static/src/xml/mail.xml | 24 | ||||
| -rw-r--r-- | addons/mail/static/src/xml/mail_followers.xml | 1 |
5 files changed, 153 insertions, 51 deletions
diff --git a/addons/mail/static/src/css/mail.css b/addons/mail/static/src/css/mail.css index 211133afaf8..e4b7f9247e3 100644 --- a/addons/mail/static/src/css/mail.css +++ b/addons/mail/static/src/css/mail.css @@ -53,6 +53,9 @@ .openerp .oe_mail > .oe_thread{ margin-left: 0px; } +.openerp .oe_inline.oe_compose_recipients { + margin-top: -2px; +} /* ---------------- MESSAGES ------------------ */ @@ -118,6 +121,9 @@ text-overflow:ellipsis; word-wrap: break-word; } +.openerp .oe_mail .oe_msg .oe_msg_content .oe_msg_body .oe_mail_cleaned { + display: none; +} /* a) Indented Messages */ @@ -632,11 +638,10 @@ } .openerp .oe_followers .oe_partner { height: 32px; - margin-right: 8px; + margin-right: 24px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; - margin-right: 10px; } .openerp .oe_followers .oe_partner img{ width: 32px; @@ -649,7 +654,18 @@ right: 0px; line-height: 20px; } - +.openerp .oe_followers .oe_edit_subtype{ + cursor: pointer; + position: absolute; + right: 12px; + line-height: 20px; +} +.openerp .oe_followers .oe_partner .oe_hidden{ + display: none; +} +.openerp.ui-dialog .ui-dialog-titlebar .ui-dialog-title{ + padding-right: 20px; +} .openerp .oe_followers .oe_show_more{ cursor: pointer; } diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index 21b0f5a9a87..35a6adfaaea 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -2,7 +2,7 @@ openerp.mail = function (session) { var _t = session.web._t, _lt = session.web._lt; - var mail = session.mail = {}; + var mail = session.mail; openerp_mail_followers(session, mail); // import mail_followers.js openerp_FieldMany2ManyTagsEmail(session); // import manyy2many_tags_email.js @@ -225,6 +225,7 @@ openerp.mail = function (session) { this.name = datasets.name || false, this.record_name = datasets.record_name || false, this.body = datasets.body || '', + this.body_short = datasets.body_short || '', this.vote_nb = datasets.vote_nb || 0, this.has_voted = datasets.has_voted || false, this.is_favorite = datasets.is_favorite || false, @@ -234,7 +235,7 @@ openerp.mail = function (session) { this.attachment_ids = datasets.attachment_ids || [], this.partner_ids = datasets.partner_ids || []; this.date = datasets.date; - + this.user_pid = datasets.user_pid || false; this.format_data(); // update record_name: Partner profile @@ -564,6 +565,7 @@ openerp.mail = function (session) { 'default_partner_ids': partner_ids, 'mail_post_autofollow': true, 'mail_post_autofollow_partner_ids': partner_ids, + 'is_private': self.is_private }; if (self.is_log) { _.extend(context, {'mail_compose_log': true}); @@ -772,7 +774,7 @@ openerp.mail = function (session) { // if clicked: call for suggested recipients if (event.type == 'click') { this.is_log = $input.hasClass('oe_compose_log'); - suggested_partners = this.parent_thread.ds_thread.call('message_get_suggested_recipients', [[this.context.default_res_id]]).done(function (additional_recipients) { + suggested_partners = this.parent_thread.ds_thread.call('message_get_suggested_recipients', [[this.context.default_res_id], this.context]).done(function (additional_recipients) { var thread_recipients = additional_recipients[self.context.default_res_id]; _.each(thread_recipients, function (recipient) { var parsed_email = mail.ChatterUtils.parse_email(recipient[1]); @@ -944,7 +946,6 @@ openerp.mail = function (session) { start: function () { this._super.apply(this, arguments); - this.expender(); this.bind_events(); if(this.thread_level < this.options.display_indented_thread) { this.create_thread(); @@ -967,6 +968,26 @@ openerp.mail = function (session) { this.$('.oe_reply').on('click', this.on_message_reply); this.$('.oe_star').on('click', this.on_star); this.$('.oe_msg_vote').on('click', this.on_vote); + this.$('.oe_mail_expand').on('click', this.on_expand); + this.$('.oe_mail_reduce').on('click', this.on_expand); + this.$('.oe_mail_action_model').on('click', this.on_record_clicked); + }, + + on_record_clicked: function (event) { + event.stopPropagation(); + var state = { + 'model': this.model, + 'id': this.res_id, + 'title': this.record_name + }; + session.webclient.action_manager.do_push_state(state); + this.do_action({ + res_model: state.model, + res_id: state.id, + type: 'ir.actions.act_window', + views: [[false, 'form']] + }); + return false; }, /* Call the on_compose_message on the thread of this message. */ @@ -977,15 +998,11 @@ openerp.mail = function (session) { return false; }, - expender: function () { - this.$('.oe_msg_body:first').expander({ - slicePoint: this.options.truncate_limit, - expandText: _t('read more'), - userCollapseText: _t('read less'), - detailClass: 'oe_msg_tail', - moreClass: 'oe_mail_expand', - lessClass: 'oe_mail_reduce', - }); + on_expand: function (event) { + event.stopPropagation(); + this.$('.oe_msg_body_short:first').toggle(); + this.$('.oe_msg_body_long:first').toggle(); + return false; }, /** @@ -1223,9 +1240,9 @@ openerp.mail = function (session) { if (datasets.author_id && !_.contains(_.flatten(datasets.partner_ids),datasets.author_id[0]) && datasets.author_id[0]) { datasets.partner_ids.push(datasets.author_id); } + this.user_pid = datasets.user_pid || false; this.partner_ids = datasets.partner_ids; this.messages = []; - this.options.flat_mode = (this.options.display_indented_thread - this.thread_level > 0); // object compose message diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index f812844194b..a0dad1fcdbc 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -29,7 +29,6 @@ openerp_mail_followers = function(session, mail) { this.displayed_limit = this.node.attrs.displayed_nb || 10; this.displayed_nb = this.displayed_limit; 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'); this.value = []; @@ -74,10 +73,33 @@ openerp_mail_followers = function(session, mail) { 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', self.on_invite_follower); + // event: click on 'edit_subtype(pencil)' button to edit subscription + this.$el.on('click', '.oe_edit_subtype', self.on_edit_subtype); this.$el.on('click', '.oe_remove_follower', self.on_remove_follower); this.$el.on('click', '.oe_show_more', self.on_show_more_followers) }, + on_edit_subtype: function(event) { + var self = this; + var $currentTarget = $(event.currentTarget); + var user_pid = $currentTarget.data('id'); + $('div.oe_edit_actions').remove(); + self.$dialog = new session.web.dialog($('<div class="oe_edit_actions">'), { + modal: true, + width: 'auto', + height: 'auto', + title: _t('Edit Subscription of ') + $currentTarget.siblings('a').text(), + buttons: [ + { text: _t("Apply"), click: function() { + self.do_update_subscription(event, user_pid); + $(this).dialog("close"); + }}, + { text: _t("Cancel"), click: function() { $(this).dialog("close"); }} + ], + }); + return self.fetch_subtypes(user_pid); + }, + on_invite_follower: function (event) { var self = this; var action = { @@ -130,7 +152,7 @@ openerp_mail_followers = function(session, mail) { fetch_followers: function (value_) { this.value = value_ || {}; - return this.ds_follow.call('read', [this.value, ['name', 'user_ids']]) + return this.ds_model.call('read_followers_data', [this.value]) .then(this.proxy('display_followers'), this.proxy('fetch_generic')) .then(this.proxy('display_buttons')) .then(this.proxy('fetch_subtypes')); @@ -147,6 +169,7 @@ openerp_mail_followers = function(session, mail) { self.message_is_follower = (_.indexOf(self.value, pid) != -1); }).then(self.proxy('display_generic')); }, + _format_followers: function(count){ var str = ''; if(count <= 0){ @@ -158,6 +181,7 @@ openerp_mail_followers = function(session, mail) { } return str; }, + /* Display generic info about follower, for people not having access to res_partner */ display_generic: function () { var self = this; @@ -168,16 +192,32 @@ openerp_mail_followers = function(session, mail) { /** Display the followers */ display_followers: function (records) { var self = this; + this.message_is_follower = false; this.followers = records || this.followers; - this.message_is_follower = this.set_is_follower(this.followers); // clean and display title var node_user_list = this.$('.oe_follower_list').empty(); this.$('.oe_follower_title').html(this._format_followers(this.followers.length)); // truncate number of displayed followers var truncated = this.followers.slice(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, 'widget': self})).appendTo(node_user_list); + partner = { + 'id': record[0], + 'name': record[1], + 'is_uid': record[2]['is_uid'], + 'is_editable': record[2]['is_editable'], + 'avatar_url': mail.ChatterUtils.get_image(self.session, 'res.partner', 'image_small', record[0]), + } + if (partner.is_uid) { + self.message_is_follower = partner.is_uid; + } + $(session.web.qweb.render('mail.followers.partner', {'record': partner, 'widget': self})).appendTo(node_user_list); + // On mouse-enter it will show the edit_subtype pencil. + if (partner.is_editable) { + self.$('.oe_follower_list').on('mouseenter mouseleave', function(e) { + self.$('.oe_edit_subtype').toggleClass('oe_hidden', e.type == 'mouseleave'); + self.$('.oe_follower_list').find('.oe_partner').toggleClass('oe_partner_name', e.type == 'mouseenter'); + }); + } }); // FVA note: be sure it is correctly translated if (truncated.length < this.followers.length) { @@ -185,12 +225,6 @@ openerp_mail_followers = function(session, mail) { } }, - /** Computes whether the current user is in the followers */ - set_is_follower: function (records) { - var user_ids = _.pluck(_.pluck(records, 'user_ids'), 0); - return _.indexOf(user_ids, this.session.uid) != -1; - }, - display_buttons: function () { if (this.message_is_follower) { this.$('button.oe_follower').removeClass('oe_notfollow').addClass('oe_following'); @@ -206,25 +240,37 @@ openerp_mail_followers = function(session, mail) { }, /** Fetch subtypes, only if current user is follower */ - fetch_subtypes: function () { + fetch_subtypes: function (user_pid) { var self = this; - var subtype_list_ul = this.$('.oe_subtype_list').empty(); - if (! this.message_is_follower) return; + var dialog = false; + if (user_pid) { + dialog = true; + } else { + var subtype_list_ul = this.$('.oe_subtype_list').empty(); + if (! this.message_is_follower) return; + } var id = this.view.datarecord.id; - this.ds_model.call('message_get_subscription_data', [[id], new session.web.CompoundContext(this.build_context(), {})]) - .then(function (data) {self.display_subtypes(data, id);}); + this.ds_model.call('message_get_subscription_data', [[id], user_pid, new session.web.CompoundContext(this.build_context(), {})]) + .then(function (data) {self.display_subtypes(data, id, dialog);}); }, /** Display subtypes: {'name': default, followed} */ - display_subtypes:function (data, id) { + display_subtypes:function (data, id, dialog) { var self = this; - var $list = this.$('.oe_subtype_list'); + if (dialog) { + var $list = self.$dialog; + } + else { + var $list = this.$('.oe_subtype_list'); + } $list.empty().hide(); var records = data[this.view.datarecord.id || this.view.dataset.ids[0]].message_subtype_data; + this.records_length = $.map(records, function(value, index) { return index; }).length; + if (this.records_length > 1) { self.display_followers(); } _(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.$('.oe_subtype_list') ); + $(session.web.qweb.render('mail.followers.subtype', {'record': record})).appendTo($list); }); if (_.size(records) > 1) { $list.show(); @@ -241,35 +287,49 @@ openerp_mail_followers = function(session, mail) { }); }, - do_unfollow: function () { + do_unfollow: function (user_pid) { if (confirm(_t("Warning! \nYou won't be notified of any email or discussion on this document. Do you really want to unfollow this document ?"))) { _(this.$('.oe_msg_subtype_check')).each(function (record) { $(record).attr('checked',false); }); + var action_unsubscribe = 'message_unsubscribe_users'; + var follower_ids = [this.session.uid]; + if (user_pid) { + action_unsubscribe = 'message_unsubscribe'; + follower_ids = [user_pid]; + } var context = new session.web.CompoundContext(this.build_context(), {}); - return this.ds_model.call('message_unsubscribe_users', [[this.view.datarecord.id], [this.session.uid], context]) - .then(this.proxy('read_value')); + return this.ds_model.call(action_unsubscribe, [[this.view.datarecord.id], follower_ids, context]) + .then(this.proxy('read_value')); } return false; }, - do_update_subscription: function (event) { + do_update_subscription: function (event, user_pid) { var self = this; + var action_subscribe = 'message_subscribe_users'; + var follower_ids = [this.session.uid]; + var oe_action = this.$('.oe_actions input[type="checkbox"]'); + if (user_pid) { + action_subscribe = 'message_subscribe'; + follower_ids = [user_pid]; + oe_action = $('.oe_edit_actions input[type="checkbox"]'); + } var checklist = new Array(); - _(this.$('.oe_actions input[type="checkbox"]')).each(function (record) { + _(oe_action).each(function (record) { if ($(record).is(':checked')) { checklist.push(parseInt($(record).data('id'))); } }); if (!checklist.length) { - if (!this.do_unfollow()) { + if (!this.do_unfollow(user_pid)) { $(event.target).attr("checked", "checked"); } } else { var context = new session.web.CompoundContext(this.build_context(), {}); - return this.ds_model.call('message_subscribe_users', [[this.view.datarecord.id], [this.session.uid], checklist, context]) + return this.ds_model.call(action_subscribe, [[this.view.datarecord.id], follower_ids, checklist, context]) .then(this.proxy('read_value')); } }, diff --git a/addons/mail/static/src/xml/mail.xml b/addons/mail/static/src/xml/mail.xml index 94ee1ff452f..e6c84eaa5df 100644 --- a/addons/mail/static/src/xml/mail.xml +++ b/addons/mail/static/src/xml/mail.xml @@ -121,21 +121,23 @@ To: <t t-if="!widget.is_private"> <span class="oe_all_follower"> - <t t-if="widget.parent_thread.parent_message.record_name" t-raw="'"' + widget.parent_thread.parent_message.record_name + '"'"> + <t t-if="widget.parent_thread.parent_message.record_name"> Followers of <t t-raw="'"' + widget.parent_thread.parent_message.record_name + '"'"/> </t> <t t-if="!widget.parent_thread.parent_message.record_name and widget.options.view_inbox">My Followers</t> <t t-if="!widget.parent_thread.parent_message.record_name and !widget.options.view_inbox">Followers of this document</t> </span> </t> - <t t-if="!widget.is_private and (widget.partner_ids.length or (widget.author_id and widget.author_id[0]))"> and </t> <t t-set="inc" t-value="0"/> <t t-foreach="widget.partner_ids" t-as="partner"> - <span t-attf-class="oe_partner_follower #{inc>=3?'oe_hidden':''}"><t t-if="inc" t-raw="', '"/> - <a t-if="widget.options.show_link" t-attf-href="#model=res.partner&id=#{partner[0]}"><t t-raw="partner[1]"/></a> - <t t-if="!widget.options.show_link" t-raw="partner[1]"/> - </span> - <t t-set="inc" t-value="inc+1"/> + <t t-if="widget.is_private or (widget.user_pid != partner[0])"> + <t t-if="!widget.is_private and inc==0"> and </t> + <span t-attf-class="oe_partner_follower #{inc>=3?'oe_hidden':''}"><t t-if="inc" t-raw="', '"/> + <a t-if="widget.options.show_link" t-attf-href="#model=res.partner&id=#{partner[0]}"><t t-raw="partner[1]"/></a> + <t t-if="!widget.options.show_link" t-raw="partner[1]"/> + </span> + <t t-set="inc" t-value="inc+1"/> + </t> </t> <t t-if="widget.partner_ids.length > 3"> <span class="oe_more">, <a><t t-raw="widget.partner_ids.length - 3"/> others...</a></span> @@ -266,7 +268,13 @@ <t t-if="widget.subject" t-raw="widget.subject"/> </h1> <div class="oe_msg_body"> - <t t-raw="widget.body"/> + <t t-if="widget.body_short"> + <div class="oe_msg_body_short"><t t-raw="widget.body_short"/></div> + <div class="oe_msg_body_long" style="display: none;"><t t-raw="widget.body"/><span class="oe_mail_reduce"><a href="#">read less</a></span></div> + </t> + <t t-if="! widget.body_short"> + <t t-raw="widget.body"/> + </t> </div> </div> <div class="oe_msg_footer"> diff --git a/addons/mail/static/src/xml/mail_followers.xml b/addons/mail/static/src/xml/mail_followers.xml index 5ad3ff09bb3..a936b8237d6 100644 --- a/addons/mail/static/src/xml/mail_followers.xml +++ b/addons/mail/static/src/xml/mail_followers.xml @@ -31,6 +31,7 @@ <div t-name="mail.followers.partner" class='oe_partner'> <img class="oe_mail_thumbnail oe_mail_frame" t-attf-src="{record.avatar_url}"/> <a t-attf-href="#model=res.partner&id=#{record.id}" t-att-title="record.name"><t t-esc="record.name"/></a> + <span t-if="record.is_editable and (widget.records_length > 1)" class="oe_edit_subtype oe_e oe_hidden" title="Edit subscription" t-att-data-id="record.id">&</span> <span t-if="widget.view_is_editable" class="oe_remove_follower oe_e" title="Remove this follower" t-att-data-id="record.id">X</span> </div> |
