Adds MARC Edit Window Tiling Feature user/catalystit/marc_edit_tiles
authorJustin Douma <jdouma@catalystitservices.com>
Thu, 17 Jan 2013 18:08:42 +0000 (10:08 -0800)
committerJustin Douma <jdouma@catalystitservices.com>
Fri, 25 Jan 2013 01:56:39 +0000 (17:56 -0800)
Adds option in the File menu of the staff client to open all currently
open records in new windows and space those windows apropriately on the
user's screen. This allows easy side-by-side comparison, and editing, of
two or more Marc records.

Signed-off-by: Justin Douma <jdouma@catalystitservices.com>
Open-ILS/web/opac/locale/en-US/lang.dtd
Open-ILS/xul/staff_client/chrome/content/main/main.js
Open-ILS/xul/staff_client/chrome/content/main/menu.js
Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul
docs/RELEASE_NOTES_NEXT/marc_tile_windows.txt [new file with mode: 0644]

index 70063d8..148e706 100644 (file)
 <!ENTITY staff.main.menu.file.label "File">
 <!ENTITY staff.main.menu.file.new.accesskey "N">
 <!ENTITY staff.main.menu.file.new.label "New Window">
+<!ENTITY staff.main.menu.file.open.record.windows.horizontal "Tile MARC Records (Horizontal)">
+<!ENTITY staff.main.menu.file.open.record.windows.vertical "Tile MARC Records (Vertical)">
 <!ENTITY staff.main.menu.file.new_tab.accesskey "T">
 <!ENTITY staff.main.menu.file.new_tab.label "New Tab">
 <!ENTITY staff.main.menu.file.portal.label "Home">
index a86b642..18c7d4f 100644 (file)
@@ -820,4 +820,41 @@ function auto_login(loginInfo) {
     return should_test_server;
 }
 
+function tileWindows(urlList, isVertical, winCount, winIndex, aContinue) {
+    if(aContinue == true && tempWindow.closed == false) {
+        //check if window finished openning
+        if(tempWindow.g == undefined || tempWindow.g.menu == undefined) {
+            setTimeout(
+                function() {
+                    tileWindows(urlList, isVertical, winCount, winIndex, true);
+                }, 500);
+            return null;
+        }
+        tempWindow = null;
+    }
+    var scrWidth = window.screen.width;
+    var scrHeight = window.screen.height;
+    var placement = '';
+    if (urlList.length > 0) {
+        var url = urlList.shift();
+        //stack windows vertically or horizontally
+        if (isVertical) {
+            var winWidth = scrWidth / winCount;
+            placement = 'screenX=' + winWidth * (winIndex) + ',width=' + winWidth+ ',height=' + scrHeight;
+        } else {
+            var winHeight = scrHeight / winCount;
+            placement = 'screenY=' + winHeight * (winIndex) + ',width=' + scrWidth+ ',height=' + winHeight
+        }
+        tempWindow = xulG.window.open(urls.XUL_MENU_FRAME
+            + '?server=' + window.escape(G.data.server) + '&firstURL=' + window.escape(url),
+            '_blank','chrome,resizable,sizemode="normal",' + placement);
+        tempWindow.xulG = xulG;
+        winIndex++;
+        setTimeout(
+            function() {
+                tileWindows(urlList, isVertical, winCount, winIndex, true);
+            }, 500);
+
+    }
+}
 dump('exiting main/main.js\n');
index f94e9ed..fd97917 100644 (file)
@@ -272,6 +272,34 @@ main.menu.prototype = {
                 ['oncommand'],
                 function() { obj.close_all_tabs(); }
             ],
+            'cmd_open_record_windows_horizontal' : [
+                ['oncommand'],
+                function(event) {
+                    var bibURLs = obj.get_opac_record_urls();
+                    if(bibURLs && bibURLs.length > 0)
+                    {
+                    var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].
+                        getService(Components.interfaces.nsIWindowMediator);
+                    wm.getMostRecentWindow('eg_main').tileWindows(bibURLs, false, bibURLs.length, 0, false);
+                    } else {
+                        alert("No Records to Display");
+                    }
+                }
+            ],
+            'cmd_open_record_windows_vertical' : [
+                ['oncommand'],
+                function(event) {
+                    var bibURLs = obj.get_opac_record_urls();
+                    if(bibURLs && bibURLs.length > 0)
+                    {
+                    var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].
+                        getService(Components.interfaces.nsIWindowMediator);
+                    wm.getMostRecentWindow('eg_main').tileWindows(bibURLs, true, bibURLs.length, 0, false);
+                    } else {
+                        alert("No Records to Display");
+                    }
+                }
+            ],
 
             /* Edit Menu */
             'cmd_edit_copy_buckets' : [
@@ -2787,7 +2815,42 @@ commands:
         } catch(E) {
             alert('Error in menu.js, render_toolbar_layout('+layout+'): ' + E);
         }
+    },
+
+    'get_opac_record_urls'  : function() {
+        var bibURLs = [];
+        var panelCount = this.controller.view.panels.childNodes.length;
+        for (var i = 1; i < panelCount; i++) {
+            var panel = this.controller.view.panels.childNodes[ i ];
+            if (panel
+                && panel.firstChild
+                && panel.firstChild.nodeName == 'iframe'
+                && panel.firstChild.contentWindow
+                )
+            {
+                var cw = panel.firstChild.contentWindow;
+                var iframes = cw.document.getElementsByTagName('iframe');
+
+                if(iframes.length > 0)
+                {
+                    for (var y = 0; y < iframes.length; y++) {
+                        if(iframes[y].getAttribute('src').match(/^[https|chrome|oils].*/)
+                            && iframes[y].contentDocument
+                            && iframes[y].contentDocument.getElementsByTagName('browser')[0]
+                            && iframes[y].contentDocument.getElementsByTagName('browser')[0].contentWindow
+                            && iframes[y].contentDocument.getElementsByTagName('browser')[0].contentWindow.location)
+                            {
+                                var opac_url = iframes[y].contentDocument.getElementsByTagName('browser')[0].contentWindow.location;
+                                opac_url = opac_url.toString();
+                                if (opac_url.match(/eg\/opac\/record\/\d+/) || opac_url.match(/\/skin\/default\/xml\/rdetail.xml\?r=\d+/)) {
+                                        bibURLs.push(urls.XUL_OPAC_WRAPPER + '?opac_url=' + window.escape( opac_url ) + '&show_nav_buttons=false,&default_view=marc_edit');
+                                    }
+                            }
+                    }
+                }
+            }
+         }
+         return bibURLs;
     }
 }
-
 dump('exiting main/menu.js\n');
index 2e984d7..e02cf3c 100644 (file)
@@ -15,6 +15,8 @@
     <command id="cmd_close_all_tabs" />
     <command id="cmd_shutdown" />
     <command id="cmd_portal" />
+    <command id="cmd_open_record_windows_horizontal" />
+    <command id="cmd_open_record_windows_vertical" />
 
     <command id="cmd_edit_copy_buckets" />
     <command id="cmd_edit_volume_buckets" />
         <menuitem label="&staff.main.menu.file.close_tab.label;" accesskey="&staff.main.menu.file.close_tab.accesskey;" command="cmd_close_tab"/>
         <menuitem label="&staff.main.menu.tabs.close;" accesskey="&staff.main.menu.tabs.close.accesskey;" command="cmd_close_all_tabs"/>
         <menuitem label="&staff.main.menu.file.close.label;" accesskey="&staff.main.menu.file.close.accesskey;" command="cmd_close_window"/>
+        <menuitem label="&staff.main.menu.file.open.record.windows.vertical;" command="cmd_open_record_windows_vertical"/>
+        <menuitem label="&staff.main.menu.file.open.record.windows.horizontal;" command="cmd_open_record_windows_horizontal"/>
         <menuseparator />
         <menuitem label="&staff.main.menu.quit;" accesskey="&staff.main.menu.quit.accesskey;" command="cmd_shutdown"/>
     </menupopup>
diff --git a/docs/RELEASE_NOTES_NEXT/marc_tile_windows.txt b/docs/RELEASE_NOTES_NEXT/marc_tile_windows.txt
new file mode 100644 (file)
index 0000000..e9d8d43
--- /dev/null
@@ -0,0 +1,23 @@
+New Feature - MARC Tile Edit Windows
+====================================
+
+.Overview
+New feature which allows MARC edit windows to be viewed side-by-side or above-below.
+
+Added functionality would allow library staff to view multiple MARC records for ease of editing.
+
+The new functionality is for staff client only.
+
+.Feature Access:
+
+The new functionality is accessed via the <File> menu, where two new menu options would be added.
+
+* <Tile MARC record horizontal> would tile all currently viewed MARC records side-by-side.
+* <Tile MARC record vertical> would tile all currently viewed MARC records above-below.
+
+.Code Changes:
+* The following files would be modified:
+* Open-ILS/xul/staff_client/chrome/content/main/main.js
+* Open-ILS/xul/staff_client/chrome/content/main/menu.js
+* Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.js
+* Open-ILS/web/opac/local/en-us/lang.dtd