Skip to content

Commit

Permalink
Renamed 'asset_attribute_columns' to 'col' and 'asset_attribute_secti…
Browse files Browse the repository at this point in the history
…on' to 'section'.
  • Loading branch information
steveyken committed Nov 14, 2012
1 parent fc11ec6 commit 1d8c2e7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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", "<br />")
fmt_value = if email
Expand All @@ -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("<small>#{ hidden ? "&#9658;" : "&#9660;" }</small> #{text}".html_safe,
Expand Down
18 changes: 9 additions & 9 deletions app/views/contacts/_extra_section.html.haml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
20 changes: 10 additions & 10 deletions app/views/contacts/_show_contact_sections.html.haml
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
- 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
- groups = fields.in_groups_of(2, false)
- 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}

0 comments on commit 1d8c2e7

Please sign in to comment.