Bugzilla – Attachment 163362 Details for
Bug 36351
CSRF Adjustments for Cataloguing editor
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36351: [failed] Use APIClient for posting
Bug-36351-failed-Use-APIClient-for-posting.patch (text/plain), 4.19 KB, created by
Nick Clemens (kidclamp)
on 2024-03-18 17:29:10 UTC
(
hide
)
Description:
Bug 36351: [failed] Use APIClient for posting
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2024-03-18 17:29:10 UTC
Size:
4.19 KB
patch
obsolete
>From 15f39215f31481305a5a67490d3ae70718153186 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Mon, 18 Mar 2024 17:28:56 +0000 >Subject: [PATCH] Bug 36351: [failed] Use APIClient for posting > >--- > .../lib/koha/cateditor/koha-backend.js | 25 +++++++++--------- > .../intranet-tmpl/prog/js/fetch/api-client.js | 2 ++ > .../prog/js/fetch/cataloguing-api-client.js | 26 +++++++++++++++++++ > 3 files changed, 40 insertions(+), 13 deletions(-) > create mode 100644 koha-tmpl/intranet-tmpl/prog/js/fetch/cataloguing-api-client.js > >diff --git a/koha-tmpl/intranet-tmpl/lib/koha/cateditor/koha-backend.js b/koha-tmpl/intranet-tmpl/lib/koha/cateditor/koha-backend.js >index 5410f775633..2fded33d038 100644 >--- a/koha-tmpl/intranet-tmpl/lib/koha/cateditor/koha-backend.js >+++ b/koha-tmpl/intranet-tmpl/lib/koha/cateditor/koha-backend.js >@@ -136,20 +136,19 @@ define( [ '/cgi-bin/koha/svc/cataloguing/framework?frameworkcode=&callback=defin > record = record.clone(); > _removeBiblionumberFields( record ); > >- $.ajax( { >- type: 'POST', >- url: '/cgi-bin/koha/svc/new_bib?frameworkcode=' + encodeURIComponent(frameworkcode), >- data: record.toXML(), >- contentType: 'text/xml' >- } ).done( function( data ) { >- var record = _fromXMLStruct( data ); >- if ( record.marcxml ) { >- record.marcxml[0].frameworkcode = frameworkcode; >+ const client = APIClient.cataloguing; >+ client.catalog_bib.create({ frameworkcode, record }).then( >+ success => { >+ var record = _fromXMLStruct( data ); >+ if ( record.marcxml ) { >+ record.marcxml[0].frameworkcode = frameworkcode; >+ } >+ callback( record ); >+ }, >+ error => { >+ callback( { error: _('Could not save record') } ); > } >- callback( record ); >- } ).fail( function( data ) { >- callback( { error: _('Could not save record') } ); >- } ); >+ ); > }, > > SaveRecord: function( id, record, callback ) { >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 87b240ac5c1..760e0d4ea8d 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,6 @@ > import ArticleRequestAPIClient from "./article-request-api-client.js"; > import AVAPIClient from "./authorised-value-api-client.js"; >+import CataloguingAPIClient from "./cataloguing-api-client.js"; > import CirculationAPIClient from "./circulation-api-client.js"; > import ClubAPIClient from "./club-api-client.js"; > import CoverImageAPIClient from "./cover-image-api-client.js"; >@@ -12,6 +13,7 @@ import TicketAPIClient from "./ticket-api-client.js"; > export const APIClient = { > article_request: new ArticleRequestAPIClient(), > authorised_value: new AVAPIClient(), >+ cataloguing: new CataloguingAPIClient(), > circulation: new CirculationAPIClient(), > club: new ClubAPIClient(), > cover_image: new CoverImageAPIClient(), >diff --git a/koha-tmpl/intranet-tmpl/prog/js/fetch/cataloguing-api-client.js b/koha-tmpl/intranet-tmpl/prog/js/fetch/cataloguing-api-client.js >new file mode 100644 >index 00000000000..435be5b834d >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/js/fetch/cataloguing-api-client.js >@@ -0,0 +1,26 @@ >+import HttpClient from "./http-client.js"; >+ >+export class CataloguingAPIClient extends HttpClient { >+ constructor() { >+ super({ >+ baseURL: "/cgi-bin/koha/svc/", >+ }); >+ } >+ >+ get catalog_bib() { >+ return { >+ create: bib_info => >+ this.post({ >+ endpoint: "new_bib/frameworkcode=%s".format( bib_info.frameworkcode ), >+ body: bib_info.record.toXML(), >+ headers: { >+ "Content-Type": >+ "text/xml", >+ }, >+ }), >+ }; >+ } >+ >+} >+ >+export default CataloguingAPIClient; >-- >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 36351
:
163362
|
163364
|
163387
|
163388
|
163457
|
163458
|
163459
|
163489
|
163490
|
163491
|
163492