edit-ingredient.xsl 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?xml version="1.0"?>
  2. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns:eat="http://msqr.us/xsd/ieat"
  4. xmlns:xweb="http://msqr.us/xsd/jaxb-web"
  5. exclude-result-prefixes="eat xweb">
  6. <!-- imports -->
  7. <xsl:import href="tmpl/default-layout.xsl"/>
  8. <!-- layout variables -->
  9. <xsl:variable name="layout.global.nav.page" select="''"/>
  10. <!-- helper vars -->
  11. <xsl:variable name="ingredient" select="xweb:x-data/xweb:x-model/eat:edit/eat:ingredient"/>
  12. <xsl:variable name="is-new" select="boolean($ingredient/@ingredientId)"/>
  13. <xsl:template match="xweb:x-data" mode="page-title">
  14. <xsl:choose>
  15. <xsl:when test="$is-new = 'false'">
  16. <xsl:value-of select="key('i18n','edit-ingredient.edit.title')"/>
  17. </xsl:when>
  18. <xsl:otherwise>
  19. <xsl:value-of select="key('i18n','edit-ingredient.create.title')"/>
  20. </xsl:otherwise>
  21. </xsl:choose>
  22. </xsl:template>
  23. <xsl:template match="xweb:x-data" mode="page-global-nav"/>
  24. <xsl:template match="xweb:x-data" mode="page-head-content">
  25. <script type="text/javascript" src="{$web-context}/js/jquery-1.3.2.js" xml:space="preserve"> </script>
  26. <script type="text/javascript" src="{$web-context}/js/xweb-locale.js" xml:space="preserve"> </script>
  27. <script type="text/javascript" src="{$web-context}/js/ieat-util.js" xml:space="preserve"> </script>
  28. <script type="text/javascript" src="{$web-context}/js/edit-recipe.js" xml:space="preserve"> </script>
  29. </xsl:template>
  30. <xsl:template match="xweb:x-data" mode="page-body">
  31. <div class="intro">
  32. <xsl:choose>
  33. <xsl:when test="$is-new = 'false'">
  34. <xsl:value-of select="key('i18n','edit-ingredient.edit.intro')"/>
  35. </xsl:when>
  36. <xsl:otherwise>
  37. <xsl:value-of select="key('i18n','edit-ingredient.create.intro')"/>
  38. </xsl:otherwise>
  39. </xsl:choose>
  40. </div>
  41. <form method="post" action="{$web-context}{$ctx/xweb:path}">
  42. <input type="hidden" name="ignoreWarnings" value="false"/>
  43. <xsl:if test="$is-new = 'false'">
  44. <input type="hidden" name="ingredient.ingredientId" value="{$ingredient/@ingredientId}"/>
  45. </xsl:if>
  46. <table class="form">
  47. <tr>
  48. <th>
  49. <xsl:if test="$err[@field='ingredient.name']">
  50. <xsl:attribute name="class">error</xsl:attribute>
  51. </xsl:if>
  52. <xsl:value-of select="key('i18n','name.displayName')"/>
  53. </th>
  54. <td colspan="3">
  55. <input type="text" name="ingredient.name" value="{$ingredient/eat:name}"/>
  56. </td>
  57. </tr>
  58. <tr>
  59. <th>
  60. <xsl:if test="$err[@field='ingredient.description']">
  61. <xsl:attribute name="class">error</xsl:attribute>
  62. </xsl:if>
  63. <xsl:value-of select="key('i18n','description.displayName')"/>
  64. </th>
  65. <td colspan="3">
  66. <input type="text" name="ingredient.description"
  67. value="{$ingredient/eat:description}"/>
  68. </td>
  69. </tr>
  70. <xsl:if test="xweb:x-model/eat:edit/@ignoreWarnings = 'true' and $err[@field='ingredient.name']">
  71. <tr>
  72. <th>
  73. <xsl:value-of select="key('i18n','ingredient.ignoreWarnings.displayName')"/>
  74. </th>
  75. <td>
  76. <input type="checkbox" onclick="handleChangeIgnoreWarnings(this)"/>
  77. <xsl:text> </xsl:text>
  78. <span class="caption">
  79. <xsl:value-of select="key('i18n','edit-ingredient.ignoreWarnings.caption')"/>
  80. </span>
  81. </td>
  82. </tr>
  83. </xsl:if>
  84. <tr>
  85. <th/>
  86. <td>
  87. <input type="submit" name="_target1" value="{key('i18n','continue.displayName')}"/>
  88. <xsl:text> </xsl:text>
  89. <input type="submit" name="_cancel" value="{key('i18n','cancel.displayName')}"/>
  90. </td>
  91. </tr>
  92. </table>
  93. </form>
  94. <script type="text/javascript" xml:space="preserve">
  95. <xsl:comment>
  96. document.forms[0].elements['ingredient.name'].focus();
  97. //</xsl:comment>
  98. </script>
  99. </xsl:template>
  100. <xsl:template match="eat:ui/eat:ingredient">
  101. <option value="{@ingredientId}">
  102. <xsl:value-of select="."/>
  103. </option>
  104. </xsl:template>
  105. </xsl:stylesheet>