Bug 16513 - Improvements and fixes for quote upload process
authorOwen Leonard <oleonard@myacpl.org>
Fri, 13 May 2016 13:59:53 +0000 (09:59 -0400)
committerKyle M Hall <kyle@bywatersolutions.com>
Fri, 24 Jun 2016 13:47:34 +0000 (13:47 +0000)
This patch fixes some minor bugs and adds a small enhancement to the
quotes editor and quotes upload pages.

To test, apply the patch and go to Tools -> Quote editor

- In the table of quotes, clicking the "ID" table header should trigger
  an alert, "Click on the quote's ide to select..."
- Go to "Import quotes" and select a file to upload.
- On the upload preview page you should see a new "Cancel import"
  button. Clicking it should return you to the quotes upload page after
  asking for confirmation.
- Test the upload cancel button:
  - If you have fast reflexes or are uploading a file large enough, you
    should be able to see a "Cancel upload" button during the upload
    process.
  - Clicking this button should cancel the upload and return you to the
    quote upload page.

Tested on top of Bug 16589, works as expected.
Signed-off-by: Marc VĂ©ron <veron@veron.ch>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
koha-tmpl/intranet-tmpl/prog/en/includes/quotes-upload-toolbar.inc
koha-tmpl/intranet-tmpl/prog/en/modules/tools/quotes-upload.tt
koha-tmpl/intranet-tmpl/prog/en/modules/tools/quotes.tt

index ea795cf..617e3b3 100644 (file)
@@ -1,4 +1,5 @@
 <div id="toolbar" class="btn-toolbar" style="visibility: hidden; position: absolute">
         <div class="btn-group"><a class="btn btn-small" id="save_quotes" href="#"><i class="fa fa-save"></i> Save quotes</a></div>
-        <div class="btn-group"><a class="btn btn-small" id="delete_quote" href="#"><i class="fa fa-remove"></i> Delete quote(s)</a></div>
+        <div class="btn-group"><a class="btn btn-small" id="delete_quote" href="#"><i class="fa fa-trash"></i> Delete quote(s)</a></div>
+        <div class="btn-group"><a href="/cgi-bin/koha/tools/quotes-upload.pl" id="cancel_quotes" class="btn btn-small"><i class="fa fa-remove"></i> Cancel import</a></div>
 </div>
index cf34371..088b730 100644 (file)
     var oTable; //DataTable object
     $(document).ready(function() {
 
+        $("#cancel_upload").on("click",function(e){
+            e.preventDefault();
+            fnAbortRead();
+        });
+        $("#cancel_quotes").on("click",function(){
+            return confirm( _("Are you sure you want to cancel this import?") );
+        });
+
     // Credits:
     // FileReader() code copied and hacked from:
     // http://www.html5rocks.com/en/tutorials/file/dndfiles/
             parent.location='quotes-upload.pl';
         };
         reader.onloadstart = function(e) {
-            $('#cancel_upload').css("visibility","visible");
+            $('#cancel_upload').show();
             $('#progress_bar').addClass("loading");
         };
         reader.onload = function(e) {
             // Ensure that the progress bar displays 100% at the end.
             progress.style.width = '100%';
             progress.textContent = '100%';
-            $('#cancel_upload').css("visibility","hidden");
+            $('#cancel_upload').hide();
             quotes = fnCSVToArray(e.target.result, ',');
             fnDataTable(quotes);
         }
                     <legend>Upload quotes</legend>
                     <div id="file_upload">
                         <input type="file" name="file" />
-                        <button id="cancel_upload" style="visibility:hidden;" onclick="fnAbortRead();">Cancel Upload</button>
+                        <button id="cancel_upload" style="display:none">Cancel upload</button>
                         <div id="progress_bar"><div class="percent">0%</div></div>
                     </div>
                 </fieldset>
index 9e80014..f0d4bd8 100644 (file)
@@ -8,7 +8,6 @@
     <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.jeditable.mini.js"></script>
     <script type="text/javascript">
     //<![CDATA[
-    var MSG_ID_HELP = _("Click on the quote's id to select or deselect the quote. Multiple quotes may be selected.");
 
     var oTable; /* oTable needs to be global */
     var sEmptyTable = _("No quotes available. Please use the 'Add quote' button to add a quote."); /* override the default message in datatables.inc */
             fnClickDeleteRow();
             return false;
         });
+        $("#id_help").on("click",function(e){
+            e.stopPropagation();
+            alert( _("Click on the quote's id to select or deselect the quote. Multiple quotes may be selected.") );
+        });
     });
 
         function fnClickAddQuote(e, node) {
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'cat-search.inc' %]
 
-<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; Quote Editor</div>
+<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; Quote editor</div>
 
 <div id="doc3" class="yui-t2">
     <div id="bd">
                 <table id="quotes_editor">
                 <thead>
                     <tr>
-                        <th><span style="cursor: help" onclick="event.stopPropagation();alert(MSG_ID_HELP);">ID</span></th>
+                        <th><span style="cursor: help" id="id_help">ID</span></th>
                         <th>Source</th>
                         <th>Text</th>
                         <th>Last displayed</th>