Fix brand color display and header upload collision
- Brand color: add # prefix when loading from DB (stored without #, CSS needs it for backgroundColor) - Header upload: delete destination file before rename to prevent collision when re-uploading same extension - Header preview: prepend BASE_PATH to image URL for local dev Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
db90d9911a
commit
d6478da03f
2 changed files with 14 additions and 5 deletions
|
|
@ -64,8 +64,17 @@ if (bizId LTE 0) {
|
|||
</cfif>
|
||||
</cfif>
|
||||
|
||||
<!--- Also delete destination file if it exists (same extension re-upload) --->
|
||||
<cfset destFile = "#headersDir#/#bizId#.#uploadResult.ClientFileExt#">
|
||||
<cfif fileExists(destFile)>
|
||||
<cftry>
|
||||
<cffile action="DELETE" file="#destFile#">
|
||||
<cfcatch></cfcatch>
|
||||
</cftry>
|
||||
</cfif>
|
||||
|
||||
<!--- Rename to BusinessID.ext --->
|
||||
<cffile action="RENAME" source="#headersDir#/#uploadResult.ServerFile#" destination="#headersDir#/#bizId#.#uploadResult.ClientFileExt#" mode="755">
|
||||
<cffile action="RENAME" source="#headersDir#/#uploadResult.ServerFile#" destination="#destFile#" mode="755">
|
||||
|
||||
<!--- Update database --->
|
||||
<cfquery datasource="payfrit">
|
||||
|
|
|
|||
|
|
@ -758,12 +758,12 @@ const Portal = {
|
|||
document.getElementById('settingState').value = biz.ADDRESSSTATE || '';
|
||||
document.getElementById('settingZip').value = biz.ADDRESSZIP || '';
|
||||
|
||||
// Load brand color if set
|
||||
// Load brand color if set (DB stores without #, CSS needs it)
|
||||
const brandColor = biz.BRANDCOLOR || '';
|
||||
if (brandColor) {
|
||||
this.brandColor = brandColor;
|
||||
this.brandColor = brandColor.charAt(0) === '#' ? brandColor : '#' + brandColor;
|
||||
const swatch = document.getElementById('brandColorSwatch');
|
||||
if (swatch) swatch.style.backgroundColor = brandColor;
|
||||
if (swatch) swatch.style.backgroundColor = this.brandColor;
|
||||
}
|
||||
|
||||
// Load header preview
|
||||
|
|
@ -774,7 +774,7 @@ const Portal = {
|
|||
headerPreview.onload = function() {
|
||||
if (headerWrapper) headerWrapper.style.display = 'block';
|
||||
};
|
||||
headerPreview.src = `${headerUrl}?t=${Date.now()}`;
|
||||
headerPreview.src = `${BASE_PATH}${headerUrl}?t=${Date.now()}`;
|
||||
}
|
||||
|
||||
// Render hours editor
|
||||
|
|
|
|||
Reference in a new issue