Skip to content

Commit 20a53a4

Browse files
committed
solved issue BU-ISCIII#311 error when no order values are set in the library parameters
1 parent a9b4134 commit 20a53a4

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

wetlab/templates/wetlab/define_protocol_parameters.html

+32-1
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,40 @@ <h4>Define the parameters used for protocol {{prot_parameters.protocol_name}}</h
8484
csvFileName:'protocol_parameters',
8585
minDimensions:[6,3],
8686
});
87-
87+
// Function to check if at least one checkbox in the "Used" column is set to true
88+
function isAnyUsedColumnChecked() {
89+
var table_data1 = table1.getData();
90+
// Assuming the "Used" column is the third column (index 2)
91+
for (var i = 0; i < table_data1.length; i++) {
92+
if (table_data1[i][2] === true && table_data1[i][0] != "") { // Check if "Used" column (index 2) is true
93+
return true;
94+
}
95+
}
96+
return false;
97+
}
98+
// Function to check if at one checkbox in the "Used" column is set to true
99+
function orderValueDefined() {
100+
var table_data1 = table1.getData();
101+
// Check that if parameter is defined then order is also defined
102+
for (var i = 0; i < table_data1.length; i++) {
103+
if (table_data1[i][0] != "" && table_data1[i][1] == "") { // Check if "Order" is set a value
104+
return false;
105+
}
106+
}
107+
return true;
108+
}
88109
$(document).ready(function () {
89110
$("#defineProtocolParameters").submit(function (e) {
111+
if (!isAnyUsedColumnChecked()) {
112+
e.preventDefault(); // Prevent form submission
113+
alert('You must select at least one "Used" checkbox before submitting.');
114+
return false;
115+
}
116+
if (!orderValueDefined()) {
117+
e.preventDefault(); // Prevent form submission
118+
alert('You must define the order number for each parameter before submitting.');
119+
return false;
120+
}
90121
//stop submitting the form to see the disabled button effect
91122
//e.preventDefault();
92123
//disable the submit button

0 commit comments

Comments
 (0)