From: Michael Peters Date: Tue, 9 Jun 2015 14:10:04 +0000 (-0400) Subject: LP#1154656 MARC Expert Search "Add Rows" adds duplicate row X-Git-Tag: sprint4-merge-nov22~1346 X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=7903e32468a78250b640d6983ba8321c3ec653c1;p=working%2FEvergreen.git LP#1154656 MARC Expert Search "Add Rows" adds duplicate row 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 Signed-off-by: Rashma Kumaran Signed-off-by: Jason Stephenson --- diff --git a/Open-ILS/src/templates/opac/css/style.css.tt2 b/Open-ILS/src/templates/opac/css/style.css.tt2 index 56cbef8e9c..cafccb64dc 100644 --- a/Open-ILS/src/templates/opac/css/style.css.tt2 +++ b/Open-ILS/src/templates/opac/css/style.css.tt2 @@ -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; +} diff --git a/Open-ILS/web/js/ui/default/opac/simple.js b/Open-ILS/web/js/ui/default/opac/simple.js index b4915862a2..7fa20cb647 100644 --- a/Open-ILS/web/js/ui/default/opac/simple.js +++ b/Open-ILS/web/js/ui/default/opac/simple.js @@ -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)