Simplify aspect dropdown views

This commit is contained in:
Raphael Sofaer 2011-08-16 12:43:08 -07:00
parent 56fc409a39
commit 140268365c
7 changed files with 17 additions and 22 deletions

View file

@ -66,20 +66,14 @@ module AspectGlobalHelper
end
def aspect_membership_dropdown(contact, person, hang, aspect=nil)
@selected_aspects = []
if contact.persisted?
@selected_aspects = all_aspects.find_all{|aspect| contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}}
end
@selected_aspects = [@selected_aspects] if @selected_aspects.kind_of? Aspect
selected_aspects = all_aspects.select{|aspect| contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id } }
render "shared/aspect_dropdown",
:contact => @contact,
:selected_aspects => @selected_aspects,
:selected_aspects => selected_aspects,
:person => person,
:hang => hang,
:dropdown_class => "aspect_membership",
:button_class => ("in_aspects" if @selected_aspects.size > 0),
:may_create_new_aspect => ( @aspect == :profile || @aspect == :tag || @aspect == :search || @aspect == :notification)
:dropdown_class => "aspect_membership"
end
def aspect_dropdown_list_item(aspect, checked)
@ -94,4 +88,8 @@ module AspectGlobalHelper
LISTITEM
str.html_safe
end
def dropdown_may_create_new_aspect
@aspect == :profile || @aspect == :tag || @aspect == :search || @aspect == :notification
end
end

View file

@ -16,7 +16,7 @@
- else
= @aspects.to_sentence
= render 'shared/publisher', :aspect => aspect, :aspect_ids => aspect_ids
= render 'shared/publisher', :selected_aspects => @aspects, :aspect_ids => aspect_ids, :aspect => @aspect
- if posts.length == 0
= render 'aspects/no_posts_message'

View file

@ -17,4 +17,4 @@
%a.more-link.paginate{:href => next_page_path}
%h2= t("more")
- content_for :subpages do
= render 'shared/publisher', :aspect_ids => @aspect_ids
= render 'shared/publisher', :aspect_ids => @aspect_ids, :selected_aspects => @aspects, :aspect => @aspect

View file

@ -3,10 +3,7 @@
-# the COPYRIGHT file.
.dropdown{:class => ["hang_#{hang}", defined?(dropdown_class) && dropdown_class]}
- selected_aspects = [selected_aspects] if selected_aspects.kind_of? Aspect
- if !selected_aspects.kind_of? Array
- selected_aspects = all_aspects
.button.toggle{:class => (button_class if defined?(button_class))}
.button.toggle{:class => ("in_aspects" if selected_aspects.size > 0)}
- if selected_aspects.size == 1
= selected_aspects.first.name
- else
@ -18,7 +15,7 @@
- for aspect in all_aspects
= aspect_dropdown_list_item(aspect, selected_aspects.include?(aspect) )
- if (defined?may_create_new_aspect && may_create_new_aspect) && (defined?person && person)
- if (dropdown_may_create_new_aspect && defined?(person) && person)
%li.newItem
.add_aspect
= link_to t('contacts.index.add_a_new_aspect'), new_aspect_path(:person_id => person.id), :rel => 'facebox'

View file

@ -39,7 +39,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')
= render "shared/aspect_dropdown", :selected_aspects => Aspect.find(aspect_ids), :hang => 'left'
= render "shared/aspect_dropdown", :selected_aspects => selected_aspects, :hang => 'left'
= status.submit t('.share'), :disable_with => t('.posting'), :class => 'button creation', :tabindex => 2
.facebox_content

View file

@ -10,7 +10,7 @@
:javascript
Diaspora.widgets.i18n.loadLocale(#{get_javascript_strings_for(current_user.language).to_json}, "#{current_user.language}");
$(document).ready(function()
$(document).ready(function()
{
Publisher.open();
$("#publisher").bind('ajax:success', function(){
@ -24,7 +24,7 @@
if ("#{params[:notes]}".length > 0){
contents = contents + " - #{params[:notes]}";
}
$("#publisher #status_message_fake_text").val(contents);
$("#publisher #status_message_text").val(contents);
$('input.button')[0].removeAttribute('disabled');
@ -34,5 +34,5 @@
.span-15.last
%h4
=t('bookmarklet.post_something')
= render :partial => 'shared/publisher', :locals => { :aspect => :profile, :aspects_with_person => @aspects, :aspect_ids => @aspect_ids}
= render :partial => 'shared/publisher', :locals => { :aspect => :profile, :selected_aspects => @aspects, :aspect_ids => @aspect_ids }

View file

@ -6,7 +6,7 @@
= javascript_include_tag "publisher.js"
:javascript
$(document).ready(function()
$(document).ready(function()
{
var person = {name: '#{@person.name}', handle: '#{@person.diaspora_handle}' };
Publisher.autocompletion.onSelect($("#status_message_fake_text"),person,'#{@person.name}');
@ -21,5 +21,5 @@
%h3
= t('.mentioning', :person => @person.name)
= render :partial => 'shared/publisher', :locals => { :aspect => @aspect, :aspect_ids => @aspect_ids, :aspects_with_person => @aspects_with_person, :person => @person}
= render :partial => 'shared/publisher', :locals => { :aspect => @aspect, :aspect_ids => @aspect_ids, :selected_aspects => @aspects_with_person, :person => @person}