var QWeb = session.web.qweb;
var suggestions = session.suggestions;
- var removed_suggested_employee = session.removed_suggested_employee = [];
- suggestions.Employees = session.mail.Wall.include({
+ var removed_suggested_employee = session.suggestions.removed_suggested_employee = [];
+
+ suggestions.Employees = session.web.Widget.extend({
events: {
- 'click .oe_remove_suggestion_employees': "remove_suggestion_employees",
- 'click .oe_remove_suggested_employee': "remove_suggested_employee",
- 'click .oe_follow_employee': "follow_employee",
- 'click .oe_open_employee': "open_employee"
+ 'click .oe_suggestion_remove.oe_suggestion_employee': 'stop_employee_suggestion',
+ 'click .oe_suggestion_remove_item.oe_suggestion_employee': 'remove_employee_suggestion',
+ 'click .oe_suggestion_follow': 'follow_employee',
},
- init: function (parent, action) {
- var self = this;
- this._super(parent, action);
- this.deferred = $.Deferred();
+
+ init: function () {
+ this._super(this, arguments);
this.hr_employee = new session.web.DataSetSearch(this, 'hr.employee');
this.res_users = new session.web.DataSetSearch(this, 'res.users');
- this.suggestions = [];
+ this.employees = [];
},
- start: function() {
- var tmp = this._super.apply(this, arguments);
- var self = this;
- var res = self.get_suggested_employee();
- $.when(res).done(function() {});
- return tmp;
+ start: function () {
+ this._super.apply(this, arguments);
+ return this.fetch_suggested_employee();
},
- get_suggested_employee: function () {
+
+ fetch_suggested_employee: function () {
var self = this;
- var employee = self.hr_employee.call('get_suggested_thread', {'removed_suggested_threads':removed_suggested_employee}).then(function(res) {
- _(res).each(function(result) {
+ var employee = self.hr_employee.call('get_suggested_thread', {'removed_suggested_threads': removed_suggested_employee}).then(function (res) {
+ _(res).each(function (result) {
result['image']=self.session.url('/web/binary/image', {model: 'hr.employee', field: 'image_small', id: result.id});
});
- self.suggestions = res;
- });
- return $.when(employee).done(function() {
- self.$el.find('.oe_suggestions_employees').html( QWeb.render("hr.suggestions.employee", {'widget': self}) );
- if (self.suggestions.length === 0) {
- self.$(".oe_sidebar_employee").hide();
- }
- });
- },
- renderFollowButtons: function() {
- var self = this;
- self.dfm = new session.web.form.DefaultFieldManager(self);
- // Generate a FieldMonetary for each .oe_goal_field_monetary
- self.$el.find(".oe_follow_employee").each(function() {
- follower_field = new session.mail_followers.Followers(self.dfm, {
- attrs: {
- view: self.view
- }
- });
- follower_field.set('value', parseInt($(this).text(), 10));
- // follower_field.replace($(this));
+ self.employees = res;
});
+ return $.when(employee).done(this.proxy('display_suggested_employees'));
},
- open_employee:function(event) {
- var self = this;
- var id = JSON.parse($(event.currentTarget).attr("id"));
- action = {
- type: 'ir.actions.act_window',
- res_model: 'hr.employee',
- res_id: id,
- views: [[false, 'form']],
- target: 'current'
- };
- this.do_action(action);
+
+ display_suggested_employees: function () {
+ var suggested_employees = this.$('.oe_sidebar_suggestion.oe_suggestion_employee');
+ if (suggested_employees) {
+ suggested_employees.remove();
+ }
+ if (this.employees.length === 0) {
+ return this.$el.empty();
+ }
+ return this.$el.empty().html(QWeb.render('hr.suggestions.employees', {'widget': this}));
},
- follow_employee:function(event) {
+
+ follow_employee: function (event) {
var self = this;
- employee_id = parseInt($(event.currentTarget).attr('id'), 10);
+ var employee_id = parseInt($(event.currentTarget).attr('id'), 10);
return this.hr_employee.call('message_subscribe_users', [[employee_id], [this.session.uid], undefined]).then(function(res) {
- self.get_suggested_employee();
+ self.fetch_suggested_employee();
});
},
- remove_suggested_employee: function(event) {
- var self = this;
+
+ remove_employee_suggestion: function (event) {
removed_suggested_employee.push($(event.currentTarget).attr('id'));
- self.get_suggested_employee();
+ return this.fetch_suggested_employee();
},
- remove_suggestion_employees: function(event) {
+
+ stop_employee_suggestion: function (event) {
var self = this;
return this.res_users.call('stop_showing_employees_suggestions', [this.session.uid]).then(function(res) {
- self.$(".oe_sidebar_employee").hide();
+ self.$(".oe_sidebar_suggestion.oe_suggestion_employee").hide();
});
}
});
+ session.mail.WallSidebar.include({
+ start: function () {
+ this._super.apply(this, arguments);
+ var sug_employees = new suggestions.Employees(this);
+ return sug_employees.appendTo(this.$('.oe_suggestions_employees'));
+ },
+ });
+
};
<?xml version="1.0" encoding="UTF-8"?>
<template>
- <t t-extend="mail.suggestions">
- <t t-jquery=".oe_suggestions_groups" t-operation="after">
- <div class="oe_suggestions_employees">No employee</div>
+ <!-- Employees placeholder in sidebar -->
+ <t t-extend="mail.wall.sidebar">
+ <t t-jquery=".oe_mail_wall_sidebar" t-operation="append">
+ <div class="oe_suggestions_employees"></div>
</t>
</t>
<!-- Suggested employees -->
- <div t-name="hr.suggestions.employee" class="oe_sidebar_suggestion oe_sidebar_employee">
- <p class="oe_suggestion_display">
- Suggested Employees
- <a class="oe_remove_suggestion oe_remove_suggestion_employees" rol="button">
- <span class="oe_kanban_action oe_kanban_action_a">X</span>
- </a>
- </p>
- <div class="oe_suggest_employees">
- <t t-foreach="widget.suggestions" t-as="result">
+ <div t-name="hr.suggestions.employees" class="oe_sidebar_suggestion oe_suggestion_employee">
+ <div class="oe_suggest_title">
+ <a class="oe_suggestion_remove oe_suggestion_employee oe_e">X</a>
+ <h2>Suggested Employees</h2>
+ </div>
+ <div class="oe_suggest_items">
+ <t t-foreach="widget.employees" t-as="result">
<div class="oe_suggested_item">
- <div class="oe_item_image">
- <img class="oe_item_image_content oe_open_employee" t-attf-src="{result.image}" t-attf-id="{result.id}"/>
- </div>
- <div class="oe_item">
- <a class="oe_item_name oe_open_employee" t-attf-id="{result.id}">
- <t t-esc="result.name"/>
- </a>
- <a class="oe_remove_suggested_item oe_remove_suggested_employee" rol="button" t-attf-id="{result.id}">
- <span class="oe_kanban_action oe_kanban_action_a">X</span>
+ <div class="oe_suggested_item_image">
+ <a t-attf-href="#model=hr.employee&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=hr.employee&id=#{result.id}"><t t-esc="result.name"/></a>
+ <a class="oe_suggestion_remove_item oe_suggestion_employee oe_e" t-attf-id="{result.id}">X</a>
<br/>
- <button class="oe_suggestion_action oe_follow_employee" t-att-id="result.id">Follow</button>
+ <button class="oe_suggestion_follow" t-att-id="result.id">Follow</button>
</div>
</div>
</t>
</div>
</div>
-
</template>
/* ------------- WALL SIDEBAR ------------- */
.openerp .oe_mail_wall .oe_mail_wall_aside {
- margin-top: 15px;
+ 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: 10px;
+ padding-top: 1px;
}
-.openerp .oe_mail_wall_aside .oe_suggestion_display {
+.openerp .oe_sidebar_suggestion .oe_suggest_title h2 {
font-size: 14px;
font-weight: bold;
margin-left: 10px;
+ padding: 0px;
}
-.openerp .oe_mail_wall_aside .oe_suggested_item {
+.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_mail_wall_aside .oe_item_image {
+.openerp .oe_sidebar_suggestion .oe_suggest_items .oe_suggested_item_image {
float: left;
padding-right: 10px;
}
-.openerp .oe_mail_wall_aside .oe_item_image_content {
+.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_mail_wall_aside .oe_suggestion_action {
+.openerp .oe_sidebar_suggestion .oe_suggest_items .oe_suggested_item_content button {
margin-top: 10px;
}
-.openerp .oe_mail_wall_aside .oe_remove_suggested_item,
-.openerp .oe_mail_wall_aside .oe_remove_suggestion {
+.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;
- width: 3%;
+ 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;
- margin-right: 10px;
+ visibility: hidden;
+ margin-right: 16px;
}
-.openerp .oe_mail_wall_aside .oe_suggested_item:hover .oe_remove_suggested_item > span,
-.openerp .oe_mail_wall_aside .oe_suggestion_display:hover .oe_remove_suggestion > span {
+.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;
}
-.openerp .oe_mail_wall_aside .oe_item,.oe_suggestion_display {
- width: 90%;
-}
-.openerp .oe_mail_wall_aside .oe_item .oe_item_name {
- text-overflow: ellipsis;
- overflow: hidden;
- width: 90%;
-}
\ No newline at end of file
+
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
/**
* ------------------------------------------------------------
/**
* ------------------------------------------------------------
+ * 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
* ------------------------------------------------------------
*
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'));
},
/**
},
});
- openerp.mail.suggestions(session, mail);
+
+ /**
+ * ------------------------------------------------------------
+ * 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)
+
};
var QWeb = session.web.qweb;
var suggestions = session.suggestions = {};
+ var removed_suggested_group = session.suggestions.removed_suggested_group = [];
- suggestions.Sidebar = session.web.Widget.extend({
- template: "mail.suggestions",
- init: function (parent, action) {
- var self = this;
- this._super(parent, action);
- this.res_user = new session.web.DataSetSearch(this, 'res.users');
- }
- });
-
- var removed_suggested_group = session.removed_suggested_group = [];
suggestions.Groups = session.web.Widget.extend({
events: {
- 'click .oe_remove_suggestion_groups': "remove_suggestion_groups",
- 'click .oe_remove_suggested_group': "remove_suggested_group",
- 'click .oe_join_group': "join_group",
- 'click .oe_open_group': "open_group"
+ '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 (parent, action) {
- var self = this;
- this._super(parent, action);
- this.deferred = $.Deferred();
+
+ 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.suggestions = [];
+ this.groups = [];
},
- start: function() {
- var self = this;
- var res = self.get_suggested_group();
- return $.when(res).done(function() {});
+
+ start: function () {
+ this._super.apply(this, arguments);
+ return this.fetch_suggested_groups();
},
- get_suggested_group: function () {
+
+ 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) {
+ 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.suggestions = res;
- });
- return $.when(group).done(function() {
- self.$el.html( QWeb.render("mail.suggestions.groups", {'widget': self}) );
- if (self.suggestions.length === 0) {
- self.$(".oe_sidebar_group").hide();
- }
+ self.groups = res;
});
+ return $.when(group).then(this.proxy('display_suggested_groups'));
},
- open_group:function(event) {
- var self = this;
- var id = JSON.parse($(event.currentTarget).attr("id"));
- action = {
- type: 'ir.actions.act_window',
- res_model: 'mail.group',
- res_id: id,
- views: [[false, 'form']],
- target: 'current'
- };
- this.do_action(action);
+
+ 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) {
+
+ 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.get_suggested_group();
+ self.fetch_suggested_groups();
});
},
- remove_suggested_group: function(event) {
- var self = this;
+
+ remove_group_suggestion: function (event) {
removed_suggested_group.push($(event.currentTarget).attr('id'));
- self.get_suggested_group();
+ return this.fetch_suggested_groups();
},
- remove_suggestion_groups: function(event) {
+
+ 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_group").hide();
+ self.$(".oe_sidebar_suggestion.oe_suggestion_group").hide();
});
}
});
- mail.Wall.include({
- start: function(options) {
- this._super(options);
- var self = this;
- var sidebar = new suggestions.Sidebar(self);
- sidebar.appendTo(self.$el.find('.oe_mail_wall_aside'));
-
- var sug_groups = new suggestions.Groups(self);
- // sug_groups.replace(self.$el.find('.oe_suggestions_groups'));
- $.when(sug_groups.start()).done(function() {
- //self.$el.find('.oe_suggestions_groups').html(sug_groups.$el.html());
- sug_groups.replace( self.$el.find('.oe_suggestions_groups') );
- });
-
- }
+ 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'));
+ },
});
};
</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">
<?xml version="1.0" encoding="UTF-8"?>
<template>
- <t t-name="mail.suggestions">
- <div class="oe_suggestions_groups"></div>
+ <!-- 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_sidebar_group">
- <p class="oe_suggestion_display">
- Suggested Groups
- <a class="oe_remove_suggestion oe_remove_suggestion_groups" rol="button">
- <span class="oe_kanban_action oe_kanban_action_a">X</span>
- </a>
- </p>
- <div class="oe_suggest_groups">
- <t t-foreach="widget.suggestions" t-as="result">
+ <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_item_image">
- <img class="oe_item_image_content oe_open_group" t-attf-src="{result.image}" t-attf-id="{result.id}"/>
- </div>
- <div class="oe_item">
- <a class="oe_item_name oe_open_group" t-attf-id="{result.id}">
- <t t-esc="result.name"/>
- </a>
- <a class="oe_remove_suggested_item oe_remove_suggested_group" rol="button" t-attf-id="{result.id}">
- <span class="oe_kanban_action oe_kanban_action_a">X</span>
+ <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_action oe_join_group">Join Group</button>
+ <button t-att-id="result.id" class="oe_suggestion_join">Join Group</button>
</div>
</div>
</t>