diff --git a/Koha/BackgroundJob/ImportKBARTFile.pm b/Koha/BackgroundJob/ImportKBARTFile.pm index 73cbae84c4..c243695127 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 3144bc510d..7587eaa84f 100644 --- a/Koha/REST/V1/ERM/EHoldings/Titles/Local.pm +++ b/Koha/REST/V1/ERM/EHoldings/Titles/Local.pm @@ -271,7 +271,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; @@ -315,12 +317,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 a72ef34bd0..6959d39237 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 6d2269db54..afc545f132 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 />