_person_form.html.erb 7.8 KB
<% @person ||= @profile %>

<% optional_field(@person, 'nickname') do %>
  <%= f.text_field(:nickname, :maxlength => 16, :size => 30, :rel => _('Nickname')) %>
  <div>
    <small><%= _('A short name by which you like to be known. Will be used in friends listings, community member listings etc.') %></small>
  </div>
<% end %>

<%= optional_field(@person, 'description', f.text_area(:description, :rows => 5, :rel => _('Description'))) %>
<%= optional_field(@person, 'preferred_domain', select_preferred_domain(:profile_data)) %>
<%= optional_field(@person, 'contact_information', f.text_field(:contact_information, :rel => _('Contact information'))) %>
<%= optional_field(@person, 'contact_phone', labelled_form_field(_('Home phone'), text_field(:profile_data, :contact_phone, :rel => _('Contact phone')))) %>
<%= optional_field(@person, 'cell_phone', f.text_field(:cell_phone, :rel => _('Cell phone'))) %>
<%= optional_field(@person, 'comercial_phone', f.text_field(:comercial_phone, :rel => _('Comercial phone'))) %>
<%= optional_field(@person, 'jabber_id', f.text_field(:jabber_id, :rel => _('Jabber'))) %>
<%= optional_field(@person, 'personal_website', f.text_field(:personal_website, :rel => _('Personal website'))) %>
<%= optional_field(@person, 'sex', f.radio_group(:profile_data, :sex, [ ['male',_('Male')], ['female',_('Female')] ])) %>
<%= optional_field(@person, 'birth_date', labelled_form_field(_('Birth date'), date_field('profile_data[birth_date]', @profile_data. birth_date, '%Y-%m-%d', {:change_month => true, :change_year => true, :year_range => '-100:-5', :date_format => 'yy-mm-dd'}, {:id => 'profile_data_birth_date'}))) %>
<%= optional_field(@person, 'nationality', f.text_field(:nationality, :rel => _('Nationality'))) %>
<%= optional_field(@person, 'country', select_country(_('Country'), 'profile_data', 'country', {:class => 'type-select'})) %>
<%= optional_field(@person, 'state', f.text_field(:state, :id => 'state_field', :rel => _('State'))) %>
<%= optional_field(@person, 'city', f.text_field(:city, :id => 'city_field', :rel => _('City'))) %>
<%= optional_field(@person, 'zip_code', labelled_form_field(_('ZIP code'), text_field(:profile_data, :zip_code, :rel => _('ZIP code')))) %>
<%= optional_field(@person, 'address', labelled_form_field(_('Address (street and number)'), text_field(:profile_data, :address, :rel => _('Address')))) %>
<%= optional_field(@person, 'address_reference', labelled_form_field(_('Address reference'), text_field(:profile_data, :address_reference, :rel => _('Address reference')))) %>
<%= optional_field(@person, 'district', labelled_form_field(_('District'), text_field(:profile_data, :district, :rel => _('District')))) %>

<% optional_field(@person, 'schooling') do %>
  <div class="formfieldline">
    <label class='formlabel' for='profile_data_schooling'><%= _('Schooling') %></label>
    <div class="formfield type-select">
      <%= select_schooling('profile_data', 'schooling', {:class => 'select-schooling'}) %>
      <%= select_schooling_status('profile_data', 'schooling_status', {:class => 'select-schooling'}) %>
    </div>
  </div>
<% end %>

<%= javascript_include_tag('city_state_validation') %>
<script type='text/javascript'>
  function toggle_text_field(id, span_id) {
    if ($(id).value == "Others") {
      $(span_id).show(); return false;
    } else {
      $(span_id).hide(); return false;
    }
  }
</script>

<%= optional_field(@person, 'formation', select_area(_('Education'), 'profile_data', 'formation', {:class => 'type-select-full-line'})) %>

<span id='profile_data_custom_formation_span' <%= "style='display:none'" if ! ['Others', nil].include?(@person.formation) %> >
  <%= optional_field(@person, 'custom_formation', f.text_field(:custom_formation, :rel => _('Custom formation'))) %>
