Ajaxy assignment adding. Will probably use the same model for resources. And maybe goals altogether, we'll see.
18 files changed, 66 lines added, 110 lines removed
Changes
--- app/controllers/assignments_controller.rb 29a9acc3ea21909c9715dc16c2816107821d693d
+++ app/controllers/assignments_controller.rb 0669796c0b3ca32be3b84fb40f0136ba8dee3b4a
@@ -15,10 +15,7 @@
- respond_to do |format|
- format.html # show.html.erb
- format.xml { render :xml => @assignment }- end
+ render :layout => false
@@ -28,10 +25,7 @@
- respond_to do |format|
- format.html # new.html.erb
- format.xml { render :xml => @assignment }- end
+ render :layout => false
@@ -44,14 +38,10 @@
- respond_to do |format|
- if @assignment.save
- format.html { redirect_to(@assignment, :notice => 'Assignment was successfully created.') }- format.xml { render :xml => @assignment, :status => :created, :location => @assignment }- else
- format.html { render :action => "new" }- format.xml { render :xml => @assignment.errors, :status => :unprocessable_entity }- end
+ if @assignment.save
+ render :json => {:id => @assignment.id, :msg =>"Successfully added assignment",:result=>"<li>#{@assignment.user.email} - #{@assignment.task}"}+ else
+ render :json => {:msg =>"Assignment was unsuccessful",:result=>""}--- app/views/assignments/_form.html.erb 29a9acc3ea21909c9715dc16c2816107821d693d
+++ app/views/assignments/_form.html.erb 0669796c0b3ca32be3b84fb40f0136ba8dee3b4a
@@ -1,28 +1,8 @@
-<%= form_for(@assignment) do |f| %>
- <% if @assignment.errors.any? %>
- <div id="error_explanation">
- <h2><%= pluralize(@assignment.errors.count, "error") %> prohibited this assignment from being saved:</h2>
-
- <ul>
- <% @assignment.errors.full_messages.each do |msg| %>
- <li><%= msg %></li>
- <% end %>
- </ul>
- </div>
- <% end %>
-
- <div class="field">
- <%= f.label :user_id %><br />
- <%= f.text_field :user_id %>
- </div>
- <div class="field">
- <%= f.hidden_field :goal_id, :value => @goal.id %>
- </div>
- <div class="field">
- <%= f.label :task %><br />
- <%= f.text_area :task %>
- </div>
- <div class="actions">
- <%= f.submit %>
- </div>
+<%= form_for @assignment, :'data-type' => 'json', :remote => true do |f| %>
+ <h3><%= f.label :user_id %></h3>
+ <%= f.text_field :user_id %>
+ <%= f.hidden_field :goal_id, :value => @goal.id %>
+ <h3><%= f.label :task %></h3>
+ <%= f.text_area :task %>
+ <%= f.submit %>
--- app/views/assignments/new.html.erb 29a9acc3ea21909c9715dc16c2816107821d693d
+++ app/views/assignments/new.html.erb 0669796c0b3ca32be3b84fb40f0136ba8dee3b4a
@@ -1,5 +1,1 @@
-<h1>New assignment</h1>
-
-
-<%= link_to 'Back', assignments_path %>
--- app/views/assignments/show.html.erb 29a9acc3ea21909c9715dc16c2816107821d693d
+++ app/views/assignments/show.html.erb 0669796c0b3ca32be3b84fb40f0136ba8dee3b4a
@@ -1,20 +1,1 @@
-<p id="notice"><%= notice %></p>
-
-<p>
- <b>User:</b>
- <%= @assignment.user_id %>
-</p>
-
-<p>
- <b>Goal:</b>
- <%= @assignment.goal_id %>
-</p>
-
-<p>
- <b>Task:</b>
- <%= @assignment.task %>
-</p>
-
-
-<%= link_to 'Edit', edit_assignment_path(@assignment) %> |
-<%= link_to 'Back', assignments_path %>
+<%= link_to @assignment.user.profile.name, @assignment.user.profile %> - <%= @assignment.task %>
--- app/views/goals/show.html.erb 29a9acc3ea21909c9715dc16c2816107821d693d
+++ app/views/goals/show.html.erb 0669796c0b3ca32be3b84fb40f0136ba8dee3b4a
@@ -1,30 +1,42 @@
+<script type="text/javascript">
+jQuery(function($){+ $('#add_assignment').click(function(){+ $('#new_assignment_target').load('<%= new_assignment_path(:goal_id => @goal.id) %>', function(){+ $('#add_assignment').hide();+ $('#new_assignment').bind('ajax:success', function(evt, data, status, xhr) {+ $('#new_assignment_target').html("");+ console.log(data.msg);
+ $('#assignments_list').append("<li></li>");+ $('#assignments_list li:last').load("/assignments/"+data.id);+ $('#add_assignment').show();+ });
+ });
+ });
+ });
+</script>
+
+
-<p>
- <b>Name:</b>
- <%= @goal.name %>
-</p>
+<h1><%= @goal.name %></h1>
-<p>
- <b>Description:</b>
- <%= @goal.description %>
-</p>
+<h3>Description</h3>
+<p><%= @goal.description %></p>
-<p>
- <b>Timeline:</b>
- <%= @goal.timeline %>
-</p>
+<h3>Timeline:</h3>
+<p><%= @goal.timeline %></p>
-<p>Assignments:</p>
+<h3>Assignments:</h3>
-<ul>
+<ul id="assignments_list">
- <li><%= assignment.user.email %> - <%= assignment.task %></li>
+ <li><%= link_to assignment.user.profile.name, assignment.user.profile %> - <%= assignment.task %></li>
-<%= link_to 'Add Assignment', new_assignment_path(:goal_id => @goal.id) %>
-<p>Resources</p>
+<button id="add_assignment">Add Assignment</button>
+<div id="new_assignment_target"></div>
+<h3>Resources</h3>
--- app/views/seeds/_form.html.erb 29a9acc3ea21909c9715dc16c2816107821d693d
+++ app/views/seeds/_form.html.erb 0669796c0b3ca32be3b84fb40f0136ba8dee3b4a
@@ -11,31 +11,18 @@
- <div class="field">
- <%= f.label :name %><br />
+<h3><%= f.label :name %></h3>
- </div>
- <div class="field">
- <%= f.label :problem %><br />
+<h3><%= f.label :problem %></h3>
- </div>
- <div class="field">
- <%= f.label :vision %><br />
+<h3><%= f.label :vision %></h3>
- </div>
- <div class="field">
- <%= f.label :scope %><br />
+<h3><%= f.label :scope %></h3>
- </div>
- <div class="field">
- <%= f.label :visibility %><br />
- <%= f.text_field :visibility %>
- </div>
- <div class="field">
- <%= f.label :category %>
+ <%#= f.label :visibility %>
+ <%#= f.text_field :visibility %>
+<h3><%= f.label :category %></h3>
- </div>
- <div class="actions">
- <%= f.submit %>
- </div>
+<hr/>
+ <%= f.submit %>
--- app/views/seeds/edit.html.erb 29a9acc3ea21909c9715dc16c2816107821d693d
+++ app/views/seeds/edit.html.erb 0669796c0b3ca32be3b84fb40f0136ba8dee3b4a
@@ -1,6 +1,5 @@
-<h1>Editing seed</h1>
+<h1>Editing <%= @seed.name %></h1>
-<%= link_to 'Show', @seed %> |
-<%= link_to 'Back', seeds_path %>
+<%= link_to "Back",@seed %>
--- app/views/tags/index.html.erb 29a9acc3ea21909c9715dc16c2816107821d693d
+++ app/views/tags/index.html.erb 0669796c0b3ca32be3b84fb40f0136ba8dee3b4a
@@ -20,7 +20,7 @@
- <td><%= link_to 'Destroy', tag, :method => :delete,:remote => true,:class =>"Destroy " %></td>
+ <td><%= link_to 'Destroy', tag, :method => :delete,:remote => true,:class =>"Destroy" %></td>
--- public/stylesheets/application.css 29a9acc3ea21909c9715dc16c2816107821d693d
+++ public/stylesheets/application.css 0669796c0b3ca32be3b84fb40f0136ba8dee3b4a
@@ -161,6 +161,10 @@
+#basics .admin-box
+{+ top:-20px;
+}
@@ -197,3 +201,10 @@
+
+textarea
+{+ font-family: "Lato",sans-serif;
+ width:1000px;
+ height:75px;
+}