From 41773cb29e1971d0fbb1fd792c84ea4b886b60c5 Mon Sep 17 00:00:00 2001 From: danielgrippi <danielgrippi@gmail.com> Date: Fri, 1 Jul 2011 14:22:38 -0700 Subject: [PATCH] Almost done with left-nav, added link to aspect edit facebox, colored share button --- app/controllers/aspects_controller.rb | 13 ++++++----- app/helpers/application_helper.rb | 4 ++++ app/views/aspects/_aspect.haml | 12 ---------- app/views/aspects/_aspect_listings.haml | 4 ++-- app/views/aspects/_new.haml | 2 +- .../aspects/_selected_contacts.html.haml | 14 ++++++++++++ app/views/aspects/index.html.haml | 12 +--------- app/views/aspects/index.js.erb | 2 +- app/views/comments/_new_comment.html.haml | 2 +- app/views/shared/_publisher.html.haml | 2 +- features/comments.feature | 2 +- features/connects_users.feature | 8 +++---- features/disconnects_users.feature | 8 +++---- features/embedder.feature | 2 +- features/manages_aspects.feature | 22 ++++++++----------- features/posts.feature | 22 ++++++++++--------- public/javascripts/stream.js | 13 ++++++++--- public/stylesheets/sass/_mixins.scss | 1 + public/stylesheets/sass/application.sass | 6 +++-- public/stylesheets/sass/ui.sass | 11 ++++++++++ 20 files changed, 90 insertions(+), 72 deletions(-) delete mode 100644 app/views/aspects/_aspect.haml create mode 100644 app/views/aspects/_selected_contacts.html.haml diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index ca10f539d1..1bfc8b3b5d 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -29,9 +29,12 @@ class AspectsController < ApplicationController return end - @selected_contacts = Contact.joins(:aspect_memberships). - where(:aspect_memberships => {:aspect_id => aspect_ids}). - includes(:person => :profile).limit(20) unless params[:only_posts] + unless params[:only_posts] + all_selected_contacts = Contact.joins(:aspect_memberships). + where(:aspect_memberships => {:aspect_id => aspect_ids}) + @selected_contacts_count = all_selected_contacts.count + @selected_contacts = all_selected_contacts.limit(24) + end @aspect_ids = @aspects.map { |a| a.id } posts = current_user.visible_posts(:by_members_of => @aspect_ids, @@ -116,9 +119,9 @@ class AspectsController < ApplicationController @contacts_in_aspect = @aspect.contacts.includes(:aspect_memberships, :person => :profile).all.sort! { |x, y| x.person.name <=> y.person.name } c = Contact.arel_table if @contacts_in_aspect.empty? - @contacts_not_in_aspect = current_user.contacts.receiving.includes(:aspect_memberships, :person => :profile).all.sort! { |x, y| x.person.name <=> y.person.name } + @contacts_not_in_aspect = current_user.contacts.includes(:aspect_memberships, :person => :profile).all.sort! { |x, y| x.person.name <=> y.person.name } else - @contacts_not_in_aspect = current_user.contacts.receiving.where(c[:id].not_in(@contacts_in_aspect.map(&:id))).includes(:aspect_memberships, :person => :profile).all.sort! { |x, y| x.person.name <=> y.person.name } + @contacts_not_in_aspect = current_user.contacts.where(c[:id].not_in(@contacts_in_aspect.map(&:id))).includes(:aspect_memberships, :person => :profile).all.sort! { |x, y| x.person.name <=> y.person.name } end @contacts = @contacts_in_aspect + @contacts_not_in_aspect diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 5425d5d61c..3f5938b380 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -106,4 +106,8 @@ module ApplicationHelper def rtl? @rtl ||= RTL_LANGUAGES.include? I18n.locale end + + def controller_index_path + self.send((request.filtered_parameters["controller"] + "_path").to_sym) + end end diff --git a/app/views/aspects/_aspect.haml b/app/views/aspects/_aspect.haml deleted file mode 100644 index ec34c93a9c..0000000000 --- a/app/views/aspects/_aspect.haml +++ /dev/null @@ -1,12 +0,0 @@ -%li{:data=>{:guid=>aspect.id}, :class => ("dull" if contacts.size == 0)} - .right - %b - = link_to t('contacts', :count => contacts.size), edit_aspect_path(aspect), :rel => 'facebox', :class => 'contact-count' - %b - = link_for_aspect(aspect, :class => 'hard_aspect_link') - %br - - - if contacts.length > 0 - .contacts - - for contact in contacts[0..15] - = person_image_link(contact.person) diff --git a/app/views/aspects/_aspect_listings.haml b/app/views/aspects/_aspect_listings.haml index 6ba2bc1fa4..7041487d05 100644 --- a/app/views/aspects/_aspect_listings.haml +++ b/app/views/aspects/_aspect_listings.haml @@ -4,7 +4,7 @@ %ul#aspect_nav.left_nav %li.all_aspects{:class => ("active" if params["set"] != "all" && params["set"] != "only_sharing")} - %a{:href => contacts_path, :class => ("sub_selected" if params["a_id"])} + %a{:href => controller_index_path, :class => ("sub_selected" if params["a_id"])} .contact_count = my_contacts_count = t('contacts.index.my_contacts') @@ -21,7 +21,7 @@ %li = link_to "+ Add an aspect", "#add_aspect_pane", :class => "new_aspect", :rel => "facebox" - %li{:class => ("active" if params["set"] == "all" || params["set"] == "only_sharing")} + %li.all_contacts{:class => ("active" if params["set"] == "all" || params["set"] == "only_sharing")} %a{:href => contacts_path(:set => "all"), :class => ("sub_selected" if params["set"] == "only_sharing")} .contact_count = all_contacts_count diff --git a/app/views/aspects/_new.haml b/app/views/aspects/_new.haml index b704af7c9e..01e2ebb3b7 100644 --- a/app/views/aspects/_new.haml +++ b/app/views/aspects/_new.haml @@ -23,5 +23,5 @@ .bottom_submit_section = submit_tag t('cancel'), :class => 'button', :type => :reset, :rel => "close" - = aspect.submit t('.create'), :class => 'button take_action' + = aspect.submit t('.create'), :class => 'button creation' diff --git a/app/views/aspects/_selected_contacts.html.haml b/app/views/aspects/_selected_contacts.html.haml new file mode 100644 index 0000000000..54eb6ac87c --- /dev/null +++ b/app/views/aspects/_selected_contacts.html.haml @@ -0,0 +1,14 @@ +#selected_aspect_contacts.section + .title.no_icon + %h5 + = "Contacts (#{count})" + + .content + - for contact in contacts + = person_image_link contact.person + + #edit_this_aspect + = link_to "View all contacts", contacts_path + - for aspect in @aspects + = link_to "Edit #{aspect.name}", edit_aspect_path(aspect), :rel => 'facebox' + %br diff --git a/app/views/aspects/index.html.haml b/app/views/aspects/index.html.haml index 20d5d12bf2..46335eb204 100644 --- a/app/views/aspects/index.html.haml +++ b/app/views/aspects/index.html.haml @@ -23,17 +23,7 @@ :posts => @posts .span-5.rightBar.last - #selected_aspect_contacts.section - .title.no_icon - %h5 - = "Contacts (#{@selected_contacts.size})" - - .content - - for contact in @selected_contacts - = person_image_link contact.person - - #edit_this_aspect - = link_to "View all contacts", "#" + = render 'selected_contacts', :contacts => @selected_contacts, :count => @selected_contacts_count .section .title diff --git a/app/views/aspects/index.js.erb b/app/views/aspects/index.js.erb index 58451a81f0..0938a3236f 100644 --- a/app/views/aspects/index.js.erb +++ b/app/views/aspects/index.js.erb @@ -1,3 +1,3 @@ $('#aspect_stream_container').html("<%= escape_javascript(render('aspects/aspect_stream', :aspect => @aspect, :aspect_ids => @aspect_ids, :posts => @posts)) %>"); -$('#aspect_listings').html("<%= escape_javascript(render('aspects/aspect_listings', :aspects => @aspects)) %>"); +$('#selected_aspect_contacts').html("<%= escape_javascript(render('aspects/selected_contacts', :count => @selected_contacts_count, :contacts => @selected_contacts)) %>"); $('a[rel*=facebox]').facebox(); diff --git a/app/views/comments/_new_comment.html.haml b/app/views/comments/_new_comment.html.haml index 5e777f4da6..2e38cf3226 100644 --- a/app/views/comments/_new_comment.html.haml +++ b/app/views/comments/_new_comment.html.haml @@ -9,5 +9,5 @@ = text_area_tag :text, nil, :rows => 2, :class => "comment_box",:id => "comment_text_on_#{post_id}" = hidden_field_tag :post_id, post_id, :id => "post_id_on_#{post_id}" .submit_button - = submit_tag t('.comment'), :id => "comment_submit_#{post_id}", :class => "comment_submit button", :disable_with => t('.commenting') + = submit_tag t('.comment'), :id => "comment_submit_#{post_id}", :class => "comment_submit button creation", :disable_with => t('.commenting') diff --git a/app/views/shared/_publisher.html.haml b/app/views/shared/_publisher.html.haml index 26f1079604..09a20c8262 100644 --- a/app/views/shared/_publisher.html.haml +++ b/app/views/shared/_publisher.html.haml @@ -47,7 +47,7 @@ - for service in current_user.services = image_tag "social_media_logos/#{service.provider}-16x16.png", :title => service.provider.titleize, :class => "service_icon dim", :id =>"#{service.provider}", :maxchar => "#{service.class::MAX_CHARACTERS}" = link_to (image_tag "icons/monotone_wrench_settings.png"), "#question_mark_pane", :class => 'question_mark', :rel => 'facebox', :title => t('shared.public_explain.manage') - = status.submit t('.share'), :disable_with => t('.posting'), :class => 'button', :tabindex => 2 + = status.submit t('.share'), :disable_with => t('.posting'), :class => 'button creation', :tabindex => 2 .facebox_content #question_mark_pane diff --git a/features/comments.feature b/features/comments.feature index 57c5f8b3c1..49713a4dac 100644 --- a/features/comments.feature +++ b/features/comments.feature @@ -15,7 +15,7 @@ Feature: commenting And I fill in "status_message_fake_text" with "Look at this dog" And I press "Share" And I wait for the ajax to finish - And I follow "All Aspects" + And I follow "My Contacts" Then I should see "Look at this dog" within ".stream_element" And I should see a "img" within ".stream_element div.photo_attachments" Then I log out diff --git a/features/connects_users.feature b/features/connects_users.feature index 43a0710e09..812343e66e 100644 --- a/features/connects_users.feature +++ b/features/connects_users.feature @@ -48,7 +48,7 @@ Feature: sending and receiving requests And I add the person to my 2nd aspect When I go to the home page - When I follow "All Aspects" in the header + When I follow "My Contacts" Then I should have 1 contact in "Unicorns" Then I should have 1 contact in "Besties" @@ -60,7 +60,7 @@ Feature: sending and receiving requests Then I go to the destroy user session page When I sign in as "bob@bob.bob" - When I follow "All Aspects" in the header + When I follow "My Contacts" Then I should have 1 contacts in "Besties" And I am on the home page @@ -79,12 +79,12 @@ Feature: sending and receiving requests And I wait for the ajax to finish When I go to the home page - When I follow "All Aspects" in the header + When I follow "My Contacts" Then I should have 1 contact in "Super People" Then I go to the destroy user session page When I sign in as "bob@bob.bob" - When I follow "All Aspects" in the header + When I follow "My Contacts" Then I should have 1 contact in "Besties" Scenario: should not see "Add to aspect" and see mention if already a follower diff --git a/features/disconnects_users.feature b/features/disconnects_users.feature index f8e3a8551c..14c2cfe0fb 100644 --- a/features/disconnects_users.feature +++ b/features/disconnects_users.feature @@ -18,7 +18,7 @@ Feature: disconnecting users And I remove the person from my 1st aspect And I am on the home page - Then I should see "no contacts" within "#sharers" + Then I should have 0 contacts in "Besties" Then I go to the destroy user session page When I sign in as "alice@alice.alice" @@ -31,7 +31,7 @@ Feature: disconnecting users And I remove the person from my 1st aspect - When I follow "All Aspects" in the header + When I follow "My Contacts" Then I should have 0 contacts in "Besties" Then I go to the destroy user session page @@ -42,14 +42,14 @@ Feature: disconnecting users Scenario: remove a non-mutual contact from the aspect edit page When I go to the home page - And I press the first ".contact-count" within "#aspect_listings" + And I follow "Edit Besties" And I wait for the ajax to finish And I preemptively confirm the alert And I press the first ".added" within "#facebox .contact_list ul > li:first-child" And I wait for the ajax to finish - When I follow "All Aspects" in the header + When I follow "My Contacts" Then I should have 0 contacts in "Besties" Then I go to the destroy user session page diff --git a/features/embedder.feature b/features/embedder.feature index 96f08da488..8a9beb4312 100644 --- a/features/embedder.feature +++ b/features/embedder.feature @@ -11,7 +11,7 @@ # Given I expand the publisher # When I fill in "status_message_fake_text" with "Look at this awesome video: https://www.youtube.com/watch?v=53tq9g35kwk" # And I press "Share" -# And I follow "All Aspects" +# And I follow "My Contacts" # Then I should see "Look at this awesome video: Youtube: Leekspin" within ".stream_element" # When I follow "Youtube: Leekspin" # And I wait for the ajax to finish diff --git a/features/manages_aspects.feature b/features/manages_aspects.feature index f42a812994..c2d6fdf395 100644 --- a/features/manages_aspects.feature +++ b/features/manages_aspects.feature @@ -6,35 +6,31 @@ Feature: User manages contacts Scenario: creating an aspect from contacts index Given I am signed in - When I follow "All Aspects" in the header - And I follow "Your Contacts" - And I follow "My Contacts" + And I am on the contacts page And I follow "+ Add an aspect" And I fill in "Name" with "Dorm Mates" in the modal window And I press "Create" in the modal window - Then I should see "Dorm Mates" in the header + Then I should see "Dorm Mates" within "#aspect_nav" Scenario: creating an aspect from homepage Given I am signed in - When I follow "All Aspects" in the header - And I follow "+" in the header + When I follow "Add an aspect" And I fill in "Name" with "losers" in the modal window And I press "Create" in the modal window - Then I should see "losers" in the header + Then I should see "losers" within "#aspect_nav" - Scenario: Editing the aspect memberships of a contact from the 'sharers' facebox + Scenario: Editing the aspect memberships of a contact from the aspect edit facebox Given I am signed in And I have 2 contacts And I have an aspect called "Cat People" - When I follow "All Aspects" in the header - And I follow "2 contacts" within "#sharers" + When I follow "My Contacts" + And I follow "Edit Cat People" And I wait for the ajax to finish - And I press the first ".toggle.button" - And I press the 2nd "li" within ".dropdown.active .dropdown_list" + And I press the first ".contact_list .button" And I wait for the ajax to finish Then I should have 1 contact in "Cat People" - When I press the 2nd "li" within ".dropdown.active .dropdown_list" + When I press the first ".contact_list .button" And I wait for the ajax to finish Then I should have 0 contacts in "Cat People" diff --git a/features/posts.feature b/features/posts.feature index 94b59108b2..89fabc5a96 100644 --- a/features/posts.feature +++ b/features/posts.feature @@ -20,7 +20,7 @@ Feature: posting Given I expand the publisher When I fill in "status_message_fake_text" with "I am eating a yogurt" And I press "Share" - And I follow "All Aspects" + And I follow "My Contacts" Then I should see "I am eating a yogurt" within ".stream_element" Scenario: post a photo without text @@ -30,7 +30,7 @@ Feature: posting Then I should see an uploaded image within the photo drop zone And I press "Share" And I wait for the ajax to finish - And I follow "All Aspects" + And I follow "My Contacts" Then I should see a "img" within ".stream_element:first div.photo_attachments" Then I log out And I sign in as "alice@alice.alice" @@ -44,7 +44,7 @@ Feature: posting And I fill in "status_message_fake_text" with "Look at this dog" And I press "Share" And I wait for the ajax to finish - And I follow "All Aspects" + And I follow "My Contacts" Then I should see a "img" within ".stream_element:first div.photo_attachments" And I should see "Look at this dog" within ".stream_element:first" Then I log out @@ -68,7 +68,7 @@ Feature: posting And I wait for the ajax to finish And I go to "bob@bob.bob"'s page Then I should not see "Here is a post for you to hide" - And I follow "All Aspects" + And I am on the aspects page Then I should not see "Here is a post for you to hide" Scenario: delete a post @@ -76,12 +76,12 @@ Feature: posting When I fill in "status_message_fake_text" with "I am eating a yogurt" And I press "Share" And I wait for the ajax to finish - And I follow "All Aspects" + And I follow "My Contacts" And I hover over the post And I preemptively confirm the alert And I click to delete the first post And I wait for the ajax to finish - And I follow "All Aspects" + And I follow "My Contacts" Then I should not see "I am eating a yogurt" Scenario Outline: post to one aspect @@ -90,8 +90,8 @@ Feature: posting And I expand the publisher And I fill in "status_message_fake_text" with "I am eating a yogurt" And I press "Share" - And I follow "All Aspects" - And I follow "<aspect>" + And I am on the aspects page + And I follow "<aspect>" within "#aspect_nav" Then I should <see> "I am eating a yogurt" Examples: @@ -106,7 +106,8 @@ Feature: posting And I expand the publisher in the modal window And I append "I am eating a yogurt" to the publisher And I press "Share" in the modal window - And I follow "<aspect>" + And I am on the aspects page + And I follow "<aspect>" within "#aspect_nav" Then I should <see> "I am eating a yogurt" Examples: @@ -122,7 +123,8 @@ Feature: posting And I append "I am eating a yogurt" to the publisher And I follow "DidntPostTo" within "#publisher" in the modal window And I press "Share" in the modal window - And I follow "<aspect>" + And I am on the aspects page + And I follow "<aspect>" within "#aspect_nav" Then I should <see> "I am eating a yogurt" Examples: diff --git a/public/javascripts/stream.js b/public/javascripts/stream.js index 3eb95739b1..3543d980a3 100644 --- a/public/javascripts/stream.js +++ b/public/javascripts/stream.js @@ -70,13 +70,20 @@ var Stream = { }); - $("textarea.comment_box", this.selector).live("focus blur", function(evt) { + $("textarea.comment_box", this.selector).live("focus", function(evt) { if (this.value === undefined || this.value === ''){ var commentBox = $(this); commentBox - .attr("rows", (evt.type === "focus") ? 2 : 1) .parent().parent() - .toggleClass("open"); + .addClass("open"); + } + }); + $("textarea.comment_box", this.selector).live("blur", function(evt) { + if (this.value === undefined || this.value === ''){ + var commentBox = $(this); + commentBox + .parent().parent() + .removeClass("open"); } }); diff --git a/public/stylesheets/sass/_mixins.scss b/public/stylesheets/sass/_mixins.scss index 3877d06892..ddde72768a 100644 --- a/public/stylesheets/sass/_mixins.scss +++ b/public/stylesheets/sass/_mixins.scss @@ -1,6 +1,7 @@ $blue: #3f8fba; $red: red; $background: #fff; +$creation-blue: #0097ff; $speed: 0.1s; $easing: linear; diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index f22455e652..45f8d3c38a 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -1,4 +1,3 @@ -// Copyright (c) 2010, Diaspora Inc. This file is // licensed under the Affero General Public License version 3 or later. See // the COPYRIGHT file. @@ -643,7 +642,7 @@ ul.show_comments, textarea :width 365px - :height 1.4em + :height 21px input :display none @@ -2925,6 +2924,9 @@ ul.left_nav .contact_count :display none !important + .all_contacts + :display none !important + .left_nav a :width 150px diff --git a/public/stylesheets/sass/ui.sass b/public/stylesheets/sass/ui.sass index 17e29802f9..0286be23ec 100644 --- a/public/stylesheets/sass/ui.sass +++ b/public/stylesheets/sass/ui.sass @@ -68,6 +68,17 @@ .button.in_aspects @include linear-gradient(lighten(#76C000,8%),#76C000) +.button.creation + @include linear-gradient(lighten($creation-blue,8%), darken($creation-blue, 3%)) + :color #fafafa + + :border 1px solid #666 + :top 1px solid #777 + :bottom 1px solid darken(#666,13%) + + &:hover + @include linear-gradient(lighten($creation-blue,3%), darken($creation-blue, 8%)) + .right :position absolute :right 0 -- GitLab