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/js | |
| 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/js')
| -rw-r--r-- | addons/mail/static/src/js/mail.js | 44 | ||||
| -rw-r--r-- | addons/mail/static/src/js/suggestions.js | 77 |
2 files changed, 117 insertions, 4 deletions
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')); + }, + }); + +}; |
