<%# locals: { persons } %>
<% meta = meta_fragment.data %>
<% contact = meta_fragment.contact %>
<% dmpID = meta["dmpID"] %>
<% licence = meta["licence"] %>

<div class="form-group"><!-- title -->
  <div class="col-md-12">
    <%= f.label(:title, _('Plan title'), class: 'control-label') %>
  </div>
  <div class="col-md-10">
    <%= f.text_field(:title, class: "form-control", "aria-required": true,
         'data-toggle': 'tooltip', spellcheck: true) %>
    <div class="checkbox">
      <%= f.hidden_field :visibility %>
      <%= f.label(:is_test, class: 'control-label') do %>
        <%= check_box_tag(:is_test, 1, @plan.is_test?, "aria-label": "is_test") %>
        <%= _('mock plan for testing, practice, or educational purposes') %>
      <% end %>
    </div>
  </div>
</div>
<div class="form-group"><!-- plan description -->
  <div class="col-md-12">
    <%= f.label(:description, _('Plan abstract'), class: 'control-label') %>
  </div>
  <div class="col-md-10" data-toggle="tooltip">
    <%= f.text_area(
          :description, rows: 6,
          class: 'form-control tinymce',
          "aria-required": false) %>
  </div>
</div>
<div class="form-group"><!-- dmpLanguage -->
    <%= create_text_field(
          f, 
          @plan.template.locale, 
          "dmpLanguage", 
          _('Language'),
          readonly: true
        ) 
    %>
</div>
<fieldset class="project-details"> <!-- DMP ID -->
  <legend class="project-details"><%= _('DMP ID') %></legend>
  <div class="form-group"><!-- Identifier Type -->
    <%= create_select_field(
          f, 
          dmpID ? dmpID["idType"] : "DOI",
          "plan[dmpID[idType]]", 
          _('Identifier Type'),
          ["DOI", "HANDLE", "ARK", "URL"]
        ) 
    %>
  </div>
  <div class="form-group"><!-- identifier -->
    <%= create_text_field(
          f, 
          dmpID ? dmpID["value"] : nil,  
          "dmpID[value]", 
          _('ID')
        ) 
    %>
  </div>
</fieldset>

<fieldset class="project-details"> <!-- Version -->
  <legend class="project-details"><%= _('Version') %></legend>
  <div class="form-group"><!-- versionNumber -->
    <%= create_text_field(
          f, 
          meta["versionNumber"],
          "versionNumber", 
          _('Number')
        ) 
    %>
  </div>
  <div class="form-group"><!-- versionNotes -->
    <%= create_text_field(
          f,
          meta["versionNotes"],
          "versionNotes", 
          _('Notes')
        ) 
    %>
  </div>
</fieldset>
<!-- TODO : IMPLEMENT MULTIPLE -->
<div class="form-group"><!-- relatedDocUrl -->
    <%= render(partial: 'shared/dynamic_form/fields/simple_multiple_field', locals: { 
      f: f, 
      field_values: meta["relatedDocUrl"],
      readonly: false,
      field_label: _('Related Documentation URL'),
      field_properties: {
        "type" => "string",
        "format" => "uri"
      },
      field_name: "relatedDocUrl", answer_id: nil 
      })
    %>
</div>
<!-- TODO : IMPLEMENT MULTIPLE -->
<div class="form-group"><!-- associatedDMPId -->
    <%= create_text_field(
          f, 
          meta["associatedDMPId"], 
          "associatedDMPId", 
          _('Associated DMPs')
        ) 
    %>
</div>

<%= render(partial: 'shared/fragments/person_fragment_form', locals: {
            f: f,
            legend: _('Data contact person'),
            person: contact ? contact.data : nil,
            person_id: contact ? contact.id : nil,
            person_list: persons,
            plan: @plan,
            fragment_name: "contact"
      }) %>

<fieldset class="project-details">
  <legend class="project-details"><%= _("Licence") %></legend>
  <div class="form-group"><!-- licenseName -->
    <%= create_text_field(
          f, 
          licence ? licence["licenseName"] : nil,
          "licence[licenseName]", 
          _('Name')
        ) 
    %>
  </div>
  <div class="form-group"><!-- licenseUrl -->
    <%= create_url_field(
          f, 
          licence ? licence["licenseUrl"] : nil,
          "licence[licenseUrl]", 
          _('URL')
        ) 
    %>
  </div>
  <div class="form-group"><!-- licenceStartDate -->
    <%= create_date_field(
          f, 
          licence ? licence["licenceStartDate"] : nil,
          "licence[licenceStartDate]", 
          _('Start Date')
        ) 
    %>
  </div>
</fieldset>

<%= f.button(_('Save'), class: "btn btn-default", type: "submit") %>