preload.push(c);
fieldmapper.IDL.fmclasses[c] = window._preload_fieldmapper_IDL[c];
+ if (!fieldmapper.IDL.fmclasses[c].label) {
+ fieldmapper.IDL.fmclasses[c].label =
+ fieldmapper.IDL.fmclasses[c].name;
+ }
+
window.fmclasses[c] = [];
- dojo.forEach(fieldmapper.IDL.fmclasses[c].fields, function(obj){ window.fmclasses[c].push(obj.name); });
+ dojo.forEach(fieldmapper.IDL.fmclasses[c].fields, function(obj){
+ if (!obj.label) obj.label = obj.name;
+ window.fmclasses[c].push(obj.name);
+ });
if (classlist && classlist.length)
classlist = dojo.filter(classlist, function(x){return x != c;});
for (var c in _preload_fieldmapper_IDL) {
var x = _preload_fieldmapper_IDL[c]; x.field_map = {};
var p = x.fields.length;
- for (var n in {isnew:1,ischanged:1,isdeleted:1}) x.fields[p] = {name:n,type:'field',virtual:true,array_position:p++};
+ for (var n in {isnew:1,ischanged:1,isdeleted:1}) x.fields[p] = {name:n,virtual:true};
for (var f in x.fields) x.field_map[x.fields[f].name] = x.fields[f];
}
</xsl:template>
</xsl:choose>
</xsl:template>
- <xsl:template match="idl:class"><xsl:value-of select="@id"/>:{name:"<xsl:value-of select="@id"/>",label:"<xsl:call-template name='defaultValue'><xsl:with-param name='v' select="@reporter:label"/><xsl:with-param name='d' select="@id"/></xsl:call-template>",restrict_primary:"<xsl:value-of select="@oils_persist:restrict_primary"/>",virtual:<xsl:call-template name='trueFalse'><xsl:with-param name='tf' select="@oils_persist:virtual"/></xsl:call-template>,pkey:"<xsl:value-of select="idl:fields/@oils_persist:primary"/>",pkey_sequence:"<xsl:value-of select="idl:fields/@oils_persist:sequence"/>",<xsl:apply-templates select="idl:fields"/><xsl:apply-templates select="permacrud:permacrud"/>}</xsl:template>
+ <xsl:template match="idl:class"><xsl:value-of select="@id"/>:{name:"<xsl:value-of select="@id"/>",<xsl:if test="@reporter:label">label:"<xsl:value-of select="@reporter:label"/>",</xsl:if><xsl:if test="@oils_persist:restrict_primary">restrict_primary:"<xsl:value-of select="@oils_persist:restrict_primary"/>",</xsl:if><xsl:if test="@oils_persist:virtual = 'true'">virtual:true,</xsl:if><xsl:if test="idl:fields/@oils_persist:primary">pkey:"<xsl:value-of select="idl:fields/@oils_persist:primary"/>",</xsl:if><xsl:if test="idl:fields/@oils_persist:sequence">pkey_sequence:"<xsl:value-of select="idl:fields/@oils_persist:sequence"/>",</xsl:if><xsl:apply-templates select="idl:fields"/><xsl:apply-templates select="permacrud:permacrud"/>}</xsl:template>
<xsl:template match="idl:fields">fields:[<xsl:for-each select="idl:field"><xsl:call-template name="printField"><xsl:with-param name='pos' select="position()"/></xsl:call-template><xsl:if test="not(position() = last())">,</xsl:if></xsl:for-each>]</xsl:template>
<xsl:template match="permacrud:permacrud">,permacrud:{<xsl:for-each select="permacrud:actions/*"><xsl:if test="name() = 'delete'">"</xsl:if><xsl:value-of select="name()"/><xsl:if test="name() = 'delete'">"</xsl:if>:{<xsl:call-template name='pcrudPerms'/>}<xsl:if test="not(position() = last())">,</xsl:if></xsl:for-each>}</xsl:template>
-<xsl:template name='printField'><xsl:param name="pos"/>{name:"<xsl:value-of select="@name"/>",label:"<xsl:call-template name='defaultValue'><xsl:with-param name='v' select="@reporter:label"/><xsl:with-param name='d' select="@name"/></xsl:call-template>",datatype:"<xsl:call-template name='defaultValue'><xsl:with-param name='v' select="@reporter:datatype"/><xsl:with-param name='d' select="string('text')"/></xsl:call-template>",primitive:"<xsl:value-of select="@oils_persist:primitive"/>",selector:"<xsl:value-of select="@reporter:selector"/>",array_position:"<xsl:value-of select="$pos - 1"/>",<xsl:call-template name='fieldOrLink'><xsl:with-param name='f' select="."/></xsl:call-template>,virtual:<xsl:call-template name='trueFalse'><xsl:with-param name='tf' select="@oils_persist:virtual"/></xsl:call-template>,required:<xsl:call-template name='trueFalse'><xsl:with-param name='tf' select="@oils_obj:required"/></xsl:call-template>,i18n:<xsl:call-template name='trueFalse'><xsl:with-param name='tf' select="@oils_persist:i18n"/></xsl:call-template>}</xsl:template>
+<!-- to simplify the logic, the first and last field are assumed to
+ have values (and practically always will) -->
+<xsl:template name='printField'>{name:"<xsl:value-of select="@name"/>",<xsl:if test="@reporter:label != ''">label:"<xsl:value-of select="@reporter:label"/>",</xsl:if><xsl:if test="@oils_persist:primitive = 'true'">primitive:true,</xsl:if><xsl:if test="@reporter:selector != ''">selector:"<xsl:value-of select="@reporter:selector"/>",</xsl:if><xsl:if test="@oils_persist:virtual = 'true'">virtual:true,</xsl:if><xsl:if test="@oils_obj:required = 'true'">required:true,</xsl:if><xsl:if test="@oils_persist:i18n = 'true'">i18n:true,</xsl:if><xsl:call-template name='fieldOrLink'><xsl:with-param name='f' select="."/></xsl:call-template>datatype:"<xsl:call-template name='defaultValue'><xsl:with-param name='v' select="@reporter:datatype"/><xsl:with-param name='d' select="string('text')"/></xsl:call-template>"}</xsl:template>
<xsl:template name="pcrudPerms">
<xsl:if test="@permission">perms:[<xsl:for-each select="str:split(@permission,' ')">'<xsl:value-of select="./text()"/>'<xsl:if test="not(position() = last())">,</xsl:if></xsl:for-each>]</xsl:if>
<xsl:template name="fieldOrLink">
<xsl:param name="f"/>
- <xsl:choose>
- <xsl:when test="$f/../../idl:links/idl:link[@field=$f/@name]">type:"link",<xsl:apply-templates select="$f/../../idl:links/idl:link[@field=$f/@name]"></xsl:apply-templates></xsl:when>
- <xsl:otherwise>type:"field"</xsl:otherwise>
- </xsl:choose>
+ <xsl:if test="$f/../../idl:links/idl:link[@field=$f/@name]">type:"link",<xsl:apply-templates select="$f/../../idl:links/idl:link[@field=$f/@name]"></xsl:apply-templates>,</xsl:if>
</xsl:template>
<xsl:template match="idl:link">key:"<xsl:value-of select="@key"/>","class":"<xsl:value-of select="@class"/>",reltype:"<xsl:value-of select="@reltype"/>"</xsl:template>
<xsl:otherwise><xsl:value-of select="$v"/></xsl:otherwise>
</xsl:choose>
</xsl:template>
-
-
+
</xsl:stylesheet>