<?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"/>
	<xsl:import href="tmpl/display-meal.xsl"/>
	
	<!-- layout variables -->
	<xsl:variable name="layout.global.nav.page" select="'admin-home'"/>
	
	<!-- helper vars -->
	<xsl:variable name="meal" select="xweb:x-data/xweb:x-model/eat:edit/eat:meal"/>
	<xsl:variable name="is-new" select="not(boolean($meal/@mealId))"/>

	<xsl:template match="xweb:x-data" mode="page-title">
		<xsl:choose>
			<xsl:when test="$is-new = 'true'">
				<xsl:value-of select="key('i18n','edit-meal.create.validate.title')"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="key('i18n','edit-meal.edit.validate.title')"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template match="xweb:x-data" mode="page-body">
		<div class="intro">
			<xsl:choose>
				<xsl:when test="$is-new = 'true'">
		            <xsl:value-of select="key('i18n','edit-meal.create.intro')"/>
				</xsl:when>
				<xsl:otherwise>
		            <xsl:value-of select="key('i18n','edit-meal.edit.intro')"/>
				</xsl:otherwise>
			</xsl:choose>
		</div>

		<xsl:apply-templates select="$meal" mode="display"/>
		
		<br/>
		
		<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:stylesheet>
