-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added edit to update the input of optim
- Loading branch information
1 parent
02f25f5
commit f8ca65f
Showing
7 changed files
with
154 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,42 @@ | ||
<h2>Add inputs to optimization #<%= @optimization.id %></h2> | ||
<%= form_for(@optimization, url: (optimization_path(@optimization)), :html => { :multipart => true, :role => "form" }) do |f| %> | ||
<% if @optimization.errors.any? %> | ||
<% @optimization.errors.full_messages.each do |message| %> | ||
<div class="alert <%= bootstrap_class_for :error %>" role="alert"> | ||
<a href="#" data-dismiss="alert" class="close">×</a> | ||
<%= message %> | ||
</div> | ||
<% end %> | ||
<% end %> | ||
|
||
<table class="inputs"> | ||
<thead> | ||
<tr> | ||
<td><label for='optimization_inputs'>Inputs <a href='#' data-bs-toggle='tooltip' style='color:#000000;' title='Add a value x with the correct dimension associated with the result y'><i class='fas fa-question-circle'></i></a></label></td> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
</tbody> | ||
<tfoot> | ||
<tr><td> | ||
<%= f.submit "Submit", class: "btn btn-primary submit" %> | ||
<%= f.submit "Cancel", class: "btn btn-secondary", name: "cancel_button" %> | ||
</td></tr> | ||
</tfoot> | ||
</table> | ||
<% end %> | ||
<% content_for :document_ready do %> | ||
<script type="text/javascript"> | ||
|
||
$(document).ready(addField()); | ||
|
||
function addField() { | ||
$('.add_input_cell').remove() | ||
$('.inputs').children('tbody').append("<tr><td><input class='form-control' type='text' name='optimization[inputs][x][]' id='optimization_inputs_x' placeholder='x'></td>" + | ||
"<td><input class='form-control' type='text' name='optimization[inputs][y][]' id='optimization_inputs_y' placeholder='y'></td></tr>" + | ||
"<tr class='add_input_cell'><td><a href='#' class='add_input'>Add input</a>"); | ||
$('.add_input').click(function(){addField();}); | ||
} | ||
</script> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,67 @@ | ||
<h1>New Optimization</h1> | ||
|
||
<%= render 'form', optimization: @optimization %> | ||
<%= form_for(@optimization, url: (@optimization.new_record? ? optimizations_path : optimization_path(@optimization)), :html => { :multipart => true, :role => "form" }) do |f| %> | ||
<% if @optimization.errors.any? %> | ||
<% @optimization.errors.full_messages.each do |message| %> | ||
<div class="alert <%= bootstrap_class_for :error %>" role="alert"> | ||
<a href="#" data-dismiss="alert" class="close">×</a> | ||
<%= message %> | ||
</div> | ||
<% end %> | ||
<% end %> | ||
|
||
<div class="row"> | ||
<div class=" col-4"> | ||
|
||
<div class="form-group"> | ||
<%= f.label :kind %> | ||
<%= f.select :kind , Optimization::OPTIMIZER_KINDS.each_key, {}, {class: "form-control"} %> | ||
</div> | ||
|
||
<div id="options" class="form-group"> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<%= f.submit "Submit", class: "btn btn-primary submit" %> | ||
<%= f.submit "Cancel", class: "btn btn-secondary", name: "cancel_button" %> | ||
</div> | ||
</div> | ||
</div> | ||
<% end %> | ||
<% content_for :document_ready do %> | ||
<script type="text/javascript"> | ||
|
||
$(document).ready(updateOptions()); | ||
$("#optimization_kind").change(function() {updateOptions();}); | ||
|
||
function updateOptions() { | ||
$("#options").empty() | ||
if ($("#optimization_kind").val() == "SEGOMOE") { | ||
$("#options").html( | ||
"<label>Xlimits <a href='#' data-bs-toggle='tooltip' style='color:#000000;' title='For each field : min, max'><i class='fas fa-question-circle'></i></a></label>" + | ||
"<div id='xlimits'></div>" + | ||
"<label for='optimization_options'>Options <a href='#' data-bs-toggle='tooltip' style='color:#000000;' title='For example : constant, cobyla'><i class='fas fa-question-circle'></i></a></label>" + | ||
"<input class='form-control' type='text' name='optimization[options][]' id='optimization_options_mod_obj__regr' placeholder='mod_obj__regr''>" + | ||
"<input class='form-control' type='text' name='optimization[options][]' id='optimization_options_optimizer' placeholder='optimizer'>" | ||
) | ||
addField('xlimits', 'Add a dimension to the input') | ||
} else { | ||
$("#options").html( | ||
"<label>Xtypes <a href='#' data-bs-toggle='tooltip' style='color:#000000;' title='For each field : type, min, max ex: float_type, 1.0, 2.0'><i class='fas fa-question-circle'></i></a></label>" + | ||
"<div id='xtypes'></div>" + | ||
"<label>cstr_specs <a href='#' data-bs-toggle='tooltip' style='color:#000000;' title='For each field : type, bound, tol ex: <, 0.0, 0.0001'><i class='fas fa-question-circle'></i></a></label>" + | ||
"<div id='cstr_specs'></div>" | ||
) | ||
addField('xtypes', 'Add a dimension to the input') | ||
addField('cstr_specs', 'Add a spec') | ||
} | ||
} | ||
|
||
function addField(type, message) { | ||
$('.add' + type).remove() | ||
$('#' + type).append("<input class='form-control' type='text' name='optimization[" + type + "][]'><a href='#' class='add" + type + "'>" + message + "</a>"); | ||
$('.add' + type).click(function(){addField(type, message);}); | ||
} | ||
</script> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters