Refactor aspect listings partial. Splited in two, one for index and
other for contacts.
This commit is contained in:
parent
0aed97599f
commit
1a6ee84ed5
6 changed files with 39 additions and 52 deletions
|
|
@ -60,22 +60,6 @@ module ApplicationHelper
|
||||||
@rtl ||= RTL_LANGUAGES.include? I18n.locale
|
@rtl ||= RTL_LANGUAGES.include? I18n.locale
|
||||||
end
|
end
|
||||||
|
|
||||||
def controller_index_path
|
|
||||||
kontroller = request.filtered_parameters["controller"]
|
|
||||||
if kontroller.downcase != "contacts"
|
|
||||||
kontroller = "aspects"
|
|
||||||
end
|
|
||||||
self.send((kontroller + "_path").to_sym)
|
|
||||||
end
|
|
||||||
|
|
||||||
def left_nav_root
|
|
||||||
if request.filtered_parameters["controller"] == "contacts"
|
|
||||||
t('contacts.index.my_contacts')
|
|
||||||
else
|
|
||||||
t('aspects.index.your_aspects')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def contacts_link
|
def contacts_link
|
||||||
if current_user.contacts.size > 0
|
if current_user.contacts.size > 0
|
||||||
contacts_path
|
contacts_path
|
||||||
|
|
|
||||||
|
|
@ -49,14 +49,6 @@ module AspectGlobalHelper
|
||||||
link_to aspect.name, aspects_path( opts[:params] ), opts
|
link_to aspect.name, aspects_path( opts[:params] ), opts
|
||||||
end
|
end
|
||||||
|
|
||||||
def aspect_listing_link_opts aspect
|
|
||||||
if controller.instance_of?(ContactsController)
|
|
||||||
{:href => contacts_path(:a_id => aspect.id)}
|
|
||||||
else
|
|
||||||
{:href => aspects_path("a_ids[]" => aspect.id), :class => "aspect_selector name hard_aspect_link", 'data-guid' => aspect.id}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def aspect_or_all_path(aspect)
|
def aspect_or_all_path(aspect)
|
||||||
if @aspect.is_a? Aspect
|
if @aspect.is_a? Aspect
|
||||||
aspect_path @aspect
|
aspect_path @aspect
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,8 @@
|
||||||
|
|
||||||
%ul#aspect_nav.left_nav
|
%ul#aspect_nav.left_nav
|
||||||
%li.all_aspects{:class => ("active" if params["set"] != "all" && params["set"] != "only_sharing" && !@featured && !@finder)}
|
%li.all_aspects{:class => ("active" if params["set"] != "all" && params["set"] != "only_sharing" && !@featured && !@finder)}
|
||||||
%a.home_selector{:href => controller_index_path, :class => ("sub_selected" if params["a_id"])}
|
%a.home_selector{:href => aspects_path, :class => ("sub_selected" if params["a_id"])}
|
||||||
.contact_count
|
= t('aspects.index.your_aspects')
|
||||||
= my_contacts_count
|
|
||||||
= left_nav_root
|
|
||||||
|
|
||||||
%ul.sub_nav
|
%ul.sub_nav
|
||||||
- for aspect in all_aspects
|
- for aspect in all_aspects
|
||||||
|
|
@ -15,24 +13,8 @@
|
||||||
.edit
|
.edit
|
||||||
= link_to image_tag("icons/pencil.svg", :height => 12, :title => t('contacts.index.edit_aspect', :name => aspect.name)), edit_aspect_path(aspect), :rel => "facebox"
|
= link_to image_tag("icons/pencil.svg", :height => 12, :title => t('contacts.index.edit_aspect', :name => aspect.name)), edit_aspect_path(aspect), :rel => "facebox"
|
||||||
|
|
||||||
%a.aspect_selector{aspect_listing_link_opts(aspect)}
|
%a.aspect_selector{:href => aspects_path("a_ids[]" => aspect.id), :class => "aspect_selector name hard_aspect_link", 'data-guid' => aspect.id}
|
||||||
.contact_count
|
|
||||||
= aspect.contacts.size
|
|
||||||
= aspect
|
= aspect
|
||||||
|
|
||||||
%li
|
%li
|
||||||
= link_to t('.add_an_aspect'), new_aspect_path, :class => "new_aspect", :rel => "facebox"
|
= link_to t('.add_an_aspect'), new_aspect_path, :class => "new_aspect", :rel => "facebox"
|
||||||
|
|
||||||
%li.all_contacts{:class => ("active" if params["set"] == "all" || params["set"] == "only_sharing")}
|
|
||||||
%a.aspect_selector{:href => contacts_path(:set => "all"), :class => ("sub_selected" if params["set"] == "only_sharing")}
|
|
||||||
.contact_count
|
|
||||||
= all_contacts_count
|
|
||||||
= t('contacts.index.all_contacts')
|
|
||||||
|
|
||||||
%ul.sub_nav
|
|
||||||
%li{:class => ("active" if params["set"] == "only_sharing")}
|
|
||||||
%a.aspect_selector{:href => contacts_path(:set => "only_sharing")}
|
|
||||||
.contact_count
|
|
||||||
= only_sharing_count
|
|
||||||
= t('contacts.index.only_sharing_with_me')
|
|
||||||
|
|
||||||
|
|
|
||||||
35
app/views/contacts/_aspect_listings.haml
Normal file
35
app/views/contacts/_aspect_listings.haml
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
-# Copyright (c) 2010, Diaspora Inc. This file is
|
||||||
|
-# licensed under the Affero General Public License version 3 or later. See
|
||||||
|
-# the COPYRIGHT file.
|
||||||
|
|
||||||
|
%ul#aspect_nav.left_nav
|
||||||
|
%li.all_aspects{:class => ("active" if params["set"] != "all" && params["set"] != "only_sharing" && !@featured && !@finder)}
|
||||||
|
%a.home_selector{:href => contacts_path, :class => ("sub_selected" if params["a_id"])}
|
||||||
|
.contact_count
|
||||||
|
= my_contacts_count
|
||||||
|
= t('contacts.index.my_contacts')
|
||||||
|
|
||||||
|
%ul.sub_nav
|
||||||
|
- for aspect in all_aspects
|
||||||
|
%li{:data => {:aspect_id => aspect.id}, :class => ("active" if params["a_id"].to_i == aspect.id)}
|
||||||
|
%a.aspect_selector{:href => contacts_path(:a_id => aspect.id)}
|
||||||
|
.contact_count
|
||||||
|
= aspect.contacts.size
|
||||||
|
= aspect
|
||||||
|
|
||||||
|
%li
|
||||||
|
= link_to t('aspects.aspect_listings.add_an_aspect'), new_aspect_path, :class => "new_aspect", :rel => "facebox"
|
||||||
|
|
||||||
|
%li.all_contacts{:class => ("active" if params["set"] == "all" || params["set"] == "only_sharing")}
|
||||||
|
%a.aspect_selector{:href => contacts_path(:set => "all"), :class => ("sub_selected" if params["set"] == "only_sharing")}
|
||||||
|
.contact_count
|
||||||
|
= all_contacts_count
|
||||||
|
= t('contacts.index.all_contacts')
|
||||||
|
|
||||||
|
%ul.sub_nav
|
||||||
|
%li{:class => ("active" if params["set"] == "only_sharing")}
|
||||||
|
%a.aspect_selector{:href => contacts_path(:set => "only_sharing")}
|
||||||
|
.contact_count
|
||||||
|
= only_sharing_count
|
||||||
|
= t('contacts.index.only_sharing_with_me')
|
||||||
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
-# the COPYRIGHT file.
|
-# the COPYRIGHT file.
|
||||||
|
|
||||||
.span-5.append-1
|
.span-5.append-1
|
||||||
= render 'aspects/aspect_listings'
|
= render 'contacts/aspect_listings'
|
||||||
|
|
||||||
%hr
|
%hr
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2927,12 +2927,6 @@ ul.left_nav
|
||||||
:width 182px
|
:width 182px
|
||||||
|
|
||||||
.section
|
.section
|
||||||
.contact_count
|
|
||||||
:display none !important
|
|
||||||
|
|
||||||
.all_contacts
|
|
||||||
:display none !important
|
|
||||||
|
|
||||||
.left_nav
|
.left_nav
|
||||||
a.aspect_selector,
|
a.aspect_selector,
|
||||||
a.home_selector
|
a.home_selector
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue