Skip to content

Commit

Permalink
Abstracted forms into partials and created edit actions where they we…
Browse files Browse the repository at this point in the history
…re missing.
  • Loading branch information
tumes committed Mar 1, 2011
1 parent e38ee40 commit 91cbb7b
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 29 deletions.
@@ -0,0 +1,16 @@
= simple_form_for @chromatographic_column do |f|
= f.input :name
= f.input :instrument_id, :collection => Instrument.all, :as => :select
%h2 Add dynamic method association select here!
= f.input :brand
%p
= f.label :description
%br/
= f.text_area :description, :rows => 2, :cols => 40
= f.input :serial
= f.input :received
%p
= f.label :notes
%br/
= f.text_area :notes, :rows => 2, :cols => 40
= f.submit @chromatographic_column.new_record? ? 'Add column' : 'Edit column'
3 changes: 3 additions & 0 deletions app/views/chromatographic_columns/edit.html.haml
@@ -0,0 +1,3 @@
%h1 Edit column

= render :partial => 'chromatographic_columns/chromatographic_column_form'
1 change: 1 addition & 0 deletions app/views/chromatographic_columns/index.html.haml
@@ -1,3 +1,4 @@
%h1 Column index
%h2= link_to "New column", new_chromatographic_column_path

= render @chromatographic_columns
11 changes: 1 addition & 10 deletions app/views/chromatographic_columns/new.html.haml
@@ -1,12 +1,3 @@
%h1 New column

= simple_form_for @chromatographic_column do |f|
= f.input :name
= f.input :instrument_id, :collection => Instrument.all, :as => :select
%h2 Add dynamic method association select here!
= f.input :brand
= f.input :description
= f.input :serial
= f.input :received
= f.input :notes
= f.submit 'Add column'
= render :partial => 'chromatographic_columns/chromatographic_column_form'
3 changes: 1 addition & 2 deletions app/views/instruments/_instrument_form.html.haml
Expand Up @@ -10,8 +10,7 @@
= f.error :analytical_methods
.links
=link_to_add_association 'Add method', f, :analytical_methods
= f.submit 'Create instrument'
= f.submit @instrument.new_record? ? 'Create instrument' : 'Update Instrument'

=@instrument.errors


1 change: 1 addition & 0 deletions app/views/instruments/index.html.haml
@@ -1,5 +1,6 @@
- title "Instrument index"

%h1 Instrument index
%h2= link_to "New instrument", new_instrument_path

= render @instruments
17 changes: 17 additions & 0 deletions app/views/maintenance_events/_maintenance_event_form.html.haml
@@ -0,0 +1,17 @@
= simple_form_for @maintenance_event do |f|
= f.input :instrument_id, :collection => Instrument.all, :as => :select
= f.input :user_id, :label => "Technician", :collection => User.all, :as => :select
= f.input :date
%p
= f.label :problem
%br/
= f.text_area :problem, :rows => 2, :cols => 40
%p
= f.label :maintenance_performed
%br/
= f.text_area :maintenance_performed, :rows => 2, :cols => 40
%p
= f.label :result
%br/
= f.text_area :result, :rows => 2, :cols => 40
= f.submit @maintenance_event.new_record? ? 'Log maintenance event' : 'Update maintenance event'
3 changes: 3 additions & 0 deletions app/views/maintenance_events/edit.html.haml
@@ -0,0 +1,3 @@
%h1 Edit maintenance event

= render :partial => 'maintenance_events/maintenance_event_form'
18 changes: 1 addition & 17 deletions app/views/maintenance_events/new.html.haml
@@ -1,19 +1,3 @@
%h1 Add a maintenance event

= simple_form_for @maintenance_event do |f|
= f.input :instrument_id, :collection => Instrument.all, :as => :select
= f.input :user_id, :label => "Technician", :collection => User.all, :as => :select
= f.input :date
%p
= f.label :problem
%br/
= f.text_area :problem, :rows => 2, :cols => 40
%p
= f.label :maintenance_performed
%br/
= f.text_area :maintenance_performed, :rows => 2, :cols => 40
%p
= f.label :result
%br/
= f.text_area :result, :rows => 2, :cols => 40
= f.button :submit
= render :partial => 'maintenance_events/maintenance_event_form'

0 comments on commit 91cbb7b

Please sign in to comment.