Revert "Merge branch 'issue1586-aspectdropdown-when-posting'"

This reverts commit 2777f16f4f, reversing
changes made to 8b278adff6.
This commit is contained in:
Ilyaaaaaaaaaaaaa Zhitomirskiy 2011-08-18 16:16:14 -07:00
parent 2777f16f4f
commit a407f12463
25 changed files with 97 additions and 159 deletions

View file

@ -158,7 +158,7 @@ class PeopleController < ApplicationController
def aspect_membership_dropdown
@person = Person.find(params[:person_id])
@contact = current_user.contact_for(@person) || Contact.new
render :partial => 'aspect_membership_dropdown', :locals => {:contact => @contact, :person => @person, :hang => 'left'}
render :partial => 'aspect_memberships/aspect_dropdown', :locals => {:contact => @contact, :person => @person, :hang => 'left'}
end
private

View file

@ -65,17 +65,8 @@ module AspectGlobalHelper
end
end
def aspect_membership_dropdown(contact, person, hang, aspect=nil)
selected_aspects = all_aspects.select{|aspect| contact.in_aspect?(aspect) }
render "shared/aspect_dropdown",
:selected_aspects => selected_aspects,
:person => person,
:hang => hang,
:dropdown_class => "aspect_membership"
end
def aspect_dropdown_list_item(aspect, checked)
def aspect_dropdown_list_item(aspect, contact, person)
checked = (contact.persisted? && contact.in_aspect?(aspect))
klass = checked ? "selected" : ""
str = <<LISTITEM
@ -85,8 +76,4 @@ 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

@ -0,0 +1,21 @@
-# Copyright (c) 2011, Diaspora Inc. This file is
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
.dropdown{:class => "hang_#{hang} #{extra_class if defined?(extra_class)}"}
.button.toggle{:class => ("in_aspects" if contact.aspects.size > 0)}
- if contact.aspects.size == 1
= contact.aspects.first.name
- else
= t('.toggle', :count => contact.aspects.size)
&#9660;
.wrapper
%ul.dropdown_list{:unSelectable => 'on', 'data-person_id' => ((person.id) if person), 'data-service_uid' => (service_uid if defined?(service_uid))}
- for aspect in all_aspects
= aspect_dropdown_list_item(aspect, contact, person)
- if @aspect && (@aspect == :profile || @aspect == :getting_started || @aspect == :tag || @aspect == :search || @aspect == :notification)
%li.newItem
.add_aspect
= link_to t('contacts.index.add_a_new_aspect'), new_aspect_path(:person_id => person.id), :rel => 'facebox', :class => 'new_aspect'

View file

@ -0,0 +1,6 @@
-# Copyright (c) 2011, Diaspora Inc. This file is
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
= aspect_dropdown_list_item(aspect, contact, person)

View file

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

View file

@ -3,7 +3,7 @@
// the COPYRIGHT file.
var dropdown = $("ul.dropdown_list[data-person_id=<%= @person.id %>]")
$('.newItem', dropdown).before("<%= escape_javascript( aspect_dropdown_list_item(@aspect, @contact.aspects.include?(@aspect))) %>");
$('.newItem', dropdown).before("<%= escape_javascript( render('aspect_memberships/aspect_dropdown_list_item', :aspect => @aspect, :person => @person, :contact => @contact)) %>");
ContactEdit.updateNumber(dropdown, "<%= @person.id %>", <%= @contact.aspects.size %>);
$.facebox.close();

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, :selected_aspects => @aspects, :aspect => @aspect
= render 'shared/publisher', :aspect_ids => @aspect_ids

View file

@ -23,7 +23,7 @@
= contact.person.diaspora_handle
.right
= aspect_membership_dropdown(contact, contact.person, 'right')
= render 'aspect_memberships/aspect_dropdown', :contact => contact, :person => contact.person, :hang => 'right'
%br
%div{:style => "text-align:right;"}

View file

@ -24,7 +24,7 @@
.stream_element{:data=>{:guid => note.id}, :class => "#{note.unread ? 'unread' : ''}"}
- if note.type == "Notifications::StartedSharing" && contact = current_user.contact_for(note[:target])
.right
= aspect_membership_dropdown(contact, note[:target], 'left')
= render 'aspect_memberships/aspect_dropdown', :contact => contact, :person => note[:target], :hang => 'left'
%span.from
= notification_message_for(note)

