summaryrefslogtreecommitdiff
path: root/addons/hr/static/src
diff options
context:
space:
mode:
authorsgo@tinyerp.com <>2013-06-26 16:40:29 +0530
committersgo@tinyerp.com <>2013-06-26 16:40:29 +0530
commit2e272a76872cee16de1ecbdc8f67fdf4a84f27e4 (patch)
tree73883be0a6ba0f3ad7f0ee6299db56279d471c6b /addons/hr/static/src
parent2ed45d19d31344e332ae3632abec8c791efab1f0 (diff)
parentc180afab26171617c1c7c22db5d9836b159e5e7d (diff)
[MERGE]sync with trunk
bzr revid: sgo@tinyerp.com-20130626111029-e6szwugpewn3cd2g
Diffstat (limited to 'addons/hr/static/src')
-rw-r--r--addons/hr/static/src/css/hr.css5
-rw-r--r--addons/hr/static/src/js/suggestions.js78
-rw-r--r--addons/hr/static/src/xml/suggestions.xml36
3 files changed, 119 insertions, 0 deletions
diff --git a/addons/hr/static/src/css/hr.css b/addons/hr/static/src/css/hr.css
index 16657394736..951ec4d02e3 100644
--- a/addons/hr/static/src/css/hr.css
+++ b/addons/hr/static/src/css/hr.css
@@ -68,3 +68,8 @@
margin: 2px 0;
padding: 0;
}
+
+.openerp .oe_employee_vignette .oe_followers {
+ width: auto;
+ float: none;
+}
diff --git a/addons/hr/static/src/js/suggestions.js b/addons/hr/static/src/js/suggestions.js
new file mode 100644
index 00000000000..3bc37e71344
--- /dev/null
+++ b/addons/hr/static/src/js/suggestions.js
@@ -0,0 +1,78 @@
+openerp.hr = function(session) {
+ var _t = session.web._t;
+ var QWeb = session.web.qweb;
+
+ var suggestions = session.suggestions;
+ var removed_suggested_employee = session.suggestions.removed_suggested_employee = [];
+
+ suggestions.Employees = session.web.Widget.extend({
+ events: {
+ '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 () {
+ 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.employees = [];
+ },
+
+ start: function () {
+ this._super.apply(this, arguments);
+ return this.fetch_suggested_employee();
+ },
+
+ 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) {
+ result['image']=self.session.url('/web/binary/image', {model: 'hr.employee', field: 'image_small', id: result.id});
+ });
+ self.employees = res;
+ });
+ return $.when(employee).done(this.proxy('display_suggested_employees'));
+ },
+
+ 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) {
+ var self = this;
+ 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.fetch_suggested_employee();
+ });
+ },
+
+ remove_employee_suggestion: function (event) {
+ removed_suggested_employee.push($(event.currentTarget).attr('id'));
+ return this.fetch_suggested_employee();
+ },
+
+ 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_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'));
+ },
+ });
+
+};
diff --git a/addons/hr/static/src/xml/suggestions.xml b/addons/hr/static/src/xml/suggestions.xml
new file mode 100644
index 00000000000..f3095627bae
--- /dev/null
+++ b/addons/hr/static/src/xml/suggestions.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<template>
+
+ <!-- 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.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_suggested_item_image">
+ <a t-attf-href="#model=hr.employee&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=hr.employee&amp;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_follow" t-att-id="result.id">Follow</button>
+ </div>
+ </div>
+ </t>
+ </div>
+ </div>
+
+</template>