Adding MeasurementRoutine selection/editing support
This commit is contained in:
7
app/views/measurement_routines/_form.html.erb
Normal file
7
app/views/measurement_routines/_form.html.erb
Normal file
@@ -0,0 +1,7 @@
|
||||
<div class="tabular">
|
||||
<%= fields_for 'measurement[routine_attributes]', @routine do |ff| %>
|
||||
<%= ff.hidden_field :id %>
|
||||
<p><%= ff.text_field :name, required: true, style: "width: 95%;" %></p>
|
||||
<p><%= ff.text_area :description, cols: 40, rows: 3, style: "width: 95%;" %></p>
|
||||
<% end %>
|
||||
</div>
|
||||
3
app/views/measurement_routines/_show.html.erb
Normal file
3
app/views/measurement_routines/_show.html.erb
Normal file
@@ -0,0 +1,3 @@
|
||||
<% unless @routine.description.empty? %>
|
||||
<p><%= @routine.description %></p>
|
||||
<% end %>
|
||||
27
app/views/measurement_routines/_show_form.html.erb
Normal file
27
app/views/measurement_routines/_show_form.html.erb
Normal file
@@ -0,0 +1,27 @@
|
||||
<div>
|
||||
<%= f.fields_for :routine do |ff| %>
|
||||
<p>
|
||||
<%= ff.select :id,
|
||||
options_from_collection_for_select(@project.measurement_routines,
|
||||
:id, :name, @routine.id),
|
||||
{label: :field_measurement_routine, required: true},
|
||||
onchange: "var mr_id = $('#measurement_routine_attributes_id option:selected').val();
|
||||
$.ajax({
|
||||
url: '#{measurement_routine_path(id: :mr_id)}'.replace('mr_id', mr_id),
|
||||
dataType: 'script'
|
||||
});
|
||||
return false;" %>
|
||||
<%= link_to l(:button_edit), '#',
|
||||
onclick: "var mr_id = $('#measurement_routine_attributes_id option:selected').val();
|
||||
$.ajax({
|
||||
url: '#{edit_measurement_routine_path(id: :mr_id)}'.replace('mr_id', mr_id),
|
||||
dataType: 'script'
|
||||
});
|
||||
return false;",
|
||||
class: 'icon icon-edit' %>
|
||||
</p>
|
||||
<% end %>
|
||||
<div id='measurement-routine'>
|
||||
<%= render partial: 'measurement_routines/show' %>
|
||||
</div>
|
||||
</div>
|
||||
1
app/views/measurement_routines/edit.js.erb
Normal file
1
app/views/measurement_routines/edit.js.erb
Normal file
@@ -0,0 +1 @@
|
||||
$('#measurement-routine-form').html('<%= j render partial: 'measurement_routines/form' %>');
|
||||
1
app/views/measurement_routines/show.js.erb
Normal file
1
app/views/measurement_routines/show.js.erb
Normal file
@@ -0,0 +1 @@
|
||||
$('#measurement-routine').html('<%= j render partial: 'measurement_routines/show' %>');
|
||||
@@ -1,17 +1,14 @@
|
||||
<%= error_messages_for @measurement %>
|
||||
|
||||
<fieldset class="box">
|
||||
<legend ><%= t('.label_routine') %></legend>
|
||||
<div class="tabular">
|
||||
<%= f.fields_for :routine do |ff| %>
|
||||
<p><%= ff.text_field :name, required: true, style: "width: 95%;" %></p>
|
||||
<p><%= ff.text_area :description, cols: 40, rows: 3, style: "width: 95%;" %></p>
|
||||
<div class="box">
|
||||
<div id='measurement-routine-form' class="tabular">
|
||||
<% if @routine.persisted? %>
|
||||
<%= render partial: 'measurement_routines/show_form', locals: {f: f} %>
|
||||
<% else %>
|
||||
<%= render partial: 'measurement_routines/form', locals: {f: f} %>
|
||||
<% end %>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="box">
|
||||
<legend ><%= t('.label_measurement') %></legend>
|
||||
<hr style="width: 95%;">
|
||||
<div class="tabular">
|
||||
<p><%= f.select :source_id, source_options,
|
||||
{required: false, include_blank: t('.null_source')} %></p>
|
||||
@@ -42,7 +39,7 @@
|
||||
onclick: 'newReadout(); return false;' %>
|
||||
</p>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
<%= javascript_tag do %>
|
||||
function newReadout() {
|
||||
|
||||
Reference in New Issue
Block a user