Bugzilla – Attachment 161383 Details for
Bug 34788
Add the ability to import KBART files to ERM
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34788: Add a relationship to a package for the imported file
Bug-34788-Add-a-relationship-to-a-package-for-the-.patch (text/plain), 6.74 KB, created by
Matt Blenkinsop
on 2024-01-25 09:41:55 UTC
(
hide
)
Description:
Bug 34788: Add a relationship to a package for the imported file
Filename:
MIME Type:
Creator:
Matt Blenkinsop
Created:
2024-01-25 09:41:55 UTC
Size:
6.74 KB
patch
obsolete
>From a85e1999affe53adbb95ebc92bb0a6b9874244c1 Mon Sep 17 00:00:00 2001 >From: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> >Date: Mon, 16 Oct 2023 10:45:25 +0000 >Subject: [PATCH] Bug 34788: Add a relationship to a package for the imported > file > >--- > Koha/BackgroundJob/ImportKBARTFile.pm | 4 ++ > Koha/REST/V1/ERM/EHoldings/Titles/Local.pm | 8 ++-- > .../swagger/paths/erm_eholdings_titles.yaml | 6 +-- > .../ERM/EHoldingsLocalTitlesKBARTImport.vue | 46 +++++++++++++++++-- > 4 files changed, 53 insertions(+), 11 deletions(-) > >diff --git a/Koha/BackgroundJob/ImportKBARTFile.pm b/Koha/BackgroundJob/ImportKBARTFile.pm >index 73cbae84c41..c2436951275 100644 >--- a/Koha/BackgroundJob/ImportKBARTFile.pm >+++ b/Koha/BackgroundJob/ImportKBARTFile.pm >@@ -77,6 +77,7 @@ sub process { > > try { > my $file = $args->{file}; >+ my $package_id = $args->{package_id}; > my ( $column_headers, $lines ) = format_file($file); > > if ( scalar( @{$lines} ) == 0 ) { >@@ -118,6 +119,9 @@ sub process { > $failed_imports++; > } else { > my $imported_title = Koha::ERM::EHoldings::Title->new($formatted_title)->store; >+ my $title_id = $imported_title->title_id; >+ Koha::ERM::EHoldings::Resource->new( { title_id => $title_id, package_id => $package_id } ) >+ ->store; > > # No need to add a message for a successful import, > # files could have 1000s of titles which will lead to lots of messages in background_job->data >diff --git a/Koha/REST/V1/ERM/EHoldings/Titles/Local.pm b/Koha/REST/V1/ERM/EHoldings/Titles/Local.pm >index d135f0ac330..b3497c73e4f 100644 >--- a/Koha/REST/V1/ERM/EHoldings/Titles/Local.pm >+++ b/Koha/REST/V1/ERM/EHoldings/Titles/Local.pm >@@ -286,7 +286,9 @@ sub import_from_list { > sub import_from_kbart_file { > my $c = shift or return; > >- my $file = $c->req->json; >+ my $import_data = $c->req->json; >+ my $file = $import_data->{file}; >+ my $package_id = $import_data->{package_id}; > > return try { > my @job_ids; >@@ -330,12 +332,12 @@ sub import_from_kbart_file { > filename => $file->{filename}, > file_content => encode_base64( join( "\r", @{$chunk} ) ) > }; >- my $params = { file => $chunked_file }; >+ my $params = { file => $chunked_file, package_id => $package_id }; > my $job_id = Koha::BackgroundJob::ImportKBARTFile->new->enqueue($params); > push @job_ids, $job_id; > } > } else { >- my $params = { file => $file }; >+ my $params = { file => $file, package_id => $package_id }; > my $job_id = Koha::BackgroundJob::ImportKBARTFile->new->enqueue($params); > push @job_ids, $job_id; > } >diff --git a/api/v1/swagger/paths/erm_eholdings_titles.yaml b/api/v1/swagger/paths/erm_eholdings_titles.yaml >index a72ef34bd04..6959d392373 100644 >--- a/api/v1/swagger/paths/erm_eholdings_titles.yaml >+++ b/api/v1/swagger/paths/erm_eholdings_titles.yaml >@@ -512,9 +512,9 @@ > schema: > type: object > properties: >- filename: >- type: string >- file_content: >+ file: >+ type: object >+ package_id: > type: string > additionalProperties: false > responses: >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalTitlesKBARTImport.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalTitlesKBARTImport.vue >index 6d2269db54d..afc545f1324 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalTitlesKBARTImport.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalTitlesKBARTImport.vue >@@ -11,6 +11,7 @@ > @change="selectFile($event)" > :id="`import_file`" > :name="`import_file`" >+ required > /> > </span> > <ol> >@@ -18,11 +19,28 @@ > {{ $__("File name") }}: > <span>{{ file.filename }}</span> > </li> >- <li v-show="file.file_type"> >- {{ $__("File type") }}: >- <span>{{ file.file_type }}</span> >- </li> > </ol> >+ <fieldset id="package_list"> >+ {{ $__("To the following local package") }}: >+ <v-select >+ v-model="package_id" >+ label="name" >+ :reduce="p => p.package_id" >+ :options="packages" >+ :clearable="false" >+ :required="!package_id" >+ > >+ <template #search="{ attributes, events }"> >+ <input >+ :required="!package_id" >+ class="vs__search" >+ v-bind="attributes" >+ v-on="events" >+ /> >+ </template> >+ </v-select> >+ <span class="required">{{ $__("Required") }}</span> >+ </fieldset> > </div> > <fieldset class="action"> > <ButtonSubmit /> >@@ -46,8 +64,20 @@ export default { > filename: null, > file_content: null, > }, >+ packages: [], >+ package_id: null, > } > }, >+ beforeCreate() { >+ const client = APIClient.erm >+ client.localPackages.getAll().then( >+ packages => { >+ this.packages = packages >+ this.initialized = true >+ }, >+ error => {} >+ ) >+ }, > methods: { > selectFile(e) { > let files = e.target.files >@@ -63,8 +93,13 @@ export default { > }, > addDocument(e) { > e.preventDefault() >+ > const client = APIClient.erm >- client.localTitles.import_kbart(this.file).then( >+ const importData = { >+ file: this.file, >+ package_id: this.package_id, >+ } >+ client.localTitles.import_kbart(importData).then( > success => { > let message = "" > if (success.job_ids) { >@@ -108,6 +143,7 @@ export default { > file_type: null, > file_content: null, > } >+ this.package_id = null > }, > }, > components: { >-- >2.37.1 (Apple Git-137.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 34788
:
161379
|
161380
|
161381
|
161382
|
161383
|
161384
|
161391
|
165189
|
165190
|
165191
|
165192
|
165193
|
165194
|
165195
|
165196
|
165197
|
165837
|
165887
|
165888
|
165889
|
165890
|
165891
|
165892
|
165893
|
165894
|
166420
|
166433
|
166434
|
166435
|
166436
|
166437
|
166438
|
166439
|
166440
|
166441
|
166571
|
166645