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

(-)a/ill/ill-requests.pl (-4 / +3 lines)
Lines 323-328 if ( $backends_available ) { Link Here
323
            # Prepare availability searching, if required
323
            # Prepare availability searching, if required
324
            # Get the definition for the z39.50 plugin
324
            # Get the definition for the z39.50 plugin
325
            if ( C4::Context->preference('ILLCheckAvailability') ) {
325
            if ( C4::Context->preference('ILLCheckAvailability') ) {
326
                # FIXME: the below get_services call is bugged, needs to be updated
326
                my $availability = Koha::Illrequest::Workflow::Availability->new($request->metadata);
327
                my $availability = Koha::Illrequest::Workflow::Availability->new($request->metadata);
327
                my $services = $availability->get_services({
328
                my $services = $availability->get_services({
328
                    ui_context => 'partners',
329
                    ui_context => 'partners',
Lines 553-560 sub get_ill_availability { Link Here
553
        }
554
        }
554
    }
555
    }
555
556
556
    my $availability = Koha::Illrequest::Workflow::Availability->new($id_types);
557
    my $availability = Koha::Illrequest::Workflow::Availability->new($id_types, 'staff');
557
    return $availability->get_services({
558
    return $availability->get_services();
558
        ui_context => 'staff'
559
    });
560
}
559
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/ill-batch-modal.inc (+3 lines)
Lines 72-77 Link Here
72
                                <th scope="col">Metadata</th>
72
                                <th scope="col">Metadata</th>
73
                                <th scope="col">Request ID</th>
73
                                <th scope="col">Request ID</th>
74
                                <th scope="col">Request Status</th>
74
                                <th scope="col">Request Status</th>
75
                                [% IF Koha.Preference('ILLCheckAvailability') %]
76
                                <th scope="col">Availability</th>
77
                                [% END %]
75
                                <th scope="col"></th>
78
                                <th scope="col"></th>
76
                            </tr>
79
                            </tr>
77
                        </thead>
80
                        </thead>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt (+1 lines)
Lines 909-914 Link Here
909
    [% INCLUDE 'select2.inc' %]
909
    [% INCLUDE 'select2.inc' %]
910
    [% IF metadata_enrichment_services %]
910
    [% IF metadata_enrichment_services %]
911
    <script>
911
    <script>
912
        var ill_check_availability_syspref = '[% Koha.Preference('ILLCheckAvailability') | html %]';
912
        var metadata_enrichment_services = [% metadata_enrichment_services | $raw %];
913
        var metadata_enrichment_services = [% metadata_enrichment_services | $raw %];
913
    </script>
914
    </script>
914
    <script>
915
    <script>
(-)a/koha-tmpl/intranet-tmpl/prog/js/ill-batch-modal.js (-24 / +48 lines)
Lines 86-92 Link Here
86
                updateTable();
86
                updateTable();
87
                updateRowCount();
87
                updateRowCount();
88
                updateProcessTotals();
88
                updateProcessTotals();
89
                checkAvailability();
89
                if (ill_check_availability_syspref == 1){
90
                    checkAvailability();
91
                }
90
            }
92
            }
91
        }
93
        }
92
    );
94
    );
Lines 247-268 Link Here
247
                !availabilitySent[row.value]
249
                !availabilitySent[row.value]
248
            ) {
250
            ) {
249
                availabilitySent[row.value] = 1;
251
                availabilitySent[row.value] = 1;
250
                getAvailability(row.value, row.metadata);
252
                getAvailability(row);
251
            }
253
            }
252
        });
254
        });
253
    };
255
    };
254
256
255
    // Check availability services for immediate availability, if found,
257
    // Check availability services for immediate availability, if found,
256
    // create a link in the table linking to the item
258
    // create a link in the table linking to the item
