From: Bill Erickson
Date: Mon, 3 Feb 2014 22:52:18 +0000 (-0500)
Subject: LP#1053397 MR TPAC filters; editing
X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=560612f653d597133743267f16c3299372276fbe;p=working%2FEvergreen.git
LP#1053397 MR TPAC filters; editing
Signed-off-by: Bill Erickson
---
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
index 5731e6bf4e..c4431f7770 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
@@ -590,8 +590,8 @@ sub fetch_user_holds {
$blob->{metarecord_filters} =
$filter_data->[0]->{metarecord};
- $blob->{metarecord_hold_extras} =
- $filter_data->[1]->{hold}->{$hold->id};
+ $blob->{metarecord_selected_filters} =
+ $filter_data->[1]->{hold};
}
push(@holds, $blob);
}
@@ -670,6 +670,10 @@ sub handle_hold_update {
m:^(\d{2})/(\d{2})/(\d{4})$:;
$val->{$field} = "$3-$1-$2";
}
+
+ $val->{holdable_formats} = # no-op for non-MR holds
+ $self->compile_holdable_formats(undef, $_);
+
$val;
} @hold_ids;
@@ -796,6 +800,7 @@ sub load_place_hold {
my $type_dispatch = {
M => sub {
+ warn "OMG HERE\n";
# target metarecords
my $mrecs = $e->batch_retrieve_metabib_metarecord([
@@ -811,30 +816,10 @@ sub load_place_hold {
'open-ils.circ',
'open-ils.circ.mmr.holds.filters.authoritative', $mr->id);
- # pull the format attr from the format info returned
- # from the API call, instead of fetching it again from
- # the DB. If there are no formats, then the format attr
- # is irrelevant.
- my $format_attr =
- $filter_data->{metarecord}->{formats}->[0]->ctype
- if $filter_data->{metarecord}->{formats}->[0];
-
- # during hold placement submission, the user selects
- # which of the available formats/langs are acceptiable.
- # Capture those here as the holdable_formats for the MR hold.
- my @selected_formats = $cgi->param('metarecord_formats_' . $mr->id);
- my @selected_langs = $cgi->param('metarecord_langs_' . $mr->id);
-
- # map the selected attrs into the JSON holdable_formats structure
- @selected_formats = map {
- {_attr => $format_attr, _val => $_} } @selected_formats;
- @selected_langs = map {
- {_attr => 'item_lang', _val => $_} } @selected_langs;
-
- my $holdable_formats = OpenSRF::Utils::JSON->perl2JSON({
- 0 => \@selected_formats,
- 1 => \@selected_langs
- });
+ my $holdable_formats =
+ $self->compile_holdable_formats($mr->id);
+
+ warn "holdable formats: $holdable_formats\n";
push(@hold_data, $data_filler->({
target => $mr,
@@ -1057,8 +1042,6 @@ sub attempt_hold_placement {
if ($hold_type eq 'M') {
$holdable_formats->{$_->{target_id}} =
$_->{holdable_formats} for @hold_data;
- # TODO: cleanup
- warn "MR Holdable formats " . Dumper($holdable_formats) . "\n";
}
my $bses = OpenSRF::AppSession->create('open-ils.circ');
@@ -1132,6 +1115,59 @@ sub attempt_hold_placement {
}
}
+# pull the selected formats and languages for metarecord holds
+# from the CGI params and map them into the JSON holdable
+# formats...er, format.
+# if no metarecord is provided, we'll pull it from the target
+# of the provided hold.
+sub compile_holdable_formats {
+ my ($self, $mr_id, $hold_id) = @_;
+ my $e = $self->editor;
+ my $cgi = $self->cgi;
+
+ warn "MR looking at params param = $_\n" for $cgi->param;
+
+ # exit early if not needed
+ return "" unless
+ grep /metarecord_formats_|metarecord_langs_/,
+ $cgi->param;
+
+ # CGI params are based on the MR id, since during hold placement
+ # we have no old ID. During hold edit, map the hold ID back to
+ # the metarecod target.
+ $mr_id =
+ $e->retrieve_action_hold_request($hold_id)->target
+ unless $mr_id;
+
+ my $format_attr = $self->ctx->{get_cgf}->(
+ 'opac.metarecord.holds.format_attr');
+
+ if (!$format_attr) {
+ $logger->error("Missing config.global_flag: ".
+ "opac.metarecord.holds.format_attr!");
+ return "";
+ }
+
+ $format_attr = $format_attr->value;
+
+ # during hold placement or edit submission, the user selects
+ # which of the available formats/langs are acceptable.
+ # Capture those here as the holdable_formats for the MR hold.
+ my @selected_formats = $cgi->param("metarecord_formats_$mr_id");
+ my @selected_langs = $cgi->param("metarecord_langs_$mr_id");
+
+ # map the selected attrs into the JSON holdable_formats structure
+ @selected_formats = map {
+ {_attr => $format_attr, _val => $_} } @selected_formats;
+ @selected_langs = map {
+ {_attr => 'item_lang', _val => $_} } @selected_langs;
+
+ return OpenSRF::Utils::JSON->perl2JSON({
+ 0 => \@selected_formats,
+ 1 => \@selected_langs
+ });
+}
+
sub fetch_user_circs {
my $self = shift;
my $flesh = shift; # flesh bib data, etc.
diff --git a/Open-ILS/src/templates/opac/myopac/holds/edit.tt2 b/Open-ILS/src/templates/opac/myopac/holds/edit.tt2
index 4664e3fc7f..d34eb89027 100644
--- a/Open-ILS/src/templates/opac/myopac/holds/edit.tt2
+++ b/Open-ILS/src/templates/opac/myopac/holds/edit.tt2
@@ -35,10 +35,6 @@
[% l('Format:') %]
[% END %]
-
- [% IF hold.metarecord_filters.formats.size OR # should this be size > 1
- hold.metarecord_filters.langs.size > 1;
- PROCESS metarecord_hold_filters_selector hold_data=hold; END %]
[% l('Status') %]: [% hold.human_status %]
@@ -104,6 +100,14 @@
[% END %]
+
+
+ [% IF hold.metarecord_filters.formats.size OR
+ hold.metarecord_filters.langs.size > 1;
+ PROCESS metarecord_hold_filters_selector
+ hold_data=hold; END %]
+