-
Notifications
You must be signed in to change notification settings - Fork 340
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3261 from rbayet/feat-optimizer-preview-prevent-s…
…electing-disabled-category [Optimizer] Prevent selecting a disabled category for previewing
- Loading branch information
Showing
3 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/module-elasticsuite-core/view/adminhtml/web/js/components/pick-active-category.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
}); | ||
}); |