From c6ca2efaa322469c15e8fe86de9c596a0cf29d98 Mon Sep 17 00:00:00 2001
From: Rosano Coutinho <pub@xeari.com>
Date: Sun, 26 Nov 2023 16:18:24 -0300
Subject: [PATCH] Search custom fields

---
 os-app/sub-browse/ui-logic-tests.js | 20 ++++++++++++++++++++
 os-app/sub-browse/ui-logic.js       |  2 +-
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/os-app/sub-browse/ui-logic-tests.js b/os-app/sub-browse/ui-logic-tests.js
index 9a967a2..d81d11a 100644
--- a/os-app/sub-browse/ui-logic-tests.js
+++ b/os-app/sub-browse/ui-logic-tests.js
@@ -53,6 +53,26 @@ describe('EMLBrowseIsMatch', function test_EMLBrowseIsMatch() {
 		}, uRandomElement('alf', 'alfa', 'ALF')), true);
 	});
 
+	context('custom field', function () {
+
+		it('returns false if no match', function() {
+			deepEqual(mod.EMLBrowseIsMatch({
+				EMLMemoCustomData: {
+					[Math.random().toString()]: Math.random().toString(),
+				},
+			}, Math.random().toString()), false);
+		});
+
+		it('matches OLSKStringMatch', function() {
+			deepEqual(mod.EMLBrowseIsMatch({
+				EMLMemoCustomData: {
+					[Math.random().toString()]: uRandomElement('alfa', 'álfa'),
+				},
+			}, uRandomElement('alf', 'alfa', 'ALF')), true);
+		});
+	
+	});
+
 });
 
 describe('EMLBrowseExactSortFunction', function test_EMLBrowseExactSortFunction() {
diff --git a/os-app/sub-browse/ui-logic.js b/os-app/sub-browse/ui-logic.js
index aa6f259..d927d38 100644
--- a/os-app/sub-browse/ui-logic.js
+++ b/os-app/sub-browse/ui-logic.js
@@ -23,7 +23,7 @@ const mod = {
 			throw new Error('EMLErrorInputNotValid');
 		}
 
-		return [param1.EMLMemoNotes].filter(function (e) {
+		return [param1.EMLMemoNotes].concat(Object.values(param1.EMLMemoCustomData || {})).filter(function (e) {
 			if (!e) {
 				return false;
 			}