Skip to content

Commit

Permalink
Added long view to lead index using view_factory.
Browse files Browse the repository at this point in the history
  • Loading branch information
steveyken committed Nov 23, 2012
1 parent b35a665 commit 8d3616f
Show file tree
Hide file tree
Showing 9 changed files with 114 additions and 70 deletions.
2 changes: 1 addition & 1 deletion app/views/accounts/_index_brief.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@
= t('pluralize.contact', account.contacts.count) << " | "
= t('pluralize.opportunity', account.opportunities.count)

= hook(:account_bottom, self, :account => account)
= hook(:account_bottom, self, :account => account)
2 changes: 1 addition & 1 deletion app/views/accounts/_index_long.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@
%dt
.tags= tags_for_index(account)

= hook(:account_bottom, self, :account => account)
= hook(:account_bottom, self, :account => account)
2 changes: 2 additions & 0 deletions app/views/contacts/_index_brief.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@
- if (lead = contact.lead) and lead.referred_by?
&ndash;
== #{t :referred_by_small} #{lead.referred_by}

= hook(:contact_bottom, self, :contact => contact)
41 changes: 41 additions & 0 deletions app/views/leads/_index_brief.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
%li.highlight[lead]
- if lead.status
.strip{:class => lead.status}= t lead.status
- else
.strip{:style => "color: gray;"}= t :other

%ul.tools
- if can?(:update, lead)
%li= link_to_edit(lead)

- if %w(converted rejected).include?(lead.status)
%li
%font{ :color => 'silver' }= t :convert
- elsif can?(:update, lead)
%li= link_to_convert(lead)

- if lead.status == "rejected"
%li
%font{ :color => 'silver' }= t :reject
- elsif can?(:update, lead)
%li= link_to_reject(lead)

- if shown_on_landing_page?
%li= link_to_discard(lead)

- if can?(:destroy, lead)
%li= link_to_delete(lead)

.indent
= link_to_if can?(:read, lead), lead.full_name(current_user.preference[:leads_naming]), lead
%tt
- if lead.company? && lead.title?
= t(:works_at, :job_title => lead.title, :company => lead.company)
- else
= lead.company if lead.company?
= lead.title if lead.title?
- if lead.referred_by?
&ndash;
== #{t :referred_by_small} #{lead.referred_by}

= hook(:lead_bottom, self, :lead => lead)
62 changes: 62 additions & 0 deletions app/views/leads/_index_long.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
%li.highlight[lead]
- if lead.status
.strip{:class => lead.status}= t lead.status
- else
.strip{:style => "color: gray;"}= t :other

%ul.tools
- if can?(:update, lead)
%li= link_to_edit(lead)

- if %w(converted rejected).include?(lead.status)
%li
%font{ :color => 'silver' }= t :convert
- elsif can?(:update, lead)
%li= link_to_convert(lead)

- if lead.status == "rejected"
%li
%font{ :color => 'silver' }= t :reject
- elsif can?(:update, lead)
%li= link_to_reject(lead)

- if shown_on_landing_page?
%li= link_to_discard(lead)

- if can?(:destroy, lead)
%li= link_to_delete(lead)

.indent
= link_to_if can?(:read, lead), lead.full_name(current_user.preference[:leads_naming]), lead
%tt
- if lead.company? && lead.title?
= t(:works_at, :job_title => lead.title, :company => lead.company)
- else
= lead.company if lead.company?
= lead.title if lead.title?
- if lead.referred_by?
&ndash;
== #{t :referred_by_small} #{lead.referred_by}

%dt
= stars_for(lead)
|
- if can?(:read, lead)
- if lead.email.present?
= link_to_email(lead.email)
|
- if lead.phone.present?
== #{t :phone_small}:
%b= lead.phone
|
- if lead.mobile.present?
== #{t :mobile_small}:
%b= lead.mobile
|
= t(:added_ago, time_ago_in_words(lead.created_at))

