Преглед на файлове

HPCC-17982 DynamicESDL: Forms should indicate visible optional fields

- Change esxdl2xsd.xslt file to include the optional attribute in the
  generated xsd.
- Change gen_form.xsl to add value of the optional next to the field
  name in the generated html form.

Signed-off-by: mayx <yanrui.ma@lexisnexisrisk.com>
mayx преди 8 години
родител
ревизия
7e4ba39167
променени са 2 файла, в които са добавени 21 реда и са изтрити 1 реда
  1. 4 1
      esp/xslt/esxdl2xsd.xslt
  2. 17 0
      esp/xslt/gen_form.xsl

+ 4 - 1
esp/xslt/esxdl2xsd.xslt

@@ -165,7 +165,7 @@
                 </xsl:attribute>
             </xsl:if>
             <xsl:if test="boolean($all_annot_Param)">
-                <xsl:if test="@html_head or @form_ui or @collapsed or @cols or @rows">
+                <xsl:if test="@html_head or @form_ui or @collapsed or @cols or @rows or @optional">
                     <xsd:annotation>
                         <xsd:appinfo>
                             <form>
@@ -189,6 +189,9 @@
                                 <xsl:if test="@rows">
                                     <xsl:attribute name="formRows"><xsl:value-of select="@rows"/></xsl:attribute>
                                 </xsl:if>
+                                <xsl:if test="@optional">
+                                    <xsl:attribute name="optional"><xsl:value-of select="@optional"/></xsl:attribute>
+                                </xsl:if>
                             </form>
                         </xsd:appinfo>
                     </xsd:annotation>

+ 17 - 0
esp/xslt/gen_form.xsl

@@ -768,6 +768,7 @@
             <xsl:with-param name="inputCtrlHtml" select="$inputCtrlHtml"/>
             <xsl:with-param name="isAttr" select="name($node)='xsd:attribute'"/>
             <xsl:with-param name="isBool" select="$node/@type='xsd:boolean'"/>
+            <xsl:with-param name="optional" select="$node/xsd:annotation/xsd:appinfo/form/@optional | $node/xsd:annotation/xsd:appinfo/xsd:form/@optional"/>
         </xsl:call-template>
     </xsl:template >
     
@@ -781,6 +782,7 @@
         <xsl:param name="inputCtrlHtml" select="''"/>
         <xsl:param name="isAttr" select="false()"/>
         <xsl:param name="isBool" select="false()"/>
+        <xsl:param name="optional" select="''"/>
 
         <!--    <xsl:if test="$verbose"><xsl:value-of select="concat('GenOneInputCtrlHtmlRaw(parentId=', $parentId, ', fieldId=', $fieldId, ', ui=', $ui, ', inputCtrlHtml=', $inputCtrlHtml, ')&lt;br/&gt;') "/> </xsl:if> -->     
 
@@ -824,6 +826,9 @@
                                 <xsl:text disable-output-escaping="yes"><![CDATA['> <b>]]></xsl:text>
                 <xsl:value-of select="$fieldName"/>
                 <xsl:text disable-output-escaping="yes"><![CDATA[</b>]]></xsl:text>
+                <xsl:call-template name="showOptionalSupscript">
+                    <xsl:with-param name="optional" select="$optional"/>
+                </xsl:call-template>
                 <xsl:value-of select="$ctrlId"/>
                 <xsl:choose>
                     <xsl:when test="$isBool">
@@ -844,6 +849,9 @@
                 <xsl:value-of select="$fieldName"/>
                 <xsl:if test="$isAttr"><![CDATA[</i>]]></xsl:if>
                 <xsl:text disable-output-escaping="yes"><![CDATA[</b></span>]]></xsl:text>
+                <xsl:call-template name="showOptionalSupscript">
+                    <xsl:with-param name="optional" select="$optional"/>
+                </xsl:call-template>
                 <xsl:value-of select="$ctrlId"/>
                 <xsl:choose>
                     <xsl:when test="$isBool">
@@ -1464,6 +1472,15 @@
             </xsl:otherwise>
         </xsl:choose>
     </xsl:template>
+    <xsl:template name="showOptionalSupscript">
+      <xsl:param name="optional" select="''"/>
+      <!-- optional starts with _ is deeemed as implementation specific and don't show it -->
+      <xsl:if test="$optional and substring($optional,1,1)!='_' and substring($optional,1,2)!='!_'">
+        <xsl:text><![CDATA[<sup style='color:red'>]]></xsl:text>
+        <xsl:value-of select="$optional"/>
+        <xsl:text><![CDATA[</sup>]]></xsl:text>
+      </xsl:if>
+    </xsl:template>
 </xsl:stylesheet>