257
    function getAvailability(identifier, metadata) {
259
    function getAvailability(row) {
260
        let metadata = row.metadata;
258
        // Prep the metadata for passing to the availability plugins
261
        // Prep the metadata for passing to the availability plugins
259
        let availability_object = {};
262
        let availability_object = {};
260
        if (metadata.issn) availability_object['issn'] = metadata.issn;
263
        if (metadata.issn) availability_object['issn'] = metadata.issn;
261
        if (metadata.doi) availability_object['doi'] = metadata.doi;
264
        if (metadata.doi) availability_object['doi'] = metadata.doi;
262
        if (metadata.pubmedid) availability_object['pubmedid'] = metadata.pubmedid;
265
        if (metadata.pubmedid) availability_object['pubmedid'] = metadata.pubmedid;
263
        var prepped = encodeURIComponent(base64EncodeUnicode(JSON.stringify(availability_object)));
266
        var prepped = encodeURIComponent(base64EncodeUnicode(JSON.stringify(availability_object)));
264
        for (i = 0; i < batch_availability_services.length; i++) {
267
        row.av_hits = [];
265
            var service = batch_availability_services[i];
268
        batch_availability_services.map(async (service) => {
266
            window.doApiRequest(
269
            window.doApiRequest(
267
                service.endpoint + prepped
270
                service.endpoint + prepped
268
            )
271
            )
Lines 272-287 Link Here
272
                .then(function (data) {
275
                .then(function (data) {
273
                    if (data.results.search_results && data.results.search_results.length > 0) {
276
                    if (data.results.search_results && data.results.search_results.length > 0) {
274
                        var result = data.results.search_results[0];
277
                        var result = data.results.search_results[0];
275
                        tableContent.data = tableContent.data.map(function (row) {
278
                        row.av_hits.push({name:service.name, url:result.url});
276
                            if (row.value === identifier) {
279
                        return row;
277
                                row.url = result.url;
280
                    }else {
278
                                row.availabilitySupplier = service.name;
281
                        row.av_hits.push({ name: service.name, empty: 1 })
279
                            }
280
                            return row;
281
                        });
282
                    }
282
                    }
283
                })
284
                .then(function (response) {
285
                    updateTable();
283
                });
286
                });
284
        }
287
            });
288
        // }
285
    };
289
    };
286
290
287
    // Help btoa with > 8 bit strings
291
    // Help btoa with > 8 bit strings
Lines 820-834 Link Here
820
        label.innerText = ill_batch_metadata[prop] + ': ';
824
        label.innerText = ill_batch_metadata[prop] + ': ';
821
825
822
        // Add a link to the availability URL if appropriate
826
        // Add a link to the availability URL if appropriate
823
        var value;
827
        var value = document.createElement('span');
824
        if (!data.url) {
825
            value = document.createElement('span');
826
        } else {
827
            value = document.createElement('a');
828
            value.setAttribute('href', data.url);
829
            value.setAttribute('target', '_blank');
830
            value.setAttribute('title', ill_batch_available_via + ' ' + data.availabilitySupplier);
831
        }
832
        value.classList.add('metadata-value');
828
        value.classList.add('metadata-value');
833
        value.innerText = meta[prop];
829
        value.innerText = meta[prop];
834
        div.appendChild(label);
830
        div.appendChild(label);
Lines 930-935 Link Here
930
        return data.requestStatus || '-';
926
        return data.requestStatus || '-';
931
    }
927
    }
932
928
929
    function createRequestAvailability(x, y, data) {
930
931
        // If the fetch failed
932
        if (data.failed.length > 0) {
933
            return data.failed;
934
        }
935
936
        let str = '';
937
        let has_some = false;
938
        if(typeof data.av_hits !== 'undefined' && data.av_hits.length>0){
939
            data.av_hits.forEach((av_hit) => {
940
                if(!av_hit.empty){
941
                    has_some = true;
942
                    str += '<li><a target="_blank" href="' + av_hit.url + '">' + av_hit.name + '</a></li>'
943
                }
944
            });
945
946
            if(!has_some){
947
                str = ill_batch_none;
948
            }
949
        }
950
        return str || ill_populate_waiting;
951
    };
952
933
    function buildTable(identifiers) {
953
    function buildTable(identifiers) {
934
        table = KohaTable('identifier-table', {
954
        table = KohaTable('identifier-table', {
935
            processing: true,
955
            processing: true,
Lines 963-970 Link Here
963
                    width: '6.5%',
983
                    width: '6.5%',
964
                    render: createRequestStatus
984
                    render: createRequestStatus
965
                },
985
                },
986
                ...( ill_check_availability_syspref == 1 ? [{
987
                    data: '',
988
                    width: '13%',
989
                    render: createRequestAvailability, }] : []
990
                    ),
966
                {
991
                {
967
                    width: '18%',
992
                    width: '6.5%',
968
                    render: createActions,
993
                    render: createActions,
969
                    className: 'action-column'
994
                    className: 'action-column'
970
                }
995
                }
971
- 

Return to bug 34282