diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index f3efac9178..aa910290d9 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -431,7 +431,7 @@ def entity_filter_checkbox(name, value, count) # Create a column in the 'asset_attributes' table. #---------------------------------------------------------------------------- - def asset_attribute_columns(title, value, last = false, email = false) + def col(title, value, last = false, email = false) # Parse and format urls as links. fmt_value = (value.to_s || "").gsub("\n", "
") fmt_value = if email @@ -445,7 +445,7 @@ def asset_attribute_columns(title, value, last = false, email = false) #---------------------------------------------------------------------------- # Combines the 'subtitle' helper with the small info text on the same line. - def asset_attribute_section(id, hidden = true, text = nil, info_text = nil) + def section(id, hidden = true, text = nil, info_text = nil) text = id.to_s.split("_").last.capitalize if text == nil content_tag("div", :class => "subtitle show_attributes") do content = link_to("#{ hidden ? "►" : "▼" } #{text}".html_safe, diff --git a/app/views/contacts/_extra_section.html.haml b/app/views/contacts/_extra_section.html.haml index 43f71ada90..b5c6c7e561 100644 --- a/app/views/contacts/_extra_section.html.haml +++ b/app/views/contacts/_extra_section.html.haml @@ -1,17 +1,17 @@ - collapsed = session[:contact_show_extra].nil? # && contact.errors.empty? -= asset_attribute_section :contact_show_extra, collapsed, t(:extra_info), t('show_extra_info_small') += section :contact_show_extra, collapsed, t(:extra_info), t('show_extra_info_small') .show_fields #contact_show_extra{ hidden_if(collapsed) } %table.asset_attributes %tr - = asset_attribute_columns(t(:title), contact.title) - = asset_attribute_columns(t(:department), contact.department) + = col(t(:title), contact.title) + = col(t(:department), contact.department) %tr - = asset_attribute_columns(t(:alt_email), contact.alt_email, false, true) - = asset_attribute_columns(t(:mobile), contact.mobile) + = col(t(:alt_email), contact.alt_email, false, true) + = col(t(:mobile), contact.mobile) %tr - = asset_attribute_columns(t(:fax), contact.fax) - = asset_attribute_columns(t(:do_not_call), contact.do_not_call == false ? "no" : "yes") + = col(t(:fax), contact.fax) + = col(t(:do_not_call), contact.do_not_call == false ? "no" : "yes") %tr %th=t(:address) + ":" %td @@ -21,6 +21,6 @@ %th= t(:web_presence) %td= web_presence_icons(contact) - if Setting.background_info && Setting.background_info.include?(:contact) - = asset_attribute_columns(t(:background_info), contact.background_info) + = col(t(:background_info), contact.background_info) %tr - = asset_attribute_columns(t(:permissions), (contact.permissions.empty? ? t(:shared_with_everyone) : contact.permissions.join(", ")), :last) + = col(t(:permissions), (contact.permissions.empty? ? t(:shared_with_everyone) : contact.permissions.join(", ")), :last) diff --git a/app/views/contacts/_show_contact_sections.html.haml b/app/views/contacts/_show_contact_sections.html.haml index c18a02e236..2533dae99e 100644 --- a/app/views/contacts/_show_contact_sections.html.haml +++ b/app/views/contacts/_show_contact_sections.html.haml @@ -1,27 +1,27 @@ - collapsed = session[:contact_show_general].nil? # && contact.errors.empty? -= asset_attribute_section :contact_show_general, collapsed, t(:general_info), t('show_general_info_small') += section :contact_show_general, collapsed, t(:general_info), t('show_general_info_small') .show_fields #contact_show_general{ hidden_if(collapsed) } %table.asset_attributes %tr - = asset_attribute_columns(t(:first_name), contact.first_name) - = asset_attribute_columns(t(:last_name), contact.last_name) + = col(t(:first_name), contact.first_name) + = col(t(:last_name), contact.last_name) %tr - = asset_attribute_columns(t(:email), contact.email, false, true) - = asset_attribute_columns(t(:phone), contact.phone) + = col(t(:email), contact.email, false, true) + = col(t(:phone), contact.phone) %tr - = asset_attribute_columns(t(:account), contact.account ? link_to(contact.account.name, url_for(contact.account)) : "") + = col(t(:account), contact.account ? link_to(contact.account.name, url_for(contact.account)) : "") - assigned_to_user = User.find_by_id(contact.assigned_to) - = asset_attribute_columns(t(:assigned_to), assigned_to_user ? link_to(assigned_to_user.name, url_for(assigned_to_user)) : "") + = col(t(:assigned_to), assigned_to_user ? link_to(assigned_to_user.name, url_for(assigned_to_user)) : "") %tr - = asset_attribute_columns(t(:tags), contact.tag_list.map{|tag| content_tag(:span, tag, :class => "fbtag")}.join(' '), :last) + = col(t(:tags), contact.tag_list.map{|tag| content_tag(:span, tag, :class => "fbtag")}.join(' '), :last) - contact.field_groups.each do |field_group| - if (fields = field_group.fields.without_pairs).any? %div[field_group] - collapsed = session[dom_id(field_group, :contact_show)].nil? - = asset_attribute_section dom_id(field_group, :contact_show), collapsed, field_group.label_i18n, t('show_tag_info_small', :tag => field_group.label_i18n) + = section dom_id(field_group, :contact_show), collapsed, field_group.label_i18n, t('show_tag_info_small', :tag => field_group.label_i18n) .show_fields %div{ hidden_if(collapsed).merge(:id => dom_id(field_group, :contact_show)) } %table.asset_attributes @@ -29,6 +29,6 @@ - groups.each_with_index do |group, i| %tr - group.each do |field| - = asset_attribute_columns(field.label, field.render_value(contact), (i == groups.size - 1) ? :last : nil) + = col(field.label, field.render_value(contact), (i == groups.size - 1) ? :last : nil) = render :partial => 'contacts/extra_section', :locals => {:contact => contact}