Bugzilla – Attachment 180984 Details for
Bug 39567
Move form-submit js into js includes files
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39567: Include form-submit code from js_includes.inc (OPAC)
Bug-39567-Include-form-submit-code-from-jsincludes.patch (text/plain), 3.89 KB, created by
Emily Lamancusa (emlam)
on 2025-04-15 18:19:41 UTC
(
hide
)
Description:
Bug 39567: Include form-submit code from js_includes.inc (OPAC)
Filename:
MIME Type:
Creator:
Emily Lamancusa (emlam)
Created:
2025-04-15 18:19:41 UTC
Size:
3.89 KB
patch
obsolete
>From bb740ce59bb8cc1f15d7689219de0a83d15a802c Mon Sep 17 00:00:00 2001 >From: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov> >Date: Tue, 15 Apr 2025 13:39:31 -0400 >Subject: [PATCH] Bug 39567: Include form-submit code from js_includes.inc > (OPAC) > >Import the form-submit.js script in the global includes file for the >OPAC, so that all pages have access to it without needing to >import it directly. > >This patch also aligns the OPAC copy of form-submit.js to the staff >interface copy, as the OPAC copy is missing 3 lines to support opening >the link in a new tab (added to the staff interface copy in bug 37192). >--- > .../bootstrap/en/includes/opac-bottom.inc | 7 +++ > .../opac-tmpl/bootstrap/js/form-submit.js | 62 +++++++++---------- > 2 files changed, 38 insertions(+), 31 deletions(-) > >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc >index 76b0e7f4ca..97952ecc04 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc >@@ -102,6 +102,13 @@ > let logged_in_user_id = "[% logged_in_user.borrowernumber | html %]"; > </script> > [% Asset.js("js/global.js") | $raw %] >+<script type="module"> >+ import { submit_form } from "/bootstrap/js/form-submit.js"; >+ $("body").on("click", ".submit-form-link", function (e) { >+ e.preventDefault(); >+ submit_form(this); >+ }); >+</script> > [% IF ( OPACAmazonCoverImages || SyndeticsCoverImages ) %] > [% Asset.js("js/amazonimages.js") | $raw %] > [% END %] >diff --git a/koha-tmpl/opac-tmpl/bootstrap/js/form-submit.js b/koha-tmpl/opac-tmpl/bootstrap/js/form-submit.js >index cb8fc2a261..30855ff297 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/js/form-submit.js >+++ b/koha-tmpl/opac-tmpl/bootstrap/js/form-submit.js >@@ -1,35 +1,35 @@ >-$(document).ready(function () { >- $(".submit-form-link").click(function (e) { >- e.preventDefault(); >- let form_data = $(this).data(); >+export function submit_form(form) { >+ let form_data = $(form).data(); > >- let confirm_msg = form_data.confirmationMsg; >- if (confirm_msg) { >- let confirmation = confirm(confirm_msg); >- if (!confirmation) { >- return false; >- } >- delete form_data.confirmationMsg; >+ let confirm_msg = form_data.confirmationMsg; >+ if (confirm_msg) { >+ let confirmation = confirm(confirm_msg); >+ if (!confirmation) { >+ return false; > } >+ delete form_data.confirmationMsg; >+ } > >- let the_form = $("<form/>"); >- if (form_data.method === "post") { >- form_data.csrf_token = $('meta[name="csrf-token"]').attr("content"); >- } >- the_form.attr("method", form_data.method); >- the_form.attr("action", form_data.action); >- delete form_data.method; >- delete form_data.action; >- $.each(form_data, function (key, value) { >- the_form.append( >- $("<input/>", { >- type: "hidden", >- name: key, >- value: value, >- }) >- ); >- }); >- $("body").append(the_form); >- the_form.submit(); >+ let the_form = $("<form/>"); >+ if (form_data.method === "post") { >+ form_data.csrf_token = $('meta[name="csrf-token"]').attr("content"); >+ } >+ the_form.attr("method", form_data.method); >+ the_form.attr("action", form_data.action); >+ delete form_data.method; >+ delete form_data.action; >+ $.each(form_data, function (key, value) { >+ the_form.append( >+ $("<input/>", { >+ type: "hidden", >+ name: key, >+ value: value, >+ }) >+ ); > }); >-}); >+ if (form_data.new_tab) { >+ the_form.attr("target", "_blank"); >+ } >+ $("body").append(the_form); >+ the_form.submit(); >+} >-- >2.34.1
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 39567
:
180669
|
180687
|
180983
|
180984
|
180985
|
180986
|
180987
|
180988
|
181235
|
182168
|
182169
|
182170
|
182171
|
182234
|
182235
|
182236
|
182237