View file

@ -1 +0,0 @@
= aspect_membership_dropdown(@contact, @person, 'left')

View file

@ -1,6 +1,6 @@
- unless person == current_user.person
- contact = current_user.contacts.find_by_person_id(person.id)
- contact ||= Contact.new(:person => person)
= aspect_membership_dropdown(contact, person, 'left')
= render 'aspect_memberships/aspect_dropdown', :contact => contact, :person => person, :hang => 'left'
-else
= t('people.person.thats_you')

View file

@ -1,7 +1,7 @@
#author_info
.right
- if user_signed_in? && current_user.person != person
= aspect_membership_dropdown(contact, person, 'left')
= render 'aspect_memberships/aspect_dropdown', :contact => contact, :person => person, :hang => 'left'
- elsif user_signed_in? && current_user.person == person
= link_to t('people.profile_sidebar.edit_my_profile'), edit_profile_path, :class => 'button creation'

View file

@ -4,9 +4,9 @@
- if friend.already_invited?
= link_to t('.resend'), service_inviter_path(:uid => friend.uid, :provider => 'facebook', :invitation_id => friend.invitation_id)
- elsif friend.on_diaspora?
= render 'shared/aspect_dropdown', :selected_aspects => contact_proxy(friend).aspects, :person => friend.person, :hang => 'left'
= render 'aspect_memberships/aspect_dropdown', :contact => contact_proxy(friend), :person => friend.person, :hang => 'left'
- else
= render 'shared/aspect_dropdown', :selected_aspects => contact_proxy(friend).aspects, :person => friend.person, :hang => 'left', :dropdown_class => 'inviter', :service_uid => friend.uid
= render 'aspect_memberships/aspect_dropdown', :contact => contact_proxy(friend), :person => friend.person, :hang => 'left', :extra_class => 'inviter', :service_uid => friend.uid
- if friend.on_diaspora?
= person_image_link(friend.person, :size => :thumb_small)

View file

@ -1,21 +0,0 @@
-# Copyright (c) 2011, Diaspora Inc. This file is
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
.dropdown{:class => ["hang_#{hang}", defined?(dropdown_class) && dropdown_class]}
.button.toggle{:class => ("in_aspects" if selected_aspects.size > 0)}
- if selected_aspects.size == 1
= selected_aspects.first.name
- else
= t('.toggle', :count => selected_aspects.size)
&#9660;
.wrapper
%ul.dropdown_list{:unSelectable => 'on', 'data-person_id' => (person.id if defined?(person) && person), 'data-service_uid' => (service_uid if defined?(service_uid))}
- for aspect in all_aspects
= aspect_dropdown_list_item(aspect, selected_aspects.include?(aspect) )
- 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

@ -29,6 +29,12 @@
= hidden_field_tag 'aspect_ids[]', aspect_id.to_s
.options_and_submit
- if aspect == :profile
.mention_helper
.badges
%i= t('.publishing_to')
= aspect_badges(aspects_with_person, :link => false)
.public_toggle
%span#publisher_service_icons
= t("shared.publisher.click_to_share_with")
@ -39,7 +45,6 @@
- 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 => 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, :selected_aspects => @aspects, :aspect_ids => @aspect_ids }
= render :partial => 'shared/publisher', :locals => { :aspect => :profile, :aspects_with_person => @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, :selected_aspects => @aspects_with_person, :person => @person}
= render :partial => 'shared/publisher', :locals => { :aspect => @aspect, :aspect_ids => @aspect_ids, :aspects_with_person => @aspects_with_person, :person => @person}

View file

@ -42,7 +42,6 @@ javascripts:
- public/javascripts/stream.js
- public/javascripts/content-updater.js
- public/javascripts/search.js
- public/javascripts/aspects-dropdown.js
- public/javascripts/contact-edit.js
- public/javascripts/contact-list.js
- public/javascripts/aspect-sorting.js

View file

