From 469cc06a29ed692d4039c74b7827bd1165320fee Mon Sep 17 00:00:00 2001 From: John Mizerek Date: Sat, 31 Jan 2026 14:27:44 -0800 Subject: [PATCH] Fix brand color save: use BusinessBrandColor column, allow # to be optional - saveBrandColor.cfm: BrandColor -> BusinessBrandColor (normalized column name) - portal.js: Accept hex colors with or without # prefix in validation - portal.js: Auto-prepend # when typing bare hex in color input Co-Authored-By: Claude Opus 4.5 --- api/businesses/saveBrandColor.cfm | 2 +- portal/portal.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/api/businesses/saveBrandColor.cfm b/api/businesses/saveBrandColor.cfm index cd744be..368a94f 100644 --- a/api/businesses/saveBrandColor.cfm +++ b/api/businesses/saveBrandColor.cfm @@ -49,7 +49,7 @@ if (len(brandColor) GT 0) { // Update the database queryExecute(" UPDATE Businesses - SET BrandColor = :color + SET BusinessBrandColor = :color WHERE BusinessID = :bizId ", { color: { value: brandColor, cfsqltype: "cf_sql_varchar" }, diff --git a/portal/portal.js b/portal/portal.js index 970d5e3..f2d2a79 100644 --- a/portal/portal.js +++ b/portal/portal.js @@ -1215,6 +1215,7 @@ const Portal = { hexInput.addEventListener('input', () => { let color = hexInput.value; + if (/^[0-9A-Fa-f]{6}$/.test(color)) color = '#' + color; if (/^#[0-9A-Fa-f]{6}$/.test(color)) { colorInput.value = color; preview.style.background = `linear-gradient(to bottom, ${color}44, ${color}00, ${color}66)`; @@ -1225,8 +1226,8 @@ const Portal = { // Save brand color async saveBrandColor() { const color = document.getElementById('brandColorHex').value.toUpperCase(); - if (!/^#[0-9A-Fa-f]{6}$/.test(color)) { - this.toast('Please enter a valid hex color (e.g., #1B4D3E)', 'error'); + if (!/^#?[0-9A-Fa-f]{6}$/.test(color)) { + this.toast('Please enter a valid hex color (e.g., #1B4D3E or 1B4D3E)', 'error'); return; }