- if lead.tag_list.present?
%dt
.tags= tags_for_index(lead)

= hook(:lead_bottom, self, :lead => lead)
65 changes: 1 addition & 64 deletions app/views/leads/_lead.html.haml
Original file line number Diff line number Diff line change
@@ -1,68 +1,5 @@
- if (params['controller'] == 'leads') and (template = template_for_current_view).present?
= render(template, :lead => lead)
- else

-# default view
%li.highlight[lead]
- if lead.status
.strip{:class => lead.status}= t lead.status
- else
.strip{:style => "color: gray;"}= t :other

%ul.tools
- if can?(:update, lead)
%li= link_to_edit(lead)

- if %w(converted rejected).include?(lead.status)
%li
%font{ :color => 'silver' }= t :convert
- elsif can?(:update, lead)
%li= link_to_convert(lead)

- if lead.status == "rejected"
%li
%font{ :color => 'silver' }= t :reject
- elsif can?(:update, lead)
%li= link_to_reject(lead)

- if shown_on_landing_page?
%li= link_to_discard(lead)

- if can?(:destroy, lead)
%li= link_to_delete(lead)

.indent
= link_to_if can?(:read, lead), lead.full_name(current_user.preference[:leads_naming]), lead
%tt
- if lead.company? && lead.title?
= t(:works_at, :job_title => lead.title, :company => lead.company)
- else
= lead.company if lead.company?
= lead.title if lead.title?
- if lead.referred_by?
&ndash;
== #{t :referred_by_small} #{lead.referred_by}

- unless current_user.preference[:leads_outline] == "brief"
%dt
= stars_for(lead)
|
- if can?(:read, lead)
- if lead.email.present?
= link_to_email(lead.email)
|
- if lead.phone.present?
== #{t :phone_small}:
%b= lead.phone
|
- if lead.mobile.present?
== #{t :mobile_small}:
%b= lead.mobile
|
= t(:added_ago, time_ago_in_words(lead.created_at))
- if lead.tag_list.present?
%dt
.tags= tags_for_index(lead)

= hook(:lead_bottom, self, :lead => lead)
= render 'leads/brief', :lead => lead
2 changes: 1 addition & 1 deletion app/views/opportunities/_index_brief.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
- user_name = opportunity.user_id == current_user.id ? t(:me) : opportunity.user.full_name
= t(:added_by, :time_ago => time_ago_in_words(opportunity.created_at), :user => user_name)

= hook(:opportunity_bottom, self, :opportunity => opportunity)
= hook(:opportunity_bottom, self, :opportunity => opportunity)
2 changes: 1 addition & 1 deletion app/views/opportunities/_index_long.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@
%dt
.tags= tags_for_index(opportunity)

= hook(:opportunity_bottom, self, :opportunity => opportunity)
= hook(:opportunity_bottom, self, :opportunity => opportunity)
6 changes: 4 additions & 2 deletions config/initializers/views.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@
{:name => 'accounts_show_normal', :title => 'Normal format', :icon => 'long.png',
:controllers => ['accounts'], :actions => ['show'], :template => nil}, # default show view

{:name => 'leads_index_normal', :title => 'Normal format', :icon => 'long.png',
:controllers => ['leads'], :actions => ['index'], :template => nil}, # default
{:name => 'leads_index_brief', :title => 'Brief format', :icon => 'brief.png',
:controllers => ['leads'], :actions => ['index'], :template => 'leads/index_brief'}, # default
{:name => 'leads_index_long', :title => 'Long format', :icon => 'long.png',
:controllers => ['leads'], :actions => ['index'], :template => 'leads/index_long'},
{:name => 'leads_show_normal', :title => 'Normal format', :icon => 'long.png',
:controllers => ['leads'], :actions => ['show'], :template => nil}, # default show view

Expand Down

0 comments on commit 8d3616f

Please sign in to comment.