Now doing immutable widgets correctly.

This commit is contained in:
sb 2009-02-04 11:32:26 +00:00
parent f3f4f5c5bf
commit 19a35b9115
2 changed files with 98 additions and 52 deletions
schemas
transforms

View file

@ -13,7 +13,7 @@
<!-- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --> <!-- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
<!-- <!--
$Revision: 1.2 $ $Revision: 1.3 $
--> -->
<!-- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --> <!-- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
@ -291,25 +291,26 @@ that we can allow HTML block level entities within content elements -->
unique; unique;
distinct='all' implies that the values are formally unique distinct='all' implies that the values are formally unique
/and/ are user friendly (NOTE: not implemented). /and/ are user friendly (NOTE: not implemented).
entity: if type='entity', the name of the entity this property is entity: if type='entity', the name of the entity this property is
a foreign key link to. a foreign key link to.
if type='list', the name of the entity that has a foreign if type='list', the name of the entity that has a foreign
key link to this entity key link to this entity
farkey: if type='list', the name of farside key in the listed farkey: if type='list', the name of farside key in the listed
entity; if type='entity' and the farside field to join to entity; if type='entity' and the farside field to join to
is not the farside primary key, then the name of that is not the farside primary key, then the name of that
farside field farside field
required: whether this propery is required (i.e. 'not null'). required: whether this propery is required (i.e. 'not null').
immutable: if true, once a value has been set it cannot be changed.
size: fieldwidth of the property if specified. size: fieldwidth of the property if specified.
concrete: if set to 'false', this property is not stored in the concrete: if set to 'false', this property is not stored in the
database but must be computed (manually written code must database but must be computed (manually written code must
be provided to support this) be provided to support this)
cascade: what action(s) on the parent entity should be cascaded to cascade: what action(s) on the parent entity should be cascaded to
entitie(s) linked on this property. Valid only if type='entity', entitie(s) linked on this property. Valid only if type='entity',
type='link' or type='list'. type='link' or type='list'.
column: name of the column in a SQL database table in which this property column: name of the column in a SQL database table in which this property
is stored. TODO: Think about this. is stored. TODO: Think about this.
unsaved-value: unsaved-value:
of a property whose persistent value is set on first being of a property whose persistent value is set on first being
committed to persistent store, the value which it holds before committed to persistent store, the value which it holds before
it has been committed it has been committed
@ -318,17 +319,18 @@ that we can allow HTML block level entities within content elements -->
<!ATTLIST property <!ATTLIST property
name CDATA #REQUIRED name CDATA #REQUIRED
type (%AllDataTypes;) #REQUIRED type (%AllDataTypes;) #REQUIRED
default CDATA #IMPLIED default CDATA #IMPLIED
typedef CDATA #IMPLIED typedef CDATA #IMPLIED
distinct (none|all|user|system) #IMPLIED distinct (none|all|user|system) #IMPLIED
entity CDATA #IMPLIED entity CDATA #IMPLIED
farkey CDATA #IMPLIED farkey CDATA #IMPLIED
required %Boolean; #IMPLIED required %Boolean; #IMPLIED
immutable %Boolean #IMPLIED
size CDATA #IMPLIED size CDATA #IMPLIED
column CDATA #IMPLIED column CDATA #IMPLIED
concrete %Boolean; #IMPLIED concrete %Boolean; #IMPLIED
cascade (%CascadeActions;) #IMPLIED> cascade (%CascadeActions;) #IMPLIED>
<!-- <!--

View file

@ -15,8 +15,8 @@
Transform ADL into velocity view templates Transform ADL into velocity view templates
$Author: sb $ $Author: sb $
$Revision: 1.23 $ $Revision: 1.24 $
$Date: 2009-02-03 13:05:08 $ $Date: 2009-02-04 11:32:27 $
--> -->
<!-- WARNING WARNING WARNING: Do NOT reformat this file! <!-- WARNING WARNING WARNING: Do NOT reformat this file!
Whitespace (or lack of it) is significant! --> Whitespace (or lack of it) is significant! -->
@ -60,6 +60,8 @@
<xsl:param name="layout-name"/> <xsl:param name="layout-name"/>
<!-- bug 1800 : the name of the area (i.e. URL path part) to use --> <!-- bug 1800 : the name of the area (i.e. URL path part) to use -->
<xsl:param name="area-name" select="auto"/> <xsl:param name="area-name" select="auto"/>
<!-- the base url of the whole site -->
<xsl:param name="site-root"/>
<xsl:template match="adl:application"> <xsl:template match="adl:application">
<output> <output>
@ -118,7 +120,7 @@
Auto generated Velocity maybe-delete form for <xsl:value-of select="@name"/>, Auto generated Velocity maybe-delete form for <xsl:value-of select="@name"/>,
generated from ADL. generated from ADL.
Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.23 $', 10)"/> Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.24 $', 10)"/>
</xsl:comment> </xsl:comment>
<xsl:call-template name="maybe-delete"> <xsl:call-template name="maybe-delete">
<xsl:with-param name="entity" select="."/> <xsl:with-param name="entity" select="."/>
@ -155,7 +157,7 @@
Auto generated Velocity maybe-delete form for <xsl:value-of select="@name"/>, Auto generated Velocity maybe-delete form for <xsl:value-of select="@name"/>,
generated from ADL. generated from ADL.
Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.23 $', 10)"/> Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.24 $', 10)"/>
<xsl:value-of select="/adl:application/@revision"/> <xsl:value-of select="/adl:application/@revision"/>
</xsl:comment> </xsl:comment>
@ -238,7 +240,7 @@
Auto generated Velocity <xsl:value-of select="@name"/> form for <xsl:value-of select="ancestor::adl:entity/@name"/>, Auto generated Velocity <xsl:value-of select="@name"/> form for <xsl:value-of select="ancestor::adl:entity/@name"/>,
generated from ADL. generated from ADL.
Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.23 $', 10)"/> Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.24 $', 10)"/>
Generation parameters were: Generation parameters were:
locale: <xsl:value-of select="$locale"/> locale: <xsl:value-of select="$locale"/>
generate-site-navigation: <xsl:value-of select="$generate-site-navigation"/> generate-site-navigation: <xsl:value-of select="$generate-site-navigation"/>
@ -263,7 +265,7 @@
#capturefor( headextras) #capturefor( headextras)
<xsl:call-template name="head"/> <xsl:call-template name="head"/>
<script type='text/javascript' language='JavaScript1.2'> <script type='text/javascript' language='JavaScript1.2'>
var siteRoot = '$siteRoot'; var site-root = '$site-root';
function performInitialisation() function performInitialisation()
{ {
@ -369,7 +371,7 @@
Auto generated Velocity form for <xsl:value-of select="ancestor::adl:entity/@name"/>, Auto generated Velocity form for <xsl:value-of select="ancestor::adl:entity/@name"/>,
generated from ADL. generated from ADL.
Generated using adl2views.xsl <xsl:value-of select="substring( '$Revision: 1.23 $', 10)"/> Generated using adl2views.xsl <xsl:value-of select="substring( '$Revision: 1.24 $', 10)"/>
Generation parameters were: Generation parameters were:
locale: <xsl:value-of select="$locale"/> locale: <xsl:value-of select="$locale"/>
generate-site-navigation: <xsl:value-of select="$generate-site-navigation"/> generate-site-navigation: <xsl:value-of select="$generate-site-navigation"/>
@ -384,7 +386,7 @@
<xsl:call-template name="install-scripts"/> <xsl:call-template name="install-scripts"/>
<script type='text/javascript' language='JavaScript1.2'> <script type='text/javascript' language='JavaScript1.2'>
var siteRoot = '$siteRoot'; var site-root = '$site-root';
function performInitialisation() function performInitialisation()
{ {
@ -852,9 +854,6 @@
<xsl:with-param name="property" select="$property"/> <xsl:with-param name="property" select="$property"/>
</xsl:call-template> </xsl:call-template>
</xsl:variable> </xsl:variable>
<xsl:comment>
matched adl:property; group = '<xsl:value-of select="@name"/>' permission = '<xsl:value-of select="$permission"/>'
</xsl:comment>
<tr> <tr>
<xsl:attribute name="class"> <xsl:attribute name="class">
<xsl:value-of select="$oddness"/> <xsl:value-of select="$oddness"/>
@ -952,21 +951,42 @@
<xsl:otherwise>1</xsl:otherwise> <xsl:otherwise>1</xsl:otherwise>
</xsl:choose> </xsl:choose>
</xsl:variable> </xsl:variable>
<xsl:variable name="href">
<xsl:choose>
<xsl:when test="$property/@type='entity' and //adl:entity[@name=$property/@entity]/adl:form[@name='edit']">
<!-- if this is an entity property, and the entity which it wraps has an edit form -->
<xsl:variable name="keys">
<xsl:call-template name="entity-keys-fragment">
<xsl:with-param name="entity" select="//adl:entity[@name=$property/@entity]"/>
<xsl:with-param name="instance" select="concat( 'instance.', $property/@name)"/>
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="concat( '../../', $property/@entity, '/edit.rails', $keys)"/>
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:if test="exsl:node-set( $editgroups)/*"> <xsl:if test="exsl:node-set( $editgroups)/*">
<!-- NOTE! NOTE! NOTE! Whitespace is significant - any linefeeds inside the #if ( ) clause <!-- NOTE! NOTE! NOTE! Whitespace is significant - any linefeeds inside the #if ( ) clause
cause the Velocity parser to break! --> cause the Velocity parser to break! -->
#if ( <xsl:for-each select="exsl:node-set( $editgroups)/*">${SecurityHelper.InGroup( "<xsl:value-of select="./@name"/>")}<xsl:if test="not( position() = last())"> || </xsl:if></xsl:for-each>) #if ( <xsl:for-each select="exsl:node-set( $editgroups)/*">${SecurityHelper.InGroup( "<xsl:value-of select="./@name"/>")}<xsl:if test="not( position() = last())"> || </xsl:if></xsl:for-each>)
${<xsl:value-of select="concat( ancestor::adl:entity/@name, 'FieldHelper')"/>.Editable( "<xsl:value-of select="concat( 'instance.', @name)"/>", "%{rendermode='<xsl:value-of select="normalize-space($render-mode)"/>',class='<xsl:value-of select="normalize-space($cssclass)"/>',title='<xsl:value-of select="normalize-space($if-missing)"/>',size='<xsl:value-of select="normalize-space($size)"/>',maxlength='<xsl:value-of select="normalize-space($maxlength)"/>',rows='<xsl:value-of select="normalize-space($rows)"/>'}")} <xsl:choose>
<xsl:when test="$property/@immutable='true'">
${<xsl:value-of select="concat( ancestor::adl:entity/@name, 'FieldHelper')"/>.Immutable( "<xsl:value-of select="concat( 'instance.', @name)"/>", "%{class='<xsl:value-of select="normalize-space($cssclass)"/>',title='<xsl:value-of select="normalize-space($if-missing)"/>',size='<xsl:value-of select="normalize-space($size)"/>',maxlength='<xsl:value-of select="normalize-space($maxlength)"/>',rows='<xsl:value-of select="normalize-space($rows)"/>',href='<xsl:value-of select="normalize-space($href)"/>'}")}
</xsl:when>
<xsl:otherwise>
${<xsl:value-of select="concat( ancestor::adl:entity/@name, 'FieldHelper')"/>.Editable( "<xsl:value-of select="concat( 'instance.', @name)"/>", "%{class='<xsl:value-of select="normalize-space($cssclass)"/>',title='<xsl:value-of select="normalize-space($if-missing)"/>',size='<xsl:value-of select="normalize-space($size)"/>',maxlength='<xsl:value-of select="normalize-space($maxlength)"/>',rows='<xsl:value-of select="normalize-space($rows)"/>'}")}
</xsl:otherwise>
</xsl:choose>
#else #else
</xsl:if> </xsl:if>
<xsl:if test="exsl:node-set( $insertgroups)/*"> <xsl:if test="exsl:node-set( $insertgroups)/*">
#if ( <xsl:for-each select="exsl:node-set( $insertgroups)/*">${SecurityHelper.InGroup( "<xsl:value-of select="./@name"/>")}<xsl:if test="not( position() = last())"> || </xsl:if></xsl:for-each>) #if ( <xsl:for-each select="exsl:node-set( $insertgroups)/*">${SecurityHelper.InGroup( "<xsl:value-of select="./@name"/>")}<xsl:if test="not( position() = last())"> || </xsl:if></xsl:for-each>)
${<xsl:value-of select="concat( '$', ancestor::adl:entity/@name, 'FieldHelper')"/>.Immutable( "<xsl:value-of select="concat( 'instance.', @name)"/>", "%{rendermode='<xsl:value-of select="normalize-space($render-mode)"/>',class='<xsl:value-of select="normalize-space($cssclass)"/>',title='<xsl:value-of select="normalize-space($if-missing)"/>',size='<xsl:value-of select="normalize-space($size)"/>',maxlength='<xsl:value-of select="normalize-space($maxlength)"/>',rows='<xsl:value-of select="normalize-space($rows)"/>'}")} ${<xsl:value-of select="concat( '$', ancestor::adl:entity/@name, 'FieldHelper')"/>.Immutable( "<xsl:value-of select="concat( 'instance.', @name)"/>", "%{class='<xsl:value-of select="normalize-space($cssclass)"/>',title='<xsl:value-of select="normalize-space($if-missing)"/>',size='<xsl:value-of select="normalize-space($size)"/>',maxlength='<xsl:value-of select="normalize-space($maxlength)"/>',rows='<xsl:value-of select="normalize-space($rows)"/>',href='<xsl:value-of select="normalize-space($href)"/>'}")}
#else #else
</xsl:if> </xsl:if>
<xsl:if test="exsl:node-set( $readgroups)/*"> <xsl:if test="exsl:node-set( $readgroups)/*">
#if ( <xsl:for-each select="exsl:node-set( $readgroups)/*">${SecurityHelper.InGroup( "<xsl:value-of select="./@name"/>")}<xsl:if test="not( position() = last())"> || </xsl:if></xsl:for-each>) #if ( <xsl:for-each select="exsl:node-set( $readgroups)/*">${SecurityHelper.InGroup( "<xsl:value-of select="./@name"/>")}<xsl:if test="not( position() = last())"> || </xsl:if></xsl:for-each>)
${<xsl:value-of select="concat( ancestor::adl:entity/@name, 'FieldHelper')"/>.DisplayAndHidden( "<xsl:value-of select="concat( 'instance.', @name)"/>", "%{rendermode='<xsl:value-of select="normalize-space($render-mode)"/>',class='<xsl:value-of select="normalize-space($cssclass)"/>',title='<xsl:value-of select="normalize-space($if-missing)"/>',size='<xsl:value-of select="normalize-space($size)"/>',maxlength='<xsl:value-of select="normalize-space($maxlength)"/>',rows='<xsl:value-of select="normalize-space($rows)"/>'}")} ${<xsl:value-of select="concat( ancestor::adl:entity/@name, 'FieldHelper')"/>.DisplayAndHidden( "<xsl:value-of select="concat( 'instance.', @name)"/>", "%{class='<xsl:value-of select="normalize-space($cssclass)"/>',title='<xsl:value-of select="normalize-space($if-missing)"/>',size='<xsl:value-of select="normalize-space($size)"/>',maxlength='<xsl:value-of select="normalize-space($maxlength)"/>',rows='<xsl:value-of select="normalize-space($rows)"/>',href='<xsl:value-of select="normalize-space($href)"/>'}")}
#else #else
</xsl:if> </xsl:if>
[Not authorised] [Not authorised]
@ -1006,7 +1026,7 @@
Auto generated Velocity list for <xsl:value-of select="@name"/>, Auto generated Velocity list for <xsl:value-of select="@name"/>,
generated from ADL. generated from ADL.
Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.23 $', 10)"/> Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.24 $', 10)"/>
Generation parameters were: Generation parameters were:
locale: <xsl:value-of select="$locale"/> locale: <xsl:value-of select="$locale"/>
generate-site-navigation: <xsl:value-of select="$generate-site-navigation"/> generate-site-navigation: <xsl:value-of select="$generate-site-navigation"/>
@ -1053,7 +1073,7 @@
Auto generated Velocity list for <xsl:value-of select="ancestor::adl:entity/@name"/>, Auto generated Velocity list for <xsl:value-of select="ancestor::adl:entity/@name"/>,
generated from ADL. generated from ADL.
Generated using adl2listview.xsl <xsl:value-of select="substring( '$Revision: 1.23 $', 10)"/> Generated using adl2listview.xsl <xsl:value-of select="substring( '$Revision: 1.24 $', 10)"/>
Generation parameters were: Generation parameters were:
locale: <xsl:value-of select="$locale"/> locale: <xsl:value-of select="$locale"/>
generate-site-navigation: <xsl:value-of select="$generate-site-navigation"/> generate-site-navigation: <xsl:value-of select="$generate-site-navigation"/>
@ -1221,24 +1241,9 @@
</xsl:call-template> </xsl:call-template>
</xsl:for-each> </xsl:for-each>
<xsl:variable name="keys"> <xsl:variable name="keys">
<!-- assemble keys in a Velocity-friendly format, then splice it into <xsl:call-template name="entity-keys-fragment">
the HREF below --> <xsl:with-param name="entity" select="$entity"/>
<xsl:for-each select="$entity/adl:key/adl:property"> </xsl:call-template>
<xsl:variable name="sep">
<xsl:choose>
<xsl:when test="position()=1">?</xsl:when>
<xsl:otherwise>&amp;</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="@type='entity'">
<xsl:value-of select="concat( $sep, @name, '=$', $entity/@name, '.', @name, '_Value')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat( $sep, @name, '=$', $entity/@name, '.', @name)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:variable> </xsl:variable>
<xsl:for-each select="$entity/adl:form"> <xsl:for-each select="$entity/adl:form">
<!-- by default create a link to each form declared for the entity. <!-- by default create a link to each form declared for the entity.
@ -1421,6 +1426,28 @@
</td> </td>
</xsl:template> </xsl:template>
<!-- assemble keys for this entity in a Velocity-friendly format, to splice into an HREF below -->
<xsl:template name="entity-keys-fragment">
<xsl:param name="entity"/>
<xsl:param name="instance" select="$entity/@name"/>
<xsl:for-each select="$entity/adl:key/adl:property">
<xsl:variable name="sep">
<xsl:choose>
<xsl:when test="position()=1">?</xsl:when>
<xsl:otherwise>&amp;</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="@type='entity'">
<xsl:value-of select="concat( $sep, @name, '=$', $instance, '.', @name, '_Value')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat( $sep, @name, '=$', $instance, '.', @name)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
<!-- overall page layout --> <!-- overall page layout -->
<xsl:template match="adl:content"/> <xsl:template match="adl:content"/>
@ -1482,7 +1509,24 @@
<li class="navigation"> <li class="navigation">
<a> <a>
<xsl:attribute name="href"> <xsl:attribute name="href">
<xsl:value-of select="concat( '$siteRoot', '/', $area-name, '/', @name, '/', adl:list[position()=1]/@name, '.rails')"/> <xsl:choose>
<xsl:when test="string-length( $site-root) &gt; 0">
<xsl:choose>
<xsl:when test="string-length( $area-name) &gt; 0">
<xsl:value-of select="concat( '$site-root', '/', $area-name, '/', @name, '/', adl:list[position()=1]/@name, '.rails')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat( '$site-root', '/', @name, '/', adl:list[position()=1]/@name, '.rails')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="string-length( $area-name) &gt; 0">
<xsl:value-of select="concat( '/', $area-name, '/', @name, '/', adl:list[position()=1]/@name, '.rails')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat( '/', @name, '/', adl:list[position()=1]/@name, '.rails')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute> </xsl:attribute>
<xsl:value-of select="@name"/> <xsl:value-of select="@name"/>
</a> </a>