From 308fc423b26de1415ccf29de0aec8d4b088286e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Tue, 5 Dec 2023 09:54:49 +0100 Subject: [PATCH] DataViews: implement `NOT IN` operator for author filter in templates (#56777) --- .../src/components/page-templates/dataviews-templates.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/edit-site/src/components/page-templates/dataviews-templates.js b/packages/edit-site/src/components/page-templates/dataviews-templates.js index 183d85ce40797..0556efa5e6379 100644 --- a/packages/edit-site/src/components/page-templates/dataviews-templates.js +++ b/packages/edit-site/src/components/page-templates/dataviews-templates.js @@ -35,6 +35,7 @@ import { TEMPLATE_POST_TYPE, ENUMERATION_TYPE, OPERATOR_IN, + OPERATOR_NOT_IN, LAYOUT_GRID, LAYOUT_TABLE, } from '../../utils/constants'; @@ -266,6 +267,14 @@ export default function DataviewsTemplates() { filteredTemplates = filteredTemplates.filter( ( item ) => { return item.author_text === filter.value; } ); + } else if ( + filter.field === 'author' && + filter.operator === OPERATOR_NOT_IN && + !! filter.value + ) { + filteredTemplates = filteredTemplates.filter( ( item ) => { + return item.author_text !== filter.value; + } ); } } ); }