Added post moderation buttons in SPV

This commit is contained in:
Faldrian 2015-01-11 20:04:26 +01:00
parent d02102c7d0
commit 31c39a59d1
12 changed files with 226 additions and 11 deletions

View file

@ -153,6 +153,7 @@ diaspora.yml file**. The existing settings from 0.4.x and before will not work a
* Strip EXIF data from newly uploaded images [#5510](https://github.com/diaspora/diaspora/pull/5510)
* Hide user setting if the community spotlight is not enabled on the pod [#5562](https://github.com/diaspora/diaspora/pull/5562)
* Add HTML view for pod statistics [#5464](https://github.com/diaspora/diaspora/pull/5464)
* Added/Moved hide, block user, report and delete button in SPV [#5547](https://github.com/diaspora/diaspora/pull/5547)
# 0.4.1.2

View file

@ -8,7 +8,10 @@ app.views.Feedback = app.views.Base.extend({
events: {
"click .like" : "toggleLike",
"click .reshare" : "resharePost",
"click .post_report" : "report"
"click .post_report" : "report",
"click .block_user" : "blockUser",
"click .hide_post" : "hidePost",
},
tooltipSelector : ".label",
@ -40,7 +43,46 @@ app.views.Feedback = app.views.Base.extend({
if(evt) { evt.preventDefault(); }
if(!window.confirm(Diaspora.I18n.t("reshares.post", {name: this.model.reshareAuthor().name}))) { return }
this.model.interactions.reshare();
}
},
blockUser: function(evt) {
if(evt) { evt.preventDefault(); }
if(!confirm(Diaspora.I18n.t('ignore_user'))) { return; }
this.model.blockAuthor()
.done(function() {
// return to stream
document.location.href = "/stream";
})
.fail(function() {
Diaspora.page.flashMessages.render({
success: false,
notice: Diaspora.I18n.t('hide_post_failed')
});
});
},
hidePost : function(evt) {
if(evt) { evt.preventDefault(); }
if(!confirm(Diaspora.I18n.t('hide_post'))) { return; }
$.ajax({
url : "/share_visibilities/42",
type : "PUT",
data : {
post_id : this.model.id
}
}).done(function() {
// return to stream
document.location.href = "/stream";
})
.fail(function() {
Diaspora.page.flashMessages.render({
success: false,
notice: Diaspora.I18n.t('ignore_post_failed')
});
});
},
});
// @license-end

View file

@ -6,6 +6,7 @@ app.views.SinglePostContent = app.views.Base.extend({
subviews : {
"#single-post-actions" : "singlePostActionsView",
'#single-post-moderation': "singlePostModerationView",
'#real-post-content' : 'postContentView',
".oembed" : "oEmbedView",
".opengraph" : "openGraphView",
@ -15,6 +16,7 @@ app.views.SinglePostContent = app.views.Base.extend({
initialize : function() {
this.singlePostActionsView = new app.views.SinglePostActions({model: this.model});
this.singlePostModerationView = new app.views.SinglePostModeration({model: this.model});
this.oEmbedView = new app.views.OEmbed({model : this.model});
this.openGraphView = new app.views.SPVOpenGraph({model : this.model});
this.postContentView = new app.views.ExpandedStatusMessage({model: this.model});

View file

@ -0,0 +1,47 @@
app.views.SinglePostModeration = app.views.Feedback.extend({
templateName: "single-post-viewer/single-post-moderation",
events: function() {
return _.defaults({
"click .remove_post": "destroyModel",
}, app.views.Feedback.prototype.events);
},
presenter: function() {
var interactions = this.model.interactions;
return _.extend(this.defaultPresenter(), {
authorIsCurrentUser : this.authorIsCurrentUser(),
});
},
renderPluginWidgets : function() {
app.views.Base.prototype.renderPluginWidgets.apply(this);
this.$('a').tooltip({placement: 'bottom'});
},
authorIsCurrentUser: function() {
return app.currentUser.authenticated() && this.model.get("author").id == app.user().id;
},
destroyModel: function(evt) {
if(evt) { evt.preventDefault(); }
var url = this.model.urlRoot + '/' + this.model.id;
if (confirm(Diaspora.I18n.t("remove_post"))) {
this.model.destroy({ url: url })
.done(function() {
// return to stream
document.location.href = "/stream";
})
.fail(function() {
var flash = new Diaspora.Widgets.FlashMessages;
flash.render({
success: false,
notice: Diaspora.I18n.t('failed_to_remove')
});
});
}
}
});

View file

@ -95,15 +95,22 @@ app.views.StreamPost = app.views.Post.extend({
if(evt) { evt.preventDefault(); }
if(!confirm(Diaspora.I18n.t('confirm_dialog'))) { return }
var self = this;
$.ajax({
url : "/share_visibilities/42",
type : "PUT",
data : {
post_id : this.model.id
}
})
this.remove();
}).done(function() {
self.remove();
})
.fail(function() {
Diaspora.page.flashMessages.render({
success: false,
notice: Diaspora.I18n.t('hide_post_failed')
});
});
},
focusCommentTextarea: function(evt){

View file

@ -84,6 +84,24 @@
}
}
}
#single-post-moderation {
a:hover {
text-decoration: none;
}
i {
padding-right: 5px;
vertical-align: top;
&:hover {
color: #424242;
}
}
a.post_report > i {
font-size: 14px;
}
i.cross {
font-size: 20px;
}
}
}
#body {

View file

@ -23,11 +23,5 @@
</a>
{{/if}}
{{/if}}
{{#if authorIsNotCurrentUser}}
<a href="#" data-type="post" class="post_report" title="{{t "report.name"}}">
<i class="entypo gray large">&#x21;</i>
</a>
{{/if}}
{{/if}}
</div>

View file

@ -58,6 +58,7 @@
{{/if}}
<div class='status-message-location' />
</div>
<div id='single-post-moderation' />
</div>
</div>
{{#unless root}}

View file

@ -0,0 +1,19 @@
<div>
{{#if loggedIn}}
{{#if authorIsCurrentUser}}
<a href="#" class="remove_post" title="{{t "delete"}}">
<i class="entypo gray cross"></i>
</a>
{{else}}
<a href="#" data-type="post" class="post_report" title="{{t "report.name"}}">
<i class="entypo gray">&#x21;</i>
</a>
<a href="#" data-type="post" class="block_user" title="{{t "ignore"}}">
<i class="entypo gray">&#128683;</i>
</a>
<a href="#" data-type="post" class="hide_post" title="{{t "stream.hide"}}">
<i class="entypo gray cross"></i>
</a>
{{/if}}
{{/if}}
</div>

View file

@ -18,6 +18,9 @@ en:
exists: "The report already exists"
ignore_user: "Ignore this user?"
ignore_failed: "Unable to ignore this user"
hide_post: "Hide this post?"
hide_post_failed: "Unable to hide this post"
remove_post: "Remove this post?"
unblock_failed: "Unblocking this user has failed"
and: "and"
comma: ","

View file

@ -0,0 +1,66 @@
@javascript
Feature: using SPV moderation buttons
Background:
Given following users exist:
| username |
| bob |
| alice |
And I sign in as "bob@bob.bob"
And a user with username "bob" is connected with "alice"
And I am on the home page
Scenario: hide a contact's post
Given I expand the publisher
When I write the status message "Here is a post to test with"
And I submit the publisher
And I log out
And I sign in as "alice@alice.alice"
And I open the show page of the "Here is a post to test with" post
And I click to hide the post
And I confirm the alert
Then I should be on the stream page
Scenario: block a contact
Given I expand the publisher
When I write the status message "Here is a post to test with"
And I submit the publisher
And I log out
And I sign in as "alice@alice.alice"
And I open the show page of the "Here is a post to test with" post
And I click to block the user
And I confirm the alert
Then I should be on the stream page
Scenario: report a contact
Given I expand the publisher
When I write the status message "Here is a post to test with"
And I submit the publisher
And I log out
And I sign in as "alice@alice.alice"
And I open the show page of the "Here is a post to test with" post
And I click to report the post
And I confirm the alert
And I should see a flash message containing "The report was successfully created"
Scenario: delete own post
Given I expand the publisher
When I write the status message "Here is a post to test with"
And I submit the publisher
And I open the show page of the "Here is a post to test with" post
And I click to delete the post
And I confirm the alert
Then I should be on the stream page

View file

@ -0,0 +1,15 @@
And /^I click to hide the post/ do
find('.hide_post').click
end
And /^I click to block the user/ do
find('.block_user').click
end
And /^I click to report the post/ do
find('.post_report').click
end
And /^I click to delete the post/ do
find('.remove_post').click
end