Bug 30708: Display AV descriptions instead of codes

Sponsored-by: BULAC - http://www.bulac.fr/
Signed-off-by: BULAC - http://www.bulac.fr/
Signed-off-by: Heather Hernandez <heather_hernandez@nps.gov>
Signed-off-by: Laurence Rault <laurence.rault@biblibre.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Jonathan Druart 2023-06-06 15:14:36 +02:00 committed by Tomas Cohen Arazi
parent 3e6c15f631
commit 5dae3d5965
No known key found for this signature in database
GPG Key ID: 0A272EA1B2F3C15F
4 changed files with 50 additions and 21 deletions

View File

@ -20,7 +20,7 @@ use Modern::Perl;
use JSON qw( to_json );
use Try::Tiny;
use Koha::Database;
use Koha::AuthorisedValues;
use base qw(Koha::Object);
@ -50,6 +50,32 @@ sub processing_attribute {
return Koha::Preservation::Processing::Attribute->_new_from_dbic($processing_attribute_rs)
}
=head3 strings_map
Returns a map of column name to string representations including the string.
=cut
sub strings_map {
my ($self) = @_;
my $str = $self->value;
if ( $self->processing_attribute->type eq 'authorised_value' ) {
my $av = Koha::AuthorisedValues->search(
{
category => $self->processing_attribute->option_source,
authorised_value => $self->value,
}
);
if ( $av->count ) {
$str = $av->next->lib || $self->value;
}
}
return {
value => { str => $str, type => 'authorised_value' },
};
}
=head2 Internal methods
=head3 _type

View File

@ -165,6 +165,7 @@
enum:
- items
- items.attributes
- items.attributes+strings
- items.attributes.processing_attribute
- default_processing
- default_processing.attributes

View File

@ -173,9 +173,8 @@
) in item.attributes"
v-bind:key="counter_attribute"
>
<!-- FIXME We need to display the description of the AV here -->
{{ attribute.processing_attribute.name }}={{
attribute.value
attribute._strings.value.str
}}
</span>
</div>
@ -238,6 +237,7 @@ export default {
train_list: [],
train_id_selected_for_copy: null,
train_item_id_to_copy: null,
av_options: {},
}
},
beforeRouteEnter(to, from, next) {
@ -252,12 +252,12 @@ export default {
await client.trains.get(train_id).then(
train => {
this.train = train
let display = this.train.items.every(
let display_table = this.train.items.every(
item =>
item.processing_id ==
this.train.default_processing_id
)
if (display) {
if (display_table) {
this.item_table.data = []
this.train.items.forEach(item => {
let item_row = {}
@ -271,7 +271,7 @@ export default {
a.processing_attribute_id ==
attribute.processing_attribute_id
)
.map(a => a.value)
.map(a => a._strings.value.str)
}
)
item_row.item = item
@ -305,7 +305,7 @@ export default {
})
}
this.initialized = true
this.item_table.display = display
this.item_table.display = display_table
},
error => {}
)

View File

@ -9,27 +9,28 @@ export class PreservationAPIClient extends HttpClient {
get trains() {
return {
get: (id) =>
get: id =>
this.get({
endpoint: "trains/" + id,
headers: {
"x-koha-embed":
"default_processing,default_processing.attributes,items,items.attributes,items.attributes.processing_attribute",
"default_processing,default_processing.attributes,items,items.attributes,items.attributes+strings,items.attributes.processing_attribute",
},
}),
getAll: (query = {}) =>
this.get({
endpoint: "trains?" +
endpoint:
"trains?" +
new URLSearchParams({
_per_page: -1,
...(query && { q: JSON.stringify(query) }),
}),
}),
delete: (id) =>
delete: id =>
this.delete({
endpoint: "trains/" + id,
}),
create: (train) =>
create: train =>
this.post({
endpoint: "trains",
body: train,
@ -54,27 +55,28 @@ export class PreservationAPIClient extends HttpClient {
get processings() {
return {
get: (id) =>
get: id =>
this.get({
endpoint: "processings/" + id,
headers: {
"x-koha-embed": "attributes",
},
}),
getAll: (query) =>
getAll: query =>
this.get({
endpoint: "processings?" +
endpoint:
"processings?" +
new URLSearchParams({
_per_page: -1,
...(query && { q: JSON.stringify(query) }),
}),
}),
delete: (id) =>
delete: id =>
this.delete({
endpoint: "processings/" + id,
}),
create: (processing) =>
create: processing =>
this.post({
endpoint: "processings",
body: processing,
@ -148,7 +150,7 @@ export class PreservationAPIClient extends HttpClient {
get waiting_list_items() {
return {
get_from_barcode: (barcode) => {
get_from_barcode: barcode => {
const q = {
"me.barcode": barcode,
};
@ -164,15 +166,15 @@ export class PreservationAPIClient extends HttpClient {
headers: {
"x-koha-embed": "biblio",
},
}).then((response) => {
}).then(response => {
return response.length ? response[0] : undefined;
});
},
delete: (id) =>
delete: id =>
this.delete({
endpoint: "waiting-list/items/" + id,
}),
createAll: (items) =>
createAll: items =>
this.post({
endpoint: "waiting-list/items",
body: items,