From b41730867c2f70d7a09852f24b778f67858b340c Mon Sep 17 00:00:00 2001 From: Pablo Date: Thu, 27 Dec 2018 17:23:15 +0100 Subject: [PATCH] [FIX] Popover destroy behaviour --- hotel_calendar/static/src/css/view.css | 2 +- .../calendar/hotel_calendar_controller.js | 20 ++++++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/hotel_calendar/static/src/css/view.css b/hotel_calendar/static/src/css/view.css index 6bcf10640..4989fcc46 100644 --- a/hotel_calendar/static/src/css/view.css +++ b/hotel_calendar/static/src/css/view.css @@ -173,7 +173,7 @@ input#bookings_search { max-width: 550px; } .popover .container { - max-width: -webkit-fill-available; + max-width: 100%; } .popover .container p { margin-top: 3px; diff --git a/hotel_calendar/static/src/js/views/calendar/hotel_calendar_controller.js b/hotel_calendar/static/src/js/views/calendar/hotel_calendar_controller.js index 1b3f68524..ae61e03c2 100644 --- a/hotel_calendar/static/src/js/views/calendar/hotel_calendar_controller.js +++ b/hotel_calendar/static/src/js/views/calendar/hotel_calendar_controller.js @@ -375,6 +375,11 @@ var PMSCalendarController = AbstractController.extend({ self.savePricelist(ev.detail.calendar_obj, ev.detail.pricelist_id, ev.detail.pricelist); }); $('.hcal-reservation noselect').popover(); + var _destroy_and_clear_popover_mark = function(ev){ + $(".marked-as-having-a-popover").popover('destroy'); + $('.hcal-reservation').removeClass("marked-as-having-a-popover"); + }; + this._multi_calendar.on_calendar('hcalOnClickReservation', function(ev){ if (ev.detail.reservationObj) { var tp = self._multi_calendar._reserv_tooltips[ev.detail.reservationObj.id]; @@ -382,18 +387,23 @@ var PMSCalendarController = AbstractController.extend({ $(".marked-as-having-a-popover").popover('destroy'); $(ev.detail.reservationDiv).addClass('marked-as-having-a-popover'); var $reservationPopover = $(ev.detail.reservationDiv).popover({ - trigger: 'click focus', + trigger: 'manual', container: 'body', animation: false, html: true, placement: 'bottom', - /* title: "Come'n popovers!", */ content: QWeb.render('HotelCalendar.TooltipReservation', qdict) }).popover('show'); + /* destroy popover if mouse click is done out the popover */ + $(document).click(function(e){ + if( $(e.target).closest(".popover-content").length == 0 && $(e.target).hasClass("marked-as-having-a-popover") == false ) { + _destroy_and_clear_popover_mark(); + } + }); /* add actions */ $reservationPopover.data('bs.popover').tip().find(".btn_popover_open_folio").on('click', {folio_id: ev.detail.reservationObj._userData.folio_id}, function(ev){ - $(".marked-as-having-a-popover").popover('destroy'); + _destroy_and_clear_popover_mark(); self.do_action({ type: 'ir.actions.act_window', res_model: 'hotel.folio', @@ -403,7 +413,7 @@ var PMSCalendarController = AbstractController.extend({ }); $reservationPopover.data('bs.popover').tip().find(".btn_popover_open_reservation").on('click', {reservation_id: ev.detail.reservationObj.id}, function(ev){ - $(".marked-as-having-a-popover").popover('destroy'); + _destroy_and_clear_popover_mark(); self.do_action({ type: 'ir.actions.act_window', res_model: 'hotel.reservation', @@ -412,7 +422,7 @@ var PMSCalendarController = AbstractController.extend({ }); }); $reservationPopover.data('bs.popover').tip().find(".btn_popover_close").on('click', function(ev){ - $(".marked-as-having-a-popover").popover('destroy'); + _destroy_and_clear_popover_mark(); }); } });