summaryrefslogtreecommitdiff
path: root/addons/mail/static/src
diff options
context:
space:
mode:
Diffstat (limited to 'addons/mail/static/src')
-rw-r--r--addons/mail/static/src/css/mail.css76
-rw-r--r--addons/mail/static/src/css/mail_group.css1
-rw-r--r--addons/mail/static/src/js/mail.js60
-rw-r--r--addons/mail/static/src/js/suggestions.js77
-rw-r--r--addons/mail/static/src/xml/mail.xml30
-rw-r--r--addons/mail/static/src/xml/suggestions.xml38
6 files changed, 255 insertions, 27 deletions
diff --git a/addons/mail/static/src/css/mail.css b/addons/mail/static/src/css/mail.css
index 958c2bccd5f..211133afaf8 100644
--- a/addons/mail/static/src/css/mail.css
+++ b/addons/mail/static/src/css/mail.css
@@ -22,10 +22,20 @@
width: 32px;
height: 32px;
padding: 0px;
- margin: 0px
+ margin: 0px;
border-radius: 0px;
}
+/* ---- GENERIC FOR MAIL-RELATED STUFF ---- */
+.openerp .oe_e.oe_e_alias {
+ font-size: 30px;
+ line-height: 15px;
+ vertical-align: top;
+ margin-right: 3px;
+ color: white;
+ text-shadow: 0px 0px 2px black;
+}
+
/* ------------ MAIL WIDGET --------------- */
.openerp .oe_mail, .openerp .oe_mail *{
-webkit-box-sizing: border-box;
@@ -665,8 +675,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..21b0f5a9a87 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,8 +264,10 @@ 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;
+ this.display_date = this.date.toString('ddd MMM dd yyyy HH:mm');
if (this.date && new Date().getTime()-this.date.getTime() < 7*24*60*60*1000) {
this.timerelative = $.timeago(this.date);
}
@@ -623,10 +632,7 @@ openerp.mail = function (session) {
// have unknown names -> call message_get_partner_info_from_emails to try to find partner_id
var find_done = $.Deferred();
if (names_to_find.length > 0) {
- var values = {
- 'res_id': this.context.default_res_id,
- }
- find_done = self.parent_thread.ds_thread._model.call('message_get_partner_info_from_emails', [names_to_find], values);
+ find_done = self.parent_thread.ds_thread._model.call('message_partner_info_from_emails', [this.context.default_res_id, names_to_find]);
}
else {
find_done.resolve([]);
@@ -672,11 +678,7 @@ openerp.mail = function (session) {
var new_names_to_find = _.difference(names_to_find, names_to_remove);
find_done = $.Deferred();
if (new_names_to_find.length > 0) {
- var values = {
- 'link_mail': true,
- 'res_id': self.context.default_res_id,
- }
- find_done = self.parent_thread.ds_thread._model.call('message_get_partner_info_from_emails', [new_names_to_find], values);
+ find_done = self.parent_thread.ds_thread._model.call('message_partner_info_from_emails', [self.context.default_res_id, new_names_to_find, true]);
}
else {
find_done.resolve([]);
@@ -745,7 +747,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 );
});
@@ -978,8 +980,8 @@ openerp.mail = function (session) {
expender: function () {
this.$('.oe_msg_body:first').expander({
slicePoint: this.options.truncate_limit,
- expandText: 'read more',
- userCollapseText: 'read less',
+ expandText: _t('read more'),
+ userCollapseText: _t('read less'),
detailClass: 'oe_msg_tail',
moreClass: 'oe_mail_expand',
lessClass: 'oe_mail_reduce',
@@ -1842,6 +1844,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 +1916,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 +2036,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..94ee1ff452f 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="'&quot;' + widget.parent_thread.parent_message.record_name + '&quot;'"/>
- <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="'&quot;' + widget.parent_thread.parent_message.record_name + '&quot;'">
+ Followers of <t t-raw="'&quot;' + widget.parent_thread.parent_message.record_name + '&quot;'"/>
+ </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">
@@ -271,16 +281,16 @@
<span class='oe_subtle'>•</span>
</t>
</t>
- <t t-if="widget.type == 'comment' and ! widget.subtype">
+ <t t-if="widget.type == 'comment' and ! widget.subtype and widget.partner_ids.length == 0">
logged a note
</t>
- <t t-if="(widget.type == 'comment' or widget.type == 'email') and widget.subtype">
+ <t t-if="(widget.type == 'comment' or widget.type == 'email') and (widget.subtype or widget.partner_ids.length > 0)">
to
<t t-if="widget.partner_ids.length == 0">
nobody
</t>
</t>
- <t t-if="widget.type == 'notification' or ( (widget.type == 'email' or widget.type == 'comment') and widget.subtype)"
+ <t t-if="widget.type == 'notification' or ( (widget.type == 'email' or widget.type == 'comment') and (widget.subtype or widget.partner_ids.length > 0))"
t-foreach="widget.partner_ids.slice(0, 3)" t-as="partner">
<span t-attf-class="oe_partner_follower">
<a t-if="widget.options.show_link" t-attf-href="#model=res.partner&amp;id=#{partner[0]}"><t t-raw="partner[1]"/></a>
@@ -295,7 +305,10 @@
notified
</t>
<span class='oe_subtle'>•</span>
- <span t-att-title="widget.date"><t t-if="widget.timerelative" t-raw="widget.timerelative"/><t t-if="!widget.timerelative" t-raw="widget.date"/></span>
+ <span t-att-title="widget.date">
+ <t t-if="widget.timerelative" t-raw="widget.timerelative"/>
+ <t t-if="!widget.timerelative" t-raw="widget.display_date"/>
+ </span>
<span t-if="!widget.options.readonly" class='oe_subtle'>•</span>
<t t-if="!widget.options.readonly" t-call="mail.thread.message.vote"/>
</div>
@@ -339,7 +352,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&amp;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&amp;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>