Skip to content

Commit

Permalink
Merge pull request #97 from hbrunn/15.0-82-attendances-in-dashboard
Browse files Browse the repository at this point in the history
[ADD] allow adding the attendance widget to dashboards
  • Loading branch information
albig authored Jan 24, 2024
2 parents e1bafd1 + 710c4d2 commit 8af863a
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 0 deletions.
1 change: 1 addition & 0 deletions verdigado_attendance/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
24 changes: 24 additions & 0 deletions verdigado_attendance/static/src/js/board_renderer.js
Original file line number Diff line number Diff line change
@@ -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);
},
});
});
19 changes: 19 additions & 0 deletions verdigado_attendance/static/src/js/hr_attendance.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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 &&
Expand All @@ -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"),
},
});
},
});
});
23 changes: 23 additions & 0 deletions verdigado_attendance/static/src/scss/backend.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
3 changes: 3 additions & 0 deletions verdigado_attendance/static/src/xml/hr_attendance.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@
</label>
</div>
</xpath>
<xpath expr="//div[hasclass('o_hr_attendance_user_badge')]" position="inside">
<a class="add_to_dashboard" href="#">Add to dashboard</a>
</xpath>
</t>
</templates>

0 comments on commit 8af863a

Please sign in to comment.