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 271-277 sub import_from_list { Link Here
271
sub import_from_kbart_file {
271
sub import_from_kbart_file {
272
    my $c = shift or return;
272
    my $c = shift or return;
273
273
274
    my $file = $c->req->json;
274
    my $import_data = $c->req->json;
275
    my $file = $import_data->{file};
276
    my $package_id = $import_data->{package_id};
275
277
276
    return try {
278
    return try {
277
        my @job_ids;
279
        my @job_ids;
Lines 315-326 sub import_from_kbart_file { Link Here
315
                    filename     => $file->{filename},
317
                    filename     => $file->{filename},
316
                    file_content => encode_base64( join( "\r", @{$chunk} ) )
318
                    file_content => encode_base64( join( "\r", @{$chunk} ) )
317
                };
319
                };
318
                my $params = { file => $chunked_file };
320
                my $params = { file => $chunked_file, package_id => $package_id };
319
                my $job_id = Koha::BackgroundJob::ImportKBARTFile->new->enqueue($params);
321
                my $job_id = Koha::BackgroundJob::ImportKBARTFile->new->enqueue($params);
320
                push @job_ids, $job_id;
322
                push @job_ids, $job_id;
321
            }
323
            }
322
        } else {
324
        } else {
323
            my $params = { file => $file };
325
            my $params = { file => $file, package_id => $package_id };
324
            my $job_id = Koha::BackgroundJob::ImportKBARTFile->new->enqueue($params);
326
            my $job_id = Koha::BackgroundJob::ImportKBARTFile->new->enqueue($params);
325
            push @job_ids, $job_id;
327
            push @job_ids, $job_id;
326
        }
328
        }
(-)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