allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [39/50] git commit: [#7051] Admin tools paging fixes/improvements
Date Tue, 25 Mar 2014 14:27:37 GMT
[#7051] Admin tools paging fixes/improvements

- Stay on same page when changing grouping threshold
- Fix broken tool drag n drop sorting
- Redirect to last page when new tool installed

Signed-off-by: Tim Van Steenburgh <tvansteenburgh@gmail.com>


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

Branch: refs/heads/db/5995
Commit: 7fbafb6fde6cc1033498aafb2205fce4af40ffbe
Parents: 3a265bd
Author: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Authored: Wed Mar 19 19:56:43 2014 +0000
Committer: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Committed: Wed Mar 19 19:56:43 2014 +0000

----------------------------------------------------------------------
 Allura/allura/ext/admin/admin_main.py            | 19 +++++++++++--------
 .../ext/admin/templates/project_tools.html       |  6 +++---
 Allura/allura/public/nf/js/project_tools.js      |  8 ++++++--
 3 files changed, 20 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/7fbafb6f/Allura/allura/ext/admin/admin_main.py
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/admin/admin_main.py b/Allura/allura/ext/admin/admin_main.py
index 696f14d..e889b29 100644
--- a/Allura/allura/ext/admin/admin_main.py
+++ b/Allura/allura/ext/admin/admin_main.py
@@ -261,7 +261,7 @@ class ProjectAdminController(BaseController):
 
     @without_trailing_slash
     @expose('jinja:allura.ext.admin:templates/project_tools.html')
-    def tools(self, page=0, limit=200, **kw):
+    def tools(self, page=None, limit=200, **kw):
         c.markdown_editor = W.markdown_editor
         c.label_edit = W.label_edit
         c.mount_delete = W.mount_delete
@@ -270,7 +270,7 @@ class ProjectAdminController(BaseController):
         c.page_list = W.page_list
         mounts = c.project.ordered_mounts()
         total_mounts = len(mounts)
-        limit, page = h.paging_sanitizer(limit, page, total_mounts)
+        limit, page = h.paging_sanitizer(limit, page or total_mounts / int(limit), total_mounts)
         start = page * limit
         return dict(
             page=page,
@@ -284,7 +284,7 @@ class ProjectAdminController(BaseController):
 
     @expose()
     @require_post()
-    def configure_tool_grouping(self, grouping_threshold='1', **kw):
+    def configure_tool_grouping(self, grouping_threshold='1', page=0, limit=200, **kw):
         try:
             grouping_threshold = int(grouping_threshold)
             if grouping_threshold < 1:
@@ -293,7 +293,7 @@ class ProjectAdminController(BaseController):
                 'allura', grouping_threshold=grouping_threshold)
         except ValueError:
             flash('Invalid threshold', 'error')
-        redirect('tools')
+        redirect('tools?limit=%s&page=%s' % (limit, page))
 
     @expose()
     @require_post()
@@ -679,20 +679,23 @@ class ProjectAdminController(BaseController):
                 h.log_action(log, 'install tool').info(
                     'install tool %s', mount_point,
                     meta=dict(tool_type=ep_name, mount_point=mount_point, mount_label=new['mount_label']))
-                c.project.install_app(
+                return c.project.install_app(
                     ep_name, mount_point, mount_label=new['mount_label'], ordinal=new['ordinal'])
         g.post_event('project_updated')
 
     @h.vardec
     @expose()
     @require_post()
-    def update_mounts(self, subproject=None, tool=None, new=None, **kw):
+    def update_mounts(self, subproject=None, tool=None, new=None, page=0, limit=200, **kw):
         try:
-            self._update_mounts(subproject, tool, new, **kw)
+            new_app = self._update_mounts(subproject, tool, new, **kw)
+            if new_app:
+                # force redir to last page of tools, where new app will be
+                page = ''
         except forge_exc.ForgeError, exc:
             flash('%s: %s' % (exc.__class__.__name__, exc.args[0]),
                   'error')
-        redirect('tools')
+        redirect('tools?limit=%s&page=%s' % (limit, page))
 
     @expose('jinja:allura.ext.admin:templates/export.html')
     def export(self, tools=None):

http://git-wip-us.apache.org/repos/asf/allura/blob/7fbafb6f/Allura/allura/ext/admin/templates/project_tools.html
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/admin/templates/project_tools.html b/Allura/allura/ext/admin/templates/project_tools.html
index 60b4d89..a51f750 100644
--- a/Allura/allura/ext/admin/templates/project_tools.html
+++ b/Allura/allura/ext/admin/templates/project_tools.html
@@ -43,8 +43,8 @@
       </a>
     </span>
   </div>
-  <form method="post" action="update_mounts" id="install_form" style="display:none">
-    <input type="hidden" name="new.ordinal" value="{{installable_tools|length + c.project.direct_subprojects|length}}"/>
+  <form method="post" action="update_mounts?limit={{limit}}&page={{page}}" id="install_form"
style="display:none">
+    <input type="hidden" name="new.ordinal" value="{{total_mounts}}"/>
     <input type="hidden" name="new.ep_name" class="new_ep_name">
     <label class="grid-13">Label</label>
     <div class="grid-13"><input type="text" name="new.mount_label" class="new_mount_label"></div>
@@ -162,7 +162,7 @@
 <div><!--dummy-->
 
 <h3 style="clear:left">Grouping</h3>
-<form method="POST" action="configure_tool_grouping" id="configure_grouping_form">
+<form method="POST" action="configure_tool_grouping?limit={{limit}}&page={{page}}"
id="configure_grouping_form">
     <label>Threshold for grouping tools by type:
         <input name="grouping_threshold" value="{{c.project.get_tool_data('allura', 'grouping_threshold',
1)}}"/>
     </label>

http://git-wip-us.apache.org/repos/asf/allura/blob/7fbafb6f/Allura/allura/public/nf/js/project_tools.js
----------------------------------------------------------------------
diff --git a/Allura/allura/public/nf/js/project_tools.js b/Allura/allura/public/nf/js/project_tools.js
index b02554b..4e4ab46 100644
--- a/Allura/allura/public/nf/js/project_tools.js
+++ b/Allura/allura/public/nf/js/project_tools.js
@@ -96,18 +96,22 @@
         var tools = 0;
         var subs = 0;
         var params = {'_session_id':$.cookie('_session_id')};
+        var action = $('#install_form').attr('action');
+        var limit = action.match(/limit=(\d+)/)[1];
+        var page = action.match(/page=(\d+)/)[1];
+        var first_tool_ordinal = parseInt(limit) * parseInt(page);
         for (var i = 0, len = sortables.length; i < len; i++) {
             var item = $(sortables[i]);
             var mount_point = item.find('input.mount_point');
             var shortname = item.find('input.shortname');
             if (mount_point.length) {
                 params['tools-' + tools + '.mount_point'] = mount_point.val();
-                params['tools-' + tools + '.ordinal'] = i;
+                params['tools-' + tools + '.ordinal'] = i + first_tool_ordinal;
                 tools++;
             }
             if (shortname.length) {
                 params['subs-' + subs + '.shortname'] = shortname.val();
-                params['subs-' + subs + '.ordinal'] = i;
+                params['subs-' + subs + '.ordinal'] = i + first_tool_ordinal;
                 subs++;
             }
         }


Mime
View raw message