allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject git commit: [#6865] sort categories on template and as added by JS
Date Mon, 11 Nov 2013 19:54:46 GMT
Updated Branches:
  refs/heads/db/6865 [created] 37e900160


[#6865] sort categories on template and as added by JS


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

Branch: refs/heads/db/6865
Commit: 37e90016034cf2e4379afd009b5e2b971b428898
Parents: f1c9240
Author: Dave Brondsema <dbrondsema@slashdotmedia.com>
Authored: Mon Nov 11 19:54:36 2013 +0000
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Mon Nov 11 19:54:36 2013 +0000

----------------------------------------------------------------------
 .../allura/ext/admin/templates/project_trove.html | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/37e90016/Allura/allura/ext/admin/templates/project_trove.html
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/admin/templates/project_trove.html b/Allura/allura/ext/admin/templates/project_trove.html
index bcd557d..dc6c074 100644
--- a/Allura/allura/ext/admin/templates/project_trove.html
+++ b/Allura/allura/ext/admin/templates/project_trove.html
@@ -25,7 +25,7 @@
 {% macro show_trove_base_cat(base) %}
   <h3>{{base.fullname}}</h3>
   <div id="trove_existing_{{base.shortname}}" class="trove_existing grid-19">
-    {% for cat in c.project.troves_by_type(base.shortname) %}
+    {% for cat in c.project.troves_by_type(base.shortname)|sort(attribute='fullname') %}
     <div style="clear: both">
       <span class="trove_fullpath">{{cat.fullpath}}</span>
       <form id="delete_trove_{{base.shortname}}_{{cat.trove_cat_id}}"
@@ -97,8 +97,20 @@
               });
             }
             else{
-              $('#trove_existing_'+type).find('span.empty_msg').remove();
-              $('#trove_existing_'+type).prepend('<div><span class="trove_fullpath">'+resp.trove_full_path+'</span>
<form class="trove_deleter"><input type="hidden" name="type" value="'+type+'"><input
type="hidden" name="trove" value="'+new_id+'">'+del_btn+'</form></div>');
+              var $existing = $('#trove_existing_'+type);
+              $existing.find('span.empty_msg').remove();
+              var insertAfter = null;
+              $existing.children().each(function() {
+                if($('.trove_fullpath', this).text() < resp.trove_full_path) {
+                    insertAfter = this;
+                }
+              });
+              var $newItem = $('<div><span class="trove_fullpath">'+resp.trove_full_path+'</span>
<form class="trove_deleter"><input type="hidden" name="type" value="'+type+'"><input
type="hidden" name="trove" value="'+new_id+'">'+del_btn+'</form></div>');
+              if (insertAfter) {
+                $newItem.insertAfter(insertAfter);
+              } else {
+                $newItem.prependTo($existing);
+              }
             }
         });
       });


Mime
View raw message