Bug 7180: QA followup
authorJonathan Druart <jonathan.druart@biblibre.com>
Mon, 1 Jul 2013 13:59:14 +0000 (15:59 +0200)
committerGalen Charlton <gmc@esilibrary.com>
Sun, 4 May 2014 19:46:04 +0000 (19:46 +0000)
Ergonomic improvements:
- Remove the green color the selected record.
- Use fieldset.rows (and legend).
- Use the required css class for quantity inputs.
- Replace "budget" with "fund".
- fix the "undefined" string
- Add a "show MARC" link
- replace "no_match" with a text.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
acqui/ajax-getauthvaluedropbox.pl
koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt

index 86f440c..57c1f99 100755 (executable)
@@ -60,7 +60,7 @@ $default = C4::Charset::NormalizeString($default);
 binmode STDOUT, ':encoding(UTF-8)';
 print $input->header(-type => 'text/plain', -charset => 'UTF-8');
 my $avs = GetAuthvalueDropbox($category, $default);
-my $html = qq|<select id="$name", name="$name">|;
+my $html = qq|<select id="$name" name="$name">|;
 for my $av ( @$avs ) {
     if ( $av->{default} ) {
         $html .= qq|<option value="$av->{value}" selected="selected">$av->{label}</option>|;
index f0187d5..3a49523 100644 (file)
@@ -7,6 +7,7 @@
  &rsaquo; Batch list
 [% END %]
 </title>
+[% INCLUDE 'greybox.inc' %]
 <link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
 [% INCLUDE 'doc-head-close.inc' %]
 [% INCLUDE 'datatables.inc' %]
         $("select[name='budget_id']").change(function(){
             var sort1_authcat = $(this).find("option:selected").attr('data-sort1-authcat');
             var sort2_authcat = $(this).find("option:selected").attr('data-sort2-authcat');
-            var destination_sort1 = $(this).siblings('span.sort1').find('input[name="sort1"]');
-            var sort1 = $(destination_sort1).val();
+            var destination_sort1 = $(this).parents('fieldset').find('li.sort1').find('input[name="sort1"]');
+            var sort1 = $(destination_sort1).val() || "";
             if ( destination_sort1.length < 1 ) {
-                destination_sort1 = $(this).siblings('span.sort1').find('select[name="sort1"]');
+                destination_sort1 = $(this).parents('fieldset').find('li.sort1 > select[name="sort1"]');
             }
-            var destination_sort2 = $(this).siblings('span.sort2').find('input[name="sort2"]');
-            var sort2 = $(destination_sort2).val();
+            var destination_sort2 = $(this).parents('fieldset').find('li.sort2').find('input[name="sort2"]');
+            var sort2 = $(destination_sort2).val() || "";
             if ( destination_sort2.length < 1 ) {
-                destination_sort2 = $(this).siblings('span.sort2').find('select[name="sort2"]');
+                destination_sort2 = $(this).parents('fieldset').find('li.sort2').find('select[name="sort2"]');
             }
             getAuthValueDropbox( 'sort1', sort1_authcat, destination_sort1, sort1 );
 
             $(this).parent().siblings('li').find('input[name="sort2"]').attr('name', 'all_sort2');
         } );
 
+        $("#records_to_import fieldset.rows ol").hide();
         $('input:checkbox[name="import_record_id"]').change(function(){
+            var container = $(this).parents("fieldset");
             if ( $(this).is(':checked') ) {
-                $(this).parent().addClass("selected");
-                $(this).parent().removeClass("unselected");
+                $(container).addClass("selected");
+                $(container).removeClass("unselected");
+                $(container).find("ol").toggle();
             } else {
-                $(this).parent().addClass("unselected");
-                $(this).parent().removeClass("selected");
+                $(container).addClass("unselected");
+                $(container).removeClass("selected");
+                $(container).find("ol").toggle();
             }
         } );
 
             return false;
         });
 
