Skip to content

Commit

Permalink
Updated manage view for #35 to incorporate new routes - still work in…
Browse files Browse the repository at this point in the history
… progress
  • Loading branch information
brzaik committed Apr 23, 2012
1 parent e74a6e4 commit 3adf69d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
4 changes: 3 additions & 1 deletion app/controllers/subscriptions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def show
def new
@subscription = Subscription.new
@subscription.screen = @screen
@subscription.field = @field

respond_to do |format|
format.html # new.html.erb
Expand All @@ -59,10 +60,11 @@ def edit
def create
@subscription = Subscription.new(params[:subscription])
@subscription.screen = @screen
@subscription.field = @field

respond_to do |format|
if @subscription.save
format.html { redirect_to([@screen, @subscription], :notice => t(:subscription_created)) }
format.html { redirect_to(manage_screen_field_subscriptions_path(@screen, @field, @subscription), :notice => t(:subscription_created)) }
format.xml { render :xml => @subscription, :status => :created, :location => @subscription }
else
format.html { render :action => "new" }
Expand Down
2 changes: 1 addition & 1 deletion app/views/subscriptions/_manage.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= form_for([screen, subscription]) do |f| %>
<%= form_for([screen, field, subscription]) do |f| %>
<% feeds ||= Feed.subscribable(screen, subscription.field) # Use feeds if it is passed, otherwise build list %>
<% feeds.push(subscription.feed) unless subscription.feed.nil? # Always show the selected value %>
<%= f.collection_select :feed_id, feeds, :id, :name %>
Expand Down
23 changes: 18 additions & 5 deletions app/views/subscriptions/manage.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
<h1><%= @this_field.name %></h1>
<% @this_field.subscriptions.where(:screen_id => @screen.id).each do |subscription| %>
<%= render subscription %>
<!-- :partial => 'manage', :locals => {:screen => @screen, :subscription => subscription} %> -->
<% end %>
<table>
<tr>
<th>Name</th>
<th>Frequency</th>
<th>Actions</th>
</tr>

<% @this_field.subscriptions.where(:screen_id => @screen.id).each do |subscription| %>
<tr>
<td><%= subscription.feed.name %></td>
<td>Select frequency</td>
<td><%= link_to "Remove", "#", :class => "btn danger" %></td>
</tr>
<% end %>

</table>

<% feeds = Feed.subscribable(@screen, @this_field) %>
<%#= render :partial => 'manage', :locals => {:screen => @screen, :subscription => Subscription.new(:field => @this_field), :feeds => feeds} unless feeds.empty? %>
<%= render :partial => 'manage', :locals => {:screen => @screen, :field => @this_field, :subscription => Subscription.new, :feeds => feeds} unless feeds.empty? %>

0 comments on commit 3adf69d

Please sign in to comment.