Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

data entry creation FTW

  • Loading branch information...
commit 71467b8a3a9cf3427d8819c5f24c5dc71098000b 1 parent ae4cc90
@bensomers bensomers authored
View
18 app/controllers/data_entries_controller.rb
@@ -2,6 +2,7 @@ class DataEntriesController < ApplicationController
#Not yet secured
before_filter :check_for_data_object
+
def new
@data_entry = DataEntry.new
@@ -20,23 +21,18 @@ def create
if @data_entry.save
flash[:notice] = "Successfully updated #{@data_entry.data_object.name}."
- if report = current_user.current_shift.report
+ if @report = current_user.current_shift.report
content = []
@data_entry.data_fields_with_contents.each {|entry| content.push("#{DataField.find(entry.first).name.humanize}: #{entry.second}")}
- report.report_items << ReportItem.new(:time => Time.now, :content => "Updated #{@data_entry.data_object.name}. #{content.join(', ')}.", :ip_address => request.remote_ip)
- end
- respond_to do |format|
- format.html {redirect_to data_object_path(@data_entry.data_object)}
- format.js {raise "warning"}
+ @report.report_items << ReportItem.new(:time => Time.now, :content => "Updated #{@data_entry.data_object.name}. #{content.join(', ')}.", :ip_address => request.remote_ip)
end
else
flash[:error] = "Could not update #{@data_entry.data_object.name}."
- respond_to do |format|
- format.html { render :action => "new"}
- format.js {}
- end
end
-# redirect_to data_object_path(@data_entry.data_object) unless request.referrer.match('reports')
+ respond_to do |format|
+ format.js
+ format.html {redirect_to @report ? @report : @data_entry.data_object}
+ end
end
## Are we removing this feature?
View
2  app/views/data_entries/_form.html.erb
@@ -1,4 +1,4 @@
-<% form_for [:data_object, @data_entry] do |f| %>
+<% form_remote_for [:data_object, @data_entry] do |f| %>
<%= f.error_messages %>
<h2><%= @data_object.name %></h2>
View
9 app/views/data_entries/create.js.rjs
@@ -0,0 +1,9 @@
+#This is almost a line-for-line copy of report_items/create.js.rjs
+#Should be improved at a later date -ben
+page << "tb_remove();"
+page.replace_html "all_report_items", :partial => 'reports/report_item', :collection => @report.report_items
+page[:current_report_item].visual_effect(:highlight,
+ :startcolor => '#3bcc77') #currently doesn't accept any options
+ #so startcolor is actually default
+ #instead of a pleasant pale green
+page[:new_report_item].reset
View
6 app/views/punch_clocks/index.html.erb
@@ -9,11 +9,7 @@ There are currently no punch clocks running.
<th>Has been running for</th>
</tr>
<% for punch_clock in @punch_clocks %>
- <tr>
- <td><%= punch_clock.user.name %></td>
- <td><%= punch_clock.running_time %></td>
- <td><%= link_to "Clock out", edit_punch_clock_path(punch_clock) %></td>
- </tr>
+<%= render :partial => "punch_clock_row" %>
<% end %>
</table>
<% end %>
View
3  app/views/report_items/create.js.rjs
@@ -2,5 +2,6 @@ page.replace_html "all_report_items", :partial => 'reports/report_item', :collec
page[:current_report_item].visual_effect(:highlight,
:startcolor => '#3bcc77') #currently doesn't accept any options
#so startcolor is actually default
+ #instead of a pleasant pale green
page[:new_report_item].reset
-
+#page << "tb_remove();"
Please sign in to comment.
Something went wrong with that request. Please try again.