+        $("#Aform").on("submit", function(){
+            if ( $("input:checkbox[name='import_record_id']:checked").length < 1 ) {
+                alert("There is no record selected");
+                return false;
+            }
+
+            var error = 0;
+            $("input:checkbox[name='import_record_id']:checked").parents('fieldset').find('input[name="quantity"]').each(function(){
+                if ( $(this).val().length < 1 || isNaN( $(this).val() ) ) {
+                    error++;
+                }
+            });
+            if ( error > 0 ) {
+                alert(error + " quantity values are not filled or not a number");
+                return false;
+            }
+
+            return disableUnchecked($(this));
+        });
     });
 
     function disableUnchecked(form){
             $(this).find('select').attr('disabled', 'disabled');
             $(this).find('input').attr('disabled', 'disabled');
         });
-        form.submit();
+        return 1;
     }
 //]]>
 </script>
                     ([% file_name %] staged on [% upload_timestamp | $KohaDates with_hours => 1 %])
                 </h1>
                 <div>
+                  <div id="records_to_import">
                     <span class="checkall"><a id="checkAll" href="#">Check All</a></span>
                     <span class="uncheckall"><a id="unCheckAll" href="#">Uncheck All</a></span>
-                    <form action="/cgi-bin/koha/acqui/addorderiso2709.pl" method="post" id="Aform" onsubmit="disableUnchecked(this); return false;">
+                    <form action="/cgi-bin/koha/acqui/addorderiso2709.pl" method="post" id="Aform">
                         <input type="hidden" name="op" value="import_records"/>
                         <input type="hidden" name="basketno" value="[% basketno %]" />
                         <input type="hidden" name="booksellerid" value="[% booksellerid %]" />
                         [% END %]
 
                         [% FOREACH biblio IN biblio_list %]
-                        <div class="biblio unselected" style="border-radius: 5px 5px; -moz-border-radius: 5px; padding: 5px; margin:5px; border-style : solid; border-color : grey; border-width:1px;">
-                            <input type="checkbox" name="import_record_id" id="record_[% biblio.import_record_id %]" value="[% biblio.import_record_id %]" />
-                            <input type="hidden" value="[% biblio.rrp %]" name="rrp" />
-                            <label for="record_[% biblio.import_record_id %]"><span class="citation" style="font-weight:bold;">[% biblio.citation %]</span></label>
-                            <span class="match" style="display:block;">
+                        <fieldset class="biblio unselected rows">
+                          <legend>
+                            <label for="record_[% biblio.import_record_id %]" style="width:auto;">
+                              <input type="checkbox" name="import_record_id" id="record_[% biblio.import_record_id %]" value="[% biblio.import_record_id %]" />
+                              <span class="citation">[% biblio.citation %]</span>
+                            </label>
+                            ( Show <a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=[% biblio.import_record_id %]" title="MARC" rel="gb_page_center[600,500]">MARC</a> | <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;id=[% biblio.import_record_id %]" title="MARC" rel="gb_page_center[600,500]">Card</a> )
+
+                          </legend>
+                          <input type="hidden" value="[% biblio.rrp %]" name="rrp" />
+                          <ol>
+                            <li class="status">
+                              <span class="match">
                                 [% IF ( biblio_lis.overlay_status == 'no_match' ) %]
                                     No match
                                 [% ELSIF ( biblio_lis.overlay_status == 'match_applied' ) %]
                                 [% ELSE %]
                                     [% biblio_lis.overlay_status %]
                                 [% END %]
