Skip to content

Commit

Permalink
Merge pull request #4 from conc-at/reply-to-interest
Browse files Browse the repository at this point in the history
Replying to an interest
  • Loading branch information
Stephan Bönnemann committed Jan 3, 2015
2 parents f6587f2 + 31d2699 commit dc60b32
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 21 deletions.
8 changes: 8 additions & 0 deletions app/controllers/contribs_controller.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
class ContribsController < PartipsController
# GET /contribs/new
def new
super

if Interest.exists?(:id => params[:in_reply_to])
@contrib.interest = Interest.find(params[:in_reply_to])
end
end
end
2 changes: 1 addition & 1 deletion app/controllers/partips_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,6 @@ def owns_partip

# Never trust parameters from the scary internet, only allow the white list through.
def partip_params
params.require(instance_name.to_sym).permit(:title, :description)
params.require(instance_name.to_sym).permit(:title, :description, :interest_id)
end
end
1 change: 1 addition & 0 deletions app/views/contribs/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<%= simple_form_for @contrib, html: { class: 'form-vertical' } do |f| %>
<%= f.hidden_field :interest_id if @contrib.interest_id %>
<div class="field">
<%= f.input :title %>
</div>
Expand Down
9 changes: 8 additions & 1 deletion app/views/contribs/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
<h1>New contrib</h1>
<h1>
New contrib
<% if @contrib.interest %>
<small>
in reply to <%= @contrib.interest.title %>
</small>
<% end %>
</h1>

<%= render 'form' %>

Expand Down
7 changes: 7 additions & 0 deletions app/views/contribs/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,12 @@
<%= @contrib.description %>
</p>

<% if @contrib.interest %>
<p>
<strong>In reply to:</strong>
<%= @contrib.interest.title %>
</p>
<% end %>

<%= link_to 'Edit', edit_contrib_path(@contrib) %> |
<%= link_to 'Back', contribs_path %>
35 changes: 22 additions & 13 deletions app/views/interests/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="col-md-10 col-md-offset-1">
<div class="col-md-8">
<h1><%= @interest.title %></h1>
<p><%= @interest.description %></p>
<p>
Expand All @@ -15,16 +15,25 @@
</p>
</div>

<div class="col-md-2 col-md-offset-1 col-xs-6">
<%= link_to interests_path, class: 'btn btn-primary btn-block' do %>
<%= icon('chevron-left', 'Back') %>
<% end %>
</div>

<% if current_user == @interest.user %>
<div class="col-md-2 col-xs-6">
<%= link_to edit_interest_path(@interest), class: 'btn btn-primary btn-block' do %>
<%= icon('pencil-square-o', 'Edit') %>
<% end %>
<div class="col-md-4">
<div class="panel panel-default">
<div class="panel-heading">
<strong>
Contribs in reply
</strong>
</div>
<div class="list-group">
<% @interest.contribs.each do |contrib| %>
<%= render 'partips/list_item', partip: contrib %>
<% end %>
<% unless @interest.contribs.length > 0 %>
<div class="list-group-item">
No Contrib yet
</div>
<% end %>
<%= link_to new_contrib_path(:in_reply_to => @interest.id), class: 'btn btn-primary btn-block' do %>
<%= icon('reply', 'Reply with your contribution') %>
<% end if user_signed_in? %>
</div>
</div>
<% end %>
</div>
12 changes: 6 additions & 6 deletions app/views/partips/_list_item.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@

<% if user_signed_in? %>
<span class="actions">
<% if current_user != partip.user %>
<!--<% if partip.class.name == 'Interest' %>
<%= link_to :root, title: 'Reply' do %>
<%= icon('reply') %>
<% end %>
<% if partip.class.name == 'Interest' %>
<%= link_to new_contrib_path(:in_reply_to => partip.id), title: 'Reply' do %>
<%= icon('reply') %>
<% end %>
<% end %>

<% if current_user != partip.user %>
<%= link_to :root, title: 'Star' do %>
<%= icon('star') %>
<% end %> -->
<% end %>
<% else %>
<%= link_to edit_polymorphic_path(partip), title: 'Edit' do %>
<%= icon('edit') %>
Expand Down

0 comments on commit dc60b32

Please sign in to comment.