From 73d10737854ba9119a3b6786117d4f2ccd02432f Mon Sep 17 00:00:00 2001 From: miker Date: Fri, 4 Dec 2009 15:37:19 +0000 Subject: [PATCH] Patch from Lebbeous Fogle-Weekley which implements the configuration interfaces required to support bookable resources, including the addition of cataloged materials as bookable items. Thus spake Lebbeous: Here it is at last. The only entry point (for now) to these interfaces besides the "admin" menu is in the holdings maintenance / copy browser context menu. There you can select items and create bookable resources out of them (basically), and upon that creation you get a new tab open in the staff client where you could further edit (in a basic, conify way) that resource. git-svn-id: svn://svn.open-ils.org/ILS/trunk@15077 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/examples/fm_IDL.xml | 56 ++++++- Open-ILS/examples/opensrf.xml.example | 23 +++ Open-ILS/examples/opensrf_core.xml.example | 1 + .../perlmods/OpenILS/Application/Booking.pm | 148 ++++++++++++++++++ Open-ILS/src/sql/Pg/002.schema.config.sql | 2 +- Open-ILS/src/sql/Pg/950.data.seed-values.sql | 13 +- .../0106.booking.admin_permissions.sql | 15 ++ Open-ILS/web/opac/locale/en-US/lang.dtd | 23 +++ .../conify/global/booking/reservation.tt2 | 39 +++++ .../booking/reservation_attr_value_map.tt2 | 39 +++++ .../conify/global/booking/resource.tt2 | 57 +++++++ .../conify/global/booking/resource_attr.tt2 | 39 +++++ .../global/booking/resource_attr_map.tt2 | 39 +++++ .../global/booking/resource_attr_value.tt2 | 39 +++++ .../conify/global/booking/resource_type.tt2 | 39 +++++ .../chrome/content/main/constants.js | 1 + .../staff_client/chrome/content/main/menu.js | 28 ++++ .../chrome/content/main/menu_frame_menus.xul | 18 +++ .../staff_client/server/cat/copy_browser.js | 65 ++++++++ .../staff_client/server/cat/copy_browser.xul | 3 + .../server/locale/en-US/cat.properties | 4 + 21 files changed, 682 insertions(+), 9 deletions(-) create mode 100644 Open-ILS/src/perlmods/OpenILS/Application/Booking.pm create mode 100644 Open-ILS/src/sql/Pg/upgrade/0106.booking.admin_permissions.sql create mode 100644 Open-ILS/web/templates/default/conify/global/booking/reservation.tt2 create mode 100644 Open-ILS/web/templates/default/conify/global/booking/reservation_attr_value_map.tt2 create mode 100644 Open-ILS/web/templates/default/conify/global/booking/resource.tt2 create mode 100644 Open-ILS/web/templates/default/conify/global/booking/resource_attr.tt2 create mode 100644 Open-ILS/web/templates/default/conify/global/booking/resource_attr_map.tt2 create mode 100644 Open-ILS/web/templates/default/conify/global/booking/resource_attr_value.tt2 create mode 100644 Open-ILS/web/templates/default/conify/global/booking/resource_type.tt2 diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index 4de8c7fd0c..64e8eb5538 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -2352,7 +2352,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - + @@ -2374,11 +2374,17 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + + + + + - + @@ -2399,11 +2405,17 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + + + + + - + @@ -2419,11 +2431,17 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + + + + + - + @@ -2438,11 +2456,17 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + + + + + - + @@ -2454,11 +2478,17 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + + + + + - + @@ -2504,11 +2534,17 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + + + + + - + @@ -2518,6 +2554,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + + + + + diff --git a/Open-ILS/examples/opensrf.xml.example b/Open-ILS/examples/opensrf.xml.example index c56b854a13..646979eba2 100644 --- a/Open-ILS/examples/opensrf.xml.example +++ b/Open-ILS/examples/opensrf.xml.example @@ -435,6 +435,28 @@ vim:et:ts=4:sw=4: + + 5 + 1 + perl + OpenILS::Application::Booking + 199 + + open-ils.booking_unix.sock + open-ils.booking_unix.pid + 1000 + open-ils.booking_unix.log + 1 + 15 + 1 + 5 + + + + LOCALSTATEDIR/templates/marc/k_book.xml + + + 5 @@ -951,6 +973,7 @@ vim:et:ts=4:sw=4: opensrf.math opensrf.dbmath open-ils.acq + open-ils.booking open-ils.cat open-ils.supercat open-ils.search diff --git a/Open-ILS/examples/opensrf_core.xml.example b/Open-ILS/examples/opensrf_core.xml.example index 695ab4a8bb..3097ce053f 100644 --- a/Open-ILS/examples/opensrf_core.xml.example +++ b/Open-ILS/examples/opensrf_core.xml.example @@ -22,6 +22,7 @@ Example OpenSRF bootstrap configuration file for Evergreen open-ils.actor open-ils.acq open-ils.auth + open-ils.booking open-ils.cat open-ils.circ open-ils.collections diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Booking.pm b/Open-ILS/src/perlmods/OpenILS/Application/Booking.pm new file mode 100644 index 0000000000..7c33bbdd25 --- /dev/null +++ b/Open-ILS/src/perlmods/OpenILS/Application/Booking.pm @@ -0,0 +1,148 @@ +package OpenILS::Application::Booking; + +use strict; +use warnings; + +use OpenILS::Application; +use base qw/OpenILS::Application/; + +use OpenILS::Utils::CStoreEditor qw/:funcs/; +use OpenILS::Utils::Fieldmapper; +use OpenILS::Application::AppUtils; +my $U = "OpenILS::Application::AppUtils"; + +use OpenSRF::Utils::Logger qw/$logger/; + +sub prepare_new_brt { + my ($record_id, $owning_lib, $mvr) = @_; + + my $brt = new Fieldmapper::booking::resource_type; + $brt->isnew(1); + $brt->name($mvr->title); + $brt->record($record_id); + $brt->catalog_item('t'); + $brt->owner($owning_lib); + + return $brt; +} + +sub get_existing_brt { + my ($e, $record_id, $owning_lib, $mvr) = @_; + my $results = $e->search_booking_resource_type( + {name => $mvr->title, owner => $owning_lib, record => $record_id} + ); + + return $results->[0] if (length @$results > 0); + return undef; +} + +sub get_mvr { + return $U->simplereq( + 'open-ils.search', + 'open-ils.search.biblio.record.mods_slim.retrieve.authoritative', + shift # record id + ); +} + +sub get_unique_owning_libs { + my %hash = (); + $hash{$_->call_number->owning_lib} = 1 foreach (@_); # @_ are copies + return keys %hash; +} + +sub fetch_copies_by_ids { + my ($e, $copy_ids) = @_; + my $results = $e->search_asset_copy([ + {id => $copy_ids}, + {flesh => 1, flesh_fields => {acp => ['call_number']}} + ]); + return $results if ref($results) eq 'ARRAY'; + return []; +} + +sub get_single_record_id { + my $record_id = undef; + foreach (@_) { # @_ are copies + return undef if + (defined $record_id && $record_id != $_->call_number->record); + $record_id = $_->call_number->record; + } + return $record_id; +} + +__PACKAGE__->register_method( + method => "create_brt_and_brsrc", + api_name => "open-ils.booking.create_brt_and_brsrc_from_copies", + signature => { + params => [ + {type => 'string', desc => 'Authentication token'}, + {type => 'array', desc => 'Copy IDs'}, + ], + return => { desc => "A two-element hash. The 'brt' element " . + "is a list of created booking resource types described by " . + "id/copyid pairs. The 'brsrc' element is a similar " . + "list of created booking resources described by copy/recordid " . + "pairs"} + } +); + +sub create_brt_and_brsrc { + my ($self, $conn, $authtoken, $copy_ids) = @_; + my (@created_brt, @created_brsrc); + my %brt_table = (); + + my $e = new_editor(xact => 1, authtoken => $authtoken); + return $e->die_event unless $e->checkauth; + + my @copies = @{fetch_copies_by_ids($e, $copy_ids)}; + my $record_id = get_single_record_id(@copies) or return $e->die_event; + my $mvr = get_mvr($record_id) or return $e->die_event; + + foreach (get_unique_owning_libs(@copies)) { + $brt_table{$_} = get_existing_brt($e, $record_id, $_, $mvr) || + prepare_new_brt($record_id, $_, $mvr); + } + + while (my ($owning_lib, $brt) = each %brt_table) { + if ($brt->isnew) { + if ($e->allowed('CREATE_BOOKING_RESOURCE_TYPE', $owning_lib)) { + # We can/should abort if this creation fails, because the + # logic isn't going to be trying to create any redundnat + # brt's, therefore any error will be more serious than + # that. See the different take on creating brsrc's below. + return $e->die_event unless ( + # v-- Important: assignment modifies original hash + $brt = $e->create_booking_resource_type($brt) + ); + } + push @created_brt, [$brt->id, $brt->record]; + } + } + + foreach (@copies) { + if ( + $e->allowed('CREATE_BOOKING_RESOURCE', $_->call_number->owning_lib) + ) { + my $brsrc = new Fieldmapper::booking::resource; + $brsrc->isnew(1); + $brsrc->type($brt_table{$_->call_number->owning_lib}->id); + $brsrc->owner($_->call_number->owning_lib); + $brsrc->barcode($_->barcode); + + # We don't want to abort the transaction or do anything dramatic if + # this fails, because quite possibly a user selected many copies on + # which to perform this "create booking resource" operation, and + # among those copies there may be some that we still need to + # create, and some that we don't. So we just do what we can. + push @created_brsrc, [$brsrc->id, $_->id] if + ($brsrc = $e->create_booking_resource($brsrc)); + # ^--- Important: assignment. + } + } + + $e->commit and + return {brt => \@created_brt, brsrc => \@created_brsrc} or + return $e->die_event; +} + +1; diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index 3166387850..61ff1a5016 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -51,7 +51,7 @@ CREATE TABLE config.upgrade_log ( install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW() ); -INSERT INTO config.upgrade_log (version) VALUES ('0105'); -- miker +INSERT INTO config.upgrade_log (version) VALUES ('0106'); -- senator CREATE TABLE config.bib_source ( id SERIAL PRIMARY KEY, diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql index 928e0474d6..d4d45d9c6a 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -1239,7 +1239,18 @@ INSERT INTO permission.perm_list VALUES (350, 'ADMIN_COPY_LOCATION_ORDER', oils_i18n_gettext(350, 'Allow a user to create/view/update/delete a copy location order', 'ppl', 'description')), -- additional permissions - (351, 'HOLD_LOCAL_AVAIL_OVERRIDE', oils_i18n_gettext(351, 'Allow a user to place a hold despite the availability of a local copy', 'ppl', 'description')); + (351, 'HOLD_LOCAL_AVAIL_OVERRIDE', oils_i18n_gettext(351, 'Allow a user to place a hold despite the availability of a local copy', 'ppl', 'description')), + + (352, 'ADMIN_BOOKING_RESOURCE', oils_i18n_gettext(352, 'Enables the user to create/update/delete booking resources', 'ppl', 'description')), + (353, 'ADMIN_BOOKING_RESOURCE_TYPE', oils_i18n_gettext(353, 'Enables the user to create/update/delete booking resource types', 'ppl', 'description')), + (354, 'ADMIN_BOOKING_RESOURCE_ATTR', oils_i18n_gettext(354, 'Enables the user to create/update/delete booking resource attributes', 'ppl', 'description')), + (355, 'ADMIN_BOOKING_RESOURCE_ATTR_MAP', oils_i18n_gettext(355, 'Enables the user to create/update/delete booking resource attribute maps', 'ppl', 'description')), + (356, 'ADMIN_BOOKING_RESOURCE_ATTR_VALUE', oils_i18n_gettext(356, 'Enables the user to create/update/delete booking resource attribute values', 'ppl', 'description')), + (357, 'ADMIN_BOOKING_RESERVATION', oils_i18n_gettext(357, 'Enables the user to create/update/delete booking reservations', 'ppl', 'description')), + (358, 'ADMIN_BOOKING_RESERVATION_ATTR_VALUE_MAP', oils_i18n_gettext(358, 'Enables the user to create/update/delete booking reservation attribute value maps', 'ppl', 'description')) +; + + ; SELECT SETVAL('permission.perm_list_id_seq'::TEXT, 1000); diff --git a/Open-ILS/src/sql/Pg/upgrade/0106.booking.admin_permissions.sql b/Open-ILS/src/sql/Pg/upgrade/0106.booking.admin_permissions.sql new file mode 100644 index 0000000000..337d5a7276 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/0106.booking.admin_permissions.sql @@ -0,0 +1,15 @@ +BEGIN; + +INSERT INTO config.upgrade_log (version) VALUES ('0106'); -- senator + +INSERT INTO permission.perm_list (id, code, description) VALUES + (352, 'ADMIN_BOOKING_RESOURCE', oils_i18n_gettext(352, 'Enables the user to create/update/delete booking resources', 'ppl', 'description')), + (353, 'ADMIN_BOOKING_RESOURCE_TYPE', oils_i18n_gettext(353, 'Enables the user to create/update/delete booking resource types', 'ppl', 'description')), + (354, 'ADMIN_BOOKING_RESOURCE_ATTR', oils_i18n_gettext(354, 'Enables the user to create/update/delete booking resource attributes', 'ppl', 'description')), + (355, 'ADMIN_BOOKING_RESOURCE_ATTR_MAP', oils_i18n_gettext(355, 'Enables the user to create/update/delete booking resource attribute maps', 'ppl', 'description')), + (356, 'ADMIN_BOOKING_RESOURCE_ATTR_VALUE', oils_i18n_gettext(356, 'Enables the user to create/update/delete booking resource attribute values', 'ppl', 'description')), + (357, 'ADMIN_BOOKING_RESERVATION', oils_i18n_gettext(357, 'Enables the user to create/update/delete booking reservations', 'ppl', 'description')), + (358, 'ADMIN_BOOKING_RESERVATION_ATTR_VALUE_MAP', oils_i18n_gettext(358, 'Enables the user to create/update/delete booking reservation attribute value maps', 'ppl', 'description')) +; + +COMMIT; diff --git a/Open-ILS/web/opac/locale/en-US/lang.dtd b/Open-ILS/web/opac/locale/en-US/lang.dtd index 39f586e904..6108fba049 100644 --- a/Open-ILS/web/opac/locale/en-US/lang.dtd +++ b/Open-ILS/web/opac/locale/en-US/lang.dtd @@ -272,6 +272,8 @@ + + @@ -666,6 +668,22 @@ + + + + + + + + + + + + + + + + @@ -2115,6 +2133,8 @@ + + @@ -2162,6 +2182,9 @@ + + + diff --git a/Open-ILS/web/templates/default/conify/global/booking/reservation.tt2 b/Open-ILS/web/templates/default/conify/global/booking/reservation.tt2 new file mode 100644 index 0000000000..40a2a5c14c --- /dev/null +++ b/Open-ILS/web/templates/default/conify/global/booking/reservation.tt2 @@ -0,0 +1,39 @@ +[% WRAPPER default/base.tt2 %] +[% ctx.page_title = 'Reservations' %] + + + + + +
+
Reservations
+
+ + +
+
+ +
+ +
+
+ +[% END %] diff --git a/Open-ILS/web/templates/default/conify/global/booking/reservation_attr_value_map.tt2 b/Open-ILS/web/templates/default/conify/global/booking/reservation_attr_value_map.tt2 new file mode 100644 index 0000000000..a879e3f688 --- /dev/null +++ b/Open-ILS/web/templates/default/conify/global/booking/reservation_attr_value_map.tt2 @@ -0,0 +1,39 @@ +[% WRAPPER default/base.tt2 %] +[% ctx.page_title = 'Reservation Attribute Value Maps' %] + + + + + +
+
Reservation Attribute Value Maps
+
+ + +
+
+ +
+ +
+
+ +[% END %] diff --git a/Open-ILS/web/templates/default/conify/global/booking/resource.tt2 b/Open-ILS/web/templates/default/conify/global/booking/resource.tt2 new file mode 100644 index 0000000000..7742bc80f3 --- /dev/null +++ b/Open-ILS/web/templates/default/conify/global/booking/resource.tt2 @@ -0,0 +1,57 @@ +[% WRAPPER default/base.tt2 %] +[% ctx.page_title = 'Resources' %] + + + + + + +
+
Resources
+
+ + +
+
+ +
+ +
+
+ +[% END %] diff --git a/Open-ILS/web/templates/default/conify/global/booking/resource_attr.tt2 b/Open-ILS/web/templates/default/conify/global/booking/resource_attr.tt2 new file mode 100644 index 0000000000..f26ef6df32 --- /dev/null +++ b/Open-ILS/web/templates/default/conify/global/booking/resource_attr.tt2 @@ -0,0 +1,39 @@ +[% WRAPPER default/base.tt2 %] +[% ctx.page_title = 'Resource Attributes' %] + + + + + +
+
Resource Attributes
+
+ + +
+
+ +
+ +
+
+ +[% END %] diff --git a/Open-ILS/web/templates/default/conify/global/booking/resource_attr_map.tt2 b/Open-ILS/web/templates/default/conify/global/booking/resource_attr_map.tt2 new file mode 100644 index 0000000000..69679afa1b --- /dev/null +++ b/Open-ILS/web/templates/default/conify/global/booking/resource_attr_map.tt2 @@ -0,0 +1,39 @@ +[% WRAPPER default/base.tt2 %] +[% ctx.page_title = 'Resource Attribute Maps' %] + + + + + +
+
Resource Attribute Maps
+
+ + +
+
+ +
+ +
+
+ +[% END %] diff --git a/Open-ILS/web/templates/default/conify/global/booking/resource_attr_value.tt2 b/Open-ILS/web/templates/default/conify/global/booking/resource_attr_value.tt2 new file mode 100644 index 0000000000..b4f92baee2 --- /dev/null +++ b/Open-ILS/web/templates/default/conify/global/booking/resource_attr_value.tt2 @@ -0,0 +1,39 @@ +[% WRAPPER default/base.tt2 %] +[% ctx.page_title = 'Resource Attribute Values' %] + + + + + +
+
Resource Attribute Values
+
+ + +
+
+ +
+ +
+
+ +[% END %] diff --git a/Open-ILS/web/templates/default/conify/global/booking/resource_type.tt2 b/Open-ILS/web/templates/default/conify/global/booking/resource_type.tt2 new file mode 100644 index 0000000000..4e8d70466b --- /dev/null +++ b/Open-ILS/web/templates/default/conify/global/booking/resource_type.tt2 @@ -0,0 +1,39 @@ +[% WRAPPER default/base.tt2 %] +[% ctx.page_title = 'Resource Types' %] + + + + + +
+
Resource Types
+
+ + +
+
+ +
+ +
+
+ +[% END %] diff --git a/Open-ILS/xul/staff_client/chrome/content/main/constants.js b/Open-ILS/xul/staff_client/chrome/content/main/constants.js index 1668bb66a0..5687bfa2a5 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/constants.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/constants.js @@ -174,6 +174,7 @@ const api = { 'FM_AUSP_REMOVE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.penalty.remove' }, 'FM_AUSP_PCRUD_UPDATE' : { 'app' : 'open-ils.pcrud', 'method' : 'open-ils.pcrud.update.ausp', 'secure' : false }, 'FM_AUSP_UPDATE_NOTE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.penalty.note.update' }, + 'FM_BOOKING_CREATE_BRT_AND_BRSRC' : { 'app' : 'open-ils.booking', 'method' : 'open-ils.booking.create_brt_and_brsrc_from_copies' }, 'FM_BRE_RETRIEVE_VIA_ID' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.biblio.record.metadata.retrieve', 'secure' : false }, 'FM_BRE_RETRIEVE_VIA_ID.authoritative' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.biblio.record.metadata.retrieve.authoritative', 'secure' : false }, 'FM_BRE_ID_SEARCH_VIA_BARCODE' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.biblio.find_by_barcode', 'secure' : false }, diff --git a/Open-ILS/xul/staff_client/chrome/content/main/menu.js b/Open-ILS/xul/staff_client/chrome/content/main/menu.js index f4474e6e71..c5bcbdf6af 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/menu.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/menu.js @@ -626,6 +626,34 @@ main.menu.prototype = { ['oncommand'], function() { open_eg_web_page('conify/global/config/usr_setting_type'); } ], + 'cmd_server_admin_booking_resource': [ + ['oncommand'], + function() { open_eg_web_page('conify/global/booking/resource'); } + ], + 'cmd_server_admin_booking_resource_type': [ + ['oncommand'], + function() { open_eg_web_page('conify/global/booking/resource_type'); } + ], + 'cmd_server_admin_booking_resource_attr': [ + ['oncommand'], + function() { open_eg_web_page('conify/global/booking/resource_attr'); } + ], + 'cmd_server_admin_booking_resource_attr_value': [ + ['oncommand'], + function() { open_eg_web_page('conify/global/booking/resource_attr_value'); } + ], + 'cmd_server_admin_booking_resource_attr_map': [ + ['oncommand'], + function() { open_eg_web_page('conify/global/booking/resource_attr_map'); } + ], + 'cmd_server_admin_booking_reservation': [ + ['oncommand'], + function() { open_eg_web_page('conify/global/booking/reservation'); } + ], + 'cmd_server_admin_booking_reservation_attr_value_map': [ + ['oncommand'], + function() { open_eg_web_page('conify/global/booking/reservation_attr_value_map'); } + ], 'cmd_acq_view_picklist' : [ ['oncommand'], function() { open_eg_web_page('acq/picklist/list', 'menu.cmd_acq_view_picklist.tab'); } diff --git a/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul b/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul index 761613534c..0f00d91c35 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul +++ b/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul @@ -122,6 +122,13 @@ + + + + + + + @@ -317,6 +324,17 @@ + + + + + + + + + + + diff --git a/Open-ILS/xul/staff_client/server/cat/copy_browser.js b/Open-ILS/xul/staff_client/server/cat/copy_browser.js index b306de02ab..1a5b3b92d6 100644 --- a/Open-ILS/xul/staff_client/server/cat/copy_browser.js +++ b/Open-ILS/xul/staff_client/server/cat/copy_browser.js @@ -142,6 +142,69 @@ cat.copy_browser.prototype = { ); } ], + 'cmd_create_brt' : [ + ['command'], + function() { + JSAN.use('util.functional'); + var cs = document.getElementById('catStrings'); + // Filter out selected rows that aren't copies. + var list = util.functional.filter_list( + obj.sel_list, + function (o) { + return o.split(/_/)[0] == 'acp'; + } + ); + // Get the IDs of all copy rows. + var copy_ids = util.functional.map_list( + list, function (o) { + return obj.map_acp[o].id(); + } + ); + // Ask the ML to create brt's and brsrc's. + var results = fieldmapper.standardRequest( + ['open-ils.booking', 'open-ils.booking.create_brt_and_brsrc_from_copies'], + [ses(), copy_ids] + ); + if (results == null) { + alert(cs.getString('staff.cat.copy_browser.brt_and_brsrc.create_failed_silent')); + } + else if (typeof results.ilsevent != 'undefined') { + // FIXME Isn't there a more standardized + // way to show this error? + alert(cs.getFormattedString( + 'staff.cat.copy_browser.brt_and_brsrc.create_failed', + [results.ilsevent, results.textcode, + results.desc, results.debug] + )); + } else { + // Spawn new tab to allow editing new + // resources. + try { + var url = urls.XUL_BROWSER + '?url=' + + window.escape( + xulG.url_prefix(urls.EG_WEB_BASE) + + '/conify/global/booking/resource?results=' + + window.escape(js2JSON(results['brsrc'])) + ); + // Sorry about the CGI params, but I + // don't see another choice for + // passing data to conify pages. This + // has the obvious problem of a + // character length limit. FIXME + xulG.new_tab(url, + {'tab_name': cs.getString('staff.cat.copy_browser.brt_and_brsrc.newtab_name'), + 'browser' : false}, + {'no_xulG' : false} + ); + } catch(E) { + JSAN.use('util.error'); + var error = new util.error; + var f = error.standard_unexpected_error_alert; + f(cs.getString('staff.cat.copy_browser.brt_and_brsrc.newtab_failed'), E); + } + } + } + ], 'cmd_add_items' : [ ['command'], function() { @@ -1613,6 +1676,7 @@ cat.copy_browser.prototype = { obj.controller.view.cmd_transfer_volume.setAttribute('disabled','true'); obj.controller.view.cmd_transfer_items.setAttribute('disabled','true'); obj.controller.view.sel_copy_details.setAttribute('disabled','true'); + obj.controller.view.cmd_create_brt.setAttribute('disabled','true'); obj.controller.view.sel_patron.setAttribute('disabled','true'); obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','true'); obj.controller.view.sel_mark_items_missing.setAttribute('disabled','true'); @@ -1637,6 +1701,7 @@ cat.copy_browser.prototype = { obj.controller.view.cmd_print_spine_labels.setAttribute('disabled','false'); obj.controller.view.cmd_transfer_items.setAttribute('disabled','false'); obj.controller.view.sel_copy_details.setAttribute('disabled','false'); + obj.controller.view.cmd_create_brt.setAttribute('disabled','false'); obj.controller.view.sel_patron.setAttribute('disabled','false'); } } catch(E) { diff --git a/Open-ILS/xul/staff_client/server/cat/copy_browser.xul b/Open-ILS/xul/staff_client/server/cat/copy_browser.xul index b46730101c..0f09ad51e3 100644 --- a/Open-ILS/xul/staff_client/server/cat/copy_browser.xul +++ b/Open-ILS/xul/staff_client/server/cat/copy_browser.xul @@ -72,6 +72,7 @@ vim:noet:sw=4:ts=4: + @@ -102,6 +103,7 @@ vim:noet:sw=4:ts=4: + @@ -153,6 +155,7 @@ vim:noet:sw=4:ts=4: + diff --git a/Open-ILS/xul/staff_client/server/locale/en-US/cat.properties b/Open-ILS/xul/staff_client/server/locale/en-US/cat.properties index 1e5a96d15b..7312dafd07 100644 --- a/Open-ILS/xul/staff_client/server/locale/en-US/cat.properties +++ b/Open-ILS/xul/staff_client/server/locale/en-US/cat.properties @@ -12,6 +12,10 @@ staff.cat.bib_brief.noncat.alert=Item not cataloged. staff.cat.copy_browser.add_item.title=Add Item staff.cat.copy_browser.add_item.error=copy browser -> add copies staff.cat.copy_browser.add_items_bucket.error=copy browser -> add copies to bucket +staff.cat.copy_browser.brt_and_brsrc.create_failed_silent=No response from server +staff.cat.copy_browser.brt_and_brsrc.create_failed=Error from server: %1$d %2$s\n%3$s\n%4$s +staff.cat.copy_browser.brt_and_brsrc.newtab_failed=Could not launch Booking Resource Editor: %1$s +staff.cat.copy_browser.brt_and_brsrc.newtab_name=Resources staff.cat.copy_browser.replace_barcode.failed=Barcode %1$s not likely replaced. staff.cat.copy_browser.replace_barcode.error=copy browser -> replace barcode staff.cat.copy_browser.edit_items.error=Copy Browser -> Edit Items -- 2.43.2