Rework hotel names tooltip in cart rules list to use core tooltip pattern

Co-authored-by: Name <sumit201@webkul.in>
This commit is contained in:
aradhana kumari
2026-08-17 18:46:30 +05:30
parent 1ffffdf25a
commit 73b9ce59bf
4 changed files with 23 additions and 117 deletions

View File

@@ -1,31 +0,0 @@
{**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License version 3.0
* that is bundled with this package in the file LICENSE.md
* It is also available through the world-wide-web at this URL:
* https://opensource.org/license/osl-3-0-php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to support@qloapps.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to a newer
* versions in the future. If you wish to customize this module for your needs
* please refer to https://store.webkul.com/customisation-guidelines for more information.
*
* @author Webkul IN
* @copyright Since 2010 Webkul
* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0
*}
{if $hotel_names_first}
<span>{$hotel_names_first|escape:'html':'UTF-8'}</span>
{if $hotel_names_remaining}
<span class="badge qlo-hotel-names-badge"
data-hotel-names="{$hotel_names_remaining_json}">+{$hotel_names_remaining|@count}</span>
{/if}
{else}
--
{/if}

View File

@@ -20,13 +20,22 @@
* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0
*}
<div id="qlo-hotel-names-tooltip" style="display:none">
<div class="bootstrap tooltip_cont">
<div class="tip_header">
<div>{l s='Selected Hotels'}</div>
</div>
<div class="tip-body">
<div class="qlo-hotel-names-list"></div>
</div>
</div>
</div>
{if $hotel_names_first}
<span>{$hotel_names_first|escape:'html':'UTF-8'}</span>
{if $hotel_names_remaining}
{capture name='hotel_names_tooltip'}
<div class="tooltip_cont">
<div class="tip_header"><div class="tip_date">{l s='Selected Hotels'}</div></div>
<div>
{foreach from=$hotel_names_remaining item='hotel'}
<div class="tip_element_value">{$hotel|escape:'html':'UTF-8'}</div>
{/foreach}
</div>
</div>
{/capture}
<span class="badge tooltip-trigger">+{$hotel_names_remaining|@count}</span>
<div class="tooltip-content" style="display: none;">{$smarty.capture.hotel_names_tooltip}</div>
{/if}
{else}
--
{/if}

View File

@@ -89,14 +89,13 @@ class AdminCartRulesControllerCore extends AdminController
public function formatHotelNames($hotelNames, $row)
{
$hotels = !empty($hotelNames) ? explode('|||', $hotelNames) : array();
$remaining = count($hotels) > 1 ? array_slice($hotels, 1) : array();
$this->context->smarty->assign(array(
'hotel_names_first' => !empty($hotels) ? $hotels[0] : null,
'hotel_names_remaining' => $remaining,
'hotel_names_remaining_json' => htmlspecialchars(json_encode($remaining)),
'hotel_names_first' => !empty($hotels) ? $hotels[0] : null,
'hotel_names_remaining' => count($hotels) > 1 ? array_slice($hotels, 1) : array(),
));
return $this->context->smarty->fetch(
'controllers/cart_rules/helpers/list/_hotel_names_column.tpl'
'controllers/cart_rules/helpers/list/_hotel_names_tooltip.tpl'
);
}
@@ -280,19 +279,9 @@ class AdminCartRulesControllerCore extends AdminController
);
$this->addJqueryUI('ui.tooltip', 'base', true);
$this->addJS(_PS_JS_DIR_.'admin/cart-rules.js');
$this->addJS(_PS_JS_DIR_.'admin/cart_rules_hotel_tooltip.js');
$this->addJqueryPlugin(array('typewatch', 'fancybox', 'autocomplete'));
}
public function renderList()
{
$this->content .= $this->context->smarty->fetch(
'controllers/cart_rules/helpers/list/_hotel_names_tooltip.tpl'
);
return parent::renderList();
}
public function initPageHeaderToolbar()
{
if (empty($this->display)) {

View File

@@ -1,61 +0,0 @@
/*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License version 3.0
* that is bundled with this package in the file LICENSE.md
* It is also available through the world-wide-web at this URL:
* https://opensource.org/license/osl-3-0-php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to support@qloapps.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to a newer
* versions in the future. If you wish to customize this module for your needs
* please refer to https://store.webkul.com/customisation-guidelines for more information.
*
* @author Webkul IN
* @copyright Since 2010 Webkul
* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0
*/
$(document).ready(function () {
if (typeof window.initHotelNamesTooltips === 'undefined') {
window.initHotelNamesTooltips = function () {
if (typeof $.fn.tooltip === 'undefined' || typeof $.ui === 'undefined' || typeof $.ui.tooltip === 'undefined') {
return;
}
$('.qlo-hotel-names-badge').each(function () {
if ($(this).data('ui-tooltip')) {
return;
}
$(this).tooltip({
items: '.qlo-hotel-names-badge',
content: function () {
var hotels = $(this).data('hotel-names');
if (!hotels || !hotels.length) {
return '';
}
var rows = $.map(hotels, function (name) {
return '<div class="tip_element_value">' + $('<div>').text(name).html() + '</div>';
}).join('');
$('#qlo-hotel-names-tooltip .qlo-hotel-names-list').html(rows);
return $('#qlo-hotel-names-tooltip').html();
},
close: function (event, ui) {
ui.tooltip.hover(function () {
$(this).stop(true).fadeTo(300, 1);
},
function () {
$(this).fadeOut('300', function () {
$(this).remove();
});
});
}
});
});
};
}
window.initHotelNamesTooltips();
});