From: Steven Chan Date: Thu, 18 Sep 2014 17:51:07 +0000 (-0700) Subject: Refine the rendering of myopac account summary table and dashboard X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=c34f04592c14da5dd3d70f229ee0f1307ff42276;p=contrib%2Foverdrive-eg-opac.git Refine the rendering of myopac account summary table and dashboard Before, the table and dashboard were built to show empty e-item entries that would sit there while the user waits for the several API requests to finish before the total values were available to be placed in the entries. Now, the entries are built and shown after values are available. A solid gray bar shows in the dashboard during the wait interval. We would have shown a progress bar, but it's too hard to get it to show because of interference from the existing style sheet. The first column of the summary table shows totals for physical items and was suppressed until the arrival of totals for e-items, but in fact the totals of physical items are already available from the old table. Now, we show them immediately, and we don't show the second column at all until it is filled with values. Signed-off-by: Steven Chan --- diff --git a/src/od_pages_myopac.coffee b/src/od_pages_myopac.coffee index b658d54..beea96a 100644 --- a/src/od_pages_myopac.coffee +++ b/src/od_pages_myopac.coffee @@ -23,25 +23,29 @@ define [ _dashboard: (x) -> if arguments.length is 0 + @append $('
') + else # Add a new dashboard for to show counts of e-items; start with # zero counts base = '/eg/opac/myopac' - @append """ - - """ + @find 'div' + .eq 2 + .append """ + + 0 E-items Checked Out + + | + + 0 E-items on Hold + + | + + 0 E-items Ready for Checkout + + """ + .end() + .end() # The following sequence is necessary to align the new dashboard # with the existing ones, but do not know why it needs to be done @@ -49,24 +53,24 @@ define [ .css float: 'none' .end() - else @_counters x # Change the values of the counters + return @ # Replace account summary area with one that shows links to go to - # e-items lists + # physical and e-items lists _account_summary: (x) -> if arguments.length is 0 # Parse a list of totals of physical items from the account summary table totals = ( +(v.textContent.match(/\d+?/)[0]) for v in @find('td').not '[align="right"]' ) - tpl = """ + tpl = _.template """ - Items Currently Checked out + <%= ncheckouts %> Items Currently Checked out @@ -75,7 +79,7 @@ define [ - Items Currently on Hold + <%= nholds %> Items Currently on Hold E-items Currently on Hold @@ -83,7 +87,7 @@ define [ - Items ready for pickup + <%= nready %> Items ready for pickup E-items ready for pickup @@ -91,11 +95,32 @@ define [ """ - @empty().append tpl - return totals + + # Build a new table consisting of two columns. The first + # column is for physical items with the existing totals. The + # second column is for e-items and is initially hidden until + # its total values are available. + @empty() + .append tpl + ncheckouts: totals[0] + nholds: totals[1] + nready: totals[2] + .find 'td' + .filter '[align="right"]' + .find 'a' + .hide() + .end() + .end() else - @_counters x # Change the values of the counters + # Change the values of the counters and reveal the e-items column + @_counters x + .find 'td' + .filter '[align="right"]' + .find 'a' + .show() + .end() + .end() # Relabel a history tab _tab_history: -> diff --git a/src/overdrive.coffee b/src/overdrive.coffee index ace8f18..4d23d42 100644 --- a/src/overdrive.coffee +++ b/src/overdrive.coffee @@ -147,14 +147,11 @@ require [ 'myopac\/main': ( $table = $('.acct_sum_table') ) -> return unless $table.length - totals = $table._account_summary() + $table._account_summary() od.$.on 'od.interests', (ev, x) -> $table._account_summary - ncheckouts: totals[0] - nholds: totals[1] - nready: totals[2] n_checkouts: x.nCheckouts n_holds: x.nHolds n_ready: x.nHoldsReady