simplified functionality on aspect edit faceboxes

This commit is contained in:
danielgrippi 2011-03-09 12:00:07 -08:00
parent c259fc65f0
commit d0569fb881
16 changed files with 135 additions and 27 deletions

View file

@ -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

View file

@ -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

View file

@ -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'

View file

@ -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

View file

@ -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');
});

View file

@ -0,0 +1,5 @@
$(document).ready(function() {
var newName = "<%= @aspect.name %>"
$("#aspect_name").val( newName );
$("*[data-guid='<%= @aspect.id %>']").find('.name').html( newName );
});

View file

@ -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'

View file

@ -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:

View file

@ -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:

View file

@ -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'

Binary file not shown.

After

Width:  |  Height:  |  Size: 486 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 467 B

View file

@ -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();
});
});

View file

@ -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: {

View file

@ -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

View file

@ -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