From 48721c85ebcfa973ee81719d2467ca80e4253dc9 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Fri, 01 May 2026 17:30:03 +0000
Subject: [PATCH] =Edmonton Ink hard test begins! Real testing of the managers and reset routes will commence. So far, just ensuring our classes are all loaded correctly: Site() and its sub-classes Membership, Login, etc. Care should be taken to load conditionally on 'init', as we finish defining most settings by 'plugins_loaded' at priority 5

---
 assets/js/concise/PopulateForm.js |   59 ++++++++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 42 insertions(+), 17 deletions(-)

diff --git a/assets/js/concise/PopulateForm.js b/assets/js/concise/PopulateForm.js
index 761a134..b7e7c02 100644
--- a/assets/js/concise/PopulateForm.js
+++ b/assets/js/concise/PopulateForm.js
@@ -64,20 +64,25 @@
 		const handlers = {
 			'repeater': this.populateRepeater.bind(this),
 			'tag-list': this.populateTagList.bind(this),
+			'group':	this.populateGroup.bind(this),
 			'location': this.populateLocation.bind(this),
 			'selector': this.populateTaxonomy.bind(this),
 			'user': 	this.populateUser.bind(this),
 			'upload': 	this.populateUpload.bind(this),
+			'gallery': 	this.populateUpload.bind(this),
+			'image': 	this.populateUpload.bind(this),
 			'set': 		this.populateMultiValue.bind(this),
 			'checkbox': this.populateMultiValue.bind(this),
 			'select': 	this.populateSingleValue.bind(this),
 			'radio':	this.populateSingleValue.bind(this),
 			'true-false': this.populateBoolean.bind(this),
+			'toggle-text': this.populateBoolean.bind(this),
 			'date': 	this.populateDate.bind(this),
 			'time': 	this.populateDate.bind(this),
 			'datetime': this.populateDate.bind(this),
 			'number': 	this.populateNumber.bind(this),
-			'textarea': this.populateTextarea.bind(this)
+			'textarea': this.populateTextarea.bind(this),
+			'quantity': this.populateNumber.bind(this),
 		};
 
 		if (Object.hasOwn(handlers, type)) {
@@ -97,19 +102,24 @@
 		window.removeChildren(container);
 
 		value.forEach((data, index) => {
-			data.index = index;
-			const row = this.templates.create(template, data);
+			const templateData = { ...data, index, repeater: field };
+
+			const row = this.templates.create(template, templateData);
 			if (!row) return;
 
+			container.append(row);
+
+			const formConfig = this.formHelper.getForm(row);
+			if (formConfig) {
+				this.formHelper.initializeFields(row, formConfig);
+			}
+
 			for (let [fieldName, fieldValue] of Object.entries(data)) {
-				if (fieldName === 'index') continue;
 				let subField = row.querySelector(`[data-field="${fieldName}"]`);
 				if (subField) {
 					this.populateField(subField, fieldName, fieldValue);
 				}
 			}
-
-			container.append(row);
 		});
 	}
 	populateTagList(field, name, value) {
@@ -161,7 +171,16 @@
 				return data[format] ?? values[0] ?? 'New Item';
 		}
 	}
+	populateGroup(field, name, value) {
+		if (!value || typeof value !== 'object') return;
 
+		for (let [subName, subValue] of Object.entries(value)) {
+			let subField = field.querySelector(`[data-field="${subName}"]`);
+			if (subField) {
+				this.populateField(subField, subName, subValue);
+			}
+		}
+	}
 	populateLocation(field, name, value) {
 		const subFields = ['address', 'lat', 'lng', 'street', 'city', 'province', 'postal_code', 'country'];
 		subFields.forEach(subField => {
@@ -243,7 +262,7 @@
 			for (const m of meta) {
 				const input = imageDataField.querySelector(`[data-field="${m}"] input, [data-field="${m}"] textarea`);
 				if (input && data[m]!=='') {
-					input.value = data[m];
+					input.value = window.decodeHTMLEntities(data[m]);
 				}
 			}
 		}
@@ -283,7 +302,7 @@
 			}
 			return;
 		}
-		field.querySelectorAll(`[type="checkbox"][name=${name}]`).forEach(checkbox => {
+		field.querySelectorAll(`input[type="checkbox"][name="${name}[]"], input[type="checkbox"][name="${name}"]`).forEach(checkbox => {
 			checkbox.checked = value.includes(checkbox.value);
 		});
 
@@ -343,18 +362,24 @@
 		}
 	}
 	populateTextarea(field, name, value) {
-		let textarea = field.querySelector('textarea');
-		if (!textarea.dataset.editor) {
-			this.populateText(field, name, value)
-			return;
+		let textarea = field.querySelector('textarea[data-editor], textarea');
+		this.populateText(field, name, value);
+
+		if (textarea?.dataset.editor) {
+			const editor = field.querySelector('.ql-editor');
+			if (editor) {
+				editor.innerHTML = value;
+			} else {
+				textarea.dispatchEvent(new Event('change', { bubbles: true }));
+			}
 		}
-		textarea.value = String(value || '');
-		textarea.dispatchEvent(new Event('change', {bubbles: true}));
 	}
 	populateText(field, name, value) {
-		let input = field.querySelector(`[name="${name}"], input, textarea`);
-		if (input && input.type !== 'file') {
-			input.value = String(value || '');
+		let input = field.querySelector(`[name="${name}"]`)
+			|| field.querySelector('textarea[data-editor]')
+			|| field.querySelector('input:not([type="hidden"]):not([type="file"]), textarea, select');
+		if (input) {
+			input.value = window.decodeHTMLEntities(value??'');
 		}
 	}
 	/********************************************************************

--
Gitblit v1.10.0