Skip to content
Extraits de code Groupes Projets
Valider 14283698 rédigé par Steffen van Bergerem's avatar Steffen van Bergerem Validation de Dennis Schubert
Parcourir les fichiers

Mobile: Add button to follow/unfollow tags

parent 59e57c01
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -18,6 +18,7 @@
//= require widgets/timeago
//= require mobile/mobile_file_uploader
//= require mobile/profile_aspects
//= require mobile/tag_following
$(document).ready(function(){
......
$(document).ready(function(){
$(".tag_following_action").bind("tap click", function(evt){
evt.preventDefault();
var button = $(this),
tagName = button.data("name");
if(button.hasClass("btn-success")){
$.ajax({
url: Routes.tag_followings_path(),
data: JSON.stringify({"name": tagName}),
type: "POST",
dataType: "json",
headers: {
"Accept": "application/json, text/javascript, */*; q=0.01"
},
contentType: "application/json; charset=UTF-8"
}).done(function(data) {
gon.preloads.tagFollowings.push(data);
button.removeClass("btn-success").addClass("btn-danger");
button.text(Diaspora.I18n.t("stream.tags.stop_following", {tag: tagName}));
}).fail(function() {
alert(Diaspora.I18n.t("stream.tags.follow_error", {name: "#" + tagName}));
});
}
else if(button.hasClass("btn-danger")){
var tagFollowing = _.findWhere(gon.preloads.tagFollowings,{name: tagName});
if(!tagFollowing) { return; }
$.ajax({
url: Routes.tag_following_path(tagFollowing.id),
dataType: "json",
type: "DELETE",
headers: {
"Accept": "application/json, text/javascript, */*; q=0.01"
}
}).done(function() {
button.removeClass("btn-danger").addClass("btn-success");
button.text(Diaspora.I18n.t("stream.tags.follow", {tag: tagName}));
}).fail(function() {
alert(Diaspora.I18n.t("stream.tags.stop_following_error", {name: "#" + tagName}));
});
}
});
});
......@@ -1210,3 +1210,5 @@ select#aspect_ids_ {
#app #main h1 {
word-wrap: break-word;
}
.tag_following_action { margin: 5px 0 10px 0; }
......@@ -4,6 +4,13 @@
%h1
= @stream.display_tag_name
- if user_signed_in?
- unless tag_followed?
.btn.btn-success.tag_following_action{data: {name: @stream.tag_name}}
= t(".follow", tag: @stream.tag_name)
- else
.btn.btn-danger.tag_following_action{data: {name: @stream.tag_name}}
= t(".stop_following", tag: @stream.tag_name)
#main_stream.stream
= render 'shared/stream', :posts => @stream.stream_posts
......
......@@ -206,6 +206,8 @@ en:
follow: "Follow #<%= tag %>"
following: "Following #<%= tag %>"
stop_following: "Stop following #<%= tag %>"
follow_error: "Couldn’t follow <%= name %> :("
stop_following_error: "Couldn’t stop following <%= name %> :("
header:
home: "Home"
......
......@@ -2,13 +2,31 @@
Feature: Interacting with tags
Background:
Given a user with username "alice"
And "alice@alice.alice" has a public post with text "Hello! i am #newhere"
When I sign in as "alice@alice.alice"
Given following users exist:
| username |
| bob |
| alice |
And "alice@alice.alice" has a public post with text "Hello! I am #newhere"
When I sign in as "bob@bob.bob"
And I visit the mobile search page
And I fill in the following:
| q | #newhere |
And I press "Search"
Then I should see "Follow #newhere" within ".tag_following_action"
Scenario: Start and stop following a tag
When I click on selector ".tag_following_action"
Then I should see "Stop following #newhere" within ".tag_following_action"
When I am on the home page
Then I should see "Hello! I am #newhere"
Scenario: Searching for a tag
When I visit the mobile search page
And I fill in the following:
| q | #newhere |
And I press "Search"
Then I should see "#newhere" within ".ltr"
Then I should see "Stop following #newhere" within ".tag_following_action"
When I click on selector ".tag_following_action"
Then I should see "Follow #newhere" within ".tag_following_action"
When I am on the home page
Then I should not see "Hello! I am #newhere"
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter