Bug 18847 - Add "Save and continue" option to notice editing
authorOwen Leonard <oleonard@myacpl.org>
Wed, 21 Jun 2017 18:57:04 +0000 (18:57 +0000)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 13 Jul 2017 17:39:26 +0000 (14:39 -0300)
This patch adds an option to "Save and continue editing" when editing
notices. The submit button is now a split button in a floating toolbar.
The secondary action of the split button is "Save and continue editing."

To test, apply the patch and go to Tools -> Notices.

- Open any notice for editing. Verify that the toolbar looks correct and
  floats as it should when sections of the form are expanded and the
  page scrolls.
- Edit a notice and click the "Save" button. Confirm that you are
  redirected to the main Notices page and that your changes were saved.
- Edit a notice and click the "Save and continue editing" menu item.
  The page should reload with your updates in place.

Signed-off-by: NickUCKohaCon17 <nicansjr@gmail.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt
tools/letter.pl

index 441b0ed..09a5e79 100644 (file)
@@ -5,10 +5,14 @@
 [% INCLUDE 'doc-head-close.inc' %]
 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
 [% INCLUDE 'datatables.inc' %]
+<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.fixFloat.js"></script>
 <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.insertatcaret.js"></script>
 <script type="text/javascript">
 //<![CDATA[
 $(document).ready(function() {
+    [% IF add_form or copy_form %]
+        $('#toolbar').fixFloat();
+    [% END %]
     $("#lettert:has(tbody tr)").dataTable($.extend(true, {}, dataTablesDefaults, {
         "sDom": 't',
         "aoColumnDefs": [
@@ -112,6 +116,13 @@ $(document).ready(function() {
     })
 
     $("#tabs").tabs();
+
+    $("#saveandcontinue").on("click",function(e){
+        e.preventDefault();
+        $("#redirect").val("just_save");
+        $("#submit_form").click();
+    });
+
 });
 [% IF add_form or copy_form %]
        
@@ -260,6 +271,20 @@ $(document).ready(function() {
        
 [% IF add_form or copy_form %]
 <h1>[% IF ( modify ) %]Modify notice[% ELSE %]Add notice[% END %]</h1>
+
+    <div id="toolbar" class="btn-toolbar">
+        <div class="btn-group">
+            <button class="btn btn-default btn-sm" id="submit_form"><i class="fa fa-save"></i> Save</button>
+            <button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown">
+            <span class="caret"></span>
+            </button>
+            <ul class="dropdown-menu">
+                <li><a id="saveandcontinue" href="#">Save and continue editing</a></li>
+            </ul>
+        </div>
+        <a class="btn btn-default btn-sm cancel" href="/cgi-bin/koha/tools/letter.pl"><i class="fa fa-remove"></i> Cancel</a>
+    </div>
+
         <form id="add_notice" name="Aform" method="post" enctype="multipart/form-data" class="validate">
         [% IF add_form %]
           <input type="hidden" name="op" id="op" value="add_validate" />
@@ -469,8 +494,9 @@ $(document).ready(function() {
         [% END %]
 
         [% IF code.search('DGST') %] <span class="overdue">Warning, this is a template for a Digest, as such, any references to branch data ( e.g. branches.branchname ) will refer to the borrower's home branch.</span> [% END %]
-        <fieldset class="action"><input type="submit" id="submit_form" value="Submit" class="button" /> <a class="cancel" href="/cgi-bin/koha/tools/letter.pl">Cancel</a></fieldset>
-      <input type="hidden" name="searchfield" value="[% searchfield %]" />
+
+        <input type="hidden" id="redirect" name="redirect" value="" />
+        <input type="hidden" name="searchfield" value="[% searchfield %]" />
     </form>
 [% END %]
 
index 5920a84..d0c52c2 100755 (executable)
@@ -66,6 +66,7 @@ my $code        = $input->param('code');
 my $module      = $input->param('module') || '';
 my $content     = $input->param('content');
 my $op          = $input->param('op') || '';
+my $redirect      = $input->param('redirect');
 my $dbh = C4::Context->dbh;
 
 our ( $template, $borrowernumber, $cookie, $staffflags ) = get_template_and_user(
@@ -94,7 +95,12 @@ $template->param(
 
 if ( $op eq 'add_validate' or $op eq 'copy_validate' ) {
     add_validate();
-    $op = q{}; # we return to the default screen for the next operation
+    if( $redirect eq "just_save" ){
+        print $input->redirect("/cgi-bin/koha/tools/letter.pl?op=add_form&branchcode=$branchcode&module=$module&code=$code&redirect=done");
+        exit;
+    } else {
+        $op = q{}; # we return to the default screen for the next operation
+    }
 }
 if ($op eq 'copy_form') {
     my $oldbranchcode = $input->param('oldbranchcode') || q||;