incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tvansteenbu...@apache.org
Subject [14/50] [abbrv] git commit: [#5112] ticket:270 Load milestone counts asynchronously
Date Mon, 25 Feb 2013 21:56:17 GMT
[#5112] ticket:270 Load milestone counts asynchronously


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/fb84e076
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/fb84e076
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/fb84e076

Branch: refs/heads/si/5453
Commit: fb84e0763600ed77964c7cdcb473f96ab03d7764
Parents: cb0892c
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Fri Feb 15 12:19:43 2013 +0000
Committer: Cory Johns <johnsca@geek.net>
Committed: Wed Feb 20 23:45:37 2013 +0000

----------------------------------------------------------------------
 ForgeTracker/forgetracker/tracker_main.py |   30 +++++++++++++++++++++--
 1 files changed, 27 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/fb84e076/ForgeTracker/forgetracker/tracker_main.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tracker_main.py b/ForgeTracker/forgetracker/tracker_main.py
index d83466c..cc477d6 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -234,7 +234,7 @@ class ForgeTrackerApp(Application):
                     SitemapEntry(
                         h.text.truncate(m.name, 72),
                         self.url + fld.name[1:] + '/' + h.urlquote(m.name) + '/',
-                        small=c.app.globals.milestone_count('%s:%s' % (fld.name, m.name))['hits']))
+                        className='milestones'))
 
         links = []
         if has_access(self, 'create')():
@@ -263,7 +263,7 @@ class ForgeTrackerApp(Application):
         return """\
         $(function() {
             $.ajax({
-                url:'%sbin_counts',
+                url:'%(app_url)sbin_counts',
                 success: function(data) {
                     $.each(data.bin_counts, function(i, item) {
                         var $span = $('.search_bin span:contains("' + item.label + '")');
@@ -273,7 +273,20 @@ class ForgeTrackerApp(Application):
                     });
                 }
             });
-        });""" % c.app.url
+            if ($('.milestones').length > 0) {
+                $.ajax({
+                    url: '%(app_url)smilestone_counts',
+                    success: function(data) {
+                        $.each(data.milestone_counts, function(i, item) {
+                            var $span = $('.milestones span:contains("' + item.name + '")');
+                            if ($span) {
+                                $span.after('<small>' + item.count + '</small>').fadeIn('fast');
+                            }
+                        });
+                    }
+                });
+            }
+        });""" % {'app_url': c.app.url}
 
     def has_custom_field(self, field):
         '''Checks if given custom field is defined. (Custom field names
@@ -456,6 +469,17 @@ class RootController(BaseController):
             bin_counts.append(dict(label=label, count=count))
         return dict(bin_counts=bin_counts)
 
+    @expose('json:')
+    def milestone_counts(self, *args, **kw):
+        milestone_counts = []
+        for fld in c.app.globals.milestone_fields:
+            for m in getattr(fld, "milestones", []):
+                if m.complete: continue
+                count = c.app.globals.milestone_count('%s:%s' % (fld.name, m.name))['hits']
+                name = h.text.truncate(m.name, 72)
+                milestone_counts.append({'name': name, 'count': count})
+        return {'milestone_counts': milestone_counts}
+
     @with_trailing_slash
     @h.vardec
     @expose('jinja:forgetracker:templates/tracker/index.html')


Mime
View raw message