Bugzilla – Attachment 162150 Details for
Bug 36084
Pass CSRF token to SVC scripts (1/2)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36084: svc - authorised_values - APIClient now global
Bug-36084-svc---authorisedvalues---APIClient-now-g.patch (text/plain), 5.07 KB, created by
Jonathan Druart
on 2024-02-14 15:34:58 UTC
(
hide
)
Description:
Bug 36084: svc - authorised_values - APIClient now global
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2024-02-14 15:34:58 UTC
Size:
5.07 KB
patch
obsolete
>From cd28d93bb2cfeffea58c4b27706232c15b2a5c22 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 14 Feb 2024 16:34:20 +0100 >Subject: [PATCH] Bug 36084: svc - authorised_values - APIClient now global > >APIClient is not a global variable, which will make the next changes >much easier! >--- > .../prog/en/includes/doc-head-close.inc | 4 ++++ > .../prog/en/modules/circ/article-requests.tt | 5 ----- > .../prog/en/modules/circ/request-article.tt | 3 --- > koha-tmpl/intranet-tmpl/prog/js/cataloging.js | 18 ++++++------------ > .../intranet-tmpl/prog/js/fetch/api-client.js | 2 ++ > 5 files changed, 12 insertions(+), 20 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc >index 956f72f3a55..6c655ffbfb8 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc >@@ -29,6 +29,10 @@ > [% Asset.css("css/print.css", { media = "print" }) | $raw %] > [% INCLUDE intranetstylesheet.inc %] > [% IF ( bidi ) %][% Asset.css("css/right-to-left.css") | $raw %][% END %] >+<script type="module"> >+ import { APIClient } from '/intranet-tmpl/prog/js/fetch/api-client.js'; >+ window.APIClient = APIClient; >+</script> > > <script> > var Koha = {}; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/article-requests.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/article-requests.tt >index 5b66241152e..7b51a5703ec 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/article-requests.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/article-requests.tt >@@ -689,11 +689,6 @@ > HandleMulti(Cancel, $(this).data('ar-id'), $(this)); > }); > >- </script> >- >- <script async type="module"> >- import { APIClient } from '/intranet-tmpl/prog/js/fetch/api-client.js'; >- > async function Process( id, a ) { > var table_row = a.closest('tr'); > var table = a.closest('table'); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/request-article.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/request-article.tt >index 4295e07a7d6..98f72ebc77d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/request-article.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/request-article.tt >@@ -415,10 +415,7 @@ > $('#format option[value="'+first_format+'"]').attr('selected', true); > } > }); >- </script> > >- <script async type="module"> >- import { APIClient } from '/intranet-tmpl/prog/js/fetch/api-client.js'; > $(".ar-update-branchcode").on('change', async function(e){ > var branchcode = this.value; > var c = confirm(_("Are you sure you want to change the pickup library from %s to %s for this request?").format( previous_branchcode, branchcode )); >diff --git a/koha-tmpl/intranet-tmpl/prog/js/cataloging.js b/koha-tmpl/intranet-tmpl/prog/js/cataloging.js >index 01c9bcfe99a..0a97e084630 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/cataloging.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/cataloging.js >@@ -625,24 +625,18 @@ $(document).ready(function() { > var description = form.description.value; > var opac_description = form.opac_description.value; > >- var data = "category="+encodeURIComponent(category) >- +"&value="+encodeURIComponent(value) >- +"&description="+encodeURIComponent(description) >- +"&opac_description="+encodeURIComponent(opac_description); >- $.ajax({ >- type: "POST", >- url: "/cgi-bin/koha/svc/authorised_values", >- data: data, >- success: function(response) { >+ const client = APIClient.authorised_value; >+ client.values.post({category, value, description, opac_description}).then( >+ success => { > $('#avCreate').modal('hide'); > >- $(current_select2).append('<option selected value="'+response.value+'">'+response.description+'</option>'); >+ $(current_select2).append('<option selected value="'+success.value+'">'+success.description+'</option>'); > $("#avCreate").modal("hide"); > }, >- error: function() { >+ error => { > $(".avCreate_error").html(__("Something went wrong. Maybe the value already exists?")).show(); > } >- }); >+ ); > return false; > } > }); >diff --git a/koha-tmpl/intranet-tmpl/prog/js/fetch/api-client.js b/koha-tmpl/intranet-tmpl/prog/js/fetch/api-client.js >index ed27a7c36c2..0f9b1510679 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/fetch/api-client.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/fetch/api-client.js >@@ -1,5 +1,7 @@ > import ArticleRequestAPIClient from "./article-request-api-client.js"; >+import AVAPIClient from "./authorised-value-api-client.js"; > > export const APIClient = { > article_request: new ArticleRequestAPIClient(), >+ authorised_value: new AVAPIClient(), > }; >-- >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 36084
:
162108
|
162109
|
162110
|
162111
|
162112
|
162133
|
162147
|
162150
|
162712