View | Details | Raw Unified | Return to bug 34788
Collapse All | Expand All

(-)a/Koha/BackgroundJob/ImportKBARTFile.pm (+4 lines)
Lines 77-82 sub process { Link Here
77
77
78
    try {
78
    try {
79
        my $file = $args->{file};
79
        my $file = $args->{file};
80
        my $package_id = $args->{package_id};
80
        my ( $column_headers, $lines ) = format_file($file);
81
        my ( $column_headers, $lines ) = format_file($file);
81
82
82
        if ( scalar( @{$lines} ) == 0 ) {
83
        if ( scalar( @{$lines} ) == 0 ) {
Lines 118-123 sub process { Link Here
118
                        $failed_imports++;
119
                        $failed_imports++;
119
                    } else {
120
                    } else {
120
                        my $imported_title = Koha::ERM::EHoldings::Title->new($formatted_title)->store;
121
                        my $imported_title = Koha::ERM::EHoldings::Title->new($formatted_title)->store;
122
                        my $title_id = $imported_title->title_id;
123
                        Koha::ERM::EHoldings::Resource->new( { title_id => $title_id, package_id => $package_id } )
124
                            ->store;
121
125
122
                        # No need to add a message for a successful import,
126
                        # No need to add a message for a successful import,
123
                        # files could have 1000s of titles which will lead to lots of messages in background_job->data
127
                        # files could have 1000s of titles which will lead to lots of messages in background_job->data
(-)a/Koha/REST/V1/ERM/EHoldings/Titles/Local.pm (-3 / +5 lines)
Lines 286-292 sub import_from_list { Link Here
286
sub import_from_kbart_file {
286
sub import_from_kbart_file {
287
    my $c = shift or return;
287
    my $c = shift or return;
288
288
289
    my $file = $c->req->json;
289
    my $import_data = $c->req->json;
290
    my $file = $import_data->{file};
291
    my $package_id = $import_data->{package_id};
290
292
291
    return try {
293
    return try {
292
        my @job_ids;
294
        my @job_ids;
Lines 330-341 sub import_from_kbart_file { Link Here
330
                    filename     => $file->{filename},
332
                    filename     => $file->{filename},
331
                    file_content => encode_base64( join( "\r", @{$chunk} ) )
333
                    file_content => encode_base64( join( "\r", @{$chunk} ) )
332
                };
334
                };
333
                my $params = { file => $chunked_file };
335
                my $params = { file => $chunked_file, package_id => $package_id };
334
                my $job_id = Koha::BackgroundJob::ImportKBARTFile->new->enqueue($params);
336
                my $job_id = Koha::BackgroundJob::ImportKBARTFile->new->enqueue($params);
335
                push @job_ids, $job_id;
337
                push @job_ids, $job_id;
336
            }
338
            }
337
        } else {
339
        } else {
338
            my $params = { file => $file };
340
            my $params = { file => $file, package_id => $package_id };
339
            my $job_id = Koha::BackgroundJob::ImportKBARTFile->new->enqueue($params);
341
            my $job_id = Koha::BackgroundJob::ImportKBARTFile->new->enqueue($params);
340
            push @job_ids, $job_id;
342
            push @job_ids, $job_id;
341
        }
343
        }
(-)a/api/v1/swagger/paths/erm_eholdings_titles.yaml (-3 / +3 lines)
Lines 512-520 Link Here
512
        schema:
512
        schema:
513
          type: object
513
          type: object
514
          properties:
514
          properties:
515
            filename:
515
            file:
516
              type: string
516
              type: object
517
            file_content:
517
            package_id:
518
              type: string
518
              type: string
519
          additionalProperties: false
519
          additionalProperties: false
520
    responses:
520
    responses:
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalTitlesKBARTImport.vue (-6 / +41 lines)
Lines 11-16 Link Here
11
                        @change="selectFile($event)"
11
                        @change="selectFile($event)"
12
                        :id="`import_file`"
12
                        :id="`import_file`"
13
                        :name="`import_file`"
13
                        :name="`import_file`"
14
                        required
14
                    />
15
                    />
15
                </span>
16
                </span>
16
                <ol>
17
                <ol>
Lines 18-28 Link Here
18
                        {{ $__("File name") }}:
19
                        {{ $__("File name") }}:
19
                        <span>{{ file.filename }}</span>
20
                        <span>{{ file.filename }}</span>
20
                    </li>
21
                    </li>
21
                    <li v-show="file.file_type">
22
                        {{ $__("File type") }}:
23
                        <span>{{ file.file_type }}</span>
24
                    </li>
25
                </ol>
22
                </ol>
23
                <fieldset id="package_list">
24
                    {{ $__("To the following local package") }}:
25
                    <v-select
26
                        v-model="package_id"
27
                        label="name"
28
                        :reduce="p => p.package_id"
29
                        :options="packages"
30
                        :clearable="false"
31
                        :required="!package_id"
32
                    >
33
                        <template #search="{ attributes, events }">
34
                            <input
35
                                :required="!package_id"
36
                                class="vs__search"
37
                                v-bind="attributes"
38
                                v-on="events"
39
                            />
40
                        </template>
41
                    </v-select>
42
                    <span class="required">{{ $__("Required") }}</span>
43
                </fieldset>
26
            </div>
44
            </div>
27
            <fieldset class="action">
45
            <fieldset class="action">
28
                <ButtonSubmit />
46
                <ButtonSubmit />
Lines 46-53 export default { Link Here
46
                filename: null,
64
                filename: null,
47
                file_content: null,
65
                file_content: null,
48
            },
66
            },
67
            packages: [],
68
            package_id: null,
49
        }
69
        }
50
    },
70
    },
71
    beforeCreate() {
72
        const client = APIClient.erm
73
        client.localPackages.getAll().then(
74
            packages => {
75
                this.packages = packages
76
                this.initialized = true
77
            },
78
            error => {}
79
        )
80
    },
51
    methods: {
81
    methods: {
52
        selectFile(e) {
82
        selectFile(e) {
53
            let files = e.target.files
83
            let files = e.target.files
Lines 63-70 export default { Link Here
63
        },
93
        },
64
        addDocument(e) {
94
        addDocument(e) {
65
            e.preventDefault()
95
            e.preventDefault()
96
66
            const client = APIClient.erm
97
            const client = APIClient.erm
67
            client.localTitles.import_kbart(this.file).then(
98
            const importData = {
99
                file: this.file,
100
                package_id: this.package_id,
101
            }
102
            client.localTitles.import_kbart(importData).then(
68
                success => {
103
                success => {
69
                    let message = ""
104
                    let message = ""
70
                    if (success.job_ids) {
105
                    if (success.job_ids) {
Lines 108-113 export default { Link Here
108
                file_type: null,
143
                file_type: null,
109
                file_content: null,
144
                file_content: null,
110
            }
145
            }
146
            this.package_id = null
111
        },
147
        },
112
    },
148
    },
113
    components: {
149
    components: {
114
- 

Return to bug 34788