[open-ils-commits] [GIT] Evergreen ILS branch master updated. d5353f6cfee00eabfed3787275f3a83b21cbc61a

Evergreen Git git at git.evergreen-ils.org
Mon Apr 2 12:37:13 EDT 2012


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, master has been updated
       via  d5353f6cfee00eabfed3787275f3a83b21cbc61a (commit)
       via  dcaca3584b28f741849bc5954f9a89ec2c2486da (commit)
       via  fc5ea41785d5f52fb18a10f657c574d937a464eb (commit)
       via  cb0f2fa74805e8f50d6906e9e37a08c0179d21c3 (commit)
      from  6ceac83b2ba88ffda97a0bc2fb1faa58d6aad7c6 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit d5353f6cfee00eabfed3787275f3a83b21cbc61a
Author: Jason Etheridge <jason at esilibrary.com>
Date:   Mon Apr 2 12:23:59 2012 -0400

    remove some cruft
    
    Signed-off-by: Jason Etheridge <jason at esilibrary.com>
    Signed-off-by: Jason Stephenson <jstephenson at mvlc.org>
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

diff --git a/Open-ILS/xul/staff_client/chrome/content/util/list.js b/Open-ILS/xul/staff_client/chrome/content/util/list.js
index b366579..b35c289 100644
--- a/Open-ILS/xul/staff_client/chrome/content/util/list.js
+++ b/Open-ILS/xul/staff_client/chrome/content/util/list.js
@@ -201,20 +201,11 @@ util.list.prototype = {
                     treecol.addEventListener(
                         'click', 
                         function(ev) {
-                            dump('click\n');
                             if (ev.button == 2 /* context menu click */ || ev.target.getAttribute('no_sort')) {
                                 return;
                             }
-                            if (document.popupNode
-                                && document.popupNode.nodeName == 'treecol'
-                                && document.popupNode.hasAttribute('locked')
-                            ) {
-                                return;
-                            }
-                            dump('click2\n');
 
                             if (ev.ctrlKey) { // sub sort
-                                dump('click3\n');
                                 var sortDir = 'asc';
                                 if (ev.shiftKey) {
                                     sortDir = 'desc';
@@ -225,7 +216,6 @@ util.list.prototype = {
                                     'sortDir' : sortDir
                                 });
                             } else { // first sort
-                                dump('click4\n');
                                 var sortDir = ev.target.getAttribute('sortDir') || 'desc';
                                 if (sortDir == 'desc') sortDir = 'asc'; else sortDir = 'desc';
                                 if (ev.shiftKey) {
@@ -246,14 +236,11 @@ util.list.prototype = {
                     treecol.addEventListener(
                         'sort',
                         function(ev) {
-                            dump('sort\n');
                             if (!obj.first_sort) {
                                 return;
                             }
-                            dump('sort2\n');
 
                             function do_it() {
-                                dump('sort3\n');
                                 obj._sort_tree();
                             }
 

commit dcaca3584b28f741849bc5954f9a89ec2c2486da
Author: Jason Etheridge <jason at esilibrary.com>
Date:   Fri Mar 30 13:06:44 2012 -0400

    add context menu to xul list column headers
    
    for multi-sort options.  Also fix ascending vs descending internally (since the
    distinction is now exposed via labels)
    
    Signed-off-by: Jason Etheridge <jason at esilibrary.com>
    Signed-off-by: Jason Stephenson <jstephenson at mvlc.org>
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

diff --git a/Open-ILS/web/opac/locale/en-US/lang.dtd b/Open-ILS/web/opac/locale/en-US/lang.dtd
index e42c1a1..bffcaee 100644
--- a/Open-ILS/web/opac/locale/en-US/lang.dtd
+++ b/Open-ILS/web/opac/locale/en-US/lang.dtd
@@ -77,6 +77,11 @@
 <!ENTITY common.textbox.delete "Delete">
 <!ENTITY common.textbox.select_all "Select All">
 
+<!ENTITY common.sort.first.ascending "Sort First (Ascending)">
+<!ENTITY common.sort.first.descending "Sort First (Descending)">
+<!ENTITY common.sort.next.ascending "Sort Next (Ascending)">
+<!ENTITY common.sort.next.descending "Sort Next (Descending)">
+
 <!ENTITY ilsevent.1000 "Login failed.  The username or password entered was incorrect.">
 <!ENTITY ilsevent.1001 "Login session has timed out or does not exist">
 <!ENTITY ilsevent.1002 "User was not found in the database">
diff --git a/Open-ILS/xul/staff_client/chrome/content/util/list.js b/Open-ILS/xul/staff_client/chrome/content/util/list.js
index 2083ef5..b366579 100644
--- a/Open-ILS/xul/staff_client/chrome/content/util/list.js
+++ b/Open-ILS/xul/staff_client/chrome/content/util/list.js
@@ -25,6 +25,7 @@ util.list = function (id) {
     JSAN.use('OpenILS.data'); this.data = new OpenILS.data(); this.data.stash_retrieve();
 
     JSAN.use('util.functional');
+    JSAN.use('util.widgets');
 
     return this;
 };
@@ -100,6 +101,9 @@ util.list.prototype = {
             var treecols = document.createElement('treecols');
             this.node.appendChild(treecols);
             this.treecols = treecols;
+            if (document.getElementById('column_sort_menu')) {
+                treecols.setAttribute('context','column_sort_menu');
+            }
 
             var check_for_id_collisions = {};
             for (var i = 0; i < this.columns.length; i++) {
@@ -122,6 +126,7 @@ util.list.prototype = {
                     treecol.setAttribute(j,value);
                 }
                 treecols.appendChild(treecol);
+
                 if (this.columns[i].type == 'checkbox') {
                     treecol.addEventListener(
                         'click',
@@ -139,49 +144,137 @@ util.list.prototype = {
                     );
                 } else {
                     treecol.addEventListener(
+                        'sort_first_asc',
+                        function(ev) {
+                            dump('sort_first_asc\n');
+                            ev.target.setAttribute('sortDir','asc');
+                            obj.first_sort = {
+                                'target' : ev.target,
+                                'sortDir' : 'asc'
+                            };
+                            obj.sub_sorts = [];
+                            util.widgets.dispatch('sort',ev.target);
+                        },
+                        false
+                    );
+                    treecol.addEventListener(
+                        'sort_first_desc',
+                        function(ev) {
+                            dump('sort_first_desc\n');
+                            ev.target.setAttribute('sortDir','desc');
+                            obj.first_sort = {
+                                'target' : ev.target,
+                                'sortDir' : 'desc'
+                            };
+                            obj.sub_sorts = [];
+                            util.widgets.dispatch('sort',ev.target);
+                        },
+                        false
+                    );
+                    treecol.addEventListener(
+                        'sort_next_asc',
+                        function(ev) {
+                            dump('sort_next_asc\n');
+                            ev.target.setAttribute('sortDir','asc');
+                            obj.sub_sorts.push({
+                                'target' : ev.target,
+                                'sortDir' : 'asc'
+                            });
+                            util.widgets.dispatch('sort',ev.target);
+                        },
+                        false
+                    );
+                    treecol.addEventListener(
+                        'sort_next_desc',
+                        function(ev) {
+                            dump('sort_next_desc\n');
+                            ev.target.setAttribute('sortDir','desc');
+                            obj.sub_sorts.push({
+                                'target' : ev.target,
+                                'sortDir' : 'desc'
+                            });
+                            util.widgets.dispatch('sort',ev.target);
+                        },
+                        false
+                    );
+
+                    treecol.addEventListener(
                         'click', 
                         function(ev) {
-                            if (ev.target.getAttribute('no_sort')) {
+                            dump('click\n');
+                            if (ev.button == 2 /* context menu click */ || ev.target.getAttribute('no_sort')) {
+                                return;
+                            }
+                            if (document.popupNode
+                                && document.popupNode.nodeName == 'treecol'
+                                && document.popupNode.hasAttribute('locked')
+                            ) {
                                 return;
                             }
+                            dump('click2\n');
 
-                            function do_it() {
-                                if (ev.ctrlKey) { // sub sort
-                                    var sortDir = 'asc';
-                                    if (ev.shiftKey) {
-                                        sortDir = 'desc';
-                                    }
-                                    obj.sub_sorts.push({
-                                        'target' : ev.target,
-                                        'sortDir' : sortDir
-                                    });
-                                } else { // first sort
-                                    var sortDir = ev.target.getAttribute('sortDir') || 'desc';
-                                    if (sortDir == 'desc') sortDir = 'asc'; else sortDir = 'desc';
-                                    if (ev.shiftKey) {
-                                        sortDir = 'desc';
-                                    }
-                                    ev.target.setAttribute('sortDir',sortDir);
-                                    obj.first_sort = {
-                                        'target' : ev.target,
-                                        'sortDir' : sortDir
-                                    };
-                                    obj.sub_sorts = [];
+                            if (ev.ctrlKey) { // sub sort
+                                dump('click3\n');
+                                var sortDir = 'asc';
+                                if (ev.shiftKey) {
+                                    sortDir = 'desc';
                                 }
-                                if (obj.first_sort) {
-                                    obj._sort_tree();
+                                ev.target.setAttribute('sortDir',sortDir);
+                                obj.sub_sorts.push({
+                                    'target' : ev.target,
+                                    'sortDir' : sortDir
+                                });
+                            } else { // first sort
+                                dump('click4\n');
+                                var sortDir = ev.target.getAttribute('sortDir') || 'desc';
+                                if (sortDir == 'desc') sortDir = 'asc'; else sortDir = 'desc';
+                                if (ev.shiftKey) {
+                                    sortDir = 'desc';
                                 }
+                                ev.target.setAttribute('sortDir',sortDir);
+                                obj.first_sort = {
+                                    'target' : ev.target,
+                                    'sortDir' : sortDir
+                                };
+                                obj.sub_sorts = [];
+                            }
+                            util.widgets.dispatch('sort',ev.target);
+                        },
+                        false
+                    );
+
+                    treecol.addEventListener(
+                        'sort',
+                        function(ev) {
+                            dump('sort\n');
+                            if (!obj.first_sort) {
+                                return;
+                            }
+                            dump('sort2\n');
+
+                            function do_it() {
+                                dump('sort3\n');
+                                obj._sort_tree();
                             }
 
-                            if (obj.row_count.total != obj.row_count.fleshed && (obj.row_count.total - obj.row_count.fleshed) > 50) {
-                                var r = window.confirm(document.getElementById('offlineStrings').getFormattedString('list.row_fetch_warning',[obj.row_count.fleshed,obj.row_count.total]));
+                            if (obj.row_count.total != obj.row_count.fleshed
+                                && (obj.row_count.total - obj.row_count.fleshed) > 50
+                            ) {
+                                var r = window.confirm(
+                                    document.getElementById('offlineStrings').getFormattedString(
+                                        'list.row_fetch_warning',
+                                        [obj.row_count.fleshed,obj.row_count.total]
+                                    )
+                                );
 
                                 if (r) {
                                     setTimeout( do_it, 0 );
                                 }
+
                             } else {
                                     setTimeout( do_it, 0 );
                             }
+
                         },
                         false
                     );
@@ -1706,14 +1799,14 @@ util.list.prototype = {
                                 var values;
                                 if (sorts[i].sortDir == 'asc') {
                                     values = normalize(
-                                        B['values'][i]['value'],
                                         A['values'][i]['value'],
+                                        B['values'][i]['value'],
                                         A['values'][i]['position']
                                     );
                                 } else {
                                     values = normalize(
-                                        A['values'][i]['value'],
                                         B['values'][i]['value'],
+                                        A['values'][i]['value'],
                                         A['values'][i]['position']
                                     );
                                 }
diff --git a/Open-ILS/xul/staff_client/chrome/content/util/sort.js b/Open-ILS/xul/staff_client/chrome/content/util/sort.js
new file mode 100644
index 0000000..083c243
--- /dev/null
+++ b/Open-ILS/xul/staff_client/chrome/content/util/sort.js
@@ -0,0 +1,21 @@
+dump('entering util/sort.js\n');
+
+if (typeof util == 'undefined') var util = {};
+util.sort = {};
+
+util.sort.EXPORT_OK    = [ 
+    'dispatch'
+];
+util.sort.EXPORT_TAGS    = { ':all' : util.sort.EXPORT_OK };
+
+util.sort.dispatch = function(what,sortDir) {
+    try {
+        dump('util.sort.dispatch('+what+','+sortDir+');\n');
+        JSAN.use('util.widgets');
+        util.widgets.dispatch('sort_'+what+'_'+sortDir, document.popupNode);
+    } catch(E) {
+        alert(E);
+    }
+}
+
+dump('exiting util/sort.js\n');
diff --git a/Open-ILS/xul/staff_client/server/OpenILS/util_overlay.xul b/Open-ILS/xul/staff_client/server/OpenILS/util_overlay.xul
index 323971f..3192a90 100644
--- a/Open-ILS/xul/staff_client/server/OpenILS/util_overlay.xul
+++ b/Open-ILS/xul/staff_client/server/OpenILS/util_overlay.xul
@@ -57,6 +57,7 @@
         <script type="text/javascript" src="/xul/server/util/mozilla.js" />
         <script type="text/javascript" src="/xul/server/util/network.js" />
         <script type="text/javascript" src="/xul/server/util/print.js" />
+        <script type="text/javascript" src="/xul/server/util/sort.js" />
         <script type="text/javascript" src="/xul/server/util/sound.js" />
         <script type="text/javascript" src="/xul/server/util/text.js" />
         <script type="text/javascript" src="/xul/server/util/widgets.js" />
@@ -79,6 +80,12 @@
             <menuitem label="&common.textbox.delete;" oncommand="document.popupNode.value = ''" />
             <menuitem label="&common.textbox.select_all;" oncommand="document.popupNode.select()" />
         </menupopup>
+        <popup id="column_sort_menu">
+            <menuitem label="&common.sort.first.ascending;" oncommand="util.sort.dispatch('first','asc');"/>
+            <menuitem label="&common.sort.first.descending;" oncommand="util.sort.dispatch('first','desc');"/>
+            <menuitem label="&common.sort.next.ascending;" oncommand="util.sort.dispatch('next','asc');"/>
+            <menuitem label="&common.sort.next.descending;" oncommand="util.sort.dispatch('next','desc');"/>
+        </popup>
         <messagecatalog id="commonStrings" src='/xul/server/locale/<!--#echo var="locale"-->/common.properties'/>
         <messagecatalog id="offlineStrings" src='/xul/server/locale/<!--#echo var="locale"-->/offline.properties'/>
         <messagecatalog id="authStrings" src='/xul/server/locale/<!--#echo var="locale"-->/auth.properties'/>

commit fc5ea41785d5f52fb18a10f657c574d937a464eb
Author: Jason Etheridge <jason at esilibrary.com>
Date:   Thu Mar 29 11:11:55 2012 -0400

    xul list secondary sorting
    
    For xul-based lists in the staff client (interfaces with a grey background),
    normal behavior is to sort the list when you left click a column header.
    
    This is still the case, but now if you control+click a column header, it sets
    up that column as a secondary sub-sort.  Control+clicking more columns will
    set up subsequent sub-sorts.
    
    Normal click a column header for primary sorting will clear out all previously
    defined sub-sorts.  Control+clicking when a primary column has not yet been
    normal clicked effectively does nothing.
    
    Signed-off-by: Jason Etheridge <jason at esilibrary.com>
    Signed-off-by: Jason Stephenson <jstephenson at mvlc.org>
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

diff --git a/Open-ILS/xul/staff_client/chrome/content/util/list.js b/Open-ILS/xul/staff_client/chrome/content/util/list.js
index c3636bd..2083ef5 100644
--- a/Open-ILS/xul/staff_client/chrome/content/util/list.js
+++ b/Open-ILS/xul/staff_client/chrome/content/util/list.js
@@ -9,6 +9,8 @@ util.list = function (id) {
 
     this.unique_row_counter = 0;
 
+    this.sub_sorts = [];
+
     if (!this.node) throw('Could not find element ' + id);
     switch(this.node.nodeName) {
         case 'listbox' : 
@@ -22,6 +24,8 @@ util.list = function (id) {
 
     JSAN.use('OpenILS.data'); this.data = new OpenILS.data(); this.data.stash_retrieve();
 
+    JSAN.use('util.functional');
+
     return this;
 };
 
@@ -137,11 +141,36 @@ util.list.prototype = {
                     treecol.addEventListener(
                         'click', 
                         function(ev) {
+                            if (ev.target.getAttribute('no_sort')) {
+                                return;
+                            }
+
                             function do_it() {
-                                var sortDir = ev.target.getAttribute('sortDir') || 'desc';
-                                if (sortDir == 'desc') sortDir = 'asc'; else sortDir = 'desc';
-                                ev.target.setAttribute('sortDir',sortDir);
-                                obj._sort_tree(ev.target,sortDir);
+                                if (ev.ctrlKey) { // sub sort
+                                    var sortDir = 'asc';
+                                    if (ev.shiftKey) {
+                                        sortDir = 'desc';
+                                    }
+                                    obj.sub_sorts.push({
+                                        'target' : ev.target,
+                                        'sortDir' : sortDir
+                                    });
+                                } else { // first sort
+                                    var sortDir = ev.target.getAttribute('sortDir') || 'desc';
+                                    if (sortDir == 'desc') sortDir = 'asc'; else sortDir = 'desc';
+                                    if (ev.shiftKey) {
+                                        sortDir = 'desc';
+                                    }
+                                    ev.target.setAttribute('sortDir',sortDir);
+                                    obj.first_sort = {
+                                        'target' : ev.target,
+                                        'sortDir' : sortDir
+                                    };
+                                    obj.sub_sorts = [];
+                                }
+                                if (obj.first_sort) {
+                                    obj._sort_tree();
+                                }
                             }
 
                             if (obj.row_count.total != obj.row_count.fleshed && (obj.row_count.total - obj.row_count.fleshed) > 50) {
@@ -1573,15 +1602,27 @@ util.list.prototype = {
         obj.full_retrieve();
     },
 
-    '_sort_tree' : function(col,sortDir) {
+    '_sort_tree' : function() {
         var obj = this;
         try {
-            if (obj.node.getAttribute('no_sort') || col.getAttribute('no_sort')) {
+            if (obj.node.getAttribute('no_sort')) {
                 return;
             }
-            var col_pos;
-            for (var i = 0; i < obj.columns.length; i++) { 
-                if (obj.columns[i].id == col.id) col_pos = function(a){return a;}(i); 
+
+            var sorts = [ obj.first_sort ].concat( obj.sub_sorts );
+            var columns = util.functional.map_list(
+                sorts,
+                function(e,idx) {
+                    return e.target;
+                }
+            );
+            var column_positions = [];
+            for (var i = 0; i < columns.length; i++) {
+                for (var j = 0; j < obj.columns.length; j++) {
+                    if (obj.columns[j].id == columns[i].id) {
+                        column_positions.push( function(a){return a;}(j) );
+                    }
+                }
             }
             obj.wrap_in_full_retrieve(
                 function() {
@@ -1592,62 +1633,99 @@ util.list.prototype = {
                         for (var i = 0; i < treeitems.length; i++) {
                             var treeitem = treeitems[i];
                             var treerow = treeitem.firstChild;
-                            var treecell = treerow.childNodes[ col_pos ];
-                            value = ( {
-                                'value' : treecell
-                                    ? treecell.getAttribute('label')
-                                    : '',
-                                'sort_value' : treecell ? treecell.hasAttribute('sort_value')
-                                    ? JSON2js(
-                                        treecell.getAttribute('sort_value'))
-                                    : '' : '',
+
+                            function get_value(treecell) {
+                                value = ( {
+                                    'value' : treecell
+                                        ? treecell.getAttribute('label')
+                                        : '',
+                                    'sort_value' : treecell ? treecell.hasAttribute('sort_value')
+                                        ? JSON2js(
+                                            treecell.getAttribute('sort_value'))
+                                        : '' : ''
+                                } );
+                                return value;
+                            }
+
+                            var values = [];
+                            for (var j = 0; j < column_positions.length; j++) {
+                                var treecell = treerow.childNodes[ column_positions[j] ];
+                                values.push({
+                                    'position' : column_positions[j],
+                                    'value' : get_value(treecell)
+                                });
+                            }
+
+                            rows.push({
+                                'values' : values,
                                 'node' : treeitem
-                            } );
-                            rows.push( value );
+                            });
                         }
-                        rows = rows.sort( function(a,b) { 
-                            if (a.sort_value) {
-                                a = a.sort_value;
-                                b = b.sort_value;
-                            } else {
-                                a = a.value;
-                                b = b.value;
-                                if (col.getAttribute('sort_type')) {
-                                    switch(col.getAttribute('sort_type')) {
-                                        case 'date' :
-                                            JSAN.use('util.date'); // to pull in dojo.date.locale
-                                            a = dojo.date.locale.parse(a,{});
-                                            b = dojo.date.locale.parse(b,{});
-                                        break;
-                                        case 'number' :
-                                            a = Number(a); b = Number(b);
-                                        break;
-                                        case 'money' :
-                                            a = util.money.dollars_float_to_cents_integer(a);
-                                            b = util.money.dollars_float_to_cents_integer(b);
-                                        break;
-                                        case 'title' : /* special case for "a" and "the".  doesn't use marc 245 indicator */
-                                            a = String( a ).toUpperCase().replace( /^\s*(THE|A|AN)\s+/, '' );
-                                            b = String( b ).toUpperCase().replace( /^\s*(THE|A|AN)\s+/, '' );
-                                        break;
-                                        default:
+                        rows = rows.sort( function(A,B) {
+                            function normalize(a,b,p) {
+                                if (a.sort_value) {
+                                    a = a.sort_value;
+                                    b = b.sort_value;
+                                } else {
+                                    a = a.value;
+                                    b = b.value;
+                                    if (obj.columns[p].getAttribute('sort_type')) {
+                                        switch(obj.columns[p].getAttribute('sort_type')) {
+                                            case 'date' :
+                                                JSAN.use('util.date'); // to pull in dojo.date.locale
+                                                a = dojo.date.locale.parse(a,{});
+                                                b = dojo.date.locale.parse(b,{});
+                                            break;
+                                            case 'number' :
+                                                a = Number(a); b = Number(b);
+                                            break;
+                                            case 'money' :
+                                                a = util.money.dollars_float_to_cents_integer(a);
+                                                b = util.money.dollars_float_to_cents_integer(b);
+                                            break;
+                                            case 'title' : /* special case for "a" and "the".  doesn't use marc 245 indicator */
+                                                a = String( a ).toUpperCase().replace( /^\s*(THE|A|AN)\s+/, '' );
+                                                b = String( b ).toUpperCase().replace( /^\s*(THE|A|AN)\s+/, '' );
+                                            break;
+                                            default:
+                                                a = String( a ).toUpperCase();
+                                                b = String( b ).toUpperCase();
+                                            break;
+                                        }
+                                    } else {
+                                        if (typeof a == 'string' || typeof b == 'string') {
                                             a = String( a ).toUpperCase();
                                             b = String( b ).toUpperCase();
-                                        break;
+                                        }
                                     }
+                                }
+                                return [ a, b ];
+                            }
+
+                            for (var i = 0; i < sorts.length; i++) {
+                                var values;
+                                if (sorts[i].sortDir == 'asc') {
+                                    values = normalize(
+                                        B['values'][i]['value'],
+                                        A['values'][i]['value'],
+                                        A['values'][i]['position']
+                                    );
                                 } else {
-                                    if (typeof a == 'string' || typeof b == 'string') {
-                                        a = String( a ).toUpperCase();
-                                        b = String( b ).toUpperCase();
-                                    }
+                                    values = normalize(
+                                        A['values'][i]['value'],
+                                        B['values'][i]['value'],
+                                        A['values'][i]['position']
+                                    );
+                                }
+                                if (values[0] < values[1] ) {
+                                    return -1;
+                                }
+                                if (values[0] > values[1] ) {
+                                    return 1;
                                 }
                             }
-                            //dump('sorting: type = ' + col.getAttribute('sort_type') + ' a = ' + a + ' b = ' + b + ' a<b= ' + (a<b) + ' a>b= ' + (a>b) + '\n');
-                            if (a < b) return -1; 
-                            if (a > b) return 1; 
                             return 0; 
                         } );
-                        if (sortDir == 'asc') rows = rows.reverse();
                         while(obj.treechildren.lastChild) obj.treechildren.removeChild( obj.treechildren.lastChild );
                         for (var i = 0; i < rows.length; i++) {
                             obj.treechildren.appendChild( rows[i].node );

commit cb0f2fa74805e8f50d6906e9e37a08c0179d21c3
Author: Jason Etheridge <jason at esilibrary.com>
Date:   Thu Mar 29 11:49:51 2012 -0400

    mitigate race conditions with ordinal line number column
    
    Signed-off-by: Jason Etheridge <jason at esilibrary.com>
    Signed-off-by: Jason Stephenson <jstephenson at mvlc.org>
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

diff --git a/Open-ILS/xul/staff_client/chrome/content/util/list.js b/Open-ILS/xul/staff_client/chrome/content/util/list.js
index ef4c96f..c3636bd 100644
--- a/Open-ILS/xul/staff_client/chrome/content/util/list.js
+++ b/Open-ILS/xul/staff_client/chrome/content/util/list.js
@@ -571,6 +571,7 @@ util.list.prototype = {
                     
                             inc_fleshed();
                     }
+                    obj.refresh_ordinals();
                 },
                 false
             );
@@ -596,6 +597,7 @@ util.list.prototype = {
                     if (obj.row_count.fleshed >= obj.row_count.total) {
                         setTimeout( function() { obj.exec_on_all_fleshed(); }, 0 );
                     }
+                    obj.refresh_ordinals();
                 },
                 false
             );
@@ -731,6 +733,7 @@ util.list.prototype = {
                     
                             inc_fleshed();
                     }
+                    obj.refresh_ordinals();
                 },
                 false
             );
@@ -760,6 +763,7 @@ util.list.prototype = {
                     if (obj.row_count.fleshed >= obj.row_count.total) {
                         setTimeout( function() { obj.exec_on_all_fleshed(); }, 0 );
                     }
+                    obj.refresh_ordinals();
                 },
                 false
             );
@@ -801,29 +805,41 @@ util.list.prototype = {
     'refresh_ordinals' : function() {
         var obj = this;
         try {
-            setTimeout( // Otherwise we can miss a row just added
+            if (obj.refresh_ordinals_timeout_id) { return; }
+
+            function _refresh_ordinals(clear) {
+                var nl = obj.node.getElementsByAttribute('label','_');
+                for (var i = 0; i < nl.length; i++) {
+                    nl[i].setAttribute(
+                        'ord_col',
+                        'true'
+                    );
+                    nl[i].setAttribute( // treecell properties for css styling
+                        'properties',
+                        'ordinal'
+                    );
+                }
+                nl = obj.node.getElementsByAttribute('ord_col','true');
+                for (var i = 0; i < nl.length; i++) {
+                    nl[i].setAttribute(
+                        'label',
+                        // we could just use 'i' here if we trust the order of elements
+                        1 + obj.node.contentView.getIndexOfItem(nl[i].parentNode.parentNode) // treeitem
+                    );
+                }
+                if (clear) { obj.refresh_ordinals_timeout_id = null; }
+            }
+
+            // spamming this to cover race conditions
+            setTimeout(_refresh_ordinals, 500); // for speedy looking UI updates
+            setTimeout(_refresh_ordinals, 2000); // for most uses
+            obj.refresh_ordinals_timeout_id = setTimeout(
                 function() {
-                    var nl = obj.node.getElementsByAttribute('label','_');
-                    for (var i = 0; i < nl.length; i++) {
-                        nl[i].setAttribute(
-                            'ord_col',
-                            'true'
-                        );
-                        nl[i].setAttribute( // treecell properties for css styling
-                            'properties',
-                            'ordinal'
-                        );
-                    }
-                    nl = obj.node.getElementsByAttribute('ord_col','true');
-                    for (var i = 0; i < nl.length; i++) {
-                        nl[i].setAttribute(
-                            'label',
-                            // we could just use 'i' here if we trust the order of elements
-                            1 + obj.node.contentView.getIndexOfItem(nl[i].parentNode.parentNode) // treeitem
-                        );
-                    }
-                }, 1000
+                    _refresh_ordinals(true);
+                },
+                4000 // just in case, say with a slow rendering list
             );
+
         } catch(E) {
             alert('Error in list.js, refresh_ordinals(): ' + E);
         }
@@ -973,6 +989,7 @@ util.list.prototype = {
             case 'tree' : obj._full_retrieve_tree(params); break;
             default: throw('NYI: Need .full_retrieve() for ' + obj.node.nodeName); break;
         }
+        obj.refresh_ordinals();
     },
 
     '_full_retrieve_tree' : function(params) {

-----------------------------------------------------------------------

Summary of changes:
 Open-ILS/web/opac/locale/en-US/lang.dtd            |    5 +
 .../xul/staff_client/chrome/content/util/list.js   |  327 +++++++++++++++-----
 .../xul/staff_client/chrome/content/util/sort.js   |   21 ++
 .../staff_client/server/OpenILS/util_overlay.xul   |    7 +
 4 files changed, 284 insertions(+), 76 deletions(-)
 create mode 100644 Open-ILS/xul/staff_client/chrome/content/util/sort.js


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list