From 1ecba7a48ac3a0df5ca5ef0dac4b178c6152f6eb Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Thu, 30 Mar 2023 15:12:38 +0200 Subject: [PATCH] Bug 8179: Adapt to new +strings embed While we rebased correctly this old patchset, we still had to make sure we are using both the +strings in embed (instead of the x-koha-av header) and the _strings key instead of the original _authorised_values one. This patch adjusts that. Signed-off-by: Tomas Cohen Arazi --- .../prog/en/modules/acqui/orderreceive.tt | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt index 193c6b566ed..978f0d130cc 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt @@ -962,6 +962,13 @@ }); [% ELSIF multiple_orders %] + function display_string(key, strings, fallback) { + if ( strings.hasOwnProperty(key) ) { + return strings[key].str && escape_str(strings[key].str) || ''; + } + return fallback != null ? fallback : ''; + } + var _build_item = function(item, tr) { var chb = $('') .prop('checked', item._checked) @@ -971,17 +978,17 @@ tr.append($('').append(chb)); tr.append(''+EDIT[0].toUpperCase()+EDIT.substr(1).toLowerCase()+''); tr.append(''+(item.external_id||'')+''); - tr.append(''+(item.home_branch && item.home_branch.name||'')+''); - tr.append(''+(item.holding_branch && item.holding_branch.name||'')+''); - tr.append(''+(item._authorised_values.not_for_loan_status && item._authorised_values.not_for_loan_status.lib||'')+''); - tr.append(''+(item._authorised_values.restricted_status && item._authorised_values.restricted_status.lib||'')+''); - tr.append(''+(item._authorised_values.location && item._authorised_values.location.lib||'')+''); + tr.append(''+display_string( 'home_library_id', item._strings, item.home_library_id ) || ''+''); + tr.append(''+display_string( 'holding_library_id', item._strings, item.holding_library_id )+''); + tr.append(''+display_string( 'not_for_loan_status', item._strings, item.not_for_loan_status )+''); + tr.append(''+display_string( 'restricted_status', item._strings, item.restricted_status )+''); + tr.append(''+display_string( 'location', item._strings, item.location )+''); tr.append(''+(item.callnumber||'')+''); tr.append(''+(item.copy_number||'')+''); tr.append(''+(item.inventory_number||'')+''); - tr.append(''+(item._authorised_values.collection_code && item._authorised_values.collection_code.lib||'')+''); - tr.append(''+(item.itemtype && item.itemtype.description || '')+''); - tr.append(''+(item._authorised_values.materials_notes && item._authorised_values.materials_notes.lib||'')+'') + tr.append(''+display_string( 'collection', item._strings, item.collection )+''); + tr.append(''+display_string( 'item_type_id', item._strings, item.item_type_id )+''); + tr.append(''+display_string( 'materials_notes', item._strings, item.materials_notes )+''); tr.append(''+(item.public_notes||'')+''); }; @@ -1000,8 +1007,7 @@ $.ajax({ dataType: "json", headers: { - "x-koha-embed": "home_branch,holding_branch,itemtype", - "x-koha-av": "1" + "x-koha-embed": "+strings" }, url: '/api/v1/items/'+itemnumber, success: function(item) { @@ -1045,19 +1051,13 @@ var pending_orders_url = "/api/v1/acquisitions/orders?only_active=1"; var options = { "ajax": { - "url": pending_orders_url + "&q=" + encodeURI(JSON.stringify(base_query)), - "headers": { - 'x-koha-av': '1' - } + "url": pending_orders_url + "&q=" + encodeURI(JSON.stringify(base_query)) }, - "header_filter": true, "embed": [ "basket", "biblio.suggestions.suggester", "fund.budget", - "items.home_branch", - "items.holding_branch", - "items.itemtype", + "items+strings", "creator" ], 'dom': 'C<"top pager"ilpfB><"#filter_c">tr<"bottom pager"ip>', -- 2.40.0