Issue #3311426: Added check to see if widget should be rendered or not in facet due to dependencies.
5 unresolved threads
Merge request reports
Activity
added 1 commit
159 159 $assert->elementNotExists('css', 'select#edit-emu--2', $form); 160 160 } 161 161 162 /** 163 * Test the facets form (facets with dependencies). - Edited by Andras Szilagyi
186 'enable' => TRUE, 187 'condition' => 'values', 188 'values' => 'item', 189 'negate' => FALSE, 190 ], 191 ], 192 ]; 193 $depending_facet->addProcessor($processor); 194 $depending_facet->setWidget('facets_form_dropdown'); 195 $depending_facet->save(); 196 197 // Place the Facets Form block for a view page source. 198 $block = $this->drupalPlaceBlock('facets_form:search_api:views_page__search_api_test_view__page_1'); 199 $this->drupalGet('admin/structure/block/manage/' . $block->id()); 200 $config_form = $assert->elementExists('css', '.block-form'); 201 $assert->fieldValueEquals('Submit button', 'Search'); 198 $block = $this->drupalPlaceBlock('facets_form:search_api:views_page__search_api_test_view__page_1'); 199 $this->drupalGet('admin/structure/block/manage/' . $block->id()); 200 $config_form = $assert->elementExists('css', '.block-form'); 201 $assert->fieldValueEquals('Submit button', 'Search'); 202 $assert->fieldValueEquals('Reset button', 'Clear filters'); 203 $config_form->fillField('Submit button', 'Apply'); 204 $config_form->fillField('Reset button', 'Reset'); 205 $config_form->checkField('Emu'); 206 $config_form->checkField('Llama'); 207 $config_form->pressButton('Save block'); 208 209 $this->drupalGet('search-api-test-fulltext'); 210 $assert->elementsCount('css', '.views-row', 5); 211 $form = $assert->elementExists('css', 'form#facets-form'); 212 213 // The form contains only the widget from the module. 217 // Check that dependent facet exists when value is set in facet. 218 $page->selectFieldOption('emu[]', 'item'); 219 $assert->buttonExists('Apply', $form)->press(); 220 $this->assertCurrentUrl('search-api-test-fulltext', ['f' => ['emu:item']]); 221 $assert->elementsCount('css', '.views-row', 3); 222 $assert->elementExists('css', 'select#edit-emu--2', $form); 223 $assert->elementExists('css', 'select#edit-llama--2', $form); 224 225 // Check that dependent facet doesn't exist when value is NOT set in facet. 226 $page->selectFieldOption('emu[]', 'article'); 227 $assert->buttonExists('Apply', $form)->press(); 228 $this->assertCurrentUrl('search-api-test-fulltext', ['f' => ['emu:article']]); 229 $assert->elementsCount('css', '.views-row', 2); 230 $assert->elementExists('css', 'select#edit-emu--2', $form); 231 $assert->elementNotExists('css', 'select#edit-llama--2', $form); 232 } - src/FacetManager/DefaultFacetFormManager.php 0 → 100644
9 use Drupal\facets\Exception\InvalidProcessorException; 10 use Drupal\facets\FacetInterface; 11 use Drupal\facets\FacetManager\DefaultFacetManager; 12 use Drupal\facets\FacetSource\FacetSourcePluginManager; 13 use Drupal\facets\Plugin\facets\facet_source\SearchApiDisplay; 14 use Drupal\facets\Processor\BuildProcessorInterface; 15 use Drupal\facets\Processor\PostQueryProcessorInterface; 16 use Drupal\facets\Processor\PreQueryProcessorInterface; 17 use Drupal\facets\Processor\ProcessorInterface; 18 use Drupal\facets\Processor\ProcessorPluginManager; 19 use Drupal\facets\QueryType\QueryTypePluginManager; 20 21 /** 22 * The facet manager. 23 */ 24 class DefaultFacetFormManager extends DefaultFacetManager { for me this is not the way to go, the dropdown widget just needs to honour the "Empty facet behavior" then it will be ok, as for the date range, that is special as it should show also when there are no results, so we need to implement something similar to this facetShouldBeEnabled method inside the widget (we need to do this as the processor only empties the results which is incompatible with the date range widget concept).
Please register or sign in to reply