summaryrefslogtreecommitdiff
path: root/addons/hr/static/src
diff options
context:
space:
mode:
authorGéry Debongnie <ged@odoo.com>2015-03-10 08:45:02 +0100
committerGéry Debongnie <ged@odoo.com>2015-03-18 09:01:52 +0100
commit2ebe3076d2abbe2bef3ed7612af212f23382c0d5 (patch)
tree0575cb0b120cd9925222b1ef76d71d727b9b4114 /addons/hr/static/src
parent858e46e977de772c36d3073d0d61b2a3c5958117 (diff)
[REF] hr: update to the new module system
Diffstat (limited to 'addons/hr/static/src')
-rw-r--r--addons/hr/static/src/js/hr.js32
-rw-r--r--addons/hr/static/src/js/suggestions.js137
2 files changed, 89 insertions, 80 deletions
diff --git a/addons/hr/static/src/js/hr.js b/addons/hr/static/src/js/hr.js
index 90e37bd35b8..80b978e7fc9 100644
--- a/addons/hr/static/src/js/hr.js
+++ b/addons/hr/static/src/js/hr.js
@@ -1,14 +1,18 @@
-openerp.hr = function(openerp) {
- "use strict";
-
- openerp.web_kanban.KanbanRecord.include({
- on_card_clicked: function() {
- if (this.view.dataset.model === 'hr.department') {
- this.$('.oe_kanban_department .oe_kanban_content a').first().click();
- } else {
- this._super.apply(this, arguments);
- }
- },
- });
-
-};
+odoo.define('hr.hr', ['web_kanban.common'], function(require) {
+"use strict";
+
+var common = require('web_kanban.common');
+
+common.KanbanRecord.include({
+ on_card_clicked: function() {
+ if (this.view.dataset.model === 'hr.department') {
+ this.$('.oe_kanban_department .oe_kanban_content a').first().click();
+ } else {
+ this._super.apply(this, arguments);
+ }
+ },
+});
+
+
+});
+
diff --git a/addons/hr/static/src/js/suggestions.js b/addons/hr/static/src/js/suggestions.js
index 3bc37e71344..94df0a4ad7b 100644
--- a/addons/hr/static/src/js/suggestions.js
+++ b/addons/hr/static/src/js/suggestions.js
@@ -1,78 +1,83 @@
-openerp.hr = function(session) {
- var _t = session.web._t;
- var QWeb = session.web.qweb;
+odoo.define('hr.suggestions', ['mail.mail', 'web.core', 'web.data', 'web.Widget'], function (require) {
+"use strict";
- var suggestions = session.suggestions;
- var removed_suggested_employee = session.suggestions.removed_suggested_employee = [];
+var mail = require('mail.mail');
+var core = require('web.core');
+var data = require('web.data');
+var Widget = require('web.Widget');
- 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',
- },
+var QWeb = core.qweb;
- 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 = [];
- },
+var removed_suggested_employee = [];
- start: function () {
- this._super.apply(this, arguments);
- return this.fetch_suggested_employee();
- },
+var Employees = 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',
+ },
- 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'));
- },
+ init: function () {
+ this._super(this, arguments);
+ this.hr_employee = new data.DataSetSearch(this, 'hr.employee');
+ this.res_users = new data.DataSetSearch(this, 'res.users');
+ this.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}));
- },
+ start: function () {
+ this._super.apply(this, arguments);
+ return this.fetch_suggested_employee();
+ },
- 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();
+ 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});
});
- },
-
- remove_employee_suggestion: function (event) {
- removed_suggested_employee.push($(event.currentTarget).attr('id'));
- return this.fetch_suggested_employee();
- },
+ self.employees = res;
+ });
+ return $.when(employee).done(this.proxy('display_suggested_employees'));
+ },
- 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();
- });
+ 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'));
- },
- });
+mail.WallSidebar.include({
+ start: function () {
+ this._super.apply(this, arguments);
+ var sug_employees = new Employees(this);
+ return sug_employees.appendTo(this.$('.oe_suggestions_employees'));
+ },
+});
-};
+});