summaryrefslogtreecommitdiff
path: root/addons/hr/static/src
diff options
context:
space:
mode:
authorMartin Trigaux <mat@openerp.com>2013-06-21 09:54:06 +0200
committerMartin Trigaux <mat@openerp.com>2013-06-21 09:54:06 +0200
commitad78a1b6aad9d4f56adf83d850cd2a22c5e8fa36 (patch)
tree8382d5327c734624c784a42a6a8c663b9c7e3263 /addons/hr/static/src
parenta2b06d2f13c11f0816ca8bb19ffb3fe3e2973249 (diff)
parent9ebfb79b6b4bd8cd2367c4467a935752e4f92e02 (diff)
[MERGE] sync with latest trunk
bzr revid: mat@openerp.com-20130621075406-d9syftu04k8iytcz
Diffstat (limited to 'addons/hr/static/src')
-rw-r--r--addons/hr/static/src/js/suggestions.js78
-rw-r--r--addons/hr/static/src/xml/suggestions.xml36
2 files changed, 114 insertions, 0 deletions
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>