diff --git a/verdigado_attendance/__manifest__.py b/verdigado_attendance/__manifest__.py index 36360ff..b424b4b 100644 --- a/verdigado_attendance/__manifest__.py +++ b/verdigado_attendance/__manifest__.py @@ -62,6 +62,7 @@ ], "web.assets_backend": [ "verdigado_attendance/static/src/scss/backend.scss", + "verdigado_attendance/static/src/js/board_renderer.js", "verdigado_attendance/static/src/js/hr_attendance.js", "verdigado_attendance/static/src/js/systray.esm.js", "verdigado_attendance/static/src/js/time_off_calendar.js", diff --git a/verdigado_attendance/static/src/js/board_renderer.js b/verdigado_attendance/static/src/js/board_renderer.js new file mode 100644 index 0000000..5cc8b48 --- /dev/null +++ b/verdigado_attendance/static/src/js/board_renderer.js @@ -0,0 +1,24 @@ +odoo.define("verdigado_attendance.BoadRenderer", function (require) { + "use strict"; + var BoardView = require("board.BoardView"); + var core = require("web.core"); + + BoardView.prototype.config.Renderer.include({ + _createController: function (params) { + if (params.viewType === "hr_attendance_my_attendances") { + var client_action = core.action_registry.get( + "hr_attendance_my_attendances" + ); + var attendances = new client_action(this, {}, {}); + attendances.do_action = function () { + params.$node.empty(); + return attendances.appendTo(params.$node).then(function () { + return attendances.willStart(); + }); + }; + return attendances.appendTo(params.$node); + } + return this._super.apply(this, arguments); + }, + }); +}); diff --git a/verdigado_attendance/static/src/js/hr_attendance.js b/verdigado_attendance/static/src/js/hr_attendance.js index f0db8ed..0e35ea8 100644 --- a/verdigado_attendance/static/src/js/hr_attendance.js +++ b/verdigado_attendance/static/src/js/hr_attendance.js @@ -5,8 +5,13 @@ odoo.define("verdigado_attendance.hr_attendance", function (require) { "use strict"; var myAttendances = require("hr_attendance.my_attendances"); + var core = require("web.core"); myAttendances.include({ + events: _.extend(myAttendances.prototype.events, { + "click a.add_to_dashboard": "_add_to_dashboard", + }), + willStart: function () { var self = this; var promise = this._rpc({ @@ -17,6 +22,7 @@ odoo.define("verdigado_attendance.hr_attendance", function (require) { }); return Promise.all([this._super.apply(this, arguments), promise]); }, + _rpc: function (params) { if ( params && @@ -29,5 +35,18 @@ odoo.define("verdigado_attendance.hr_attendance", function (require) { } return this._super.apply(this, arguments); }, + + _add_to_dashboard: function () { + return this._rpc({ + route: "/board/add_to_dashboard", + params: { + action_id: -1, + context_to_save: {}, + domain: [], + view_mode: "hr_attendance_my_attendances", + name: core._t("Check In / Check Out"), + }, + }); + }, }); }); diff --git a/verdigado_attendance/static/src/scss/backend.scss b/verdigado_attendance/static/src/scss/backend.scss index aad3af2..15457fc 100644 --- a/verdigado_attendance/static/src/scss/backend.scss +++ b/verdigado_attendance/static/src/scss/backend.scss @@ -35,3 +35,26 @@ span[data-menu-xmlid="mail.menu_root_discuss"] { background-color: #e7f7eb !important; } } + +/* adapt display of attendance client action within dashboard */ +.oe_dashboard .o_hr_attendance_kiosk_mode_container { + position: relative; + margin-top: 90px; +} + +.oe_dashboard .o_hr_attendance_kiosk_backdrop { + background: none; +} + +/* hide add to dashboard link without mouseover */ +.o_hr_attendance_user_badge .add_to_dashboard { + display: none; +} +.o_hr_attendance_user_badge:hover .add_to_dashboard { + display: block; + color: white; +} + +.oe_dashboard .o_hr_attendance_user_badge:hover .add_to_dashboard { + display: none; +} diff --git a/verdigado_attendance/static/src/xml/hr_attendance.xml b/verdigado_attendance/static/src/xml/hr_attendance.xml index 712d501..1880826 100644 --- a/verdigado_attendance/static/src/xml/hr_attendance.xml +++ b/verdigado_attendance/static/src/xml/hr_attendance.xml @@ -12,5 +12,8 @@ + + Add to dashboard +