diff --git a/Changelog.md b/Changelog.md index d773a2b92..6501cb5e8 100644 --- a/Changelog.md +++ b/Changelog.md @@ -192,6 +192,7 @@ diaspora.yml file**. The existing settings from 0.4.x and before will not work a * Update and improve help section [#5665](https://github.com/diaspora/diaspora/pull/5665), [#5706](https://github.com/diaspora/diaspora/pull/5706) * Expose participation controls in the stream view [#5511](https://github.com/diaspora/diaspora/pull/5511) * Reimplement photo export [#5685](https://github.com/diaspora/diaspora/pull/5685) +* Add participation controls in the single post view [#5722](https://github.com/diaspora/diaspora/pull/5722) # 0.4.1.2 diff --git a/app/assets/javascripts/app/views/single-post-viewer/single_post_moderation.js b/app/assets/javascripts/app/views/single-post-viewer/single_post_moderation.js index d206e31db..ad636addf 100644 --- a/app/assets/javascripts/app/views/single-post-viewer/single_post_moderation.js +++ b/app/assets/javascripts/app/views/single-post-viewer/single_post_moderation.js @@ -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"); } }); diff --git a/app/assets/templates/single-post-viewer/single-post-moderation_tpl.jst.hbs b/app/assets/templates/single-post-viewer/single-post-moderation_tpl.jst.hbs index 40c67cb68..fa96417b2 100644 --- a/app/assets/templates/single-post-viewer/single-post-moderation_tpl.jst.hbs +++ b/app/assets/templates/single-post-viewer/single-post-moderation_tpl.jst.hbs @@ -11,6 +11,15 @@ + {{#if participation}} + + + + {{else}} + + + + {{/if}}