Skip to content

Commit

Permalink
VACMS-12933: Exclude forms from appearing in VACO and VBA results (#2…
Browse files Browse the repository at this point in the history
…0391)

* VACMS-12933: Adds patch for taxonomy entity index to allow for fields to be excluded from views result.

* VACMS-12933: Exclude the field_va_form_administration field from taxonomy term View argument query.
  • Loading branch information
dsasser authored Feb 5, 2025
1 parent 32e1bf8 commit a4f60e5
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 1 deletion.
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,9 @@
"3195203 - Copying caption to value breaks some data exports 3195203": "patches/3195203-tablefield-caption-copied-to-value.patch",
"3341971 - Drag & drop addition adds meaningless numbers to table data, could break integrating code": "patches/3341971-tablefield-disable-drag-drop-controls.patch"
},
"drupal/taxonomy_entity_index" : {
"3504104 - Support for excluding field names in views argument": "patches/3504104-support-for-excluding-field-names-4.patch"
},
"drupal/textfield_counter": {
"3380997 - Textarea with summary and counter doesn't respect count only setting": "patches/3380997-fix-textfield-counter-respect-count-only-mode.patch"
},
Expand Down
2 changes: 1 addition & 1 deletion composer.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "cc5409aacd5faa175b81905e676d1265",
"content-hash": "04240978e87cabbd346cf7de223d09a8",
"packages": [
{
"name": "asm89/stack-cors",
Expand Down
1 change: 1 addition & 0 deletions config/sync/views.view.taxonomy_term.yml
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,7 @@ display:
break_phrase: false
depth: 4
use_taxonomy_term_path: false
field_names: field_va_form_administration
filters:
title:
id: title
Expand Down
88 changes: 88 additions & 0 deletions patches/3504104-support-for-excluding-field-names-4.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
From c6e380a47cf178ecce26e3072608a57b5e8d7ede Mon Sep 17 00:00:00 2001
From: Daniel Sasser <[email protected]>
Date: Mon, 3 Feb 2025 11:16:44 -0800
Subject: [PATCH 1/2] Issue 3504104: Adds support to exclude field names from
Views argument query.

---
.../argument/TaxonomyEntityIndexDepth.php | 32 +++++++++++++++++++
1 file changed, 32 insertions(+)

diff --git a/src/Plugin/views/argument/TaxonomyEntityIndexDepth.php b/src/Plugin/views/argument/TaxonomyEntityIndexDepth.php
index 4741581..f581401 100644
--- a/src/Plugin/views/argument/TaxonomyEntityIndexDepth.php
+++ b/src/Plugin/views/argument/TaxonomyEntityIndexDepth.php
@@ -57,6 +57,28 @@ abstract class TaxonomyEntityIndexDepth extends IndexTidDepth {
$this->baseTableInfo = $this->viewsData->get($this->table);
}

+ /**
+ * {@inhritdoc}
+ */
+ protected function defineOptions() {
+ $options = parent::defineOptions();
+ $options['field_names'] = ['default' => ''];
+ return $options;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
+ $form['field_names'] = [
+ '#type' => 'textfield',
+ '#title' => $this->t('Excluded Field Names'),
+ '#default_value' => $this->options['field_names'],
+ '#description' => $this->t("Enter field names, separated by commas, that should be excluded from results. If content references taxonomy by the provided field name(s) they will be filtered out of the results. This is useful to ignore certain fields, particularly if content references the same Vocabulary using more than one field."),
+ ];
+ parent::buildOptionsForm($form, $form_state);
+ }
+
/**
* {@inheritdoc}
*/
@@ -106,6 +128,16 @@ abstract class TaxonomyEntityIndexDepth extends IndexTidDepth {

$subquery->condition($where);

+ // Add conditional for field_names if configured.
+ if (!empty($this->options['field_names'])) {
+ $field_names = array_filter(array_map('trim', explode(',', $this->options['field_names'])));
+ $andFieldNames = new Condition('AND');
+ foreach ($field_names as $field_name) {
+ $andFieldNames->condition('tn.field_name', $field_name, '!=');
+ }
+ $subquery->condition($andFieldNames);
+ }
+
$this->query->addWhere(0, "$this->tableAlias.$real_field", $subquery, 'IN');
}

--
GitLab


From 851d8f47dce1c2bf45ca2ca92a17456c1e73cf94 Mon Sep 17 00:00:00 2001
From: Daniel Sasser <[email protected]>
Date: Mon, 3 Feb 2025 11:29:36 -0800
Subject: [PATCH 2/2] Correct missing use statement for FormStateInterface.

---
src/Plugin/views/argument/TaxonomyEntityIndexDepth.php | 1 +
1 file changed, 1 insertion(+)

diff --git a/src/Plugin/views/argument/TaxonomyEntityIndexDepth.php b/src/Plugin/views/argument/TaxonomyEntityIndexDepth.php
index f581401..00f96fb 100644
--- a/src/Plugin/views/argument/TaxonomyEntityIndexDepth.php
+++ b/src/Plugin/views/argument/TaxonomyEntityIndexDepth.php
@@ -9,6 +9,7 @@ use Drupal\Core\Database\Query\Condition;
use Drupal\Core\Entity\EntityRepositoryInterface;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\taxonomy\Plugin\views\argument\IndexTidDepth;
+use Drupal\Core\Form\FormStateInterface;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\ViewExecutable;
use Symfony\Component\DependencyInjection\ContainerInterface;
--
GitLab

0 comments on commit a4f60e5

Please sign in to comment.