-                            </span>
-                            [% IF ( biblio.match_biblionumber ) %]
-                                Matches biblio [% biblio.match_biblionumber %] (score = [% biblio.match_score %]): <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblio.match_biblionumber %]">[% biblio.match_citation %]</a>
-                            [% END %]
-                            <span class="quantity" style="display:block;">
-                                Quantity: <input type="text" value="[% biblio.quantity %]" name="quantity" />
-                            </span>
-                            <span class="price" style="display:block;">
-                                Price: <input type="text" value="[% biblio.price %]" name="price" />
-                            </span>
-                            <span class="discount" style="display:block;">
-                                Discount: <input type="text" value="[% biblio.discount %]" name="discount" />
-                            </span>
-                            <span class="budget" style="display:block;">
+                                [% IF ( biblio.match_biblionumber ) %]
+                                  Matches biblio [% biblio.match_biblionumber %] (score = [% biblio.match_score %]): <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblio.match_biblionumber %]">[% biblio.match_citation %]</a>
+                                [% END %]
+                              </span>
+                            </li>
+                            <li class="quantity">
+                                <label for="quantity_record_[% biblio.import_record_id %]" class="required">Quantity: </label>
+                                <input id="quantity_record_[% biblio.import_record_id %]" type="text" value="[% biblio.quantity %]" name="quantity" />
+                            </li>
+                            <li class="price">
+                                <label for="price_record_[% biblio.import_record_id %]">Price: </label>
+                                <input id="price_record_[% biblio.import_record_id %]" type="text" value="[% biblio.price %]" name="price" />
+                            </li>
+                            <li class="discount">
+                                <label for="discount_record_[% biblio.import_record_id %]">Discount: </label>
+                                <input id="discount_record_[% biblio.import_record_id %]" type="text" value="[% biblio.discount %]" name="discount" />
+                            </li>
+                            <li class="budget">
+                                <label for="fund_record_[% biblio.import_record_id %]">Fund: </label>
                                 [% IF ( close ) %]
-                                <span class="label">Budget: </span>
-                                    <input type="hidden" size="20" name="budget_id" value="[% budget_id %]" />[% Budget_name %]
+                                  <input type="hidden" size="20" name="budget_id" value="[% budget_id %]" />[% Budget_name %]
                                 [% ELSE %]
-                                <label for="budget_id">Budget: </label>
-                                <select size="1" name="budget_id">
+                                  <select id="fund_record_[% biblio.import_record_id %]" size="1" name="budget_id">
                                     <option value=""></option>
                                     [% FOREACH budget IN budget_loop %]
                                         [% IF ( budget.b_id == biblio.budget_id ) %]
                                             <option value="[% budget.b_id %]" data-sort1-authcat="[% budget.b_sort1_authcat %]" data-sort2-authcat="[% budget.b_sort2_authcat %]">[% budget.b_txt %]</option>
                                         [% END %]
                                     [% END %]
-                                </select>
+                                  </select>
                                 [% END %]
-                                <span class="sort1">
-                                    <label for="sort1">Planning value1: </label>
-                                    <input type="text" id="sort1" size="20" name="sort1" value="[% biblio.sort1 %]" />
-                                </span>
-                                <span class="sort2">
-                                    <label for="sort2">Planning value2: </label>
-                                    <input type="text" id="sort2" size="20" name="sort2" value="[% biblio.sort2 %]" />
-                                </span>
-                            </span>
-                        </div>
+                            </li>
+                            <li class="sort1">
+                                <label for="sort1_record_[% biblio.import_record_id %]">Planning value1: </label>
+                                <input id="sort1_record_[% biblio.import_record_id %]" type="text" id="sort1" size="20" name="sort1" value="[% biblio.sort1 %]" />
+                            </li>
+                            <li class="sort2">
+                                <label for="sort2_record_[% biblio.import_record_id %]">Planning value2: </label>
+                                <input id="sort2_record_[% biblio.import_record_id %]" type="text" id="sort2" size="20" name="sort2" value="[% biblio.sort2 %]" />
+                            </li>
+                          </ol>
+                        </fieldset>
                         [% END %]
-                        <div>
+                      </div>
+                      <div id="import_all">
                         <h2>Import all</h2>
                         <p>Import all the lines in the basket with the following parameters:</p>