diff options
| author | Thibault Delavallée <tde@openerp.com> | 2013-06-12 14:12:58 +0200 |
|---|---|---|
| committer | Thibault Delavallée <tde@openerp.com> | 2013-06-12 14:12:58 +0200 |
| commit | 43d08b898fc3a5c5d5eaec140e7acd3b7e7faf43 (patch) | |
| tree | 63506a148af90b389f29b0de689b01eff5bbeb74 /addons/mail/static/src | |
| parent | 70f16ce73b0dab305b9e7d63a74416cbcb0448da (diff) | |
| parent | 99dd06cfd0f87e0bdd6be402f85328f1006667aa (diff) | |
[MERGE] [IMP] 'Social Aspects' Task
Purpose:
- mail is now focused on messaging; partner document is now a classic document, without specific behavior; removed the concept of 'my followers' from mail;
- hr adds social features to mail: employee profile is used to display internal messages; employees can follow other employees, comment and react on their profile messages;
- display suggestion of Groups and Employees to follow in the Inbox, using a new widget. The purpose is to promote social interactions between employees and to improve the visibility of groups;
mail:
- add suggestions.Group widget that allows to display a list of suggested groups to follow; this widget is displayed in the Inbox;
- display 'Partner profile of' or 'News from' when reading messages from a partner profile / employee profile in the Inbox;
- 'Compose a new message or Write to my followers' is not present anymore when hr is not installed, because this social aspect comes with HR;
- mail_thread: add a search function on message_is_follower;
- mail_group: implement suggested groups behavior;
- res_partner: removed specific code changing message_post with type='email' to a private discussion between author and destination partner; partner document behaves like a classic document;
- res_users: add 'display_groups_suggestions' field that controls the display of suggested groups to follow;
- res_users: writing on a res.users object is considered as a private discussion; when Hr is not installed, only aliases should be able to post on a user;
hr_employee:
- when creating an employee, post a message on its profile and push it to every employees of the same company;
- add follow/unfollow and message and follower count on employee kanban view;
- implement suggested employee behavior;
- HR improves the basic Inbox by adding the 'Compose a new message or Write to my followers';
- allow to post on an employee profile when having read access right if the user that posts is an employee;
HR:
- add suggestions.Employee widget that allows to display a list of suggested employees to follow; this widget is displayed in the Inbox;
- res_users: add 'display_employees_suggestions' field that controls the display of suggested employees to follow;
- res_users: do not welcome new users anymore, welcome new employees instead
- res_users: incoming emails are still considered as private messages (using aliases); however messages posted on user profile are redirected to the related employee profiles (used for 'Write to my followers')
bzr revid: tde@openerp.com-20130612121258-j38do5opsot2ur7c
Diffstat (limited to 'addons/mail/static/src')
| -rw-r--r-- | addons/mail/static/src/css/mail.css | 66 | ||||
| -rw-r--r-- | addons/mail/static/src/css/mail_group.css | 1 | ||||
| -rw-r--r-- | addons/mail/static/src/js/mail.js | 44 | ||||
| -rw-r--r-- | addons/mail/static/src/js/suggestions.js | 77 | ||||
| -rw-r--r-- | addons/mail/static/src/xml/mail.xml | 19 | ||||
| -rw-r--r-- | addons/mail/static/src/xml/suggestions.xml | 38 |
6 files changed, 233 insertions, 12 deletions
diff --git a/addons/mail/static/src/css/mail.css b/addons/mail/static/src/css/mail.css index 958c2bccd5f..c969d3f3b16 100644 --- a/addons/mail/static/src/css/mail.css +++ b/addons/mail/static/src/css/mail.css @@ -22,7 +22,7 @@ width: 32px; height: 32px; padding: 0px; - margin: 0px + margin: 0px; border-radius: 0px; } @@ -665,8 +665,72 @@ .openerp .oe_mail_wall .oe_mail{ margin: 16px; width: 600px; + display: inline-block; } .openerp .oe_mail .oe_view_nocontent > p { padding-left: 15px; } + + +/* ------------- WALL SIDEBAR ------------- */ + +.openerp .oe_mail_wall .oe_mail_wall_aside { + margin: 16px; + position: relative; + display: inline-block; + vertical-align: top; + width: 260px; +} +.openerp .oe_mail_wall_aside .oe_sidebar_suggestion { + background-color: #EDEDF6; + border-radius: 2px; + padding-top: 1px; +} +.openerp .oe_sidebar_suggestion .oe_suggest_title h2 { + font-size: 14px; + font-weight: bold; + margin-left: 10px; + padding: 0px; +} +.openerp .oe_sidebar_suggestion .oe_suggest_items .oe_suggested_item { + border-radius: 2px; + width: 100%; + margin-left: 10px; + min-height: 67px; /* image_small 66x66px */ +} +.openerp .oe_sidebar_suggestion .oe_suggest_items .oe_suggested_item_image { + float: left; + padding-right: 10px; +} +.openerp .oe_sidebar_suggestion .oe_suggest_items .oe_suggested_item_image img { + border-radius: 2px; + border: solid 1px rgba(0,0,0,0.03); +} +.openerp .oe_sidebar_suggestion .oe_suggest_items .oe_suggested_item_content button { + margin-top: 10px; +} +.openerp .oe_sidebar_suggestion .oe_suggest_items .oe_suggested_item_content a.oe_suggestion_item_name { + text-overflow: ellipsis; + overflow: hidden; + width: 90%; +} +.openerp .oe_sidebar_suggestion .oe_suggest_title a.oe_suggestion_remove { + line-height: 15px; + margin-top: -2px; + float: right; + visibility: hidden; + margin-right: 7px; +} +.openerp .oe_sidebar_suggestion .oe_suggest_items .oe_suggested_item_content a.oe_suggestion_remove_item { + line-height: 15px; + margin-top: -2px; + float: right; + visibility: hidden; + margin-right: 16px; +} +.openerp .oe_sidebar_suggestion .oe_suggest_title:hover a.oe_suggestion_remove, +.openerp .oe_sidebar_suggestion .oe_suggest_items:hover a.oe_suggestion_remove_item { + visibility: visible; +} + diff --git a/addons/mail/static/src/css/mail_group.css b/addons/mail/static/src/css/mail_group.css index 4f2b8a16dd0..9560a4765d0 100644 --- a/addons/mail/static/src/css/mail_group.css +++ b/addons/mail/static/src/css/mail_group.css @@ -48,7 +48,6 @@ text-align: center; overflow: hidden; -moz-border-radius: 3px; - border-collapse: separate; -webkit-border-radius: 3px; -o-border-radius: 3px; -ms-border-radius: 3px; diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index 7df6cdbef0d..0bc24ac4264 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -4,8 +4,8 @@ openerp.mail = function (session) { var mail = session.mail = {}; - openerp_mail_followers(session, mail); // import mail_followers.js - openerp_FieldMany2ManyTagsEmail(session); // import manyy2many_tags_email.js + openerp_mail_followers(session, mail); // import mail_followers.js + openerp_FieldMany2ManyTagsEmail(session); // import manyy2many_tags_email.js /** * ------------------------------------------------------------ @@ -237,8 +237,15 @@ openerp.mail = function (session) { this.format_data(); + // update record_name: Partner profile + if (this.model == 'res.partner') { + this.record_name = 'Partner Profile of ' + this.record_name; + } + else if (this.model == 'hr.employee') { + this.record_name = 'News from ' + this.record_name; + } // record options and data - this.show_record_name = this.options.show_record_name && this.record_name && !this.thread_level && this.model != 'res.partner'; + this.show_record_name = this.options.show_record_name && this.record_name && !this.thread_level; this.options.show_read = false; this.options.show_unread = false; if (this.options.show_read_unread_button) { @@ -257,6 +264,7 @@ openerp.mail = function (session) { /* Convert date, timerelative and avatar in displayable data. */ format_data: function () { + //formating and add some fields for render this.date = this.date ? session.web.str_to_datetime(this.date) : false; if (this.date && new Date().getTime()-this.date.getTime() < 7*24*60*60*1000) { @@ -745,7 +753,7 @@ openerp.mail = function (session) { } // create object and attach to the thread object thread.message_fetch([["id", "=", message_id]], false, [message_id], function (arg, data) { - var message = thread.create_message_object( data[0] ); + var message = thread.create_message_object( data.slice(-1)[0] ); // insert the message on dom thread.insert_message( message, root ? undefined : self.$el, root ); }); @@ -1842,6 +1850,19 @@ openerp.mail = function (session) { /** * ------------------------------------------------------------ + * Aside Widget + * ------------------------------------------------------------ + * + * This widget handles the display of a sidebar on the Wall. Its main use + * is to display group and employees suggestion (if hr is installed). + */ + mail.WallSidebar = session.web.Widget.extend({ + template: 'mail.wall.sidebar', + }); + + + /** + * ------------------------------------------------------------ * Wall Widget * ------------------------------------------------------------ * @@ -1901,6 +1922,9 @@ openerp.mail = function (session) { if (! this.searchview.has_defaults) { this.message_render(); } + // render sidebar + var wall_sidebar = new mail.WallSidebar(this); + wall_sidebar.appendTo(this.$el.find('.oe_mail_wall_aside')); }, /** @@ -2018,4 +2042,16 @@ openerp.mail = function (session) { }); }, }); + + + /** + * ------------------------------------------------------------ + * Sub-widgets loading + * ------------------------------------------------------------ + * + * Load here widgets that could depend on widgets defined in mail.js + */ + + openerp.mail.suggestions(session, mail); // import suggestion.js (suggestion widget) + }; diff --git a/addons/mail/static/src/js/suggestions.js b/addons/mail/static/src/js/suggestions.js new file mode 100644 index 00000000000..4d0fcec32bf --- /dev/null +++ b/addons/mail/static/src/js/suggestions.js @@ -0,0 +1,77 @@ +openerp.mail.suggestions = function(session, mail) { + var _t = session.web._t; + var QWeb = session.web.qweb; + + var suggestions = session.suggestions = {}; + var removed_suggested_group = session.suggestions.removed_suggested_group = []; + + suggestions.Groups = session.web.Widget.extend({ + events: { + 'click .oe_suggestion_remove.oe_suggestion_group': 'stop_group_suggestion', + 'click .oe_suggestion_remove_item.oe_suggestion_group': 'remove_group_suggestion', + 'click .oe_suggestion_join': 'join_group', + }, + + init: function () { + this._super.apply(this, arguments); + this.mail_group = new session.web.DataSetSearch(this, 'mail.group'); + this.res_users = new session.web.DataSetSearch(this, 'res.users'); + this.groups = []; + }, + + start: function () { + this._super.apply(this, arguments); + return this.fetch_suggested_groups(); + }, + + fetch_suggested_groups: function () { + var self = this; + var group = self.mail_group.call('get_suggested_thread', {'removed_suggested_threads': removed_suggested_group}).then(function (res) { + _(res).each(function (result) { + result['image']=self.session.url('/web/binary/image', {model: 'mail.group', field: 'image_small', id: result.id}); + }); + self.groups = res; + }); + return $.when(group).then(this.proxy('display_suggested_groups')); + }, + + display_suggested_groups: function () { + var suggested_groups = this.$('.oe_sidebar_suggestion.oe_suggestion_group'); + if (suggested_groups) { + suggested_groups.empty(); + } + if (this.groups.length === 0) { + return this.$el.empty(); + } + return this.$el.empty().html(QWeb.render('mail.suggestions.groups', {'widget': this})); + }, + + join_group: function (event) { + var self = this; + return this.mail_group.call('message_subscribe_users', [[$(event.currentTarget).attr('id')],[this.session.uid]]).then(function(res) { + self.fetch_suggested_groups(); + }); + }, + + remove_group_suggestion: function (event) { + removed_suggested_group.push($(event.currentTarget).attr('id')); + return this.fetch_suggested_groups(); + }, + + stop_group_suggestion: function (event) { + var self = this; + return this.res_users.call('stop_showing_groups_suggestions', [this.session.uid]).then(function(res) { + self.$(".oe_sidebar_suggestion.oe_suggestion_group").hide(); + }); + } + }); + + session.mail.WallSidebar.include({ + start: function () { + this._super.apply(this, arguments); + var sug_groups = new suggestions.Groups(this); + return sug_groups.appendTo(this.$('.oe_suggestions_groups')); + }, + }); + +}; diff --git a/addons/mail/static/src/xml/mail.xml b/addons/mail/static/src/xml/mail.xml index f5004941a8d..5062491ecbb 100644 --- a/addons/mail/static/src/xml/mail.xml +++ b/addons/mail/static/src/xml/mail.xml @@ -121,9 +121,11 @@ To: <t t-if="!widget.is_private"> <span class="oe_all_follower"> - Followers of - <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">this document</t> + <t t-if="widget.parent_thread.parent_message.record_name" t-raw="'"' + 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> @@ -197,9 +199,17 @@ </tbody> </table> <div class="oe_mail-placeholder"></div> + <aside class="oe_mail_wall_aside"></aside> </div> <!-- + Empty template that holds the sidebar of the Wall + --> + <t t-name="mail.wall.sidebar"> + <div class="oe_mail_wall_sidebar"></div> + </t> + + <!-- display message on the wall when there are no message --> <t t-name="mail.wall_no_message"> @@ -339,7 +349,4 @@ </a> </span> - <!-- mail.thread.message.star - Template used to display stared/unstared message in a mail.message - --> </template> diff --git a/addons/mail/static/src/xml/suggestions.xml b/addons/mail/static/src/xml/suggestions.xml new file mode 100644 index 00000000000..9157dcbe32e --- /dev/null +++ b/addons/mail/static/src/xml/suggestions.xml @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<template> + + <!-- Groups placeholder in sidebar --> + <t t-extend="mail.wall.sidebar"> + <t t-jquery=".oe_mail_wall_sidebar" t-operation="append"> + <div class="oe_suggestions_groups"></div> + </t> + </t> + + + <!-- Suggested groups --> + <div t-name="mail.suggestions.groups" class="oe_sidebar_suggestion oe_suggestion_group"> + <div class="oe_suggest_title"> + <a class="oe_suggestion_remove oe_suggestion_group oe_e">X</a> + <h2>Suggested Groups</h2> + </div> + <div class="oe_suggest_items"> + <t t-foreach="widget.groups" t-as="result"> + <div class="oe_suggested_item"> + <div class="oe_suggested_item_image"> + <a t-attf-href="#model=mail.group&id=#{result.id}"> + <img t-attf-src="{result.image}" t-attf-alt="{result.name}"/> + </a> + </div> + <div class="oe_suggested_item_content"> + <a class="oe_suggestion_item_name" t-attf-href="#model=mail.group&id=#{result.id}"><t t-esc="result.name"/></a> + <a class="oe_suggestion_remove_item oe_suggestion_group oe_e" t-attf-id="{result.id}">X</a> + <br/> + <button t-att-id="result.id" class="oe_suggestion_join">Join Group</button> + </div> + </div> + </t> + </div> + </div> + + +</template> |
