Verified Commit a551f2b2 authored by Dave Long's avatar Dave Long
Browse files

Issue #3098560 by vasike, smustgrave, tetranz, joevagyok, pankaj.singh,...

Issue #3098560 by vasike, smustgrave, tetranz, joevagyok, pankaj.singh, vikashsoni, quietone, lendude: Add  'Is empty (NULL)' and 'Is not empty (NOT NULL)' to field Filter Operators Options
parent 41663286
Loading
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -596,8 +596,12 @@ protected function mapSingleFieldViewsData($table, $field_name, $field_type, $co
        }
    }

    // Do post-processing for a few field types.
    if (!$field_definition->isRequired()) {
      // Provides "Is empty (NULL)" and "Is not empty (NOT NULL)" operators.
      $views_field['filter']['allow empty'] = TRUE;
    }

    // Do post-processing for a few field types.
    $process_method = 'processViewsDataFor' . Container::camelize($field_type);
    if (method_exists($this, $process_method)) {
      $this->{$process_method}($table, $field_definition, $views_field, $column_name);
+8 −0
Original line number Diff line number Diff line
@@ -428,6 +428,14 @@ public function testBaseTableFields(): void {
        ],
      ],
    ], $data['entity_test__string']['table']['join']['entity_test']);

    // Check the "allow empty" option for non-required fields.
    $this->assertArrayHasKey('allow empty', $data['entity_test']['name']['filter']);
    $this->assertTrue($data['entity_test']['name']['filter']['allow empty']);
    // Reconfigure the field to be required.
    $this->commonBaseFields['name']->setRequired(TRUE);
    $data = $this->entityTypeManager->getHandler('entity_test', 'views_data')->getViewsData();
    $this->assertArrayNotHasKey('allow empty', $data['entity_test']['name']['filter']);
  }

  /**