1<#-- $This file is distributed under the terms of the license in LICENSE$ -->

<#-- Template for adding a new individual from the Site Admin page: VIVO version -->

<#import "lib-vivo-form.ftl" as lvf>

<#--Retrieve certain edit configuration information-->
<#assign typeName = editConfiguration.pageData.typeName />
<#assign isCompilationType = editConfiguration.pageData.isCompilationType />

<#--Get existing value for specific data literals and uris-->
<#assign newCompilationLabel = lvf.getFormFieldValue(editSubmission, editConfiguration, "newCompilationLabel")/>
<#assign excerptsCounter = editConfiguration.pageData.excerptsCounter/>



<#--If edit submission exists, then retrieve validation errors if they exist-->
<#if editSubmission?has_content && editSubmission.submissionExists = true && editSubmission.validationErrors?has_content>
	<#assign submissionErrors = editSubmission.validationErrors/>
</#if>


<h2>${i18n().create_new} ${typeName}</h2>


<#if submissionErrors?has_content >
    <section id="error-alert" role="alert">
        <img src="${urls.images}/iconAlert.png" width="24" height="24" alert="${i18n().error_alert_icon}" />
        <p>
        <#list submissionErrors?keys as errorFieldName>
    	    <#if errorFieldName == "firstName">
    	        ${i18n().enter_first_name}
    	    <#elseif  errorFieldName == "lastName">
    	        ${i18n().enter_last_name}
        	<#elseif  errorFieldName == "label">
        	    ${i18n().enter_a_name}
    	    </#if>
    	    <br />
    	</#list>
        </p>
    </section>
</#if>

<#assign requiredHint = "<span class='requiredHint'> *</span>" />

<section id="newCompilation" role="region">

    <form id="newCompilation" class="customForm noIE67" action="${submitUrl}"  role="add new individual" method="POST">

    <#if isCompilationType = "true">
      <p>
        <label for="newCompilationLabel">${i18n().name_capitalized} ${requiredHint}</label>
        <input size="30"  type="text" id="newCompilationLabel" name="newCompilationLabel" value="${newCompilationLabel}" />
      </p>
      <#if excerptsCounter &gt; 0 >  
	      <#list 1..excerptsCounter as i>
	        <p>
	          <label for="tocItem${i}Name">TOC Item ${i} name ${requiredHint}</label>
	          <input size="30"  type="text" id="tocItem${i}Name" name="tocItem${i}Name" value="" />
	        </p>
	        <p>
	          <label for="tocLevel${i}Name">TOC Level ${i} name ${requiredHint}</label>
	          <input size="30"  type="text" id="tocLevel${i}Name" name="tocLevel${i}Name" value="" />
	        </p>
	        <p>
	          <label for="excerpt${i}">Excerpt ${i} URI ${requiredHint}</label>
	          <input size="30"  type="text" id="excerpt${i}" name="excerpt${i}" value="" />
	        </p>
	      </#list>
      </#if>
      <p>
        <label for="rawQueryString">Search query</label>
        <input size="30"  type="text" id="rawQueryString" name="rawQueryString" value="" />
      </p>
      <p>
        <label for="queryBuilderRules">Query builder rules </label>
        <input size="30"  type="text" id="queryBuilderRules" name="queryBuilderRules" value="" />
      </p>
    <#else>
	  <p>
        <label for="newCompilationLabel">${i18n().name_capitalized} ${requiredHint}</label>
        <input size="30"  type="text" id="firstName" name="firstName" value="${newCompilationLabel}" />
      </p>
    </#if>

    <p class="submit">
        <input type="hidden" name = "editKey" value="${editKey}"/>
        <input type="submit" id="submit" value="${i18n().create_capitalized} ${typeName}"/>
        <span class="or"> ${i18n().or} </span><a class="cancel" href="${urls.base}/siteAdmin" title="${i18n().cancel_title}">${i18n().cancel_link}</a>
    </p>

    <p id="requiredLegend" class="requiredHint">* ${i18n().required_fields}</p>

    </form>
</section>

${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customForm.css" />')}
${scripts.add('<script type="text/javascript" src="${urls.base}/templates/freemarker/edit/forms/js/newIndividualFormUtils.js"></script>')}
