<%# locals: { persons } %>
<% project_abstract_tooltip = _("Briefly summarise your research project to help others understand the purposes for which the data are being collected or created.") %>

<% project = project_fragment.data %>
<% fundings = project_fragment.fundings %>
<% partners = project_fragment.partners %>
<% principalInvestigator = project_fragment.principalInvestigator %>

<div class="form-group"><!-- project_title -->
  <%= create_text_field(
        f, 
        project["title"], 
        "project_title", 
        _('Project title')
      ) 
  %>
</div>
<div class="form-group"><!-- project_acronym -->
  <%= create_text_field(
        f, 
        project["acronym"], 
        "project_acronym", 
        _('Acronym')
      ) 
  %>
</div>
<div class="form-group"><!-- project_id -->
  <%= create_text_field(
        f, 
        project["projectId"], 
        "project_id", 
        _('Project ID')
      ) 
  %>
</div>
<div class="form-group"><!-- project_description -->
  <div class="col-md-12">
    <%= f.label "plan[project_description]", _('Project abstract'), class: 'control-label' %>
  </div>
  <div class="col-md-10" data-toggle="tooltip" title="<%= project_abstract_tooltip %>">
    <em class="sr-only"><%= project_abstract_tooltip %></em>
    <%= text_area_tag "plan[project_description]", project["description"],
                        { rows: 6, class: "form-control tinymce", "aria-required": true,
                        'data-toggle': 'tooltip', spellcheck: true } %>
  </div>
</div>

<%= render(partial: 'shared/dynamic_form/fields/complex_multiple_field', locals: { 
  field_values: fundings, 
  parent_id: project_fragment.id,
  schema: MadmpSchema.find_by(classname: "funding"),
  readonly: false,
  template_locale: @plan.template.locale,
  field_name: "funding", answer_id: nil 
  }
) %>

<div class="form-group"><!-- project_start_date -->
  <%= create_date_field(
        f, 
        project["startDate"], 
        "project_start_date", 
        _('Start Date')
      ) 
  %>
</div>
<div class="form-group"><!-- project_end_date -->
  <%= create_date_field(
        f, 
        project["endDate"], 
        "project_end_date", 
        _('End Date')
      ) 
  %>
</div>

<%= render(partial: 'shared/dynamic_form/fields/complex_multiple_field', locals: { 
  field_values: partners, 
  parent_id: project_fragment.id,
  schema: MadmpSchema.find_by(classname: "partner"),
  readonly: false,
  template_locale: @plan.template.locale,
  field_name: "partner", answer_id: nil 
  }
) %>

<div class="form-group"><!-- experimental_plan_url -->
  <%= create_url_field(
        f, 
        project["experimentalPlanUrl"], 
        "experimental_plan_url", 
        _('Experimental Plan URL')
      ) 
  %>
</div>


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

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