Skip to content
Permalink
Browse files

[REF] web: calendar: allow to override popover

This commit move some code to be able to override
Bootstrap popover in web_enterprise for mobile.

Task ID: 2052506

closes #35727

Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com>
  • Loading branch information...
rfr-odoo committed Aug 13, 2019
1 parent a01b834 commit 6e04e59ec5ac4320755cade4b1563090a86dea04
Showing with 37 additions and 15 deletions.
  1. +37 −15 addons/web/static/src/js/views/calendar/calendar_renderer.js
@@ -512,6 +512,18 @@ return AbstractRenderer.extend({
this.$sidebar_container = this.$(".o_calendar_sidebar_container");
this._initCalendarMini();
},
/**
* Finalise the popover
*
* @param {jQueryElement} $popoverElement
* @param {web.CalendarPopover} calendarPopover
* @private
*/
_onPopoverShown: function ($popoverElement, calendarPopover) {
var $popover = $($popoverElement.data('bs.popover').tip);
$popover.find('.o_cw_popover_close').on('click', this._unselectEvent.bind(this));
$popover.find('.o_cw_body').replaceWith(calendarPopover.$el);
},
/**
* Render the calendar view, this is the main entry point.
*
@@ -699,6 +711,27 @@ return AbstractRenderer.extend({

return context;
},
/**
* Prepare the parameters for the popover.
* This allow the parameters to be extensible.
*
* @private
* @param {Object} eventData
*/
_getPopoverParams: function (eventData) {
return {
animation: false,
delay: {
show: 50,
hide: 100
},
trigger: 'manual',
html: true,
title: eventData.record.display_name,
template: qweb.render('CalendarView.event.popover.placeholder', {color: this.getColor(eventData.color_index)}),
container: eventData.allDay ? '.fc-view' : '.fc-scroller',
}
},
/**
* Render event popover
*
@@ -712,21 +745,10 @@ return AbstractRenderer.extend({
// Initialize popover widget
var calendarPopover = new self.config.CalendarPopover(self, self._getPopoverContext(eventData));
calendarPopover.appendTo($('<div>')).then(() => {
$eventElement.popover({
animation: false,
delay: {
show: 50,
hide: 100
},
trigger: 'manual',
html: true,
title: eventData.record.display_name,
template: qweb.render('CalendarView.event.popover.placeholder', {color: this.getColor(eventData.color_index)}),
container: eventData.allDay ? '.fc-view' : '.fc-scroller',
}).on('shown.bs.popover', function () {
var $popover = $($(this).data('bs.popover').tip);
$popover.find('.o_cw_popover_close').on('click', self._unselectEvent.bind(self));
$popover.find('.o_cw_body').replaceWith(calendarPopover.$el);
$eventElement.popover(
self._getPopoverParams(eventData)
).on('shown.bs.popover', function () {
self._onPopoverShown($(this), calendarPopover);
}).popover('show');
});
},

0 comments on commit 6e04e59

Please sign in to comment.
You can’t perform that action at this time.