From d0569fb881b301f909afead66e8ffb955f0c99ae Mon Sep 17 00:00:00 2001 From: danielgrippi <daniel@joindiaspora.com> Date: Wed, 9 Mar 2011 12:00:07 -0800 Subject: [PATCH] simplified functionality on aspect edit faceboxes --- app/controllers/aspects_controller.rb | 11 +++++ app/views/aspects/_aspect.haml | 2 +- app/views/aspects/edit.html.haml | 43 +++++++++++------- app/views/aspects/index.html.haml | 5 -- .../aspects/toggle_contact_visibility.js | 12 +++++ app/views/aspects/update.js.erb | 5 ++ app/views/layouts/_header.html.haml | 2 +- config/assets.yml | 1 + config/locales/diaspora/en.yml | 2 +- config/routes.rb | 4 +- public/images/icons/padlock-closed.png | Bin 0 -> 486 bytes public/images/icons/padlock-open.png | Bin 0 -> 467 bytes public/javascripts/aspect-edit-pane.js | 20 ++++++++ public/javascripts/view.js | 3 ++ public/stylesheets/sass/application.sass | 32 ++++++++++++- spec/controllers/aspects_controller_spec.rb | 20 ++++++++ 16 files changed, 135 insertions(+), 27 deletions(-) create mode 100644 app/views/aspects/toggle_contact_visibility.js create mode 100644 app/views/aspects/update.js.erb create mode 100644 public/images/icons/padlock-closed.png create mode 100644 public/images/icons/padlock-open.png create mode 100644 public/javascripts/aspect-edit-pane.js diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index 519f0383ed..670b275970 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 f8af70117c..673c5ed3d6 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 c703b8887d..0ea61a4eba 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 24ef5199aa..222a7a3e00 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 0000000000..0f4c3cbccd --- /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 0000000000..52aee29be7 --- /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 07cac5d000..6e2ef5b293 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 6dc20d3db6..c4fe13165b 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 75aa1c1261..c75f8f3aee 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 793ac7a9c4..7e75420462 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 0000000000000000000000000000000000000000..af69232630ca096dbfc3f60b78b996283a4c5b97 GIT binary patch literal 486 zcmeAS@N?(olHy`uVBq!ia0y~yV2}i14mJh`h9fUqlNlHo*Lu1*hIn+oowPAKI8fr~ z`JeBqzo@csDtZ<Qy}Gin{>bXkER8K3X=R01FC9GUTM$rK@XdZl^8#l!dEF8bmsd&C ze~HgHsMuln(l&NdP~7JxLp~+T+k5Z-Jomn?M*K(ok^6?J?CiH0-c8Qwtx{RZ{NU@^ zuV1$pJMQ_uE^58K%7-Z_lh%9x(tPmod*1iZ-FNMDPjxPHT-AF_Z|QRt-%I>n@0)H4 zF3o0mH))M?RbZ|O$Ai?sK2gz4I?+qFxL;zKW6&};{_nrN(V4$=l;l|wxDTXHa?8{| zz3J*qb<T6SRz;Er4med5B_}IOU%zA`%k<+zUH$)wGxsX)ta)`ut>N)Zway0934WKh zGycqc<jmIGKVe@}iQtB?DWM#VkxUFK&K!=yii$jpJo>-Vn;D)TOf&l^eyq@E!kOQn zcWs&Mw|w)J*I#`mF>`vhY<aR*|LI;8VGpxUmhWp<2CZxfTYYstSLfs>-fLslIcqsG zHLRX^GjZ)rp6Ln<s#D$fS#M4Iyv^wa(+)dPr=rv=CU(*dr;hI4SY&RvWX6-Jd-8Aj u{hK8=fi;EkCv(S=dp3=qzx}^$#jN8rzkl7GqC5r$1_n=8KbLh*2~7YWvfkPN literal 0 HcmV?d00001 diff --git a/public/images/icons/padlock-open.png b/public/images/icons/padlock-open.png new file mode 100644 index 0000000000000000000000000000000000000000..895a25a76fe036bf9e4a5b8f15f93dab8adcf7ca GIT binary patch literal 467 zcmeAS@N?(olHy`uVBq!ia0y~yV2}i14mJh`h9fUqlNlHoXL-6fhIn+oon)UK94K+D z{=DV)OD--(DkUN%uP*RUyx}G2C~mxa$EuQoLSdN@nK^&i$^}YJJXm^@Rd8<18+C(b z=M~px&pWPqRbcTKv&oavYtDb(xBvV3#{aHXxk;8Xam;z1yNuQ*-)4UBvuyqMB2AA# zk&RdL?hD#XxiX`E``@z#|4(OpS#$rrJY!0!;#$Aw>)srn)by75=K3Ix_o?&Q^E|SW z?K4ZQnC3CHST$_YF;98##ntBT_43#E!-r>2-+kA8W{LH|&<D*+6souDobJ6fd5J{% zqAh$Oic8t2Z`*e2@%Fs!){OV|+`GM7+^Iq_^RLD+*$2sMJ&kU-bZxT_zqGrxH{@#c zo7yEa4ys*=5mz)}P+2-<lDJdQEQZOE^|l;;bYz?&ei(nY5ucRySAEyX1cM0a{^JMB zTn=s9aJ_3$#<^-$(+!8Oh<7i_;94NV_g&OUdN=2jZIhQUFZmKJIN`0a1B=#@^?sRK z?!J!w6Fm9mlsd-$Q5%;q%$eIOo2@q~`T3-Ce{+RP^NY0BDrleJDst+0`_agC+S&i* bUzquhE=b%}z*Wb<z`)??>gTe~DWM4f`^44! literal 0 HcmV?d00001 diff --git a/public/javascripts/aspect-edit-pane.js b/public/javascripts/aspect-edit-pane.js new file mode 100644 index 0000000000..97d37b67b8 --- /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 6f79f0d63b..7ae0300eeb 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 1016c158b8..d1bfdf2c3c 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 7db3811bfd..bca8e8df13 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 -- GitLab