Commit 071803bd authored by Matthieu Muffato's avatar Matthieu Muffato
Browse files

Several changes in the pipeline-wide parameters tab

- New button to restore the initial value
- Enables / disables the buttons when needed
- Simpler HTML structure
parent f7668e7a
......@@ -333,7 +333,7 @@ function onSuccess_dbConnect(res) {
fetch_resources();
// And the pipeline-wide parameters
fetch_and_setup_change_listener( "scripts/db_fetch_pipeline_params.pl", "scripts/db_update_nonobject.pl", "#pipeline_wide_parameters", ".update_pwp_param" );
fetch_and_setup_change_listener( "scripts/db_fetch_pipeline_params.pl", "scripts/db_update_nonobject.pl", "#pipeline_wide_parameters" );
// We load the jobs form
$.get('./scripts/db_jobs_form.pl', {url : guiHive.pipeline_url, version : guiHive.version} ,function(data) {
......@@ -400,7 +400,7 @@ function onSuccess_fetchResources(resourcesRes, analysis_id, fetch_url) {
}
function fetch_and_setup_change_listener(fetch_url, write_url, target_div, updatable_class, callback) {
function fetch_and_setup_change_listener(fetch_url, write_url, target_div) {
function doFetch() {
$.ajax({
......@@ -417,12 +417,35 @@ function fetch_and_setup_change_listener(fetch_url, write_url, target_div, updat
if (resp.status != "ok") {
log(resp);
} else {
$(target_div).html(resp.out_msg);
var d = $(target_div);
d.html(resp.out_msg);
d.find(".ajaxable_btn").click( onClick_handler );
d.find(".monitored_input").keyup( onChange_handler );
d.find(".input_restorer").click( onRestoreRequest_handler );
}
$(updatable_class).click( onClick_handler );
};
function onClick_handler(obj) {
function onChange_handler(evt) {
var curr_val = this.value;
var ref_val = this.dataset.value;
var target_container = $('#' + this.id + "_monitor");
var targets = target_container.find(".btn");
if (curr_val === ref_val) {
targets.addClass("disabled");
} else {
targets.removeClass("disabled");
}
};
function onRestoreRequest_handler(evt) {
var target_name = $(this).attr("data-linkTo");
var elem = $('#'+target_name);
elem.val(elem.data("value"));
$('#' + target_name + "_monitor").find(".btn").addClass("disabled");
}
function onClick_handler(evt) {
$.ajax({
url : write_url,
type : "post",
......
......@@ -76,22 +76,14 @@ sub template_mappings_PARAMS {
for my $param (sort keys %$all_params_hash) {
my $this_param_data = {
"key" => $param,
"value" => stringify_if_needed($all_params_hash->{$param}),
"parameterKeyID" => "p_$param",
"parameterValueID" => "v_$param",
"value" => stringify_if_needed($all_params_hash->{$param}),
"delete_parameter" => [{
"adaptor" => "PipelineWideParameters",
"method" => "remove",
"fields" => "param_name",
"parameterKeyID" => "p_$param",
}],
"change_parameter" => [{
"adaptor" => "PipelineWideParameters",
"method" => "update",
"fields" => "param_name,param_value",
"parameterKeyID" => "p_$param",
"parameterValueID" => "v_$param",
}],
"adaptor" => "PipelineWideParameters",
"key_field" => "param_name",
"key_value" => "param_value",
"update_method" => "update",
"delete_method" => "remove",
};
push @{$vals->{existing_parameters}}, $this_param_data;
}
......
......@@ -34,7 +34,7 @@ use hive_extended;
use msg;
use version_check;
my $json_data = shift @ARGV || '{"adaptor":["PipelineWideParameters"],"method":["store"],"url":["mysql://ensro@127.0.0.1:4306/mm14_protein_trees_78"],"fields":["param_name,param_value"],"args":["a,2"],"version":["62"]}'
my $json_data = shift @ARGV || '{"adaptor":["PipelineWideParameters"],"method":["store"],"url":["mysql://ensro@127.0.0.1:4306/mm14_protein_trees_78"],"fields":["param_name,param_value"],"args":["a,2"],"version":["62"]}';
my $var = decode_json($json_data);
my $url = $var->{url}->[0];
......
......@@ -28,28 +28,26 @@
</span></td>
<td><input
id="<TMPL_VAR NAME=parameterValueID>"
class="monitored_input"
type="text"
data-value="<TMPL_VAR NAME=value ESCAPE=HTML>"
value="<TMPL_VAR NAME=value ESCAPE=HTML>">
</td>
<TMPL_LOOP NAME=change_parameter>
<td class="button-cell"><a class="update_pwp_param btn btn-mini"
data-analysisID="<TMPL_VAR NAME=id>"
<td id="<TMPL_VAR NAME=parameterValueID>_monitor">
<a class="ajaxable_btn btn btn-mini disabled"
data-adaptor="<TMPL_VAR NAME=adaptor>"
data-method="<TMPL_VAR NAME=method>"
data-fields="<TMPL_VAR NAME=fields>"
data-linkTo="<TMPL_VAR NAME=parameterKeyID>,<TMPL_VAR NAME=parameterValueID>"><i class="icon-plus-sign"></i></a>
data-method="<TMPL_VAR NAME=update_method>"
data-fields="<TMPL_VAR NAME=key_field>,<TMPL_VAR NAME=key_value>"
data-linkTo="<TMPL_VAR NAME=parameterKeyID>,<TMPL_VAR NAME=parameterValueID>"><i class="icon-ok-sign"></i></a>
<a class="input_restorer btn btn-mini disabled"
data-linkTo="<TMPL_VAR NAME=parameterValueID>"><i class="icon-remove-sign"></i></a>
</td>
</TMPL_LOOP> <!-- change_paramter -->
<TMPL_LOOP NAME=delete_parameter>
<td class="button-cell"><a class="update_pwp_param btn btn-mini"
data-analysisID="<TMPL_VAR NAME=id>"
<td><a class="ajaxable_btn btn btn-mini"
data-adaptor="<TMPL_VAR NAME=adaptor>"
data-method="<TMPL_VAR NAME=method>"
data-fields="<TMPL_VAR NAME=fields>"
data-method="<TMPL_VAR NAME=delete_method>"
data-fields="<TMPL_VAR NAME=key_field>"
data-linkTo="<TMPL_VAR NAME=parameterKeyID>"><i class="icon-minus-sign"></i></a>
</td>
</TMPL_LOOP> <!-- delete_parameter -->
</tr>
</TMPL_LOOP> <!-- existing_parameters -->
......@@ -57,8 +55,7 @@
<tr>
<td><input type="text" id="p_new_key" placeholder="new parameter's name"></td>
<td><input type="text" id="p_new_value" placeholder="new parameter's value"></td>
<td class="button-cell"><a class="update_pwp_param btn btn-mini"
data-analysisID="<TMPL_VAR NAME=id>"
<td><a class="ajaxable_btn btn btn-mini"
data-adaptor="<TMPL_VAR NAME=adaptor>"
data-method="<TMPL_VAR NAME=method>"
data-fields="<TMPL_VAR NAME=fields>"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment