Considerable progress on adjunct editing suite, but some lacunae remain.
This commit is contained in:
parent
22567139f3
commit
e423b325a4
4 changed files with 177 additions and 92 deletions
|
|
@ -12,8 +12,8 @@
|
|||
Transform ADL into velocity view templates
|
||||
|
||||
$Author: sb $
|
||||
$Revision: 1.7 $
|
||||
$Date: 2008-03-03 17:35:28 $
|
||||
$Revision: 1.8 $
|
||||
$Date: 2008-03-04 17:30:52 $
|
||||
-->
|
||||
<!-- WARNING WARNING WARNING: Do NOT reformat this file!
|
||||
Whitespace (or lack of it) is significant! -->
|
||||
|
|
@ -27,17 +27,16 @@
|
|||
TODO: we need to generate views for each available locale, but this is not
|
||||
yet implemented. When it is we will almost certainly still need a 'default locale' -->
|
||||
<xsl:param name="locale" select="en-UK"/>
|
||||
<!--
|
||||
The convention to use for naming auto-generated abstract primary keys. Known values are
|
||||
Id - the autogenerated primary key, if any, is called just 'Id'
|
||||
Name - the autogenerated primary key has the same name as the entity
|
||||
NameId - the name of the auto generated primary key is the name of the entity followed by 'Id'
|
||||
Name_Id - the name of the auto generated primary key is the name of the entity followed by '_Id'
|
||||
-->
|
||||
<xsl:param name="abstract-key-name-convention" select="Id"/>
|
||||
|
||||
|
||||
<!-- whether or not to auto-generate site navigation - by default, don't -->
|
||||
<xsl:param name="generate-site-navigation"/>
|
||||
|
||||
<!-- the current state of play is that we can only generate views with permissions for one group.
|
||||
TODO: this isn't how it's supposed to be. It's supposed to be that at service time the system
|
||||
checks which groups the current user is member of, and renders each widget with the most relaxed
|
||||
permissions applicable to that user - but we don't yet have the parts in place to do that.
|
||||
This variable selects which group's permissions should be used when generating widgets -->
|
||||
<xsl:param name="permissions-group" select="public"/>
|
||||
|
||||
<!-- what's all this about? the objective is to get the revision number of the
|
||||
transform into the output, /without/ getting that revision number overwritten
|
||||
|
|
@ -45,7 +44,7 @@
|
|||
stored to CVS -->
|
||||
|
||||
<xsl:variable name="transform-rev1"
|
||||
select="substring( '$Revision: 1.7 $', 11)"/>
|
||||
select="substring( '$Revision: 1.8 $', 11)"/>
|
||||
<xsl:variable name="transform-revision"
|
||||
select="substring( $transform-rev1, 0, string-length( $transform-rev1) - 1)"/>
|
||||
|
||||
|
|
@ -65,18 +64,10 @@
|
|||
<xsl:template match="adl:entity">
|
||||
<xsl:variable name="keyfield">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$abstract-key-name-convention='Name'">
|
||||
<xsl:value-of select="@name"/>
|
||||
<xsl:when test="adl:key/adl:property">
|
||||
<xsl:value-of select="adl:key/adl:property[position()=1]/@name"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$abstract-key-name-convention = 'NameId'">
|
||||
<xsl:value-of select="concat( @name, 'Id')"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$abstract-key-name-convention = 'Name_Id'">
|
||||
<xsl:value-of select="concat( @name, '_Id')"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="'Id'"/>
|
||||
</xsl:otherwise>
|
||||
<xsl:otherwise>[none]</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
|
||||
|
|
@ -193,9 +184,10 @@
|
|||
${ScriptsHelper.InstallScript( "Sitewide")}
|
||||
${ScriptsHelper.InstallScript( "Behaviour")}
|
||||
${ScriptsHelper.InstallScript( "Epoch")}
|
||||
${ScriptsHelper.InstallScript( "Panes")}
|
||||
|
||||
<script type='text/javascript' language='JavaScript1.2'>
|
||||
var panes = new Array( <xsl:for-each select='fieldgroup'>
|
||||
var panes = new Array( <xsl:for-each select='adl:fieldgroup'>
|
||||
"<xsl:value-of select='@name'/>"<xsl:choose>
|
||||
<xsl:when test="position() = last()"/>
|
||||
<xsl:otherwise>,</xsl:otherwise>
|
||||
|
|
@ -250,7 +242,7 @@
|
|||
<script type="text/javascript" language='JavaScript1.2' src="../script/panes.js"></script>
|
||||
|
||||
<style type="text/css">
|
||||
<xsl:for-each select="../adl:property[@required='true']">
|
||||
<xsl:for-each select="ancestor::adl:entity//adl:property[@required='true']">
|
||||
#<xsl:value-of select="concat( 'advice-required-instance_', @name)"/>
|
||||
{
|
||||
color: white;
|
||||
|
|
@ -320,20 +312,7 @@
|
|||
<!-- there isn't a natural primary key; create a hidden widget
|
||||
for the abstract primary key -->
|
||||
<xsl:variable name="keyfield">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$abstract-key-name-convention='Name'">
|
||||
<xsl:value-of select="ancestor::adl:entity/@name"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$abstract-key-name-convention = 'NameId'">
|
||||
<xsl:value-of select="concat( ancestor::adl:entity/@name, 'Id')"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$abstract-key-name-convention = 'Name_Id'">
|
||||
<xsl:value-of select="concat( ancestor::adl:entity/@name, '_Id')"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="'Id'"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:value-of select="ancestor::adl:entity/adl:key/adl:property[position()=1]/@name"/>
|
||||
</xsl:variable>
|
||||
${FormHelper.HiddenField( "instance.<xsl:value-of select="$keyfield"/>")}
|
||||
</xsl:otherwise>
|
||||
|
|
@ -432,31 +411,39 @@
|
|||
|
||||
<xsl:template match="adl:auxlist">
|
||||
<xsl:variable name="listprop" select="@property"/>
|
||||
<xsl:variable name="farent" select="ancestor::entity/property[@name=$listprop]/@entity"/>
|
||||
<xsl:variable name="nearent" select="ancestor::entity/@name"/>
|
||||
<xsl:variable name="farent" select="ancestor::adl:entity//adl:property[@name=$listprop]/@entity"/>
|
||||
<xsl:variable name="nearent" select="ancestor::adl:entity/@name"/>
|
||||
<xsl:variable name="farid">
|
||||
<xsl:choose>
|
||||
<xsl:when test="//adl:entity[@name=$farent]/@natural-key">
|
||||
<xsl:value-of select="//adl:entity[@name=$farent]/@natural-key"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="concat( $farent, 'Id')"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:value-of select="//adl:entity[@name=$farent]/adl:key//adl:property[position()=1]/@name"/>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="farkey">
|
||||
<xsl:value-of select="//adl:entity[@name=$farent]/adl:property[@entity=$nearent]/@name"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="//adl:entity[@name=$farent]//adl:property[@entity=$nearent]/@farkey">
|
||||
<xsl:value-of select="//adl:entity[@name=$farent]//adl:property[@entity=$nearent]/@farkey"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="//adl:entity[@name=$farent]//adl:property[@entity=$nearent]/@name"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="nearkey">
|
||||
<xsl:choose>
|
||||
<xsl:when test="ancestor::adl:entity[@natural-key]">
|
||||
<xsl:value-of select="ancestor::adl:entity[@natural-key]"/>
|
||||
<xsl:when test="ancestor::adl:entity/adl:key/adl:property[position()=1 and @type='entity']">
|
||||
<xsl:value-of select="concat( ancestor::adl:entity/adl:key/adl:property[position()=1]/@name, '_Value')"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="concat( $nearent, 'Id')"/>
|
||||
<xsl:value-of select="ancestor::adl:entity/adl:key/adl:property[position()=1]/@name"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:comment>
|
||||
$listprop = <xsl:value-of select="$listprop"/>;
|
||||
$farent = <xsl:value-of select="$farent"/>;
|
||||
$nearent = <xsl:value-of select="$nearent"/>;
|
||||
$farid = <xsl:value-of select="$farid"/>;
|
||||
$farkey = <xsl:value-of select="$farkey"/>;
|
||||
$nearkey = <xsl:value-of select="$nearkey"/>;
|
||||
</xsl:comment>
|
||||
<xsl:variable name="action" select="concat( '../', $farent, '/', @onselect)"/>
|
||||
<xsl:if test="@canadd='true'">
|
||||
<tr>
|
||||
|
|
@ -482,7 +469,7 @@
|
|||
<!-- Getting the prompt for the field from a property of another entity is a bit
|
||||
complex... -->
|
||||
<xsl:call-template name="showprompt">
|
||||
<xsl:with-param name="node" select="//adl:entity[@name=$farent]/adl:property[@name=$fieldprop]"/>
|
||||
<xsl:with-param name="node" select="//adl:entity[@name=$farent]//adl:property[@name=$fieldprop]"/>
|
||||
<xsl:with-param name="fallback" select="@property"/>
|
||||
</xsl:call-template>
|
||||
</th>
|
||||
|
|
@ -502,15 +489,15 @@
|
|||
<xsl:variable name="fieldprop" select="@property"/>
|
||||
<td>
|
||||
<xsl:choose>
|
||||
<xsl:when test="//adl:entity[@name=$farent]/adl:property[@name=$fieldprop]/@type='entity'">
|
||||
<xsl:when test="//adl:entity[@name=$farent]//adl:property[@name=$fieldprop]/@type='entity'">
|
||||
#if ( $item.<xsl:value-of select="@property"/>)
|
||||
$item.<xsl:value-of select="@property"/>.UserIdentifier
|
||||
#end
|
||||
</xsl:when>
|
||||
<xsl:when test="//adl:entity[@name=$farent]/adl:property[@name=$fieldprop]/adl:option">
|
||||
<xsl:when test="//adl:entity[@name=$farent]//adl:property[@name=$fieldprop]/adl:option">
|
||||
<!-- if we can get a prompt value for the option, it would be better to
|
||||
show it than the raw value-->
|
||||
<xsl:for-each select="//adl:entity[@name=$farent]/adl:property[@name=$fieldprop]/adl:option">
|
||||
<xsl:for-each select="//adl:entity[@name=$farent]//adl:property[@name=$fieldprop]/adl:option">
|
||||
#if ( $item.<xsl:value-of select="$fieldprop"/> == '<xsl:value-of select="@value"/>')
|
||||
<xsl:call-template name="showprompt">
|
||||
<xsl:with-param name="fallback" select="@value"/>
|
||||
|
|
@ -536,10 +523,9 @@
|
|||
#end
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<!-- properties not listed, so therefore presumably all. TODO: This won't work, rewrite. Need to
|
||||
find the entity of the property this auxlist depends on, and then interrogate that -->
|
||||
<!-- properties not listed, so therefore presumably all. -->
|
||||
<tr>
|
||||
<xsl:for-each select="ancestor::adl:entity/adl:property[@distinct='user']">
|
||||
<xsl:for-each select="//adl:entity[@name=$farent]//adl:property[@distinct='user']">
|
||||
<th>
|
||||
<xsl:choose>
|
||||
<xsl:when test="adl:prompt[@locale=$locale]">
|
||||
|
|
@ -553,22 +539,43 @@
|
|||
</xsl:for-each>
|
||||
<th>-</th>
|
||||
</tr>
|
||||
#foreach( $instance in $instances)
|
||||
#foreach( $item in $instance.<xsl:value-of select="@property"/>)
|
||||
#if ( $velocityCount % 2 == 0)
|
||||
#set( $oddity = "even")
|
||||
#else
|
||||
#set( $oddity = "odd")
|
||||
#end
|
||||
<tr class="$oddity">
|
||||
<xsl:for-each select="ancestor::adl:entity/adl:property[@distinct='user']">
|
||||
<xsl:for-each select="//adl:entity[@name=$farent]//adl:property[@distinct='user']">
|
||||
<td>
|
||||
$!instance.<xsl:value-of select="@name"/>
|
||||
<xsl:variable name="fieldprop" select="@name"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="@type='entity'">
|
||||
#if ( $item.<xsl:value-of select="@name"/>)
|
||||
$item.<xsl:value-of select="@name"/>.UserIdentifier
|
||||
#end
|
||||
</xsl:when>
|
||||
<xsl:when test="adl:option">
|
||||
<!-- if we can get a prompt value for the option, it would be better to
|
||||
show it than the raw value-->
|
||||
<xsl:for-each select="adl:option">
|
||||
#if ( $item.<xsl:value-of select="$fieldprop"/> == '<xsl:value-of select="@value"/>')
|
||||
<xsl:call-template name="showprompt">
|
||||
<xsl:with-param name="fallback" select="@value"/>
|
||||
</xsl:call-template>
|
||||
#end
|
||||
</xsl:for-each>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
$!item.<xsl:value-of select="@name"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</td>
|
||||
</xsl:for-each>
|
||||
<td>
|
||||
<a>
|
||||
<xsl:attribute name="href">
|
||||
<xsl:value-of select="concat( $action, '.rails?', ../@name, 'Id=$instance.', ../@name, 'Id')"/>
|
||||
<xsl:value-of select="concat( $action, '.rails?', $farid, '=$item.', $farid)"/>
|
||||
</xsl:attribute>
|
||||
Edit!
|
||||
</a>
|
||||
|
|
@ -615,9 +622,9 @@
|
|||
<xsl:value-of select="@property"/>
|
||||
</xsl:variable>
|
||||
<xsl:choose>
|
||||
<xsl:when test="ancestor::adl:entity/adl:property[@name=$propname]">
|
||||
<xsl:when test="ancestor::adl:entity//adl:property[@name=$propname]">
|
||||
<!-- there is a real property -->
|
||||
<xsl:apply-templates select="ancestor::adl:entity/adl:property[@name=$propname]">
|
||||
<xsl:apply-templates select="ancestor::adl:entity//adl:property[@name=$propname]">
|
||||
<xsl:with-param name="oddness">
|
||||
<xsl:choose>
|
||||
<xsl:when test="position() mod 2 = 0">even</xsl:when>
|
||||
|
|
@ -628,7 +635,7 @@
|
|||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<!-- it's presumably intended to be a computed field -->
|
||||
Computed field (<xsl:value-of select="@name"/>)? TODO: Not yet implememented
|
||||
<xsl:comment>Computed field (<xsl:value-of select="$propname"/>)? TODO: Not yet implememented</xsl:comment>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
|
@ -792,14 +799,15 @@
|
|||
<xsl:variable name="permission">
|
||||
<xsl:choose>
|
||||
<xsl:when test="adl:permission">
|
||||
<xsl:value-of select="adl:permission[position()=1]/@permission"/>
|
||||
<xsl:value-of select="adl:permission[@group=$permissions-group]/@permission"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="../adl:permission">
|
||||
<xsl:value-of select="../adl:permission[position()=1]/@permission"/>
|
||||
<xsl:when test="ancestor::adl:entity/adl:permission">
|
||||
<xsl:value-of select="ancestor::adl:entity/adl:permission[@group=$permissions-group]/@permission"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>none</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:if test="$permission != 'none'">
|
||||
<tr>
|
||||
<xsl:attribute name="class">
|
||||
<xsl:value-of select="$oddness"/>
|
||||
|
|
@ -831,6 +839,7 @@
|
|||
is no current value, else a 'not authorised' message -->
|
||||
<!-- TODO: if $permission='noedit', then you should get an editable widget if there
|
||||
is no current value, else just the value -->
|
||||
<!-- TODO: if required='true', then you should not get the firstoption stuff -->
|
||||
<xsl:when test="@type='entity'">
|
||||
<!-- a menu of the appropriate entity -->
|
||||
#if ( $instance)
|
||||
|
|
@ -935,7 +944,7 @@
|
|||
</xsl:if>
|
||||
<!-- TODO: generate javascript to do client-side validation -->
|
||||
</xsl:when>
|
||||
<xsl:when test="option">
|
||||
<xsl:when test="adl:option">
|
||||
<!-- if a property has options, we definitely want a select widget-->
|
||||
<select>
|
||||
<xsl:attribute name="id">
|
||||
|
|
@ -947,7 +956,7 @@
|
|||
<xsl:attribute name="title">
|
||||
<xsl:value-of select="normalize-space( $if-missing)"/>
|
||||
</xsl:attribute>
|
||||
<xsl:apply-templates select="option"/>
|
||||
<xsl:apply-templates select="adl:option"/>
|
||||
</select>
|
||||
<script type="text/javascript" language="javascript">
|
||||
// <![CDATA[
|
||||
|
|
@ -995,6 +1004,7 @@
|
|||
<xsl:apply-templates select="adl:help[@locale = $locale]"/>
|
||||
</td>
|
||||
</tr>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="adl:prompt">
|
||||
|
|
@ -1122,7 +1132,7 @@
|
|||
<xsl:for-each select="adl:field">
|
||||
<th>
|
||||
<xsl:variable name="pname" select="@property"/>
|
||||
<xsl:variable name="property" select="ancestor::adl:entity/adl:property[@name=$pname]"/>
|
||||
<xsl:variable name="property" select="ancestor::adl:entity//adl:property[@name=$pname]"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$property/adl:prompt[@locale=$locale]">
|
||||
<xsl:value-of select="$property/adl:prompt[@locale=$locale]/@prompt"/>
|
||||
|
|
@ -1148,15 +1158,15 @@
|
|||
<td>
|
||||
<xsl:variable name="prop" select="@property"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="ancestor::adl:entity/adl:property[@name=$prop]/@type = 'date'">
|
||||
<xsl:when test="ancestor::adl:entity//adl:property[@name=$prop]/@type = 'date'">
|
||||
#if ( $instance.<xsl:value-of select="@property"/>)
|
||||
$instance.<xsl:value-of select="@property"/>.ToString( 'd')
|
||||
#end
|
||||
</xsl:when>
|
||||
<xsl:when test="ancestor::adl:entity/adl:property[@name=$prop]/@type='message'">
|
||||
<xsl:when test="ancestor::adl:entity//adl:property[@name=$prop]/@type='message'">
|
||||
$t.Msg( $instance.<xsl:value-of select="$prop"/>)
|
||||
</xsl:when>
|
||||
<xsl:when test="ancestor::adl:entity/adl:property[@name=$prop]/@type='entity'">
|
||||
<xsl:when test="ancestor::adl:entity//adl:property[@name=$prop]/@type='entity'">
|
||||
#if( $instance.<xsl:value-of select="$prop"/>)
|
||||
$instance.<xsl:value-of select="$prop"/>.UserIdentifier
|
||||
#end
|
||||
|
|
@ -1177,7 +1187,14 @@
|
|||
<xsl:otherwise>&</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:value-of select="concat( $sep, @name, '=$instance.', @name)"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="@type='entity'">
|
||||
<xsl:value-of select="concat( $sep, @name, '_Value=$instance.', @name, '_Value')"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="concat( $sep, @name, '=$instance.', @name)"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:for-each>
|
||||
</xsl:variable>
|
||||
<xsl:for-each select="ancestor::adl:entity/adl:form">
|
||||
|
|
@ -1198,7 +1215,7 @@
|
|||
<xsl:otherwise>
|
||||
<!-- properties are not 'listed' -->
|
||||
<tr>
|
||||
<xsl:for-each select="ancestor::adl:entity/adl:property[@distinct='user']">
|
||||
<xsl:for-each select="ancestor::adl:entity//adl:property[@distinct='user' and not( @type='link' or @type='list')]">
|
||||
<th>
|
||||
<xsl:choose>
|
||||
<xsl:when test="adl:prompt[@locale=$locale]">
|
||||
|
|
@ -1221,7 +1238,7 @@
|
|||
#set( $oddity = "odd")
|
||||
#end
|
||||
<tr class="$oddity">
|
||||
<xsl:for-each select="ancestor::adl:entity/adl:property[@distinct='user']">
|
||||
<xsl:for-each select="ancestor::adl:entity//adl:property[@distinct='user']">
|
||||
<td>
|
||||
<xsl:choose>
|
||||
<xsl:when test="@type='entity'">
|
||||
|
|
@ -1245,7 +1262,14 @@
|
|||
<xsl:otherwise>&</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:value-of select="concat( $sep, @name, '=$instance.', @name)"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="@type='entity'">
|
||||
<xsl:value-of select="concat( $sep, @name, '_Value=$instance.', @name, '_Value')"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="concat( $sep, @name, '=$instance.', @name)"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:for-each>
|
||||
</xsl:variable>
|
||||
<xsl:for-each select="ancestor::adl:entity/adl:form">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue