Skip to content

workaround for dynamic struct keys #107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: p740
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions packages/forms/forms.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,19 @@

<!--- Get default values --->
<cfloop collection="#application.stCOAPI[variables.typename].stProps#" item="prop">

<cfparam name="application.stCOAPI[variables.typename].stProps[prop].metadata.Default" default="">
<cfparam name="application.stCOAPI[variables.typename].stProps[prop].metadata.ftDefaultType" default="value">
<cfparam name="application.stCOAPI[variables.typename].stProps[prop].metadata.ftDefault" default="#application.stCOAPI[variables.typename].stProps[prop].metadata.Default#">

<cfif not structKeyExists(application.stCOAPI[variables.typename].stProps[prop], "metadata") >
<cfset application.stCOAPI[variables.typename].stProps[prop].metadata = structNew() >
</cfif>
<cfif not structKeyExists(application.stCOAPI[variables.typename].stProps[prop].metadata, "Default") >
<cfset application.stCOAPI[variables.typename].stProps[prop].metadata.Default = "" >
</cfif>
<cfif not structKeyExists(application.stCOAPI[variables.typename].stProps[prop].metadata, "ftDefaultType") >
<cfset application.stCOAPI[variables.typename].stProps[prop].metadata.ftDefaultType = "value" >
</cfif>
<cfif not structKeyExists(application.stCOAPI[variables.typename].stProps[prop].metadata, "ftDefault") >
<cfset application.stCOAPI[variables.typename].stProps[prop].metadata.ftDefault = application.stCOAPI[variables.typename].stProps[prop].metadata.Default >
</cfif>

<cfif application.stCOAPI[variables.typename].stProps[prop].metadata.type eq "array">
<!--- set to the default if it is not already defined above --->
Expand Down
7 changes: 6 additions & 1 deletion packages/fourq/TableMetadata.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,15 @@


<cfif structKeyExists(arguments.md,'properties')>

<cfparam name="variables.tableDefinition" default="#structNew()#" >

<!--- If we got to here there should be some properties to parse --->
<cfloop from="1" to="#arrayLen(arguments.md.properties)#" index="i">
<cfparam name="variables.tableDefinition[arguments.md.properties[i].name]" default="#structNew()#" />

<cfif not structKeyExists(variables.tableDefinition,arguments.md.properties[i].name)>
<cfset variables.tableDefinition[arguments.md.properties[i].name] = structNew() />
</cfif>

<cfset bSuccess = StructAppend(variables.tableDefinition[arguments.md.properties[i].name],parseProperty(arguments.md.properties[i]),false)>

Expand Down
17 changes: 13 additions & 4 deletions packages/fourq/fourq.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -661,10 +661,19 @@ So in the case of a database called 'fourq' - the correct application.dbowner va
<!--- check if date type, and set default to the default assigned OR to now() --->

<cfif NOT StructKeyExists(stProps, propertie)>

<cfparam name="stDefaultProperties[propertie].metadata.Default" default="">
<cfparam name="stDefaultProperties[propertie].metadata.ftDefaultType" default="value">
<cfparam name="stDefaultProperties[propertie].metadata.ftDefault" default="#stDefaultProperties[propertie].metadata.Default#">

<cfif not structKeyExists(stDefaultProperties[propertie], "metadata") >
<cfset stDefaultProperties[propertie].metadata = structNew() >
</cfif>
<cfif not structKeyExists(stDefaultProperties[propertie].metadata, "Default") >
<cfset stDefaultProperties[propertie].metadata.Default = "" >
</cfif>
<cfif not structKeyExists(stDefaultProperties[propertie].metadata, "ftDefaultType") >
<cfset stDefaultProperties[propertie].metadata.ftDefaultType = "value" >
</cfif>
<cfif not structKeyExists(stDefaultProperties[propertie].metadata, "ftDefault") >
<cfset stDefaultProperties[propertie].metadata.ftDefault = stDefaultProperties[propertie].metadata.Default >
</cfif>



Expand Down
12 changes: 8 additions & 4 deletions packages/lib/fapi.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -374,10 +374,14 @@
<cfset var stResult = "" />
<cfset var o = application.fapi.getContentType("#arguments.typename#") />

<cfparam name="session.stTempObjectStoreKeys" default="#structNew()#" />
<cfparam name="session.stTempObjectStoreKeys[arguments.typename]" default="#structNew()#" />


<cfif not structKeyExists(session, "stTempObjectStoreKeys") >
<cfset session.stTempObjectStoreKeys = structNew() >
</cfif>
<cfif not structKeyExists(session.stTempObjectStoreKeys, arguments.typename) >
<cfset session.stTempObjectStoreKeys[arguments.typename] = structNew() >
</cfif>


<cfloop collection="#arguments#" item="i">
<cfif NOT listFindNoCase(lReserved, i)>
<cfset arguments.stProperties[i] = arguments[i] />
Expand Down
4 changes: 3 additions & 1 deletion tags/webskin/view.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@
<cfset st = o.getData(objectID = attributes.objectid) />
<cfelseif len(attributes.key)>
<cfparam name="session.stTempObjectStoreKeys" default="#structNew()#" />
<cfparam name="session.stTempObjectStoreKeys[attributes.typename]" default="#structNew()#" />
<cfif not structKeyExists(session.stTempObjectStoreKeys, attributes.typename) >
<cfset session.stTempObjectStoreKeys[attributes.typename] = structNew() >
</cfif>

<cfif structKeyExists(session.stTempObjectStoreKeys[attributes.typename], attributes.key)>
<cfif structKeyExists(Session.TempObjectStore, session.stTempObjectStoreKeys[attributes.typename][attributes.key])>
Expand Down
10 changes: 8 additions & 2 deletions webtop/customadmin/utilities/listfilelocations.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@
<cfif listcontains("type,rule",application.stCOAPI[thistype].class)>
<cfloop collection="#application.stCOAPI[thistype].stProps#" item="thisprop">
<cfif isdefined("application.stCOAPI.#thistype#.stProps.#thisprop#.metadata.ftType") and listcontains("image,file",application.stCOAPI[thistype].stProps[thisprop].metadata.ftType)>
<cfparam name="stFileProps[thistype]" default="#structnew()#" />
<cfparam name="stFileProps[thistype][thisprop]" default="#application.stCOAPI[thistype].stProps[thisprop].metadata#" />

<cfif not structKeyExists(stFileProps, thistype) >
<cfset stFileProps[thistype] = structNew() >
</cfif>
<cfif not structKeyExists(stFileProps[thistype], thisprop) >
<cfset stFileProps[thistype][thisprop] = application.stCOAPI[thistype].stProps[thisprop].metadata >
</cfif>

</cfif>
</cfloop>
</cfif>
Expand Down