From a24a06002081ad71a78ffeff9072725ba39cf121 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Tue, 17 Feb 2026 20:05:31 +0000
Subject: [PATCH] =minor changes, particularly around the JVB_CHILD_URL pattern
---
assets/js/concise/PopulateForm.js | 63 ++++++++++++++++++++++---------
1 files changed, 44 insertions(+), 19 deletions(-)
diff --git a/assets/js/concise/PopulateForm.js b/assets/js/concise/PopulateForm.js
index 2bd02b8..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 => {
@@ -203,7 +222,7 @@
}
const grid = field.querySelector('.item-grid');
- let uploadContainer = field.querySelector('.file-upload-container');
+ let uploadContainer = field.querySelector('.file-upload-wrapper');
uploadContainer.hidden = ids.length > 0;
field.querySelector('.progress')?.remove();
if (grid) {
@@ -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]);
}
}
}
@@ -251,7 +270,7 @@
if (!value || !Array.isArray(value) || value.length === 0) return;
let grid = field.querySelector('.item-grid');
- let uploadContainer = field.querySelector('.file-upload-container');
+ let uploadContainer = field.querySelector('.file-upload-wrapper');
uploadContainer.hidden = value.length > 0;
if (grid) {
window.removeChildren(grid);
@@ -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