add some feedback text & animation; added spec for collapsing tags

This commit is contained in:
danielgrippi 2011-10-27 19:57:00 -07:00
parent e8169ee581
commit 0def71d74f
8 changed files with 23 additions and 10 deletions

View file

@ -14,13 +14,13 @@ class TagFollowingsController < ApplicationController
# POST /tag_followings
# POST /tag_followings.xml
def create
@tag = ActsAsTaggableOn::Tag.find_or_create_by_name(params[:name])
@tag = ActsAsTaggableOn::Tag.find_or_create_by_name(tag_name)
@tag_following = current_user.tag_followings.new(:tag_id => @tag.id)
if @tag_following.save
flash[:notice] = I18n.t('tag_followings.create.success', :name => params[:name])
flash[:notice] = I18n.t('tag_followings.create.success', :name => tag_name)
else
flash[:error] = I18n.t('tag_followings.create.failure', :name => params[:name])
flash[:error] = I18n.t('tag_followings.create.failure', :name => tag_name)
end
redirect_to :back
@ -63,4 +63,9 @@ class TagFollowingsController < ApplicationController
redirect_to multi_path
end
private
def tag_name
@tag_name ||= params[:name].gsub(/\s/,'') if params[:name]
end
end

View file

@ -10,7 +10,7 @@
%ul.sub_nav
- if tags.size > 0
- for tg in tags
%li.unfollow{:id => tg.name}
%li.unfollow{:id => "tag-following-#{tg.name}"}
.unfollow_icon.hidden
= link_to image_tag("icons/monotone_close_exit_delete.png", :height => 16, :title => t('aspects.index.unfollow_tag', :tag => tg.name)), tag_tag_followings_path(:name => tg.name, :remote => true), :confirm => t('are_you_sure'), :method => :delete, :remote => true, :id => "unfollow_" + tg.name
= link_to "##{tg.name}", tag_path(:name => tg.name), :class => "tag_selector"

View file

@ -1 +1,3 @@
$("#followed_tags_listing").first().html("<%= escape_javascript(render('tags/followed_tags_listings')) =%>");
var tagName = "<%= escape_javascript(@tag.name) %>"
$("#followed_tags_listing").find("#tag-following-"+tagName).slideUp(100);
Diaspora.page.flashMessages.render({success: true, notice: Diaspora.I18n.t("tags.wasnt_that_interesting", {tagName: tagName})});

View file

@ -819,8 +819,8 @@ en:
followed_by: 'followed by'
tag_followings:
create:
success: "Successfully following: #%{name}"
failure: "Failed to follow: #%{name}"
success: "Horray! You're now following #%{name}."
failure: "Failed to follow #%{name}. Are you already following it?"
destroy:
success: "Successfully stopped following: #%{name}"
failure: "Failed to stop following: #%{name}"

View file

@ -66,3 +66,5 @@ en:
preparing_your_stream: "Preparing your personialized stream..."
photo_uploader:
looking_good: "OMG, you look awesome!"
tags:
wasnt_that_interesting: "OK, I suppose #{{tagName}} wasn't all that interesting..."

View file

@ -49,8 +49,6 @@ var View = {
/* tag following */
$("#new_tag_following .tag_input").bind('focus', function(evt){
$(this).siblings("#tag_following_submit").removeClass('hidden');
}).bind('blur', function(evt){
$(this).siblings("#tag_following_submit").addClass('hidden');
});
/* Autoexpand textareas */

View file

@ -91,7 +91,8 @@ form
@include border-radius(6px)
@include box-shadow(0, 1px, 5px, rgba(0,0,0,0.4))
:display inline-block
:width 400px
:min-width 400px
:max-width 800px
:padding
:top 45px
:bottom 8px

View file

@ -66,6 +66,11 @@ describe TagFollowingsController do
flash[:error].should == "Failed to follow: ##{valid_attributes[:name]}"
end
it 'squashes the tag' do
post :create, :name => "some stuff"
assigns[:tag].name.should == "somestuff"
end
it 'downcases the tag name' do
pending "THIS CAUSES A 500 WE NEED TO FIX IT"
post "tags/#{valid_attributes[:name].upcase}/tag_followings"