Add a notification subscribtion to the single post view
This commit is contained in:
parent
fb8bc7b99e
commit
0887137262
2 changed files with 32 additions and 2 deletions
|
|
@ -6,12 +6,14 @@ app.views.SinglePostModeration = app.views.Feedback.extend({
|
|||
events: function() {
|
||||
return _.defaults({
|
||||
"click .remove_post": "destroyModel",
|
||||
"click .create_participation": "createParticipation",
|
||||
"click .destroy_participation": "destroyParticipation"
|
||||
}, app.views.Feedback.prototype.events);
|
||||
},
|
||||
|
||||
presenter: function() {
|
||||
return _.extend(this.defaultPresenter(), {
|
||||
authorIsCurrentUser : this.authorIsCurrentUser(),
|
||||
authorIsCurrentUser : this.authorIsCurrentUser()
|
||||
});
|
||||
},
|
||||
|
||||
|
|
@ -42,6 +44,25 @@ app.views.SinglePostModeration = app.views.Feedback.extend({
|
|||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
createParticipation: function (evt) {
|
||||
if(evt) { evt.preventDefault(); }
|
||||
var self = this;
|
||||
$.post(Routes.post_participation_path(this.model.get("id")), {}, function () {
|
||||
self.model.set({participation: true});
|
||||
self.render();
|
||||
});
|
||||
},
|
||||
|
||||
destroyParticipation: function (evt) {
|
||||
if(evt) { evt.preventDefault(); }
|
||||
var self = this;
|
||||
$.post(Routes.post_participation_path(this.model.get("id")), { _method: "delete" }, function () {
|
||||
self.model.set({participation: false});
|
||||
self.render();
|
||||
});
|
||||
},
|
||||
|
||||
participation: function(){ return this.model.get("participation"); }
|
||||
});
|
||||
|
|
|
|||
|
|
@ -11,6 +11,15 @@
|
|||
<a href="#" data-type="post" class="block_user" title="{{t "ignore"}}">
|
||||
<i class="entypo block"></i>
|
||||
</a>
|
||||
{{#if participation}}
|
||||
<a href="#" data-type="nofollow" class="destroy_participation" title="{{t "stream.disable_post_notifications"}}">
|
||||
<i class="entypo bell"></i>
|
||||
</a>
|
||||
{{else}}
|
||||
<a href="#" data-type="nofollow" class="create_participation" title="{{t "stream.enable_post_notifications"}}">
|
||||
<i class="entypo bell"></i>
|
||||
</a>
|
||||
{{/if}}
|
||||
<a href="#" data-type="post" class="hide_post" title="{{t "stream.hide"}}">
|
||||
<i class="entypo cross"></i>
|
||||
</a>
|
||||
|
|
|
|||
Loading…
Reference in a new issue