From 1a6ee84ed522a87dfb9c13538b8022b8d965155b Mon Sep 17 00:00:00 2001 From: Gonzalo Rodriguez Date: Wed, 7 Sep 2011 00:09:39 -0300 Subject: [PATCH] Refactor aspect listings partial. Splited in two, one for index and other for contacts. --- app/helpers/application_helper.rb | 16 ---------- app/helpers/aspect_global_helper.rb | 8 ----- app/views/aspects/_aspect_listings.haml | 24 ++------------ app/views/contacts/_aspect_listings.haml | 35 +++++++++++++++++++++ app/views/shared/_contact_sidebar.html.haml | 2 +- public/stylesheets/sass/application.sass | 6 ---- 6 files changed, 39 insertions(+), 52 deletions(-) create mode 100644 app/views/contacts/_aspect_listings.haml diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 12951f2fd..78ad9d141 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -60,22 +60,6 @@ module ApplicationHelper @rtl ||= RTL_LANGUAGES.include? I18n.locale 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 if current_user.contacts.size > 0 contacts_path diff --git a/app/helpers/aspect_global_helper.rb b/app/helpers/aspect_global_helper.rb index 9b38b7a09..57829eb58 100644 --- a/app/helpers/aspect_global_helper.rb +++ b/app/helpers/aspect_global_helper.rb @@ -49,14 +49,6 @@ module AspectGlobalHelper link_to aspect.name, aspects_path( opts[:params] ), opts 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) if @aspect.is_a? Aspect aspect_path @aspect diff --git a/app/views/aspects/_aspect_listings.haml b/app/views/aspects/_aspect_listings.haml index f012862aa..2c8b82d9f 100644 --- a/app/views/aspects/_aspect_listings.haml +++ b/app/views/aspects/_aspect_listings.haml @@ -4,10 +4,8 @@ %ul#aspect_nav.left_nav %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"])} - .contact_count - = my_contacts_count - = left_nav_root + %a.home_selector{:href => aspects_path, :class => ("sub_selected" if params["a_id"])} + = t('aspects.index.your_aspects') %ul.sub_nav - for aspect in all_aspects @@ -15,24 +13,8 @@ .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" - %a.aspect_selector{aspect_listing_link_opts(aspect)} - .contact_count - = aspect.contacts.size + %a.aspect_selector{:href => aspects_path("a_ids[]" => aspect.id), :class => "aspect_selector name hard_aspect_link", 'data-guid' => aspect.id} = aspect %li = 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') - diff --git a/app/views/contacts/_aspect_listings.haml b/app/views/contacts/_aspect_listings.haml new file mode 100644 index 000000000..204c893a3 --- /dev/null +++ b/app/views/contacts/_aspect_listings.haml @@ -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') + diff --git a/app/views/shared/_contact_sidebar.html.haml b/app/views/shared/_contact_sidebar.html.haml index e070364de..ed5cd5045 100644 --- a/app/views/shared/_contact_sidebar.html.haml +++ b/app/views/shared/_contact_sidebar.html.haml @@ -3,7 +3,7 @@ -# the COPYRIGHT file. .span-5.append-1 - = render 'aspects/aspect_listings' + = render 'contacts/aspect_listings' %hr diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index a5f994500..e55cb4554 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -2927,12 +2927,6 @@ ul.left_nav :width 182px .section - .contact_count - :display none !important - - .all_contacts - :display none !important - .left_nav a.aspect_selector, a.home_selector