Bug 34788: Add a relationship to a package for the imported file
Signed-off-by: Clemens Tubach <clemens.tubach@kit.edu> Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
parent
4760863cfb
commit
698c1e930b
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -512,9 +512,9 @@
|
|||
schema:
|
||||
type: object
|
||||
properties:
|
||||
filename:
|
||||
type: string
|
||||
file_content:
|
||||
file:
|
||||
type: object
|
||||
package_id:
|
||||
type: string
|
||||
additionalProperties: false
|
||||
responses:
|
||||
|
|
|
|||
|
|
@ -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: {
|
||||
|
|
|
|||
Loading…
Reference in New Issue