Rough working MFHD editor
authordbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 22 May 2009 14:42:33 +0000 (14:42 +0000)
committerdbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 22 May 2009 14:42:33 +0000 (14:42 +0000)
To do:
  * Support internationalization
  * Open the MARC editor in a tab instead of a pop-up window

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

Open-ILS/examples/fm_IDL.xml
Open-ILS/web/opac/skin/default/js/rdetail.js

index 6330cda..ad8f2b2 100644 (file)
@@ -2285,7 +2285,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                        <field name="incomplete" oils_persist:virtual="true" />
                </fields>
        </class>
-       <class id="sre" controller="open-ils.cstore" oils_obj:fieldmapper="serial::record_entry" oils_persist:tablename="serial.record_entry" reporter:label="Record Entry">
+       <class id="sre" controller="open-ils.pcrud open-ils.cstore" oils_obj:fieldmapper="serial::record_entry" oils_persist:tablename="serial.record_entry" reporter:label="Serial Record Entry">
                <fields oils_persist:primary="id" oils_persist:sequence="serial.record_entry_id_seq">
                        <field name="active" reporter:datatype="bool"/>
                        <field reporter:label="Bib Record" name="record" reporter:datatype="link"/>
@@ -2304,8 +2304,16 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                        <link field="editor" reltype="has_a" key="id" map="" class="au"/>
                        <link field="creator" reltype="has_a" key="id" map="" class="au"/>
                </links>
+               <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+                       <actions>
+                               <create permission="CREATE_MFHD_RECORD" global_required="true"/>
+                               <retrieve/>
+                               <update permission="UPDATE_MFHD_RECORD" global_required="true"/>
+                               <delete permission="DELETE_MFHD_RECORD" global_required="true"/>
+                       </actions>
+               </permacrud>
        </class>
-       <class id="sfr" controller="open-ils.cstore" oils_obj:fieldmapper="serial::full_rec" oils_persist:tablename="serial.full_rec" reporter:label="Full Record">
+       <class id="sfr" controller="open-ils.cstore" oils_obj:fieldmapper="serial::full_rec" oils_persist:tablename="serial.full_rec" reporter:label="Serial Full Record">
                <fields oils_persist:primary="id" oils_persist:sequence="serial.full_rec_id_seq">
                        <field name="id" reporter:datatype="id" />
                        <field name="ind1" />
index 7f27b23..971bdb1 100644 (file)
@@ -180,6 +180,34 @@ function rdetailShowAllCopies() {
        hideMe(G.ui.rdetail.cp_info_none); 
 }
 
+function OpenMarcEditWindow(pcrud, rec) {
+    /*
+        To run in Firefox directly, must set signed.applets.codebase_principal_support
+        to true in about:config
+    */
+    netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
+    win = window.open('/xul/server/cat/marcedit.xul'); // XXX version?
+    dojo.require('openils.PermaCrud');
+
+    win.xulG = {
+        record : {marc : rec.marc()},
+        save : {
+            label: 'Save',
+            func: function(xmlString) {
+                rec.marc(xmlString);
+               rec.ischanged(true);
+               pcrud.update(rec);
+            },
+        }
+    };
+}
+
+function loadMarcEditor(recId) {
+       var pcrud = new openils.PermaCrud({"authtoken": G.user.session});
+       var recs = pcrud.search("sre", {"record": recId});
+       OpenMarcEditWindow(pcrud, recs[0]);
+}
+
 /*
  * This function could be written much more intelligently
  * Limited brain power means that I'm brute-forcing it for now
@@ -205,7 +233,7 @@ function _holdingsDraw(h) {
                return null;
        }
        
-       dojo.place("<table><caption  class='rdetail_header color_1'>Holdings summary</caption><tbody id='rdetail_holdings_tbody'></tbody></table>", "rdetail_details_table", "after");
+       dojo.place("<table><caption id='mfhdHoldingsCaption' class='rdetail_header color_1'>Holdings summary</caption><tbody id='rdetail_holdings_tbody'></tbody></table>", "rdetail_details_table", "after");
        if (hh.length > 0) {
                dojo.place("<tr><td> </td><td nowrap='nowrap' class='rdetail_desc'>Holdings</td><td  class='rdetail_item'>" + hh + "</td></tr>", "rdetail_holdings_tbody", "last");
        }
@@ -233,6 +261,11 @@ function _holdingsDraw(h) {
        if (hinc.length > 0) {
                dojo.place("<tr><td> </td><td nowrap='nowrap' class='rdetail_desc'>Incomplete</td><td  class='rdetail_item'>" + hinc + "</td></tr>", "rdetail_holdings_tbody", "last");
        }
+       if (isXUL()) {
+               dojo.require('openils.Event');
+               dojo.require('openils.PermaCrud');
+               dojo.place("<span> - </span><a class='classic_link' href='javascript:loadMarcEditor(" + getRid() + ")'> Edit</a>", "mfhdHoldingsCaption", "last");
+       }
 }
 
 function _rdetailDraw(r) {