From 6965d6da2485d97c3c52d52cd70ad53bf4b0d355 Mon Sep 17 00:00:00 2001 From: danielgrippi <danielgrippi@gmail.com> Date: Mon, 20 Feb 2012 20:15:51 -0800 Subject: [PATCH] fix feedback views. use gross callbacks for now --- app/controllers/likes_controller.rb | 4 +++- app/controllers/participations_controller.rb | 4 +++- public/javascripts/app/models/post.js | 10 ++++++++-- public/javascripts/app/pages/post-viewer.js | 2 +- public/javascripts/app/views.js | 11 ++++++++++- public/javascripts/app/views/post_view.js | 2 +- public/javascripts/app/views/stream_object_view.js | 4 ---- public/stylesheets/sass/new-templates.scss | 5 ++++- 8 files changed, 30 insertions(+), 12 deletions(-) diff --git a/app/controllers/likes_controller.rb b/app/controllers/likes_controller.rb index dc55eae4a1..766150b8ac 100644 --- a/app/controllers/likes_controller.rb +++ b/app/controllers/likes_controller.rb @@ -2,6 +2,8 @@ # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. +require Rails.root.join("app", "presenters", "post_presenter") + class LikesController < ApplicationController include ApplicationHelper before_filter :authenticate_user! @@ -17,7 +19,7 @@ class LikesController < ApplicationController respond_to do |format| format.html { render :nothing => true, :status => 201 } format.mobile { redirect_to post_path(@like.post_id) } - format.json { render :json => @like.parent.as_api_response(:backbone), :status => 201 } + format.json { render :json => PostPresenter.new(@like.parent, current_user).to_json, :status => 201 } end else render :nothing => true, :status => 422 diff --git a/app/controllers/participations_controller.rb b/app/controllers/participations_controller.rb index 4a4b3f31ee..a8b64d2448 100644 --- a/app/controllers/participations_controller.rb +++ b/app/controllers/participations_controller.rb @@ -2,6 +2,8 @@ # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. +require Rails.root.join("app", "presenters", "post_presenter") + class ParticipationsController < ApplicationController include ApplicationHelper before_filter :authenticate_user! @@ -15,7 +17,7 @@ class ParticipationsController < ApplicationController if @participation respond_to do |format| format.mobile { redirect_to post_path(@participation.post_id) } - format.json { render :json => @participation.parent.as_api_response(:backbone), :status => 201 } + format.json { render :json => PostPresenter.new(@participation.parent, current_user).to_json, :status => 201 } end else render :nothing => true, :status => 422 diff --git a/public/javascripts/app/models/post.js b/public/javascripts/app/models/post.js index 360dd8de6b..ff4a79a8da 100644 --- a/public/javascripts/app/models/post.js +++ b/public/javascripts/app/models/post.js @@ -38,7 +38,10 @@ app.models.Post = Backbone.Model.extend({ }, follow : function() { - this.set({ user_participation : this.participations.create() }); + var self = this; + this.participations.create({}, {success : function(resp){ + self.set(resp.attributes.post) + }}); }, unfollow : function() { @@ -59,7 +62,10 @@ app.models.Post = Backbone.Model.extend({ }, like : function() { - this.set({ user_like : this.likes.create() }); + var self = this; + this.likes.create({}, {success : function(resp){ + self.set(resp.attributes.post) + }}); }, unlike : function() { diff --git a/public/javascripts/app/pages/post-viewer.js b/public/javascripts/app/pages/post-viewer.js index 9a8f2e126e..eedadfb7b3 100644 --- a/public/javascripts/app/pages/post-viewer.js +++ b/public/javascripts/app/pages/post-viewer.js @@ -11,7 +11,7 @@ app.pages.PostViewer = app.views.Base.extend({ postView : function(){ return new app.views.Post({ model : this.model, - className : "loaded", + className : "dd", templateName : "post-viewer/content/" + this.options.postTemplateName }) }, diff --git a/public/javascripts/app/views.js b/public/javascripts/app/views.js index 9b15044c16..7d2a5ac770 100644 --- a/public/javascripts/app/views.js +++ b/public/javascripts/app/views.js @@ -1,4 +1,8 @@ -app.views.Base = Backbone.View.extend({ +app.views.Base = Backbone.View.extend({ + + initialize : function(options) { + this.setupRenderEvents(); + }, presenter : function(){ return this.defaultPresenter() @@ -18,6 +22,7 @@ app.views.Base = Backbone.View.extend({ this.renderTemplate() this.renderSubviews() this.renderPluginWidgets() + this.removeTooltips() return this }, @@ -45,5 +50,9 @@ app.views.Base = Backbone.View.extend({ renderPluginWidgets : function() { this.$(this.tooltipSelector).twipsy(); this.$("time").timeago(); + }, + + removeTooltips : function() { + $(".twipsy").remove(); } }) diff --git a/public/javascripts/app/views/post_view.js b/public/javascripts/app/views/post_view.js index c924038994..67013a42fb 100644 --- a/public/javascripts/app/views/post_view.js +++ b/public/javascripts/app/views/post_view.js @@ -42,7 +42,7 @@ app.views.Post = app.views.StreamObject.extend({ feedbackView : function(){ if(!window.app.user()) { return null } - return new app.views.Feedback({model : this.model}); + return new app.views.Feedback({model : this.model}); }, postContentView: function(){ diff --git a/public/javascripts/app/views/stream_object_view.js b/public/javascripts/app/views/stream_object_view.js index 85334ab69d..054cdee889 100644 --- a/public/javascripts/app/views/stream_object_view.js +++ b/public/javascripts/app/views/stream_object_view.js @@ -1,8 +1,4 @@ app.views.StreamObject = app.views.Base.extend({ - - initialize: function(options) { - this.setupRenderEvents(); - }, postRenderTemplate : function() { // collapse long posts diff --git a/public/stylesheets/sass/new-templates.scss b/public/stylesheets/sass/new-templates.scss index 14b8ba83e5..8f30f09ab5 100644 --- a/public/stylesheets/sass/new-templates.scss +++ b/public/stylesheets/sass/new-templates.scss @@ -137,6 +137,7 @@ $light-grey: #999; .note { width: 550px; + padding-bottom: 50px; p { font-size: 20px; @@ -306,6 +307,7 @@ $light-grey: #999; #post-interactions { @include center(horizontal); + z-index: 20; #post-interactions-container { @include box-shadow(0, 6px, 15px, #000); @@ -316,6 +318,7 @@ $light-grey: #999; border-left: 1px solid #444; width: 420px; + background-color: #444; background-image: url("../images/hatched-bg-dark.png"); color: #ccc; @@ -329,7 +332,7 @@ $light-grey: #999; } #new-post-comment { - border: 2px solid #333; + border-top: 2px solid #333; text-align: left; background-image: url("../images/hatched-bg-dark.png"); } -- GitLab