From eef16f5a0f5af0aea313e411534643678ba4bea1 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Sun, 06 Sep 2026 20:58:21 +0000
Subject: [PATCH] =Polishing up the gutenberg sidebar for custom meta. Seems to be working more or less. Added integration with OpenStreetMaps for location fields. Still to add: row ordering for repeaters, Maybe a better view for the selector field (terms, posts, etc), ensure fields save correctly and repopulate.

---
 src/editor-fields/Fields.js |   29 ++++++++++++++++++++++++++++-
 1 files changed, 28 insertions(+), 1 deletions(-)

diff --git a/src/editor-fields/Fields.js b/src/editor-fields/Fields.js
index bcc16c7..f0bdafa 100644
--- a/src/editor-fields/Fields.js
+++ b/src/editor-fields/Fields.js
@@ -5,6 +5,10 @@
 import DateField from './fields/date-field';
 import TimeField from './fields/time-field';
 import DateTimeField from "./fields/datetime-field";
+import RepeaterField from "./fields/repeater-field";
+import UploadField from "./fields/upload-field";
+import SelectorField from "./fields/selector-field";
+import LocationField from "./fields/location-field.js";
 import { PanelRow } from '@wordpress/components';
 
 const FIELD_MAP = {
@@ -22,9 +26,32 @@
 	date: DateField,
 	time: TimeField,
 	datetime: DateTimeField,
+	repeater: RepeaterField,
+	upload: UploadField,
+	selector: SelectorField,
+	location: LocationField
 };
 
-const Fields = ({ field, value, onChange }) => {
+const OPERATORS = {
+	'=':  (a, b) => a == b,
+	'==': (a, b) => a == b,
+	'!=': (a, b) => a != b,
+	'>':  (a, b) => a > b,
+	'<':  (a, b) => a < b,
+	'in': (a, b) => Array.isArray(b) ? b.includes(a) : String(b).split(',').includes(a),
+};
+
+export const checkCondition = (condition, meta) => {
+	if (!condition?.field) return true;
+	const compare = OPERATORS[condition.operator] || OPERATORS['='];
+	return compare(meta?.[condition.field], condition.value);
+};
+
+const Fields = ({ id, field, value, onChange, meta }) => {
+	if (!checkCondition(field.condition, meta)) {
+		return null;
+	}
+
 	const Component = FIELD_MAP[field.type];
 	if (!Component) return null; // repeater/upload/selector: TODO
 	return <PanelRow><Component field={field} value={value} onChange={onChange} /></PanelRow>;

--
Gitblit v1.10.0