Add paragraphs search functionality

Created on 4 March 2024, 10 months ago
Updated 26 August 2024, 4 months ago

I have many paragraphs on my Drupal site and I'm facing problems searching through them. Could you please add search functionality to this module?

Feature request
Status

Needs review

Version

1.17

Component

Code

Created by

🇮🇳India vishalydv

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @vishalydv
  • Status changed to Needs review 8 months ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.4 + Environment: PHP 8.1 & MariaDB 10.3.22
    last update 8 months ago
    182 pass
  • 🇪🇸Spain cmarrufo

    Hi @vishal-yaduvanshi

    I have had the same problem and I think it would be a good idea to have a paragraphs type finder so I have made a patch that I think you could use.

  • 🇮🇳India vishalydv

    hey @cmarrufo

    thank you for your response, this functionality is very useful for me and the community of Drupal.

  • Status changed to RTBC 6 months ago
  • Status changed to Needs work 4 months ago
  • 🇨🇭Switzerland berdir Switzerland

    Looks intersting, but all non-trivial contributions must be merge requests now. A test would be great as well, but I can live without for non-critical functionality.

  • 🇨🇭Switzerland berdir Switzerland
    1. +++ b/src/Controller/ParagraphsTypeListBuilder.php
      @@ -63,9 +73,123 @@ class ParagraphsTypeListBuilder extends ConfigEntityListBuilder {
      +
      +    $search_param = \Drupal::request()->get('search');
      +    $query = $this->getStorage()->getQuery();
      +
      +    if ($search_param) {
      +      $orCondition = $query->orConditionGroup()
      +        ->condition('label', $search_param, 'CONTAINS')
      +        ->condition('id', $search_param, 'CONTAINS');
      +      $query->condition($orCondition);
      +      $entity_ids = $query->execute();
      +      $filtered_array = [];
      +
      

      if we stick with a server-side implementation then this should override the getEntityListQuery() method, so we don't need to query and list twice.

    2. +++ b/src/Controller/ParagraphsTypeListBuilder.php
      @@ -63,9 +73,123 @@ class ParagraphsTypeListBuilder extends ConfigEntityListBuilder {
      +  public function buildForm(array $form, FormStateInterface $form_state) {
      +    $form['search'] = [
      +      '#type' => 'textfield',
      +      '#title' => $this->t('Search'),
      +      '#default_value' => \Drupal::request()->query->get('search'),
      +      '#description' => $this->t('Search paragraphs types by Label or ID'),
      

      would it make sense to default the focus on this field, then you can visit and type immediately.

      I'm also wondering if this should be a client-side functionality, similar to how \Drupal\views_ui\ViewListBuilder::render does it. That would require no reloads. would require to disable the pager, like views does.

  • Assigned to cmarrufo
  • Pipeline finished with Failed
    4 months ago
    Total: 298s
    #265093
  • Status changed to Needs review 4 months ago
  • Pipeline finished with Failed
    4 months ago
    Total: 324s
    #265931
Production build 0.71.5 2024