bug 1943: Shuffle widget for properties of type list now allowing /inclusion/; semantics for /exclusion/ are not so obvious, and perhaps this option should be

greyed. Shuffle widget for properties of type link may be broken, must be tested.
This commit is contained in:
sb 2008-06-04 16:17:31 +00:00
parent 5b09885eb8
commit f9fd11c101
3 changed files with 78 additions and 49 deletions

View file

@ -13,7 +13,7 @@
<!-- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
<!--
$Revision: 1.15 $
$Revision: 1.16 $
-->
<!-- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
@ -104,11 +104,11 @@ that we can allow HTML block level entities within content elements -->
<!--
data types which are more complex than SimpleDataTypes...
entity : a foreign key link to another entity (i.e. the 'many' end of a
one-to-many link);
list : a list of some other entity that links to me (i.e. the 'one' end of
a one-to-many link);
one-to-many link);
list : a list of some other entity that links to me (i.e. the 'one' end of
a one-to-many link);
link : a many to many link (via a link table);
defined : a type defined by a typedef.
defined : a type defined by a typedef.
-->
<!ENTITY % ComplexDataTypes "entity|link|list|defined" >

View file

@ -9,8 +9,8 @@
Transform ADL into (partial) controller classes
$Author: sb $
$Revision: 1.8 $
$Date: 2008-06-03 16:09:07 $
$Revision: 1.9 $
$Date: 2008-06-04 16:17:39 $
-->
<!-- WARNING WARNING WARNING: Do NOT reformat this file!
@ -72,7 +72,7 @@
//
// Automatically generated abstract super class for controllers for the
// <xsl:value-of select="/adl:application/@name"/> application; generated using
// adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.8 $', 10)"/>
// adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.9 $', 10)"/>
//
// This file is automatically generated; DO NOT EDIT IT.
//
@ -135,7 +135,7 @@ namespace <xsl:value-of select="$controllerns"/> {
//
// Controller for auto-generated forms for editing <xsl:value-of select="@name"/>s
// Automatically generated from application description using
// adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.8 $', 10)"/>
// adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.9 $', 10)"/>
//
// This file is automatically generated; DO NOT EDIT IT.
//
@ -416,6 +416,25 @@ namespace <xsl:value-of select="$controllerns"/> {
</xsl:for-each>
<xsl:for-each select="descendant::adl:property[@type='list']">
<xsl:variable name="farentityname" select="@entity"/>
<xsl:variable name="farkey" select="//adl:entity[@name=$farentityname]/adl:key/adl:property[position()=1]/@name"/>
<xsl:variable name="farkeybasetype">
<xsl:call-template name="base-type">
<xsl:with-param name="property" select="//adl:entity[@name=$farentityname]/adl:key/adl:property[position()=1]"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="foreignkey">
<xsl:choose>
<xsl:when test="@farkey">
<xsl:value-of select="@farkey"/>
</xsl:when>
<xsl:otherwise>
<!-- If I haven't been told what the far side foreign key is, assume it has the
name of my entity -->
<xsl:value-of select="ancestor::adl:entity/@name"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
/* with a list we cannot just smash the old values! Instead we need to check
* each one and exclude it if no longer required */
if ( Form.GetValues( "<xsl:value-of select="concat( 'instance.', @name)"/>") != null)
@ -440,21 +459,46 @@ namespace <xsl:value-of select="$controllerns"/> {
if ( ! found)
{
record.<xsl:value-of select="@name"/>.Remove( item);
break;
}
} /* foreach ( <xsl:value-of select="@entity"/> item ... */
/* then add any on the included list which are not already members */
foreach ( string index in <xsl:value-of select="concat(@name, 'Values')"/>)
{
<xsl:variable name="entityname" select="@entity"/>
<xsl:value-of select="@entity"/> item =
<xsl:value-of select="concat( $entityns, '.', @entity)"/> item =
hibernator.CreateCriteria(typeof(<xsl:value-of select="@entity"/>))
.Add(Expression.Eq("<xsl:value-of select="@entity"/>Id", index))
.UniqueResult&lt;<xsl:value-of select="$entityns"/>.<xsl:value-of select="@entity"/>&gt;();
.Add(Expression.Eq("<xsl:value-of select="$farkey"/>", <xsl:choose>
<xsl:when test="$farkeybasetype = 'string'">
index
</xsl:when>
<xsl:when test="$farkeybasetype = 'integer'">
Int32.Parse( index)
</xsl:when>
<xsl:otherwise>
<xsl:message terminate="yes">
ADL: Error: keys of type <xsl:value-of select="$farkeybasetype"/> cannot yet be used
in lists
</xsl:message>
</xsl:otherwise>
</xsl:choose>))
.UniqueResult&lt;<xsl:value-of select="concat( $entityns, '.', @entity)"/>&gt;();
if ( ! record.<xsl:value-of select="@name"/>.Contains( item))
{
/* check whether it's already a child of another <xsl:value-of select="ancestor::adl:entity/@name"/>
* and, if it is, remove it */
<xsl:value-of select="concat( $entityns, '.', ancestor::adl:entity/@name)"/> oldparent =
<xsl:value-of select="concat( 'item.', $foreignkey)"/>;
if ( oldparent != null) {
oldparent.<xsl:value-of select="@name"/>.Remove( item);
hibernator.Save( oldparent);
}
/* then add it to my <xsl:value-of select="@name"/> */
record.<xsl:value-of select="@name"/>.Add( item);
<xsl:value-of select="concat( 'item.', $foreignkey)"/> = record;
hibernator.Save( item);
}
} /* foreach ( string index... */
} /* if ( Form.GetValues( "<xsl:value-of select="concat( 'instance.', @name)"/>") != null) */

View file

@ -13,8 +13,8 @@
Transform ADL into velocity view templates
$Author: sb $
$Revision: 1.5 $
$Date: 2008-06-03 16:09:11 $
$Revision: 1.6 $
$Date: 2008-06-04 16:17:39 $
-->
<!-- WARNING WARNING WARNING: Do NOT reformat this file!
Whitespace (or lack of it) is significant! -->
@ -124,7 +124,7 @@
Auto generated Velocity maybe-delete form for <xsl:value-of select="@name"/>,
generated from ADL.
Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.5 $', 10)"/>
Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.6 $', 10)"/>
</xsl:comment>
<xsl:call-template name="maybe-delete">
<xsl:with-param name="entity" select="."/>
@ -162,7 +162,7 @@
Auto generated Velocity maybe-delete form for <xsl:value-of select="@name"/>,
generated from ADL.
Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.5 $', 10)"/>
Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.6 $', 10)"/>
</xsl:comment>
<xsl:call-template name="install-scripts"/>
</head>
@ -243,7 +243,7 @@
Auto generated Velocity <xsl:value-of select="@name"/> form for <xsl:value-of select="ancestor::adl:entity/@name"/>,
generated from ADL.
Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.5 $', 10)"/>
Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.6 $', 10)"/>
</xsl:comment>
#capturefor( title)
#if ( $instance)
@ -261,8 +261,18 @@
function performInitialisation()
{
<xsl:for-each select="../adl:property[@type='link']">
<xsl:for-each select="../adl:property[@type='link' or @type='list']">
<xsl:variable name="propname" select="@name"/>
<xsl:choose>
<xsl:when test="not( @properties='listed')">
document.<xsl:value-of select="$formname"/>.<xsl:value-of select="@name"/>.submitHandler = shuffleSubmitHandler;
</xsl:when>
<xsl:when test=".//field[@property=$propname]">
document.<xsl:value-of select="$formname"/>.<xsl:value-of select="@name"/>.submitHandler = shuffleSubmitHandler;
</xsl:when>
<!-- if we're not doing all properties, and if this property is not the property of a field,
we /don't/ set up a submit handler. -->
</xsl:choose>
</xsl:for-each>
<xsl:if test="fieldgroup">
switchtab( '<xsl:value-of select="fieldgroup[1]/@name"/>');
@ -354,7 +364,7 @@
Auto generated Velocity form for <xsl:value-of select="ancestor::adl:entity/@name"/>,
generated from ADL.
Generated using adl2views.xsl <xsl:value-of select="substring( '$Revision: 1.5 $', 10)"/>
Generated using adl2views.xsl <xsl:value-of select="substring( '$Revision: 1.6 $', 10)"/>
</xsl:comment>
<xsl:call-template name="install-scripts"/>
<script type='text/javascript' language='JavaScript1.2'>
@ -363,7 +373,7 @@
function performInitialisation()
{
<xsl:for-each select="../property[@type='link']">
<xsl:for-each select="../property[@type='link' or @type='list']">
document.<xsl:value-of select="$formname"/>.<xsl:value-of select="@name"/>.submitHandler = shuffleSubmitHandler;
</xsl:for-each>
var validator = new Validation('<xsl:value-of select="$formname"/>', {immediate : true, useTitles : true});
@ -475,7 +485,7 @@
<xsl:for-each select="$form/ancestor::adl:entity/adl:key/adl:property">
<xsl:variable name="keyname" select="@name"/>
<xsl:choose>
<xsl:when test="$form/adl:field[@property=$keyname]">
<xsl:when test="$form//adl:field[@property=$keyname]">
<!-- it's already a field of the form - no need to add a hidden one -->
</xsl:when>
<xsl:otherwise>
@ -486,31 +496,6 @@
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
<xsl:if test="$form/adl:fieldgroup">
<!-- div id="tabbar">
<xsl:for-each select="$form/adl:fieldgroup">
<span class="tab">
<xsl:attribute name="id">
<xsl:value-of select="concat( @name, 'tab')"/>
</xsl:attribute>
<a>
<xsl:attribute name="href">
<xsl:value-of select="concat( '#', @name, 'anchor')"/>
</xsl:attribute>
<xsl:attribute name="onclick">
switchtab( '<xsl:value-of select="@name"/>'); return false;
</xsl:attribute>
<xsl:call-template name="showprompt">
<xsl:with-param name="node" select="."/>
<xsl:with-param name="fallback" select="@name"/>
<xsl:with-param name="entity" select="$form/ancestor::adl:entity"/>
<xsl:with-param name="locale" select="$locale"/>
</xsl:call-template>
</a>
</span>
</xsl:for-each>
</div -->
</xsl:if>
<xsl:apply-templates select="$form/adl:fieldgroup"/>
<div class="non-pane">
<table>
@ -966,7 +951,7 @@
Auto generated Velocity list for <xsl:value-of select="@name"/>,
generated from ADL.
Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.5 $', 10)"/>
Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.6 $', 10)"/>
</xsl:comment>
#capturefor( title)
@ -1005,7 +990,7 @@
Auto generated Velocity list for <xsl:value-of select="ancestor::adl:entity/@name"/>,
generated from ADL.
Generated using adl2listview.xsl <xsl:value-of select="substring( '$Revision: 1.5 $', 10)"/>
Generated using adl2listview.xsl <xsl:value-of select="substring( '$Revision: 1.6 $', 10)"/>
</xsl:comment>
<xsl:call-template name="install-scripts"/>
</head>