backport editor swapping functionality from 2.0 for 1.6.2
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 13 Oct 2010 14:05:20 +0000 (14:05 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 13 Oct 2010 14:05:20 +0000 (14:05 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_6@18308 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/opac/locale/en-US/lang.dtd
Open-ILS/xul/staff_client/server/cat/marcedit.js
Open-ILS/xul/staff_client/server/cat/marcedit.xul

index d74fde9..246a4fe 100644 (file)
 <!ENTITY staff.cat.marcedit.validate.accesskey "V">
 <!ENTITY staff.cat.marcedit.save-button.accesskey "d">
 <!ENTITY staff.cat.marcedit.help.label "Help">
+<!ENTITY staff.cat.marcedit.swapEditor.label "Swap Editor Type">
 <!ENTITY staff.cat.marcedit.help.accesskey "H">
 <!ENTITY staff.cat.marcedit.caption.label "MARC Record">
 <!ENTITY staff.cat.marcedit.toggleFFE.label "Fixed Fields -- Record type: ">
index c29af00..a0b0053 100644 (file)
@@ -89,6 +89,36 @@ function wrap_long_fields (node) {
     }
 }
 
+function swap_editors () {
+
+       dojo.require('MARC.Record');
+
+       var xe = $('xul-editor');
+       var te = $('text-editor');
+
+       te.hidden = te.hidden ? false : true;
+       xe.hidden = xe.hidden ? false : true;
+
+       if (te.hidden) {
+               // get the marcxml from the text box
+               var xml_string = new MARC.Record({
+                       marcbreaker : $('text-editor-box').value,
+                       delimiter : '$'
+               }).toXmlString();
+
+               // reset the xml record and rerender it
+               xml_record = new XML( xml_string );
+               loadRecord(xml_record);
+       } else {
+               var xml_string = xml_record.toXMLString();
+
+               // push the xml record into the textbox
+               var rec = new MARC.Record ({ delimiter : '$', marcxml : xml_string });
+               $('text-editor-box').value = rec.toBreaker();
+       }
+}
+
+
 function my_init() {
     try {
 
@@ -137,6 +167,7 @@ function my_init() {
 
         document.getElementById('save-button').setAttribute('label', window.xulG.save.label);
         document.getElementById('save-button').setAttribute('oncommand',
+                       'if ($("xul-editor").hidden) swap_editors(); ' +
             'mangle_005(); ' + 
             'var xml_string = xml_escape_unicode( xml_record.toXMLString() ); ' + 
             'save_attempt( xml_string ); ' +
index f357a1a..78029d7 100644 (file)
@@ -36,6 +36,7 @@
         </hbox>
         <button label="&staff.cat.marcedit.validate.label;" accesskey="&staff.cat.marcedit.validate.accesskey;" oncommand="validateAuthority(this);"/>
         <button id="save-button" accesskey="&staff.cat.marcedit.save-button.accesskey;"/>
+        <button label="&staff.cat.marcedit.swapEditor.label;" oncommand="swap_editors()"/>
         <button label="&staff.cat.marcedit.help.label;" accesskey="&staff.cat.marcedit.help.accesskey;"
             oncommand="alert(
                 $('catStrings').getString('staff.cat.marcedit.help.add_row') + '\n' +
@@ -53,7 +54,7 @@
     </hbox>
 </groupbox>
 
-<groupbox flex="1">
+<groupbox id="xul-editor" flex="1">
     <caption label="&staff.cat.marcedit.caption.label;"/>
     <vbox flex="1" style="overflow: auto;">
         <hbox>
     </vbox>
 </groupbox>
 
+<hbox hidden="true" id="text-editor" flex="1">
+    <xhtml:textarea rows="50" cols='100' id="text-editor-box"></xhtml:textarea>
+</hbox>
+
 <grid name="authority-marc-template" hidden="true">
     <columns>
         <column/>