Store brand color without # prefix, normalize on output
saveBrandColor.cfm no longer prepends # before storing. API responses (get.cfm, items.cfm, getForBuilder.cfm) prepend # if missing so consumers always get a CSS-ready value. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
8f9da2fbf0
commit
cc96d891b2
4 changed files with 5 additions and 5 deletions
|
|
@ -141,7 +141,7 @@ try {
|
||||||
"IsHiring": q.BusinessIsHiring == 1,
|
"IsHiring": q.BusinessIsHiring == 1,
|
||||||
"TaxRate": taxRate,
|
"TaxRate": taxRate,
|
||||||
"TaxRatePercent": taxRate * 100,
|
"TaxRatePercent": taxRate * 100,
|
||||||
"BrandColor": len(q.BusinessBrandColor) ? q.BusinessBrandColor : ""
|
"BrandColor": len(q.BusinessBrandColor) ? (left(q.BusinessBrandColor, 1) == chr(35) ? q.BusinessBrandColor : chr(35) & q.BusinessBrandColor) : ""
|
||||||
};
|
};
|
||||||
|
|
||||||
// Add header image URL if extension exists
|
// Add header image URL if extension exists
|
||||||
|
|
|
||||||
|
|
@ -47,8 +47,8 @@ if (len(brandColor) GT 0) {
|
||||||
if (len(brandColor) != 6 || !reFind("^[0-9A-Fa-f]{6}$", brandColor)) {
|
if (len(brandColor) != 6 || !reFind("^[0-9A-Fa-f]{6}$", brandColor)) {
|
||||||
apiAbort({ "OK": false, "ERROR": "invalid_color", "MESSAGE": "Color must be a valid 6-digit hex color (e.g. 1B4D3E or ##1B4D3E)" });
|
apiAbort({ "OK": false, "ERROR": "invalid_color", "MESSAGE": "Color must be a valid 6-digit hex color (e.g. 1B4D3E or ##1B4D3E)" });
|
||||||
}
|
}
|
||||||
// Store with # prefix, uppercase
|
// Store uppercase, no # prefix
|
||||||
brandColor = chr(35) & uCase(brandColor);
|
brandColor = uCase(brandColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the database
|
// Update the database
|
||||||
|
|
|
||||||
|
|
@ -411,7 +411,7 @@ try {
|
||||||
SELECT BusinessBrandColor FROM Businesses WHERE BusinessID = :bizId
|
SELECT BusinessBrandColor FROM Businesses WHERE BusinessID = :bizId
|
||||||
", { bizId: businessID }, { datasource: "payfrit" });
|
", { bizId: businessID }, { datasource: "payfrit" });
|
||||||
if (qBrand.recordCount > 0 && len(trim(qBrand.BusinessBrandColor))) {
|
if (qBrand.recordCount > 0 && len(trim(qBrand.BusinessBrandColor))) {
|
||||||
brandColor = qBrand.BusinessBrandColor;
|
brandColor = left(qBrand.BusinessBrandColor, 1) == chr(35) ? qBrand.BusinessBrandColor : chr(35) & qBrand.BusinessBrandColor;
|
||||||
}
|
}
|
||||||
} catch (any e) {
|
} catch (any e) {
|
||||||
// Column may not exist yet, ignore
|
// Column may not exist yet, ignore
|
||||||
|
|
|
||||||
|
|
@ -497,7 +497,7 @@
|
||||||
{ datasource = "payfrit" }
|
{ datasource = "payfrit" }
|
||||||
)>
|
)>
|
||||||
<cfif qBrand.recordCount GT 0 AND len(trim(qBrand.BusinessBrandColor))>
|
<cfif qBrand.recordCount GT 0 AND len(trim(qBrand.BusinessBrandColor))>
|
||||||
<cfset brandColor = qBrand.BusinessBrandColor>
|
<cfset brandColor = left(qBrand.BusinessBrandColor, 1) EQ chr(35) ? qBrand.BusinessBrandColor : chr(35) & qBrand.BusinessBrandColor>
|
||||||
</cfif>
|
</cfif>
|
||||||
<cfcatch>
|
<cfcatch>
|
||||||
<!--- Column may not exist yet, ignore --->
|
<!--- Column may not exist yet, ignore --->
|
||||||
|
|
|
||||||
Reference in a new issue