Skip to content

Commit

Permalink
solved issue BU-ISCIII#311 error when no order values are set in the …
Browse files Browse the repository at this point in the history
…library parameters
  • Loading branch information
luissian committed Sep 28, 2024
1 parent a9b4134 commit 20a53a4
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion wetlab/templates/wetlab/define_protocol_parameters.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,40 @@ <h4>Define the parameters used for protocol {{prot_parameters.protocol_name}}</h
csvFileName:'protocol_parameters',
minDimensions:[6,3],
});

// Function to check if at least one checkbox in the "Used" column is set to true
function isAnyUsedColumnChecked() {
var table_data1 = table1.getData();
// Assuming the "Used" column is the third column (index 2)
for (var i = 0; i < table_data1.length; i++) {
if (table_data1[i][2] === true && table_data1[i][0] != "") { // Check if "Used" column (index 2) is true
return true;
}
}
return false;
}
// Function to check if at one checkbox in the "Used" column is set to true
function orderValueDefined() {
var table_data1 = table1.getData();
// Check that if parameter is defined then order is also defined
for (var i = 0; i < table_data1.length; i++) {
if (table_data1[i][0] != "" && table_data1[i][1] == "") { // Check if "Order" is set a value
return false;
}
}
return true;
}
$(document).ready(function () {
$("#defineProtocolParameters").submit(function (e) {
if (!isAnyUsedColumnChecked()) {
e.preventDefault(); // Prevent form submission
alert('You must select at least one "Used" checkbox before submitting.');
return false;
}
if (!orderValueDefined()) {
e.preventDefault(); // Prevent form submission
alert('You must define the order number for each parameter before submitting.');
return false;
}
//stop submitting the form to see the disabled button effect
//e.preventDefault();
//disable the submit button
Expand Down

0 comments on commit 20a53a4

Please sign in to comment.