<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:eat="http://msqr.us/xsd/ieat"
	xmlns:xweb="http://msqr.us/xsd/jaxb-web"
	exclude-result-prefixes="eat xweb">
	
    <!-- imports -->
	<xsl:import href="tmpl/default-layout.xsl"/>
	
	<!-- layout variables -->
	<xsl:variable name="layout.global.nav.page" select="'admin-home'"/>
	
	<!-- helper vars -->
	<xsl:variable name="ingredient" select="xweb:x-data/xweb:x-model/eat:edit/eat:ingredient"/>
	<xsl:variable name="is-new" select="boolean($ingredient/@ingredientId)"/>

	<xsl:template match="xweb:x-data" mode="page-title">
		<xsl:choose>
			<xsl:when test="$is-new = 'false'">
				<xsl:value-of select="key('i18n','edit-ingredient.edit.validate.title')"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="key('i18n','edit-ingredient.create.validate.title')"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	
	<xsl:template match="xweb:x-data" mode="page-global-nav"/>
	
	<xsl:template match="xweb:x-data" mode="page-body">
		<div class="intro">
			<xsl:choose>
				<xsl:when test="$is-new = 'false'">
					<xsl:value-of select="key('i18n','edit-ingredient.edit.validate.intro')" 
						disable-output-escaping="yes"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="key('i18n','edit-ingredient.create.validate.intro')" 
						disable-output-escaping="yes"/>
				</xsl:otherwise>
			</xsl:choose>
		</div>
		
		<xsl:apply-templates select="$ingredient" mode="validate"/>
		
		<form method="post" action="{$web-context}{$ctx/xweb:path}">
			<input type="submit" name="_finish" value="{key('i18n','save.displayName')}"/>
			<xsl:text> </xsl:text>
			<input type="submit" name="_target0" value="{key('i18n','reedit.displayName')}"/>
		</form>
	</xsl:template>

    <xsl:template match="eat:ingredient" mode="validate">
    	<div class="ingredient-view">
			<table class="view">
				<tr>
					<th><xsl:value-of select="key('i18n','name.displayName')"/>:</th>
					<td><xsl:value-of select="eat:name"/></td>
				</tr>
				<tr>
					<th><xsl:value-of select="key('i18n','description.displayName')"/>:</th>
					<td><xsl:value-of select="eat:description"/></td>
				</tr>
			</table>
		</div>
    </xsl:template>

</xsl:stylesheet>
