You can now have multiple rows in your MARC Expert Search
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Thu, 28 Jul 2011 15:10:47 +0000 (11:10 -0400)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Thu, 28 Jul 2011 15:10:47 +0000 (11:10 -0400)
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
Open-ILS/web/js/ui/default/opac/simple.js
Open-ILS/web/templates/default/opac/parts/advanced/expert.tt2
Open-ILS/web/templates/default/opac/parts/advanced/global_row.tt2
Open-ILS/web/templates/default/opac/parts/result/lowhits.tt2

index 2a9e5cd..f9594b3 100644 (file)
@@ -6,6 +6,8 @@ use OpenILS::Utils::CStoreEditor qw/:funcs/;
 use OpenILS::Utils::Fieldmapper;
 use OpenILS::Application::AppUtils;
 use OpenSRF::Utils::JSON;
+use Data::Dumper;
+$Data::Dumper::Indent = 0;
 my $U = 'OpenILS::Application::AppUtils';
 
 
@@ -274,12 +276,14 @@ sub marc_expert_search {
 
     my $query = [];
     for (my $i = 0; $i < scalar @tags; $i++) {
+        next if ($tags[$i] eq "" || $subfields[$i] eq "" || $terms[$i] eq "");
         push @$query, {
             "term" => $terms[$i],
             "restrict" => [{"tag" => $tags[$i], "subfield" => $subfields[$i]}]
         };
     }
 
+    $logger->info("query for expert search: " . Dumper($query));
     # loc, limit and offset
     my $page = $self->cgi->param("page") || 0;
     my $limit = $self->_get_search_limit;
index d80b108..eaa11e2 100644 (file)
@@ -14,7 +14,7 @@ function addClass(node, cls) {
 function unHideMe(node) { removeClass(node, "hide_me"); }
 function hideMe(node) { addClass(node, "hide_me"); }
 
-var _search_row_template;
+var _search_row_template, _expert_row_template;
 function addSearchRow() {
     if (!_search_row_template) {
         t = $("adv_global_row").cloneNode(true);
@@ -27,6 +27,23 @@ function addSearchRow() {
         $("adv_global_addrow")
     );
 }
+function addExpertRow() {
+    if (!_expert_row_template) {
+        t = $("adv_expert_row").cloneNode(true);
+        t.id = null;
+        _expert_row_template = t;
+    }
+
+    $("adv_expert_rows_here").appendChild(
+        _expert_row_template.cloneNode(true)
+    );
+}
+function killRowIfAtLeast(min, link) {
+    var row = link.parentNode.parentNode;
+    if (row.parentNode.getElementsByTagName("tr").length > min)
+        row.parentNode.removeChild(row);
+    return false;
+}
 function print_node(node_id) {
     var iframe = document.createElement("iframe");
     var source_node = document.getElementById(node_id);
@@ -38,7 +55,7 @@ function print_node(node_id) {
      * hurt FF/Chrome. */
     iwin.document.open();
     iwin.document.write(    /* XXX make better/customizable? */
-        "<html><head><title>Recipt</title></head><body></body></html>"
+        "<html><head><title>Receipt</title></head><body></body></html>"
     );
     iwin.document.close();
 
index 640b4f2..935da51 100644 (file)
@@ -2,19 +2,24 @@
     <div class="header_middle">[% l("Expert Search") %]</div>
     <input type="hidden" name="_special" value="1" />
     <table class="expert-search">
-        <tbody id="rows_here">
-            <tr id="clone_this">
+        <tbody id="adv_expert_rows_here">
+            <tr id="adv_expert_row">
                 <th>[% l("Tag:") %]</th>
                 <td><input type="text" name="tag" size="3" /></td>
                 <th>[% l("Subfield:") %]</th>
                 <td><input type="text" name="subfield" size="1" /></td>
                 <th>[% l("Value:") %]</th>
                 <td><input type="text" name="term" size="16" /></td>
+                <td>
+                    <a href="javascript:;" class="row-remover"
+                        title="[% l('Remove row') %]" alt="[% l('Remove row') %]"
+                        onclick='return killRowIfAtLeast(1, this);'><img src="[% ctx.media_prefix %]/images/adv_row_close_btn.png" /></a>
+                </td>
             </tr>
         </tbody>
         <tfoot>
             <tr>
-                <td colspan="2"><a href="javascript:alert('XXX coming soon');">[ [% l("Add row") %] ]</a></td>
+                <td colspan="2"><a href="javascript:addExpertRow();">[ [% l("Add row") %] ]</a></td>
                 <td colspan="4">
                     <input type="image" src="[% ctx.media_prefix %]/images/search_btn.gif" alt="[% l('Search') %]" title="[% l('Search') %]" />
                 </td>
index ae8081e..926504e 100644 (file)
@@ -26,7 +26,7 @@
         <input type='text' size='18' name='query' value="[% q | html %]" />
         <a href="javascript:;" class="row-remover"
             title="[% l('Remove row') %]" alt="[% l('Remove row') %]"
-            onclick='var row = this.parentNode.parentNode;var tbody = row.parentNode; if( tbody.getElementsByTagName("tr").length > 2 ) row.parentNode.removeChild(row);'><img src="[% ctx.media_prefix %]/images/adv_row_close_btn.png" /></a>
+            onclick='return killRowIfAtLeast(2, this);'><img src="[% ctx.media_prefix %]/images/adv_row_close_btn.png" /></a>
     </td>
 </tr>
 [%      i = i + 1;
index c66b114..7526f1d 100644 (file)
@@ -2,7 +2,7 @@
     <div id="zero_search_hits">
         <div>
             <p>[% l('Sorry, no entries were found for') %]
-                [% IF is_advanced; l('your search'); ELSE %]
+                [% IF is_advanced OR is_special; l('your search'); ELSE %]
                 <q>[% CGI.param('query') | html %]</q>
                 [% END %]
                 <br />