@ -180,6 +180,14 @@ en:
success: "Successfully removed person from aspect"
failure: "Failed to remove person from aspect"
no_membership: "Could not find the selected person in that aspect"
aspect_dropdown:
add_to_aspect: "Add to aspect"
toggle:
zero: "Add to aspect"
one: "In %{count} aspect"
few: "In %{count} aspects"
many: "In %{count} aspects"
other: "In %{count} aspects"
bookmarklet:
heading: "Bookmarklet"
@ -645,14 +653,6 @@ en:
not_on_diaspora: "Not yet on Diaspora"
shared:
aspect_dropdown:
add_to_aspect: "Add to aspect"
toggle:
zero: "Add to aspect"
one: "In %{count} aspect"
few: "In %{count} aspects"
many: "In %{count} aspects"
other: "In %{count} aspects"
publisher:
posting: "Posting..."
share: "Share"

View file

@ -154,8 +154,7 @@ Feature: posting
And I click "Mention" button
And I expand the publisher in the modal window
And I append "I am eating a yogurt" to the publisher
And I press the aspect dropdown in the modal window
And I toggle the aspect "DidntPostTo" in the modal window
And I follow "DidntPostTo" within "#publisher" in the modal window
And I press "Share" in the modal window
And I am on the aspects page
And I follow "<aspect>" within "#aspect_nav"

View file

@ -11,15 +11,6 @@ And /^I expand the publisher$/ do
')
end
When /^I press the aspect dropdown$/ do
find('.dropdown .button').click
end
And /^I toggle the aspect "([^"]*)"$/ do |aspect_name|
aspect = @me.aspects.where(:name => aspect_name).first
find("li[data-aspect_id='#{aspect.id}']").click
end
Then /^the publisher should be collapsed$/ do
find("#publisher")["class"].should include("closed")
end

View file

@ -1,33 +0,0 @@
// Copyright (c) 2011, Diaspora Inc. This file is
// licensed under the Affero General Public License version 3 or later. See
// the COPYRIGHT file.
var AspectsDropdown = {
updateNumber: function(dropdown, personId, number, inAspectClass){
var button = dropdown.parents(".dropdown").children('.button.toggle'),
replacement;
if (number == 0) {
button.removeClass(inAspectClass);
replacement = Diaspora.widgets.i18n.t("aspect_dropdown.toggle.zero");
}else if (number == 1) {
button.addClass(inAspectClass);
replacement = dropdown.find(".selected").first().text();
}else if (number < 3) {
replacement = Diaspora.widgets.i18n.t('aspect_dropdown.toggle.few', { count: number.toString()})
}else if (number > 3) {
replacement = Diaspora.widgets.i18n.t('aspect_dropdown.toggle.many', { count: number.toString()})
}else {
//the above one are a tautology, but I want to have them here once for once we figure out a neat way i18n them
replacement = Diaspora.widgets.i18n.t('aspect_dropdown.toggle.other', { count: number.toString()})
}
button.html(replacement + ' ▼');
},
toggleCheckbox:
function(check){
check.parent('li').toggleClass('selected');
},
};

View file

