LP#1154656 MARC Expert Search "Add Rows" adds duplicate row
authorMichael Peters <mpeters@emeralddata.net>
Tue, 9 Jun 2015 14:10:04 +0000 (10:10 -0400)
committerJason Stephenson <jstephenson@mvlc.org>
Fri, 12 Jun 2015 19:58:41 +0000 (15:58 -0400)
This patch changes the behavior of the "Add Search Row" link
(JavaScript function from simple.js "addExpertRow()") so that
we are always cloning the initial "empty" row instead of
potentially cloning a row -- by way of cloneNode() -- with user
input in place, and causing duplicate search rows.

To reproduce the bug, go to Advanced Search, fill in all three
search fields with some text, click on Add Search Row.  You wil
see that the Title search row along with the data in the text
box is duplicated and added to the search.

After this patch, the new row should be added with an empty
text box.

Signed-off-by: Michael Peters <mpeters@emeralddata.net>
Signed-off-by: Rashma Kumaran <rkumaran@kcls.org>
Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Open-ILS/src/templates/opac/css/style.css.tt2
Open-ILS/web/js/ui/default/opac/simple.js

index 56cbef8..cafccb6 100644 (file)
@@ -2101,4 +2101,10 @@ See also http://webaim.org/techniques/css/invisiblecontent/
     overflow: hidden;                                                            
     clip: rect(0, 0, 0, 0);                                                      
     border: 0;                                                                   
-} 
+}
+
+/* Make added rows in Expert Search have bold labels like the initial row */
+label[for*=expert_]
+{
+    font-weight: bold;
+}  
index b491586..7fa20cb 100644 (file)
@@ -26,18 +26,33 @@ function addSearchRow() {
         _search_row_template.cloneNode(true),
         $("adv_global_addrow")
     );
+
+    $("adv_global_input_table").rows[$("adv_global_input_table").rows.length - 2].getElementsByTagName("input")[0].value = "";
 }
-function addExpertRow() {
-    if (!_expert_row_template) {
-        t = $("adv_expert_row").cloneNode(true);
-        t.id = null;
-        _expert_row_template = t;
-    }
 
+(function($){
+var _search_row_template, _expert_row_template, t;
+var _el_adv_global_row = $("adv_global_row"), _el_adv_expert_row = $("adv_expert_row");
+if (_el_adv_global_row) {
+    t = _el_adv_global_row.cloneNode(true);
+    t.id = null;
+    _search_row_template = t;
+}
+
+if (_el_adv_expert_row) {
+    t = _el_adv_expert_row.cloneNode(true);
+    t.id = null;
+    _expert_row_template = t;
+}
+function addExpertRow() {
     $("adv_expert_rows_here").appendChild(
         _expert_row_template.cloneNode(true)
     );
 }
+
+window.addSearchRow = addSearchRow;
+window.addExpertRow = addExpertRow;
+})($);
 function killRowIfAtLeast(min, link) {
     var row = link.parentNode.parentNode;
     if (row.parentNode.getElementsByTagName("tr").length > min)