<metal:block use-macro="container/macro_normal_view/macros/normal_view"
  xmlns:i18n="http://xml.zope.org/namespaces/i18n"
  i18n:domain="silva_document">
  <metal:block fill-slot="node_content"
    tal:define="source here/get_source | nothing;"
    >
    <tal:block tal:condition="not:source">
      <div class="warning"><strong>[<tal:block i18n:translate="">external source element is broken</tal:block>]</strong>
    </tal:block>
    <tal:block tal:condition="source">
    <div class="csvsource">
    <div>
        <h3 class="front5" tal:content="source/meta_type">external source</h3>
        <tal:block i18n:translate="">id:</tal:block>&nbsp;<tal:block content="source/id" />
        <br />
        <span tal:condition='source/get_title'><tal:block i18n:translate="">title:</tal:block>&nbsp;
          <tal:block content="source/get_title" /> <br />
        </span>
        <span tal:condition='source/description'><tal:block i18n:translate="">description:</tal:block>
         <tal:block tal:content="source/description" />
        </span>
      </div>
      <h1></h1>    
      <div
        tal:define="
          form source/form | nothing;
          fields form/get_fields | nothing;
          has_parameters python: form and fields;
          current_parameters here/get_parameters;
          "
        >
        <strong tal:condition="not: has_parameters" i18n:translate="">
          No parameters to be filled for this source.
        </strong>
        <table cellspacing="0" cellpadding="2" border="0" class="csvtable"
          tal:condition="has_parameters"
          >
          <thead>
            <tr>
              <th colspan="3">
                <strong i18n:translate="">Source parameters</strong>
              </th>
            </tr>
          </thead>
          <tbody>
            <tal:block repeat="field fields">
              <tr 
                tal:define="
                  iterate repeat/field/odd;
                  id field/id;
                  title python: field.get_value('title') or nothing;
                  description python: field.get_value('description') or nothing;
                  is_required field/is_required | nothing;
                  current_value current_parameters/?id | nothing;
                  "
                tal:attributes="class python: iterate and 'odd' or 'even'"
                >
                <td class="align-right">
                  <span tal:replace="structure title">
                    title
                  </span><span class="warning" tal:condition="is_required">*</span>
                </td>
                <td tal:content="structure python: current_value and field.render_view(value=current_value) or ''" />
              </tr>
            </tal:block>
          </tbody>
        </table>
      </div>    
    </div>
    </tal:block>
  </metal:block>
</metal:block>