@ -4,8 +4,7 @@
var ContactEdit = {
init: function(){
$.extend(ContactEdit, AspectsDropdown);
$('.dropdown.aspect_membership .dropdown_list > li').live('click', function(evt){
$('.dropdown .dropdown_list > li').live('click', function(evt){
ContactEdit.processClick($(this), evt);
});
},
@ -45,11 +44,33 @@ var ContactEdit = {
"_method": (selected) ? "DELETE" : "POST"
}, function(aspectMembership) {
li.removeClass('loading')
ContactEdit.toggleCheckbox(checkbox);
ContactEdit.updateNumber(li.closest(".dropdown_list"), li.parent().data("person_id"), aspectMembership.aspect_ids.length, 'in_aspect');
li.toggleClass("selected");
ContactEdit.updateNumber(li.closest(".dropdown_list"), li.parent().data("person_id"), aspectMembership.aspect_ids.length);
Diaspora.widgets.publish("aspectDropdown/updated", [li.parent().data("person_id"), li.parents(".dropdown").parent(".right").html()]);
});
},
updateNumber: function(dropdown, personId, number){
var button = dropdown.parents(".dropdown").children('.button.toggle'),
replacement;
if (number == 0) {
button.removeClass("in_aspects");
replacement = Diaspora.widgets.i18n.t("aspect_dropdown.toggle.zero");
}else if (number == 1) {
button.addClass("in_aspects");
replacement = dropdown.find(".selected").first().text();
}else if (number < 3) {
replacement = Diaspora.widgets.i18n.t('aspect_dropdown.toggle.few', { count: number.toString()})
}else if (number > 3) {
replacement = Diaspora.widgets.i18n.t('aspect_dropdown.toggle.many', { count: number.toString()})
}else {
//the above one are a tautology, but I want to have them here once for once we figure out a neat way i18n them
replacement = Diaspora.widgets.i18n.t('aspect_dropdown.toggle.other', { count: number.toString()})
}
button.html(replacement + ' ▼');
},
};
$(document).ready(function(){

View file

@ -315,12 +315,6 @@ var Publisher = {
'<input id="services_" name="services[]" type="hidden" value="'+provider+'">');
}
},
selectedAspectIds: function() {
var aspects = $('#publisher [name="aspect_ids[]"]');
var aspectIds = [];
aspects.each(function() { aspectIds.push( parseInt($(this).attr('value'))); });
return aspectIds;
},
toggleAspectIds: function(aspectId) {
var hidden_field = $('#publisher [name="aspect_ids[]"][value="'+aspectId+'"]');
if(hidden_field.length > 0){
@ -344,25 +338,18 @@ var Publisher = {
$('#status_message_fake_text').charCount({allowed: min, warning: min/10 });
}
},
bindAspectToggles: function() {
$('#publisher .dropdown .dropdown_list li').bind("click", function(evt){
var li = $(this),
button = li.find('.button'),
checkbox = li.find('img.check');
if(button.hasClass('disabled')) { return; }
AspectsDropdown.toggleCheckbox(checkbox);
AspectsDropdown.updateNumber(li.closest(".dropdown_list"), null, li.parent().find('li.selected').length, '');
Publisher.toggleAspectIds(li.attr('data-aspect_id'));
$('#publisher .aspect_badge').bind("click", function(){
var unremovedAspects = $(this).parent().children('.aspect_badge').length - $(this).parent().children(".aspect_badge.removed").length;
if(!$(this).hasClass('removed') && ( unremovedAspects == 1 )){
alert(Diaspora.widgets.i18n.t('publisher.at_least_one_aspect'));
}else{
Publisher.toggleAspectIds($(this).children('a').attr('data-guid'));
$(this).toggleClass("removed");
}
});
},
beforeSubmit: function(){
if($("#publisher .content_creation form #aspect_ids_").length == 0){
alert(Diaspora.widgets.i18n.t('publisher.at_least_one_aspect'));
return false;
}
},
onSubmit: function(data, json, xhr){
$("#photodropzone").find('li').remove();
$("#publisher textarea").removeClass("with_attachments").css('paddingBottom', '');
@ -376,21 +363,7 @@ var Publisher = {
}
},
onSuccess: function(data, json, xhr){
var isPostVisible = false;
var postedTo = Publisher.selectedAspectIds();
$.each(AspectFilters.selectedGUIDS, function(index, value){
if(postedTo.indexOf(parseInt(value))>-1)
isPostVisible = true;
});
if(isPostVisible)
ContentUpdater.addPostToStream(json.html);
else
Diaspora.widgets.flashes.render({
success: true,
message: Diaspora.widgets.i18n.t('successfully_posted_message_to_an_aspects_that_is_not_visible')
});
ContentUpdater.addPostToStream(json.html);
//collapse publisher
Publisher.close();
Publisher.clear();
@ -398,7 +371,6 @@ var Publisher = {
Stream.setUpAudioLinks();
},
bindAjax: function(){
Publisher.form().bind('submit', Publisher.beforeSubmit);
Publisher.form().bind('ajax:loading', Publisher.onSubmit);
Publisher.form().bind('ajax:failure', Publisher.onFailure);
Publisher.form().bind('ajax:success', Publisher.onSuccess);

View file

@ -765,12 +765,8 @@ a.paginate, #infscr-loading
&:hover
:border 1px solid #1C6D99
#main_stream
:position relative
:z-index 0
.pagination
:display none
#main_stream .pagination
:display none
.request_buttons
:position absolute
@ -870,7 +866,7 @@ label
#publisher
:z-index 1
:z-index 0
:color #999
:position relative
:margin
@ -934,9 +930,6 @@ label
.public_toggle
:text
:align right
.dropdown
:text
:align left
#publisher_service_icons
:position relative
@ -952,7 +945,6 @@ label
:position relative
:top -2px
.content_creation
:margin
:top 1em