added a container update method
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 9 Mar 2006 20:31:42 +0000 (20:31 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 9 Mar 2006 20:31:42 +0000 (20:31 +0000)
added opac interface for publishing / unpublishing bookbags

git-svn-id: svn://svn.open-ils.org/ILS/trunk@3302 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Actor/Container.pm
Open-ILS/src/support-scripts/test-scripts/container.pl
Open-ILS/web/opac/common/js/config.js
Open-ILS/web/opac/skin/default/js/container.js
Open-ILS/web/opac/skin/default/js/myopac.js
Open-ILS/web/opac/skin/default/xml/myopac/myopac_bookbags.xml

index 44ade3c..d5ff96d 100644 (file)
@@ -184,7 +184,7 @@ sub bucket_create {
        return $evt if $evt;
 
        $logger->activity( "User " . $staff->id . 
-               " creating a new continer for user " . $bucket->owner );
+               " creating a new container for user " . $bucket->owner );
 
        $bucket->clear_id;
        $logger->debug("Creating new container object: " . Dumper($bucket));
@@ -224,7 +224,7 @@ sub bucket_delete {
        return $evt if $evt;
 
        $logger->activity( "User " . $staff->id . 
-               " deleting continer $bucketid for user " . $bucket->owner );
+               " deleting container $bucketid for user " . $bucket->owner );
 
        my $method = $types{$class} . ".delete";
        my $resp = $apputils->simplereq( $svc, $method, $bucketid );
@@ -253,7 +253,7 @@ sub item_create {
        return $evt if $evt;
 
        $logger->activity( "User " . $staff->id . 
-               " creating continer item  " . Dumper($item) . " for user " . $bucket->owner );
+               " creating container item for bucket " . $item->bucket . " and user " . $bucket->owner );
 
        my $method = $types{$class} . "_item.create";
        my $resp = $apputils->simplereq( $svc, $method, $item );
@@ -324,6 +324,37 @@ sub full_delete {
        return $apputils->simplereq( $svc, $meth, $containerId );
 }
 
+__PACKAGE__->register_method(
+       method          => 'container_update',
+       api_name                => 'open-ils.actor.container.update',
+       signature       => q/
+               Updates the given container item.
+               @param authtoken The login session key
+               @param class The container class
+               @param container The container item
+               @return true on success, 0 on no update, Event on error
+               /
+);
+
+sub container_update {
+       my( $self, $conn, $authtoken, $class, $container )  = @_;
+
+       my( $staff, $target, $dbcontainer, $evt);
+
+       ( $dbcontainer, $evt ) = $apputils->fetch_container($container->id, $class);
+       return $evt if $evt;
+
+       ( $staff, $target, $evt ) = $apputils->checkses_requestor( 
+               $authtoken, $dbcontainer->owner, 'UPDATE_CONTAINER' );
+       return $evt if $evt;
+
+       $logger->activity("User " . $staff->id . " updating container ". $container->id);
+
+       my $meth = $types{$class}.".update";
+       return $U->storagereq($meth, $container);
+}
+
+
 
 
 1;
index 929d3cb..1db674f 100755 (executable)
@@ -62,6 +62,14 @@ sub containers_create {
                oils_event_die($resp);
                printl("Created new $type bucket with id $resp");
                $containers{$type} = $resp;
+
+               $bucket->id($resp);
+               $bucket->pub(1);
+
+               $resp = simplereq($ACTOR, 
+                       'open-ils.actor.container.update', $authtoken, $type, $bucket );
+               oils_event_die($resp);
+               printl("Updated container type $type");
        }
 }
 
@@ -104,6 +112,7 @@ sub items_delete {
 }
 
 
