Skip to content

Commit

Permalink
Better attribute configuration screen (Smile-SA#325)
Browse files Browse the repository at this point in the history
* Conditioning the visibility of the is_displayed_in_autocomplete to the field being filterable in search.
  • Loading branch information
romainruaud authored and afoucret committed Feb 8, 2017
1 parent 5522599 commit d7c9d5e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ public function aroundSetForm(Front $subject, \Closure $proceed, Form $form)
$form->getElement('is_used_in_autocomplete')->setValue(1);
}

$this->appendFieldsDependency($form, $subject);

return $block;
}

Expand Down Expand Up @@ -353,4 +355,26 @@ private function appendSliderDisplayRelatedFields($form, $subject)

return $this;
}

/**
* Manage dependency between fields.
*
* @param Front $subject The StoreFront tab
*
* @return FrontPlugin
*/
private function appendFieldsDependency($subject)
{
/** @var \Magento\Backend\Block\Widget\Form\Element\Dependence $dependencyBlock */
$dependencyBlock = $subject->getChildBlock('form_after');

if ($dependencyBlock) {
$dependencyBlock
->addFieldMap('is_displayed_in_autocomplete', 'is_displayed_in_autocomplete')
->addFieldMap('is_filterable_in_search', 'is_filterable_in_search')
->addFieldDependence('is_displayed_in_autocomplete', 'is_filterable_in_search', '1');
}

return $this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,13 @@
{
checkOptionsPanelVisibility();
switchDefaultValueField();
if($('frontend_input') && ($('frontend_input').value=='select' || $('frontend_input').value=='multiselect' || $('frontend_input').value=='price' || $('frontend_input').value=='text')) {
if($('frontend_input') &&
($('frontend_input').value == 'select'
|| $('frontend_input').value == 'multiselect'
|| $('frontend_input').value == 'price'
|| $('frontend_input').value == 'text')
|| $('frontend_input').value == 'boolean')
) {
if($('is_filterable') && !$('is_filterable').getAttribute('readonly')){
$('is_filterable').disabled = false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
checkOptionsPanelVisibility();
switchDefaultValueField();
if (frontendInput
&& (jQuery.inArray(frontendInput.value, selectFields) >= 0 || (frontendInput.value == "text"))
&& (jQuery.inArray(frontendInput.value, selectFields) >= 0 || (frontendInput.value == "text") || frontendInput.value == "boolean")
) {
if (isFilterable && !isFilterable.getAttribute('readonly')) {
isFilterable.disabled = false;
Expand Down

0 comments on commit d7c9d5e

Please sign in to comment.