Bugzilla – Attachment 154726 Details for
Bug 34085
Remove the use of event attributes from basket groups template
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34085: Remove the use of event attributes from basket groups template
Bug-34085-Remove-the-use-of-event-attributes-from-.patch (text/plain), 14.31 KB, created by
David Cook
on 2023-08-24 06:26:24 UTC
(
hide
)
Description:
Bug 34085: Remove the use of event attributes from basket groups template
Filename:
MIME Type:
Creator:
David Cook
Created:
2023-08-24 06:26:24 UTC
Size:
14.31 KB
patch
obsolete
>From 3c616680c1a152bdec4dc0e9df826c9ce420b45f Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Wed, 21 Jun 2023 17:24:20 +0000 >Subject: [PATCH] Bug 34085: Remove the use of event attributes from basket > groups template > >This patch removes the use of event attributes (onclick, onsubmit) from >the basket groups template. These events are defined now along with the >other in-page JS. > >This change allows us to move the scripts to the bottom of the page. > >Unrelated changes: There was no confirmation tied to the process of >deleting a basket group. I've added one. And there were several "MSG_" >variables defined which were unused and have been removed. > >To test you should have at least one vendor with at least one basket >group. > >- Apply the patch and go to Acquisitions. >- Locate a vendor with an associated basket group. >- Edit a basketgroup > - Confirm that editing works correctly (leaving "Close basket group" > unchecked") > - Confirm that editing works correctly with "Close basket group" > checked. >- In the list of closed basket groups, confirm that all the controls > work correctly. >- Create an empty basket group and confirm that clicking the associated > "Delete" button in the list of basket groups triggers a confirmation, > "Are you sure you want to delete this basket group?" Test that both > confirming and cancelling work correctly. > >Signed-off-by: David Cook <dcook@prosentient.com.au> >--- > .../prog/en/modules/acqui/basketgroup.tt | 197 ++++++++++-------- > 1 file changed, 105 insertions(+), 92 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tt >index 83d998fe58..40ac36d100 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tt >@@ -3,97 +3,12 @@ > [% USE Branches %] > [% USE Price %] > [% USE Koha %] >+[% SET footerjs = 1 %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Basket grouping for [% booksellername | html %] › Koha</title> > [% INCLUDE 'doc-head-close.inc' %] >-[% INCLUDE 'datatables.inc' %] >-<script> >- >- var MSG_CONFIRM_CLOSE_BASKETGROUP = _("Are you sure you want to close this basketgroup?"); >- var MSG_CLOSE_EMPTY_BASKET = _("Why close an empty basket?"); >- var MSG_SAVE_BEFORE_PRINTING = _("You need to save the page before printing"); >- var MSG_REOPEN_BASKETGROUP = _("reopen basketgroup"); >- var MSG_FILE_DOWNLOAD_ERROR = _("Error downloading the file"); >- >- function submitForm(form) { >- if (form.close.checked == true) { >- var input = document.createElement("input"); >- input.setAttribute("type", "hidden"); >- input.setAttribute("name", "closed"); >- input.setAttribute("value", "1"); >- form.appendChild(input); >- } >- } >- >- function closeandprint(bg){ >- if(document.location = '/cgi-bin/koha/acqui/basketgroup.pl?op=closeandprint&basketgroupid=' + bg ){ >- setTimeout("window.location.reload();", 3000); >- } else { >- alert(MSG_FILE_DOWNLOAD_ERROR); >- } >- } >- >- $(document).ready(function() { >- [% IF ( listclosed) %] >- $("#basket_groups a[href='#closed']").tab("show"); >- [% ELSE %] >- $("#basket_groups a[href='#opened']").tab("show"); >- [% END %] >- [% UNLESS ( grouping ) %] >- $("table").dataTable($.extend(true, {}, dataTablesDefaults, { >- "aoColumnDefs": [ >- { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false }, >- ], >- "bAutoWidth": false, >- "sPaginationType": "full" >- } )); >- [% ELSE %] >- grouped = $("#grouped").DataTable($.extend(true, {}, dataTablesDefaults, { >- "dom": 't', >- "columnDefs": [ >- { 'sortable': false, 'targets': [ 'NoSort' ] } >- ], >- 'autoWidth': false, >- "language": { >- "emptyTable": _("There are no baskets in this group") >- } >- } )); >- ungrouped = $("#ungrouped").DataTable($.extend(true, {}, dataTablesDefaults, { >- "dom": 't', >- "columnDefs": [ >- { 'sortable': false, 'targets': [ 'NoSort' ] } >- ], >- 'autoWidth': false, >- "language": { >- "emptyTable": _("There are no ungrouped baskets") >- } >- } )); >- [% END %] >- >- $("#basketgroupcolumns").on("click", ".addtogroup", function(){ >- const row = $("#" + $(this).data("basketid") ); >- if( row ){ >- $(this).removeClass("addtogroup").addClass("removefromgroup").html("<i class=\"fa fa-trash-can\" aria-hidden=\"true\"></i> " + _("Remove") ); >- row.removeClass("ungrouped").addClass("grouped"); >- ungrouped.row( row ).remove().draw(); >- grouped.row.add( row ).draw(); >- } >- }); >- >- $("#basketgroupcolumns").on("click", ".removefromgroup", function(){ >- const row = $("#" + $(this).data("basketid") ); >- if( row ){ >- $(this).removeClass("removefromgroup").addClass("addtogroup").html("<i class=\"fa fa-plus\" aria-hidden=\"true\"></i> " + _("Add to group") ); >- $(this).removeClass("").addClass(""); >- row.removeClass("grouped").addClass("ungrouped"); >- grouped.row( row ).remove().draw(); >- ungrouped.row.add( row ).draw(); >- } >- }); >- }); >-</script> >- > </head> >+ > <body id="acq_basketgroup" class="acq"> > [% WRAPPER 'header.inc' %] > [% INCLUDE 'acquisitions-search.inc' %] >@@ -201,7 +116,7 @@ > [% ELSE %] > <div class="col-xs-6 col-xs-pull-6"> > [% END %] >- <form action="/cgi-bin/koha/acqui/basketgroup.pl" method="post" id="groupingform" onsubmit="return submitForm(this)"> >+ <form action="/cgi-bin/koha/acqui/basketgroup.pl" method="post" id="groupingform"> > <fieldset id="various" class="brief"> > <ol> > [% UNLESS (closedbg) %] >@@ -359,10 +274,10 @@ > <td>[% IF (basketgroup.freedeliveryplace) %]Free delivery place[% ELSE %][% Branches.GetName( basketgroup.deliveryplace ) | html %][% END %]</td> > <td>[% basketgroup.basketsqty | html %]</td> > <td> >- <input type="button" onclick="closeandprint('[% basketgroup.id | html %]');" value="Close and export as PDF" /> >+ <input type="button" id="close_and_print" data-basketgroupid="[% basketgroup.id | html %]" value="Close and export as PDF" /> > <form action="/cgi-bin/koha/acqui/basketgroup.pl" method="get"><input type="hidden" name="op" value="add" /><input type="hidden" name="booksellerid" value="[% basketgroup.booksellerid | html %]" /><input type="hidden" name="basketgroupid" value="[% basketgroup.id | html %]" /><input type="submit" class="btn btn-primary" value="Edit" /></form> > [% UNLESS basketgroup.basketsqty %] >- <form action="/cgi-bin/koha/acqui/basketgroup.pl" method="get"><input type="hidden" name="op" value="delete" /><input type="hidden" name="booksellerid" value="[% basketgroup.booksellerid | html %]" /><input type="hidden" name="basketgroupid" value="[% basketgroup.id | html %]" /><input type="submit" class="btn btn-primary" value="Delete" /></form> >+ <form action="/cgi-bin/koha/acqui/basketgroup.pl" method="get"><input type="hidden" name="op" value="delete" /><input type="hidden" name="booksellerid" value="[% basketgroup.booksellerid | html %]" /><input type="hidden" name="basketgroupid" value="[% basketgroup.id | html %]" /><input type="submit" id="delete_basketgroup" class="btn btn-primary" value="Delete" /></form> > [% END %] > </td> > </tr> >@@ -406,7 +321,7 @@ > <form action="/cgi-bin/koha/acqui/basketgroup.pl" method="get"><input type="hidden" name="op" value="export" /><input type="hidden" name="basketgroupid" value="[% basketgroup.id | html %]" /><input type="submit" class="btn btn-primary" value="Export as CSV" /></form> > [% IF Koha.Preference('EDIFACT') %] > [% IF (ediaccount) %] >- <form action="/cgi-bin/koha/acqui/basketgroup.pl" method="get"><input type="hidden" name="op" value="ediprint" /><input type="hidden" name="basketgroupid" value="[% basketgroup.id | html %]" /><input type="submit" class="btn btn-primary" value="Generate EDIFACT order" /></form> >+ <form action="/cgi-bin/koha/acqui/basketgroup.pl" method="get"><input type="hidden" name="op" value="ediprint" /><input type="hidden" name="basketgroupid" value="[% basketgroup.id | html %]" /><input type="hidden" name="booksellerid" value="[% basketgroup.booksellerid | html %]" /><input type="submit" class="btn btn-primary" value="Generate EDIFACT order" /></form> > [% ELSE %] > <div>No EDIFACT configuration for [% booksellername | html %]</div> > [% END %] >@@ -433,4 +348,102 @@ > </aside> > </div> > </div> <!-- /.row --> >- [% INCLUDE 'intranet-bottom.inc' %] >+ >+[% MACRO jsinclude BLOCK %] >+ [% INCLUDE 'datatables.inc' %] >+ <script> >+\ function submitForm(form) { >+ if (form.closedbg.checked == true) { >+ var input = document.createElement("input"); >+ input.setAttribute("type", "hidden"); >+ input.setAttribute("name", "closed"); >+ input.setAttribute("value", "1"); >+ form.appendChild(input); >+ } >+ form.submit(); >+ } >+ >+ function closeandprint(bg){ >+ if(document.location = '/cgi-bin/koha/acqui/basketgroup.pl?op=closeandprint&basketgroupid=' + bg ){ >+ setTimeout("window.location.reload();", 3000); >+ } else { >+ alert( _("Error downloading the file") ); >+ } >+ } >+ >+ $(document).ready(function() { >+ [% IF ( listclosed) %] >+ $("#basket_groups a[href='#closed']").tab("show"); >+ [% ELSE %] >+ $("#basket_groups a[href='#opened']").tab("show"); >+ [% END %] >+ [% UNLESS ( grouping ) %] >+ $("table").dataTable($.extend(true, {}, dataTablesDefaults, { >+ "aoColumnDefs": [ >+ { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false }, >+ ], >+ "bAutoWidth": false, >+ "sPaginationType": "full" >+ } )); >+ [% ELSE %] >+ grouped = $("#grouped").DataTable($.extend(true, {}, dataTablesDefaults, { >+ "dom": 't', >+ "columnDefs": [ >+ { 'sortable': false, 'targets': [ 'NoSort' ] } >+ ], >+ 'autoWidth': false, >+ "language": { >+ "emptyTable": _("There are no baskets in this group") >+ } >+ } )); >+ ungrouped = $("#ungrouped").DataTable($.extend(true, {}, dataTablesDefaults, { >+ "dom": 't', >+ "columnDefs": [ >+ { 'sortable': false, 'targets': [ 'NoSort' ] } >+ ], >+ 'autoWidth': false, >+ "language": { >+ "emptyTable": _("There are no ungrouped baskets") >+ } >+ } )); >+ [% END %] >+ >+ $("#basketgroupcolumns").on("click", ".addtogroup", function(){ >+ const row = $("#" + $(this).data("basketid") ); >+ if( row ){ >+ $(this).removeClass("addtogroup").addClass("removefromgroup").html("<i class=\"fa fa-trash-can\" aria-hidden=\"true\"></i> " + _("Remove") ); >+ row.removeClass("ungrouped").addClass("grouped"); >+ ungrouped.row( row ).remove().draw(); >+ grouped.row.add( row ).draw(); >+ } >+ }); >+ >+ $("#basketgroupcolumns").on("click", ".removefromgroup", function(){ >+ const row = $("#" + $(this).data("basketid") ); >+ if( row ){ >+ $(this).removeClass("removefromgroup").addClass("addtogroup").html("<i class=\"fa fa-plus\" aria-hidden=\"true\"></i> " + _("Add to group") ); >+ $(this).removeClass("").addClass(""); >+ row.removeClass("grouped").addClass("ungrouped"); >+ grouped.row( row ).remove().draw(); >+ ungrouped.row.add( row ).draw(); >+ } >+ }); >+ >+ $("#close_and_print").on("click", function(e){ >+ e.preventDefault(); >+ const basketgroupid = $(this).data("basketgroupid"); >+ closeandprint( basketgroupid ); >+ }); >+ >+ $("#groupingform").on("submit", function(e){ >+ e.preventDefault(); >+ submitForm(this); >+ }); >+ >+ $("#delete_basketgroup").on("click", function(e){ >+ return confirm(_("Are you sure you want to delete this basket group?")); >+ }); >+ }); >+ </script> >+[% END %] >+[% INCLUDE 'intranet-bottom.inc' %] >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 34085
:
152536
|
154726
|
154727
|
155399
|
155400