</span>
<%= observe_field 'profile_data_formation', :function =>'toggle_text_field("profile_data_formation", "profile_data_custom_formation_span")' %>

<%= optional_field(@person, 'area_of_study', select_area(_('Area of study'), 'profile_data', 'area_of_study', {:class => 'type-select-full-line'})) %>

<span id='profile_data_custom_area_of_study_span' <%= "style='display:none'" if ! ['Others', nil].include?(@person.area_of_study) %> >
  <%= optional_field(@person, 'custom_area_of_study', f.text_field(:custom_area_of_study, :rel => _('Custom area of study'))) %>
</span>
<%= observe_field 'profile_data_area_of_study', :function =>'toggle_text_field("profile_data_area_of_study", "profile_data_custom_area_of_study_span")' %>

<%= optional_field(@person, 'professional_activity', f.text_field(:professional_activity, :rel => _('Professional activity'))) %>
<%= optional_field(@person, 'organization', f.text_field(:organization, :rel => _('Organization'))) %>
<%= optional_field(@person, 'organization_website', f.text_field(:organization_website, :rel => _('Organization website'))) %>

<br />

<div id="custom-fields-container">

  <h2><%= _('Custom fields') %></h2>

  <% if @person.is_template? %>

  <%= javascript_include_tag "manage-custom-fields.js" %>

  <table border="0" style="display: none;">
    <tr>
      <th><%= _('Field name') %></th>
      <th><%= _('Active') %></th>
      <th><%= _('Required') %></th>
      <th><%= _('Display on signup?') %></th>
      <th>&nbsp;</th>
    </tr>

    <% @person.custom_fields.each { |key,value| %>
        <tr>
          <td>
            <%= text_field_tag( "profile_data[custom_fields][#{key}][label]", value[:label], :style => "display:block") %>
          </td>
          <td align="center">
            <%= check_box_tag "profile_data[custom_fields][#{key}][active]", value['active'], value['active'], :onclick => "active_action(this, 'profile_data[custom_fields][#{key}][required]', 'profile_data[custom_fields][#{key}][signup]')" %>
          </td>
          <td align="center">
            <%= check_box_tag "profile_data[custom_fields][#{key}][required]", value['required'], value['required'], :onclick => "required_action('profile_data[custom_fields][#{key}][active]','profile_data[custom_fields][#{key}][required]', 'profile_data[custom_fields][#{key}][signup]')" %>
          </td>
          <td align="center">
            <%= check_box_tag "profile_data[custom_fields][#{key}][signup]", value['signup'], value['signup'], :onclick => "signup_action('profile_data[custom_fields][#{key}][active]','profile_data[custom_fields][#{key}][required]', 'profile_data[custom_fields][#{key}][signup]')" %>
          </td>
          <td align="center">
            <%= link_to content_tag(:span, _('Delete')), '#', onclick: "return remove_custom_field(this);", title: "Delete", class: "button icon-delete" %>
          </td>
        </tr>
    <% } %>

  </table>

  <% if @person.custom_fields.length > 0 %>
    <script>
      jQuery('#custom-fields-container table').css('display', 'table');
    </script>
  <% end %>

  <span>
    <%= link_to_function(_('Add field'), "add_new_field('person');", :class => 'button icon-add with-text') %>
  </span>

  <% else %>

    <% Profile.find(@person.template_id).custom_fields.each { |key,value| %>

      <% if value['active'] %>
      <div class="field-with-privacy-selector">
        <div class="formfieldline">

          <span style="display: block;">
            <% if value['required'] %>
              <%= label_tag value[:label] + ' (*)', nil, class: 'required' %>
            <% else %>
              <%= label_tag value[:label] %>
            <% end %>
          </span>

          <div class="formfield type-text" style="display: inline-block;">
            <%= text_field_tag( "profile_data[custom_fields][#{key}][value]", @person.custom_fields[key][:value], :size => 30 ) %>
          </div>

        </div>

        <div class="field-privacy-selector">
          <input id="checkbox-44" name="" title="This field must be public" type="checkbox" value="">
          <label for="checkbox-44">Public</label>
        </div>

      </div>
      <% end %>

    <% } %>

  <% end %>

</div>