Bug 19627: Move patron clubs templates JS to the footer
authorOwen Leonard <oleonard@myacpl.org>
Wed, 15 Nov 2017 14:13:46 +0000 (14:13 +0000)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 14 Dec 2017 19:58:14 +0000 (16:58 -0300)
This patch modifies the staff client's patron clubs templates so that
JavaScript is included in the footer instead of the header.

To test, apply the patch and test the JavaScript-driven features of
each page: All button controls, DataTables functionality, tabs, etc.

Signed-off-by: Simon Pouchol <simon.pouchol@biblibre.com>
Signed-off-by: Claire Gravely <claire.gravely@bsz-bw.de>
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
koha-tmpl/intranet-tmpl/prog/en/modules/clubs/club-enrollments.tt
koha-tmpl/intranet-tmpl/prog/en/modules/clubs/clubs-add-modify.tt
koha-tmpl/intranet-tmpl/prog/en/modules/clubs/clubs.tt

index 94e7148..daf07d0 100644 (file)
@@ -1,27 +1,11 @@
 [% USE KohaDates %]
 [% USE Branches %]
 [% USE Koha %]
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Tools &rsaquo; Patron clubs &rsaquo; Club enrollments</title>
 [% INCLUDE 'doc-head-close.inc' %]
-
 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
-[% INCLUDE 'datatables.inc' %]
-
-<script type="text/javascript">
-//<![CDATA[
-    $(document).ready(function() {
-        eTable = $('#enrollments-table').dataTable($.extend(true, {}, dataTablesDefaults, {
-            "sPaginationType": "four_button",
-            "sDom": 'C<"top pager"ilpf><"#filter_c">tr<"bottom pager"ip>',
-            "aoColumnDefs": [
-                    { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false },
-            ]
-        } ));
-    });
-//]]>
-</script>
-
 </head>
 
 <body id="club_enrollments" class="clubs">
         </div>
     </div>
 </div>
+
+[% MACRO jsinclude BLOCK %]
+    [% INCLUDE 'datatables.inc' %]
+    <script type="text/javascript">
+        $(document).ready(function() {
+            eTable = $('#enrollments-table').dataTable($.extend(true, {}, dataTablesDefaults, {
+                "sPaginationType": "four_button",
+                "sDom": 'C<"top pager"ilpf><"#filter_c">tr<"bottom pager"ip>',
+                "aoColumnDefs": [
+                        { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false },
+                ]
+            } ));
+        });
+    </script>
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]
index ec76ded..3d7da82 100644 (file)
@@ -2,6 +2,7 @@
 [% USE Branches %]
 [% USE AuthorisedValues %]
 [% SET AuthorisedValuesCategories = AuthorisedValues.GetCategories %]
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Tools &rsaquo; Patron clubs &rsaquo;
     [% IF club %]
@@ -11,7 +12,6 @@
     [% END %]
 </title>
 [% INCLUDE 'doc-head-close.inc' %]
-[% INCLUDE 'calendar.inc' %]
 </head>
 
 <body id="clubs_add_modify" class="clubs">
         </div>
     </div>
 
+[% MACRO jsinclude BLOCK %]
+    [% INCLUDE 'calendar.inc' %]
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]
index 0c96f79..318d821 100644 (file)
@@ -1,71 +1,12 @@
 [% USE KohaDates %]
 [% USE Branches %]
 [% USE Koha %]
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Tools &rsaquo; Patron clubs</title>
 [% INCLUDE 'doc-head-close.inc' %]
 
 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
-[% INCLUDE 'datatables.inc' %]
-
-<script type="text/javascript">
-//<![CDATA[
-    $(document).ready(function() {
-        tTable = $('#club-templates-table').dataTable($.extend(true, {}, dataTablesDefaults, {
-            "sPaginationType": "four_button",
-            "sDom": 'C<"top pager"ilpf><"#filter_c">tr<"bottom pager"ip>',
-            "aoColumnDefs": [
-                { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
-            ]
-        } ));
-
-        cTable = $('#clubs-table').dataTable($.extend(true, {}, dataTablesDefaults, {
-            "sPaginationType": "four_button",
-            "sDom": 'C<"top pager"ilpf><"#filter_c">tr<"bottom pager"ip>',
-            "aoColumnDefs": [
-                { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
-            ]
-        } ));
-    });
-
-    function ConfirmDeleteTemplate( id, name, a ) {
-        if ( confirm( _("Are you sure you want to delete the club template %s? This will delete all clubs using this template and cancel patron enrollments" ).format(name) ) ) {
-            $.ajax({
-                type: "POST",
-                url: '/cgi-bin/koha/svc/club/template/delete',
-                data: { id: id },
-                success: function( data ) {
-                    if ( data.success ) {
-                        location.reload();
-                    } else {
-                        alert(_("Unable to delete template!"));
-                    }
-                },
-                dataType: 'json'
-            });
-        }
-    }
-
-    function ConfirmDeleteClub( id, name, a ) {
-        if ( confirm( _("Are you sure you want to delete the club %s? This will cancel all patron enrollments in this club." ).format(name) ) ) {
-            $.ajax({
-                type: "POST",
-                url: '/cgi-bin/koha/svc/club/delete',
-                data: { id: id },
-                success: function( data ) {
-                    if ( data.success ) {
-                        location.reload();
-                    } else {
-                        alert(_("Unable to delete club!"));
-                    }
-                },
-                dataType: 'json'
-            });
-        }
-    }
-//]]>
-</script>
-
 </head>
 
 <body id="clubs_clubs" class="clubs">
         </div>
     </div> <!-- /#bd -->
 
+[% MACRO jsinclude BLOCK %]
+    [% INCLUDE 'datatables.inc' %]
+
+    <script type="text/javascript">
+        $(document).ready(function() {
+            tTable = $('#club-templates-table').dataTable($.extend(true, {}, dataTablesDefaults, {
+                "sPaginationType": "four_button",
+                "sDom": 'C<"top pager"ilpf><"#filter_c">tr<"bottom pager"ip>',
+                "aoColumnDefs": [
+                    { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
+                ]
+            } ));
+
+            cTable = $('#clubs-table').dataTable($.extend(true, {}, dataTablesDefaults, {
+                "sPaginationType": "four_button",
+                "sDom": 'C<"top pager"ilpf><"#filter_c">tr<"bottom pager"ip>',
+                "aoColumnDefs": [
+                    { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
+                ]
+            } ));
+        });
+
+        function ConfirmDeleteTemplate( id, name, a ) {
+            if ( confirm( _("Are you sure you want to delete the club template %s? This will delete all clubs using this template and cancel patron enrollments" ).format(name) ) ) {
+                $.ajax({
+                    type: "POST",
+                    url: '/cgi-bin/koha/svc/club/template/delete',
+                    data: { id: id },
+                    success: function( data ) {
+                        if ( data.success ) {
+                            location.reload();
+                        } else {
+                            alert(_("Unable to delete template!"));
+                        }
+                    },
+                    dataType: 'json'
+                });
+            }
+        }
+
+        function ConfirmDeleteClub( id, name, a ) {
+            if ( confirm( _("Are you sure you want to delete the club %s? This will cancel all patron enrollments in this club." ).format(name) ) ) {
+                $.ajax({
+                    type: "POST",
+                    url: '/cgi-bin/koha/svc/club/delete',
+                    data: { id: id },
+                    success: function( data ) {
+                        if ( data.success ) {
+                            location.reload();
+                        } else {
+                            alert(_("Unable to delete club!"));
+                        }
+                    },
+                    dataType: 'json'
+                });
+            }
+        }
+    </script>
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]