[Koha-patches] [PATCH] Bug 9697 - Replace YUI buttons on the patron cards batch edit page with Bootstrap

Owen Leonard oleonard at myacpl.org
Fri Feb 22 16:34:02 CET 2013


The patron card creator's batch edit page uses an include file to
display buttons styled by YUI. Bootstrap should be used instead.

This patch moves the contents of the include file into the main
template, this being the only page which requires it. YUI markup and
code has been removed and Bootstrap markup is added. The include file is
deleted.

To test, edit a batch of patrons in the patron card creator. Each
toolbar button should look correct and work correctly:

- Add item(s)
- Remove item(s)
- Delete batch
- Remove duplicates (Keeping Bug 9535 in mind)
- Export item(s)
- Export batch
---
 .../en/includes/patroncards-batches-toolbar.inc    |  179 --------------------
 .../prog/en/modules/patroncards/edit-batch.tt      |  136 ++++++++++++++-
 2 files changed, 135 insertions(+), 180 deletions(-)
 delete mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/patroncards-batches-toolbar.inc

diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patroncards-batches-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patroncards-batches-toolbar.inc
deleted file mode 100644
index 226210c..0000000
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/patroncards-batches-toolbar.inc
+++ /dev/null
@@ -1,179 +0,0 @@
-<div id="toolbar">
-    <script type="text/JavaScript">
-        //<![CDATA[
-           function DeleteConfirm() {
-                var msg = "Are you sure you want to delete batch [% batch_id %]?"
-                var answer = confirm(msg);
-                if (answer) {
-                    window.location = "/cgi-bin/koha/patroncards/manage.pl?op=delete&card_element=batch&element_id=[% batch_id %]";
-                }
-                else {
-                    return; // abort delete
-                }
-            };
-            function Remove() {
-                items = new Array;
-                item_num = new Array;
-                if(document.items.action.length > 0) {
-                    for (var i=0; i < document.items.action.length; i++) {
-                        if (document.items.action[i].checked) {
-                            items.push("label_id=" +  document.items.action[i].value);
-                            item_num.push(i+1);
-                        }
-                    }
-                    if (items.length < 1) {
-                        alert(_("Please select at least one item to delete."));
-                        return;     // no item selected
-                    }
-                    getstr = items.join("&");
-                    item_msg = item_num.join(", ");
-                    var msg = "Are you sure you want to remove card number(s): " + item_msg + " from this batch?"
-                }
-//                else if (document.items.action.checked) {
-//                    getstr = "label_id="+document.items.action.value;
-//                    var msg = "Are you sure you want to remove selected item from this batch?"
-//                }
-                else {
-                    alert(_("Please select at least label to delete."));
-                    return;     // no item selected
-                }
-                var answer = confirm(msg);
-                if (answer) {
-                    window.location = "/cgi-bin/koha/patroncards/edit-batch.pl?op=remove&batch_id=[% batch_id %]&" + getstr;
-                }
-                else {
-                    return; // abort delete
-                }
-            };
-            function Add() {
-                window.open("/cgi-bin/koha/patroncards/members-search.pl?batch_id=[% batch_id %]",'FindABibIndex','width=875,height=400,toolbar=no,scrollbars=yes');
-            };
-            function DeDuplicate() {
-                window.location = "/cgi-bin/koha/patroncards/edit-batch.pl?op=de_duplicate&batch_id=[% batch_id %]";
-            };
-            function Xport(mode) {
-                if (mode == 'label') {
-                    patroncards= new Array;
-                    if(document.items.action.length > 0) {
-                        for (var i=0; i < document.items.action.length; i++) {
-                            if (document.items.action[i].checked) {
-                                patroncards.push("label_id=" +  document.items.action[i].value);
-                            }
-                        }
-                        if (patroncards.length < 1) {
-                            alert(_("Please select at least one card to export."));
-                            return;     // no batch selected
-                        }
-                        getstr = patroncards.join("&");
-                    }
-                    else if (document.items.action.checked) {
-                        getstr = document.items.action.value;
-                    }
-                    else {
-                        alert(_("Please select at least one card to export."));
-                        return;     // no batch selected
-                    }
-                    return GB_showCenter('Export labels', "/cgi-bin/koha/patroncards/print.pl?batch_id=[% batch_id %]&" + getstr, 700, 800);
-                }
-                else if (mode == 'batch') {
-                    return GB_showCenter('Export labels', "/cgi-bin/koha/patroncards/print.pl?batch_id=[% batch_id %]", 700, 800);
-                }
-                else {
-                    // some pass-thru error trapping just in case...
-                }
-            };
-           function selected_layout() {
-                if (document.items.action.length) {
-                for (i=0;i<document.items.action.length;i++){
-                    if (document.items.action[i].checked==true){
-                        return(document.items.action[i].value);
-                    }
-                };
-                }
-                else {
-                    if (document.items.action.checked){
-                        return(document.items.action.value);
-                    }
-                };
-                alert(_("Please select at least one item."));
-                return (-1);
-            };
-
-        // prepare DOM for YUI Toolbar
-         $(document).ready(function() {
-            $("#additemsc").empty();
-            $("#removeitemsc").empty();
-            $("#deletebatchc").empty();
-            $("#deduplicatec").empty();
-            $("#exportitemsc").empty();
-            $("#exportbatchc").empty();
-            yuiToolbar();
-         });
-        // YUI Toolbar Functions
-        function yuiToolbar() {
-            new YAHOO.widget.Button({
-                id: "additems",
-                type: "link",
-                href: "#",
-                label: _("Add item(s)"),
-                container: "additemsc",
-                onclick: {fn:function(){Add()}}
-            });
-
-            new YAHOO.widget.Button({
-                id: "removeitems",
-                type: "link",
-                href: "#",
-                label: _("Remove item(s)"),
-                container: "removeitemsc",
-                onclick: {fn:function(){Remove()}}
-            });
-
-            new YAHOO.widget.Button({
-                id: "deletebatch",
-                type: "link",
-                href: "#",
-                label: _("Delete batch"),
-                container: "deletebatchc",
-                onclick: {fn:function(){DeleteConfirm()}}
-            });
-
-            new YAHOO.widget.Button({
-                id: "deduplicate",
-                type: "link",
-                href: "#",
-                label: _("Remove duplicates"),
-                container: "deduplicatec",
-                onclick: {fn:function(){DeDuplicate()}}
-            });
-
-            new YAHOO.widget.Button({
-                id: "exportitems",
-                type: "link",
-                href: "#",
-                label: _("Export item(s)"),
-                container: "exportitemsc",
-                onclick: {fn:function(){Xport('label')}}
-            });
-
-            new YAHOO.widget.Button({
-                id: "exportbatch",
-                type: "link",
-                href: "#",
-                label: _("Export batch"),
-                container: "exportbatchc",
-                onclick: {fn:function(){Xport('batch')}}
-            });
-            new YAHOO.widget.Button("deletebatch");
-        }
-        //]]>
-    </script>
-    <ul class="toolbar">
-        <li id="additemsc"><a id="additems" href="#">Add item(s)</a></li>[% IF ( table_loop ) %]
-        <li id="removeitemsc"><a id="removeitems" href="#">Remove item(s)</a></li>
-        <li id="deletebatchc"><a id="deletebatch" href="#">Delete batch</a></li>
-        <li id="deduplicatec"><a id="deduplicate" href="#">Remove duplicates</a></li>
-        <li id="exportitemsc"><a id="exportitems" href="#">Export item(s)</a></li>
-        <li id="exportbatchc"><a id="exportbatch" href="#">Export batch</a></li>[% END %]
-    </ul>
-</div>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-batch.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-batch.tt
index 7a0811b..51b585a 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-batch.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-batch.tt
@@ -2,6 +2,130 @@
     <title>Koha › Tools › Patron card creator › Manage patron card batches</title>
     [% INCLUDE 'doc-head-close.inc' %]
     [% INCLUDE 'greybox.inc' %]
