From b647b03191dc9c5c7721463ad429f1c35dd71cd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20FOUCRET?= Date: Fri, 23 Feb 2018 09:22:10 +0100 Subject: [PATCH] FIx #539 : price slider bounds display. --- .../Model/Layer/Filter/DecimalFilterTrait.php | 2 +- .../frontend/web/js/range-slider-widget.js | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/module-elasticsuite-catalog/Model/Layer/Filter/DecimalFilterTrait.php b/src/module-elasticsuite-catalog/Model/Layer/Filter/DecimalFilterTrait.php index 4022ae4df..a42272292 100644 --- a/src/module-elasticsuite-catalog/Model/Layer/Filter/DecimalFilterTrait.php +++ b/src/module-elasticsuite-catalog/Model/Layer/Filter/DecimalFilterTrait.php @@ -52,7 +52,7 @@ public function apply(\Magento\Framework\App\RequestInterface $request) $this->getLayer()->getProductCollection()->addFieldToFilter( $this->getAttributeModel()->getAttributeCode(), - ['from' => $fromValue, 'to' => $toValue] + ['gte' => $fromValue, 'lt' => $toValue] ); $this->getLayer()->getState()->addFilter( diff --git a/src/module-elasticsuite-catalog/view/frontend/web/js/range-slider-widget.js b/src/module-elasticsuite-catalog/view/frontend/web/js/range-slider-widget.js index 7c1ddb2d0..d2adc9969 100644 --- a/src/module-elasticsuite-catalog/view/frontend/web/js/range-slider-widget.js +++ b/src/module-elasticsuite-catalog/view/frontend/web/js/range-slider-widget.js @@ -23,16 +23,17 @@ define(["jquery", 'Magento_Catalog/js/price-utils', 'mage/template', "jquery/ui" $.widget('smileEs.rangeSlider', { options: { - fromLabel : '[data-role=from-label]', - toLabel : '[data-role=to-label]', - sliderBar : '[data-role=slider-bar]', - message : '[data-role=message-box]', - applyButton : '[data-role=apply-range]', - rate : 1.0000, + fromLabel : '[data-role=from-label]', + toLabel : '[data-role=to-label]', + sliderBar : '[data-role=slider-bar]', + message : '[data-role=message-box]', + applyButton : '[data-role=apply-range]', + rate : 1.0000, + maxLabelOffset : 0.01, messageTemplates : { "displayCount": '<%- count %> items', "displayEmpty": 'No items in the current range.' - } + }, }, _create: function () { @@ -78,7 +79,7 @@ define(["jquery", 'Magento_Catalog/js/price-utils', 'mage/template', "jquery/ui" } if (this.element.find('[data-role=to-label]')) { - this.element.find('[data-role=to-label]').html(this._formatLabel(this.to)); + this.element.find('[data-role=to-label]').html(this._formatLabel(this.to - this.options.maxLabelOffset)); } if (this.element.find('[data-role=message-box]')) { @@ -109,7 +110,7 @@ define(["jquery", 'Magento_Catalog/js/price-utils', 'mage/template', "jquery/ui" _getItemCount : function() { var from = this.from, to = this.to, intervals = this.intervals; - var count = intervals.map(function(item) {return item.value >= from && item.value <= to ? item.count : 0;}) + var count = intervals.map(function(item) {return item.value >= from && item.value < to ? item.count : 0;}) .reduce(function(a,b) {return a + b;}); return count; },