From: dbs Date: Tue, 21 Jul 2009 13:53:28 +0000 (+0000) Subject: Use pcrud to delete MFHD records, per berick's suggestion. One less Perl mess :) X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=31d2b211e07679a825537fddcd0d9b3da315a364;p=evergreen%2Ftadl.git Use pcrud to delete MFHD records, per berick's suggestion. One less Perl mess :) git-svn-id: svn://svn.open-ils.org/ILS/trunk@13661 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm b/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm index d9781e1e68..269ad73428 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm @@ -873,8 +873,9 @@ sub create_serial_record_xml { my $e = new_editor(xact=>1, authtoken=>$login); return $e->die_event unless $e->checkauth; - return $e->die_event unless $e->allowed('CREATE_MFHD_RECORD', $owning_lib); + return $e->die_event unless $e->allowed('CREATE_MFHD_RECORD', $owning_lib); + # Auto-populate the location field of a placeholder MFHD record with the library name my $aou = $e->retrieve_actor_org_unit($owning_lib) or return $e->die_event; my $mfhd = Fieldmapper::serial::record_entry->new; @@ -886,51 +887,24 @@ sub create_serial_record_xml { $mfhd->create_date('now'); $mfhd->edit_date('now'); $mfhd->owning_lib($owning_lib); - $xml = " 00307cy a22001094 4500 42153 20090601182414.0 051011 eng 090309 " . $aou->name . " "; + + # If the caller did not pass in MFHD XML, create a placeholder record. + # The placeholder will only contain the name of the owning library. + # The goal is to generate common patterns for the caller in the UI that + # then get passed in here. + if (!$xml) { + $xml = " 00307cy a22001094 4500 42153 20090601182414.0 051011 eng 090309 " . $aou->name . " "; + } my $marcxml = XML::LibXML->new->parse_string($xml); $marcxml->documentElement->setNamespace("http://www.loc.gov/MARC21/slim", "marc", 1 ); $marcxml->documentElement->setNamespace("http://www.loc.gov/MARC21/slim"); $mfhd->marc($U->entityize($marcxml->documentElement->toString)); - $e->create_serial_record_entry($mfhd) or return $e->die_event; + $e->create_serial_record_entry($mfhd) or return $e->die_event; $e->commit; return $mfhd->id; } -__PACKAGE__->register_method( - method => "delete_serial_record", - api_name => "open-ils.cat.serial.record.delete.override", - signature => q/@see open-ils.cat.serial.record.delete/); - -__PACKAGE__->register_method( - method => "delete_serial_record", - api_name => "open-ils.cat.serial.record.delete", - signature => q/ - Deletes a serial record with the given ID - / -); - -sub delete_serial_record { - my( $self, $client, $login, $mfhd_id ) = @_; - - my $override = 1 if $self->api_name =~ /override/; # not currently used - - my $e = new_editor(xact=>1, authtoken=>$login); - return $e->die_event unless $e->checkauth; - - my $record = $e->retrieve_serial_record_entry($mfhd_id) - or return $e->die_event; - - return $e->die_event unless $e->allowed('DELETE_MFHD_RECORD', $record->owning_lib); - - $record->deleted('t'); - $record->edit_date('now'); - $e->update_serial_record_entry($record) or return $e->die_event; - - $e->commit; - return 1; -} - 1; diff --git a/Open-ILS/web/js/dojo/openils/opac/nls/opac.js b/Open-ILS/web/js/dojo/openils/opac/nls/opac.js index 69d5bd25f0..c1978605e0 100644 --- a/Open-ILS/web/js/dojo/openils/opac/nls/opac.js +++ b/Open-ILS/web/js/dojo/openils/opac/nls/opac.js @@ -1,8 +1,9 @@ { - "CREATE_MFHD": "Add MFHD record", + "CREATE_MFHD": "Add MFHD Record", "CREATED_MFHD_RECORD": "Created MFHD record for ${0}", + "DELETE_MFHD": "Delete Record", "DELETED_MFHD_RECORD": "Deleted MFHD record ${0}", - "EDIT_MFHD_RECORD": "Edit MFHD Record", + "EDIT_MFHD_RECORD": "Edit Record", "EDIT_MFHD_MENU": "Edit Holdings", "EDIT_PROPERTIES": "Edit Propeties", "HOLDINGS": "Previous volumes", diff --git a/Open-ILS/web/opac/skin/default/js/rdetail.js b/Open-ILS/web/opac/skin/default/js/rdetail.js index be85f365d8..6f597d8582 100644 --- a/Open-ILS/web/opac/skin/default/js/rdetail.js +++ b/Open-ILS/web/opac/skin/default/js/rdetail.js @@ -304,10 +304,13 @@ function _holdingsDrawMFHD(holdings, entryNum) { var mfhd_edit = new dijit.Menu({}); new dijit.MenuItem({onClick: function(){loadMarcEditor(holdings.id())}, label:opac_strings.EDIT_MFHD_RECORD}).placeAt(mfhd_edit, "first"); new dijit.MenuItem({onClick:function(){ - var req = new Request(DELETE_MFHD_RECORD, G.user.session, holdings.id()); - var res = req.send(); - alert(dojo.string.substitute(opac_strings.DELETED_MFHD_RECORD, [holdings.id()])); - }, label:"Delete"}).placeAt(mfhd_edit, "last"); + var pcrud = new openils.PermaCrud({"authtoken": G.user.session}); + var mfhd_rec = pcrud.retrieve("sre", holdings.id()); + if (mfhd_rec) { + pcrud.delete(mfhd_rec); + alert(dojo.string.substitute(opac_strings.DELETED_MFHD_RECORD, [holdings.id()])); + } + }, label:opac_strings.DELETE_MFHD}).placeAt(mfhd_edit, "last"); // new dijit.MenuItem({onClick:function(){alert("Edit properties " + holdings.id());}, label:opac_strings.EDIT_PROPERTIES}).placeAt(mfhd_edit, "last"); var mfhd_mb = new dijit.form.DropDownButton({dropDown: mfhd_edit, label:opac_strings.EDIT_MFHD_MENU, style:"float:right"}); mfhd_mb.placeAt("mfhdHoldingsCaption" + entryNum, "last");