+    <script type="text/javascript">
+        //<![CDATA[
+           function DeleteConfirm() {
+                var msg = _("Are you sure you want to delete batch") + " [% batch_id %]?";
+                var answer = confirm(msg);
+                if (answer) {
+                    window.location = "/cgi-bin/koha/patroncards/manage.pl?op=delete&card_element=batch&element_id=[% batch_id %]";
+                }
+                else {
+                    return; // abort delete
+                }
+            };
+            function Remove() {
+                items = new Array;
+                item_num = new Array;
+                if(document.items.action.length > 0) {
+                    for (var i=0; i < document.items.action.length; i++) {
+                        if (document.items.action[i].checked) {
+                            items.push("label_id=" +  document.items.action[i].value);
+                            item_num.push(i+1);
+                        }
+                    }
+                    if (items.length < 1) {
+                        alert(_("Please select at least one item to delete."));
+                        return;     // no item selected
+                    }
+                    getstr = items.join("&");
+                    item_msg = item_num.join(", ");
+                    var msg = "Are you sure you want to remove card number(s): " + item_msg + " from this batch?"
+                }
+                else {
+                    alert(_("Please select at least label to delete."));
+                    return;     // no item selected
+                }
+                var answer = confirm(msg);
+                if (answer) {
+                    window.location = "/cgi-bin/koha/patroncards/edit-batch.pl?op=remove&batch_id=[% batch_id %]&" + getstr;
+                }
+                else {
+                    return; // abort delete
+                }
+            };
+            function Add() {
+                window.open("/cgi-bin/koha/patroncards/members-search.pl?batch_id=[% batch_id %]",'FindABibIndex','width=875,height=400,toolbar=no,scrollbars=yes');
+            };
+            function DeDuplicate() {
+                window.location = "/cgi-bin/koha/patroncards/edit-batch.pl?op=de_duplicate&batch_id=[% batch_id %]";
+            };
+            function Xport(mode) {
+                if (mode == 'label') {
+                    patroncards= new Array;
+                    if(document.items.action.length > 0) {
+                        for (var i=0; i < document.items.action.length; i++) {
+                            if (document.items.action[i].checked) {
+                                patroncards.push("label_id=" +  document.items.action[i].value);
+                            }
+                        }
+                        if (patroncards.length < 1) {
+                            alert(_("Please select at least one card to export."));
+                            return;     // no batch selected
+                        }
+                        getstr = patroncards.join("&");
+                    }
+                    else if (document.items.action.checked) {
+                        getstr = document.items.action.value;
+                    }
+                    else {
+                        alert(_("Please select at least one card to export."));
+                        return;     // no batch selected
+                    }
+                    return GB_showCenter(_('Export labels'), "/cgi-bin/koha/patroncards/print.pl?batch_id=[% batch_id %]&" + getstr, 700, 800);
+                }
+                else if (mode == 'batch') {
+                    return GB_showCenter(_('Export labels'), "/cgi-bin/koha/patroncards/print.pl?batch_id=[% batch_id %]", 700, 800);
+                }
+                else {
+                    // some pass-thru error trapping just in case...
+                }
+            };
+           function selected_layout() {
+                if (document.items.action.length) {
+                for (i=0;i<document.items.action.length;i++){
+                    if (document.items.action[i].checked==true){
+                        return(document.items.action[i].value);
+                    }
+                };
+                }
+                else {
+                    if (document.items.action.checked){
+                        return(document.items.action.value);
+                    }
+                };
+                alert(_("Please select at least one item."));
+                return (-1);
+            };
+
+         $(document).ready(function() {
+            $("#additems").click(function(){
+                Add();
+                return false;
+            });
+            $("#removeitems").click(function(){
+                Remove();
+                return false;
+            });
+            $("#deletebatch").click(function(){
+                DeleteConfirm();
+                return false;
+            });
+            $("#deduplicate").click(function(){
+                DeDuplicate();
+                return false;
+            });
+            $("#exportitems").click(function(){
+                Xport('label');
+                return false;
+            });
+            $("#exportbatch").click(function(){
+                Xport('batch');
+                return false;
+            });
+         });
+        //]]>
+    </script>
 </head>
 <body id="pcard_edit-batch" class="tools pcard">
     [% INCLUDE 'header.inc' %]
@@ -17,7 +141,17 @@
         <div id="bd">
             <div id="yui-main">
                 <div class="yui-b">
-                    [% INCLUDE 'patroncards-batches-toolbar.inc' %]
+
+                <div id="toolbar" class="btn-toolbar">
+                    <a class="btn btn-small" id="additems" href="#">Add item(s)</a>[% IF ( table_loop ) %]
+                    <a class="btn btn-small" id="removeitems" href="#">Remove item(s)</a>
+                    <a class="btn btn-small" id="deletebatch" href="#">Delete batch</a>
+                    <a class="btn btn-small" id="deduplicate" href="#">Remove duplicates</a>
+                    <a class="btn btn-small" id="exportitems" href="#">Export item(s)</a>
+                    <a class="btn btn-small" id="exportbatch" href="#">Export batch</a>[% END %]
+                </div>
+
+
                     [% INCLUDE 'error-messages.inc' %]
                     <div class="yui-g">
                         <div class="yui-u first" id="manage-patroncard-batches">
-- 
1.7.9.5


More information about the Koha-patches mailing list