+
 sub containers_delete {
        for my $type (keys %containers) {
                my $id = $containers{$type};
index 812aac7..3da5a13 100644 (file)
@@ -280,6 +280,7 @@ var CREATE_CONTAINER_ITEM           = 'open-ils.actor:open-ils.actor.container.item.creat
 var DELETE_CONTAINER_ITEM              = 'open-ils.actor:open-ils.actor.container.item.delete';
 var FLESH_CONTAINER                            = 'open-ils.actor:open-ils.actor.container.flesh';
 var FLESH_PUBLIC_CONTAINER             = 'open-ils.actor:open-ils.actor.container.public.flesh';
+var UPDATE_CONTAINER                           = 'open-ils.actor:open-ils.actor.container.update';
 var FETCH_COPY                                         = 'open-ils.search:open-ils.search.asset.copy.retrieve';
 var CHECK_HOLD_POSSIBLE                        = 'open-ils.circ:open-ils.circ.title_hold.is_possible';
 var FETCH_BIBLIO_NOTES                 = 'open-ils.circ:open-ils.circ.biblio_notes.public.batch.retrieve';
index e64eb35..cce4607 100644 (file)
@@ -43,6 +43,11 @@ function containerCreate( name, pub, callback, args ) {
        return containerDoRequest( req, callback, args );
 }
 
+function containerUpdate( container, callback, args ) {
+       var req = new Request(UPDATE_CONTAINER, G.user.session, 'biblio', container);
+       return containerDoRequest(req, callback, args);
+}
+
 function containerCreateItem( containerId, target, callback, args ) {
 
        var item = new cbrebi();
index 87fc390..e230088 100644 (file)
@@ -642,8 +642,15 @@ function myOPACShowBookbags(force) {
                        link.setAttribute('target', '_blank' );
                        unHideMe(link);
 
+                       link = $n(row, 'myopac_bb_make_unpublished');
+                       link.setAttribute('href', 'javascript:myOPACMakeBBPublished("'+cont.id()+'", true);');
+                       unHideMe(link);
+
                } else { 
                        unHideMe($n(row, 'myopac_bb_published_no')); 
+                       var link = $n(row, 'myopac_bb_make_published');
+                       link.setAttribute('href', 'javascript:myOPACMakeBBPublished("'+cont.id()+'");');
+                       unHideMe(link);
                }
 
                tbody.appendChild(row); 
@@ -653,6 +660,29 @@ function myOPACShowBookbags(force) {
        else unHideMe($('myopac_bookbag_table'));       
 }
 
+function myOPACMakeBBPublished(bbid, hideme) {
+
+       var bb = fleshedContainers[bbid];
+
+       if(hideme) {
+               if(!confirm($('myopac_make_unpublished_confirm').innerHTML)) return;
+               bb.pub(0);
+       } else {
+               if(!confirm($('myopac_make_published_confirm').innerHTML)) return;
+               bb.pub(1);
+       }
+
+       var result = containerUpdate(bb);
+
+       var code = checkILSEvent(result);
+       if(code) { alertILSEvent(code); return; }
+
+       if(result) alert($('myopac_bb_update_success').innerHTML);
+       myOPACShowBookbags(true);
+}
+
+
+
 function myOPACDeleteBookbag(id) {
        if( confirm( $('myopac_delete_bookbag_warn').innerHTML ) ) {
                var result = containerDelete(id);
index 65caeff..fa45e66 100644 (file)
@@ -17,7 +17,7 @@
        <br/>
        <table width='100%' class='data_grid data_grid_center hide_me' id='myopac_bookbag_table'>
                <thead>
-                       <tr><td>Name</td><td># Items</td><td>Published</td><td>Delete this bookbag?</td></tr>
+                       <tr><td>Name</td><td># Items</td><td>Shared</td><td>Share / Hide</td><td>Delete this bookbag?</td></tr>
                </thead>
                <tbody id='myopac_bookbag_tbody'>
                        <tr id='myopac_bookbag_tr'>
                                        <span name='myopac_bb_published_yes' class='hide_me'>Yes</span>
                                        <a name='myopac_bb_published_view' class='classic_link hide_me'>(View)</a>
                                </td>
+
+                               <td>
+                                       <a name='myopac_bb_make_unpublished' class='classic_link hide_me'>Hide</a>
+                                       <a name='myopac_bb_make_published' class='classic_link hide_me'>Share</a>
+                               </td>
+
                                <td>
                                        <a class='classic_link' href='javascript:void(0);' name='myopac_container_delete'>Delete</a>
                                </td>
@@ -52,7 +58,7 @@
                        </tr>
                        <tr>
                                <td>
-                                       <span style='padding: 5px;'>Publish this Bookbag</span>
+                                       <span style='padding: 5px;'>Share this Bookbag</span>
                                        <a class='classic_link' href='javascript:alert($("bb_publish_text").innerHTML);'>(<b>??</b>)</a>
                                        <span>Yes</span> <input type='radio' name='bb_public' id='bb_public_yes'/>
                                        <span>No</span> <input type='radio' name='bb_public' id='bb_public_no' checked='checked'/>
        <!--</div>-->
 
        <span id='bb_publish_text' class='hide_me'>
-               Publishing a Bookbag means that the contents of the Bookbag will be visible to others.  
-               To see the public view of a published Bookbag, click the "View" link in the 
-               "Published" column of the Bookbag list at the top of this page.
+               Sharing a Bookbag means that the contents of the Bookbag will be visible to others.  
+               To see the public view of a shared Bookbag, click the "View" link in the 
+               "Shared" column of the Bookbag list at the top of this page.
        </span>
 
        <span id='myopac_remove_bb_item_confirm' class='hide_me'>
                Are you sure you wish to remove this bookbag item?
        </span>
 
+       <span id='myopac_make_published_confirm' class='hide_me'>
+               Sharing this bookbag will allow the contents 
+               of the bookback to be seen by others.
+               Are you sure you wish to share this bookbag?  
+       </span>
+
+       <span id='myopac_make_unpublished_confirm' class='hide_me'>
+               Are you sure you wish to hide this bookbag?
+       </span>
+
+       <span id='myopac_bb_update_success'>
+               The Bookbag was successfully updated.
+       </span>
+
 </div>