Skip to content

Commit

Permalink
Merge pull request #3261 from rbayet/feat-optimizer-preview-prevent-s…
Browse files Browse the repository at this point in the history
…electing-disabled-category

[Optimizer] Prevent selecting a disabled category for previewing
  • Loading branch information
rbayet authored Apr 18, 2024
2 parents 1e6044c + 4c956ba commit 3afba70
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@
<item name="label" xsi:type="string" translate="true">Category Preview</item>
<item name="componentType" xsi:type="string">field</item>
<item name="formElement" xsi:type="string">select</item>
<item name="component" xsi:type="string">Magento_Catalog/js/components/new-category</item>
<item name="component" xsi:type="string">Smile_ElasticsuiteCore/js/components/pick-active-category</item>
<item name="elementTmpl" xsi:type="string">ui/grid/filters/elements/ui-select</item>
<item name="dataScope" xsi:type="string">category_preview</item>
<item name="filterOptions" xsi:type="boolean">true</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ div.optimizer-preview-fieldset {
.admin__field-label {
width: auto;
}
._unclickable {
.admin__action-multiselect-label {
cursor: default;
font-weight: normal;
color: #aaa;
}
}
}

.query-text {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Smile ElasticSuite to newer
* versions in the future.
*
* @category Smile
* @package Smile\ElasticsuiteCore
* @author Richard Bayet <richard.bayet@smile.fr>
* @copyright 2024 Smile
* @license Open Software License ("OSL") v. 3.0
*/

define([
'Magento_Catalog/js/components/new-category'
], function (Category) {
'use strict';

return Category.extend({

/**
* Check label decoration
*
* @param {Object} data - selected option data
* @returns {boolean}
*/
isLabelDecoration: function (data) {
return (
(data.hasOwnProperty(this.separator) && this.labelsDecoration) ||
(data.hasOwnProperty('is_active') &&
((data.is_active === false) || (parseInt(data.is_active, 10) === 0)))
);
},


/**
* Toggle activity list element
*
* @param {Object} data - selected option data
* @returns {Object} Chainable
*/
toggleOptionSelected: function (data) {
if (data.hasOwnProperty('is_active') &&
((data.is_active === false) || (parseInt(data.is_active, 10) === 0))
) {
return this;
}

return this._super(data);
}
});
});

0 comments on commit 3afba70

Please sign in to comment.