diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index 519f0383e..670b27597 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -136,6 +136,17 @@ class AspectsController < ApplicationController respond_with @aspect end + def toggle_contact_visibility + @aspect = current_user.aspects.where(:id => params[:aspect_id]).first + + if @aspect.contacts_visible? + @aspect.contacts_visible = false + else + @aspect.contacts_visible = true + end + @aspect.save + end + def move_contact @person = Person.find(params[:person_id]) @from_aspect = current_user.aspects.where(:id => params[:from]).first diff --git a/app/views/aspects/_aspect.haml b/app/views/aspects/_aspect.haml index f8af70117..673c5ed3d 100644 --- a/app/views/aspects/_aspect.haml +++ b/app/views/aspects/_aspect.haml @@ -3,7 +3,7 @@ %b = link_to t('contacts', :count => contacts.size), edit_aspect_path(aspect), :rel => 'facebox' %b - = link_to aspect.name, edit_aspect_path(aspect), :rel => 'facebox' + = link_to aspect.name, edit_aspect_path(aspect), :rel => 'facebox', :class => 'name' %br - if contacts.length > 0 diff --git a/app/views/aspects/edit.html.haml b/app/views/aspects/edit.html.haml index c703b8887..0ea61a4eb 100644 --- a/app/views/aspects/edit.html.haml +++ b/app/views/aspects/edit.html.haml @@ -6,25 +6,34 @@ = include_javascripts :aspects #aspect_edit_pane - #facebox_header - %h4 - = @aspect - .description - = t('contacts', :count =>@aspect_contacts_count) + #facebox_header{:data=>{:guid=>@aspect.id}} + .right + = t('contacts', :count =>@aspect_contacts_count) + + - if @aspect.contacts_visible + = link_to image_tag('icons/padlock-open.png', :height => 16, :width => 16, :id => "contact_visibility_padlock", :class => 'open'), + "aspects/#{@aspect.id}/toggle_contact_visibility", :remote => true + + - else + = link_to image_tag('icons/padlock-closed.png', :height => 16, :width => 16, :id => "contact_visibility_padlock"), + "aspects/#{@aspect.id}/toggle_contact_visibility", :remote => true + + + %h3#aspect_name_title + %span.name= @aspect + %span.tiny_text + = link_to 'rename', '#', :id => 'rename_aspect_link' + + #aspect_name_edit.hidden + = form_for @aspect, :remote => true do |aspect| + = aspect.text_field :name + = aspect.submit 'update', :disable_with => 'updating', :class => 'button' - if @contacts.count > 0 = render 'shared/contact_list', :aspect => @aspect, :contacts => @contacts - #aspect_edit_controls - = link_to t('delete'), @aspect, :method => "delete", :confirm => t('.confirm_remove_aspect') - - #rename_aspect - = form_for @aspect do |asp| - = asp.text_field :name - %p.checkbox_select{:style => 'font-size:14px'} - = asp.label :contacts_visible, t('.make_aspect_list_visible') - = asp.check_box :contacts_visible - %br - %div{:style => "text-align:right;"} - = asp.submit t('.save'), :class => 'button' + %br + %div{:style => "text-align:right;"} + = link_to t('.done'), '#', :class => 'button', :rel => 'close' + = link_to t('delete'), @aspect, :method => "delete", :confirm => t('.confirm_remove_aspect'), :class => 'button' diff --git a/app/views/aspects/index.html.haml b/app/views/aspects/index.html.haml index 24ef5199a..222a7a3e0 100644 --- a/app/views/aspects/index.html.haml +++ b/app/views/aspects/index.html.haml @@ -31,11 +31,6 @@ %h4 = new_request_link(@request_count) - #new_notifications - - if @notification_count > 0 - = image_tag 'icons/mail_big.png', :height => 20, :width => 20, :style=>"margin-top:3px;" - %h4 - = new_notification_link(@notification_count) %hr - if @invites > 0 diff --git a/app/views/aspects/toggle_contact_visibility.js b/app/views/aspects/toggle_contact_visibility.js new file mode 100644 index 000000000..0f4c3cbcc --- /dev/null +++ b/app/views/aspects/toggle_contact_visibility.js @@ -0,0 +1,12 @@ +$(document).ready(function() { + + var padlockImg = $("#contact_visibility_padlock"); + + if(padlockImg.hasClass('open')) { + padlockImg.attr('src', 'images/icons/padlock-closed.png'); + } else { + padlockImg.attr('src', 'images/icons/padlock-open.png'); + } + padlockImg.toggleClass('open'); + +}); diff --git a/app/views/aspects/update.js.erb b/app/views/aspects/update.js.erb new file mode 100644 index 000000000..52aee29be --- /dev/null +++ b/app/views/aspects/update.js.erb @@ -0,0 +1,5 @@ +$(document).ready(function() { + var newName = "<%= @aspect.name %>" + $("#aspect_name").val( newName ); + $("*[data-guid='<%= @aspect.id %>']").find('.name').html( newName ); +}); diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml index 07cac5d00..6e2ef5b29 100644 --- a/app/views/layouts/_header.html.haml +++ b/app/views/layouts/_header.html.haml @@ -51,7 +51,7 @@ - for aspect in @all_aspects %li{:data=>{:guid=>aspect.id}, :class => ("selected" if @object_aspect_ids.include?(aspect.id))} - = link_for_aspect(aspect, :class => 'aspect_selector', :title => t('contacts', :count => aspect.contacts.size)) + = link_for_aspect(aspect, :class => 'aspect_selector name', :title => t('contacts', :count => aspect.contacts.size)) %li = link_to '+', '#add_aspect_pane', :class => "add_aspect_button", :title => t('aspects.manage.add_a_new_aspect'), :rel => 'facebox' diff --git a/config/assets.yml b/config/assets.yml index 6dc20d3db..c4fe13165 100644 --- a/config/assets.yml +++ b/config/assets.yml @@ -52,6 +52,7 @@ javascripts: - public/javascripts/publisher.js - public/javascripts/aspect-filters.js - public/javascripts/contact-list.js + - public/javascripts/aspect-edit-pane.js people: - public/javascripts/vendor/jquery.autoSuggest.js photos: diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index 75aa1c126..c75f8f3ae 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -167,7 +167,7 @@ en: remove_aspect: "Delete this aspect" confirm_remove_aspect: "Are you sure you want to delete this aspect?" add_existing: "Add an existing contact" - save: "Save" + done: "Done" rename: "rename" make_aspect_list_visible: "make aspect list visible to others in aspect" aspect_contacts: diff --git a/config/routes.rb b/config/routes.rb index 793ac7a9c..7e7542046 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -63,7 +63,9 @@ Diaspora::Application.routes.draw do match 'aspects/add_to_aspect', :to => 'aspects#add_to_aspect', :as => 'add_to_aspect' match 'aspects/remove_from_aspect',:to => 'aspects#remove_from_aspect', :as => 'remove_from_aspect' match 'aspects/manage', :to => 'aspects#manage' - resources :aspects + resources :aspects do + match '/toggle_contact_visibility', :to => 'aspects#toggle_contact_visibility' + end #public routes match 'webfinger', :to => 'publics#webfinger' diff --git a/public/images/icons/padlock-closed.png b/public/images/icons/padlock-closed.png new file mode 100644 index 000000000..af6923263 Binary files /dev/null and b/public/images/icons/padlock-closed.png differ diff --git a/public/images/icons/padlock-open.png b/public/images/icons/padlock-open.png new file mode 100644 index 000000000..895a25a76 Binary files /dev/null and b/public/images/icons/padlock-open.png differ diff --git a/public/javascripts/aspect-edit-pane.js b/public/javascripts/aspect-edit-pane.js new file mode 100644 index 000000000..97d37b67b --- /dev/null +++ b/public/javascripts/aspect-edit-pane.js @@ -0,0 +1,20 @@ +/* Copyright (c) 2010, Diaspora Inc. This file is +* licensed under the Affero General Public License version 3 or later. See +* the COPYRIGHT file. +*/ + +function toggleAspectTitle(){ + $("#aspect_name_title").toggleClass('hidden'); + $("#aspect_name_edit").toggleClass('hidden'); +} + +$(document).ready(function() { + $('#rename_aspect_link').live('click', function(){ + toggleAspectTitle(); + }); + + $(".edit_aspect").live('ajax:success', function(data, json, xhr) { + toggleAspectTitle(); + }); + +}); diff --git a/public/javascripts/view.js b/public/javascripts/view.js index 6f79f0d63..7ae0300ee 100644 --- a/public/javascripts/view.js +++ b/public/javascripts/view.js @@ -58,6 +58,9 @@ var View = { $.facebox.settings.closeImage = '/images/facebox/closelabel.png' $.facebox.settings.loadingImage = '/images/facebox/loading.gif' $('a[rel*=facebox]').facebox(); + + /* facebox 'done' buttons */ + $("a[rel*=close]").live('click', function(){ $.facebox.close() }); }, addAspectButton: { diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 1016c158b..d1bfdf2c3 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -1191,7 +1191,6 @@ ul#aspect_nav .tip :display inline - .aspect_name :position relative @@ -2340,6 +2339,7 @@ ul.show_comments :width 200px #facebox_header + :position relative :padding 1em :background :color #222 @@ -2350,11 +2350,38 @@ ul.show_comments :-moz-border-radius 5px 5px 0 0 :border-radius 5px 5px 0 0 + .right + :z-index 3 + :right 1em + :top 14px + :color #ccc + + img + :vertical + :align top + :position relative + :top 0px + + h3, h4 :color #eee :margin :bottom 0 + .description + :margin + :top 0px + :left -3px + + .tiny_text + :font + :size 11px + :weight normal + +#facebox + .close + :display none + #aspect_edit_controls :margin :top 8px @@ -2709,3 +2736,6 @@ ul.show_comments :align right :margin :right 5px + +#contact_visibility_padlock:hover + :opacity 0.7 diff --git a/spec/controllers/aspects_controller_spec.rb b/spec/controllers/aspects_controller_spec.rb index 7db3811bf..bca8e8df1 100644 --- a/spec/controllers/aspects_controller_spec.rb +++ b/spec/controllers/aspects_controller_spec.rb @@ -279,6 +279,26 @@ describe AspectsController do describe "#hashes_for_posts" do it 'returns only distinct people' do + pending end end + + describe "#toggle_contact_visibility" do + it 'sets contacts visible' do + @aspect0.contacts_visible = false + @aspect0.save + + get :toggle_contact_visibility, :format => 'js', :aspect_id => @aspect0.id + @aspect0.reload.contacts_visible.should be_true + end + + it 'sets contacts hidden' do + @aspect0.contacts_visible = true + @aspect0.save + + get :toggle_contact_visibility, :format => 'js', :aspect_id => @aspect0.id + @aspect0.reload.contacts_visible.should be_false + end + + end end