Permalink
Browse files

add sortability to the pull request table

  • Loading branch information...
Scott Reis
Scott Reis committed Aug 23, 2013
1 parent 2cce540 commit 0ce3533e5806aba279c8bfd4694aaa2f903b0add
View
@@ -16,3 +16,5 @@ rerun.txt
pickle-email-*.html
*.swp
/builds/
+/.idea/
+*.iml
@@ -19,6 +19,7 @@
//= require backbone_datalink
//= require backbone_rails_sync
//= require backbone/chrysalis
+//= require sortable
//= require_tree .
$(document).ready(function() {
@@ -30,9 +30,10 @@ class Chrysalis.Routers.ReposRouter extends Backbone.Router
@view = new Chrysalis.Views.Repos.ShowView(model: repo)
@view.listenTo this, 'tick', =>
repo.fetch success: ->
- repo.fetchRelated('pull_requests', {}, true)
+ repo.fetchRelated('pull_requests', {success: -> $.bootstrapSortable(true)}, true)
$("#repos").html(@view.render().el)
+ $.bootstrapSortable(true)
edit: (id) ->
@view?.remove()
@@ -25,7 +25,7 @@
<td><a href="<%= url %>" target="_blank"><%= title %></a></td>
<td><img width=32 height=32 src="<%= user_avatar_url %>" /> <%= user_login %></td>
-<td><%= jQuery.timeago(github_updated_at) %></td>
+<td data-value="<%= github_updated_at %>"><%= jQuery.timeago(github_updated_at) %></td>
<td><span class="status badge <%= statusClass %>"><%= loader %> <%= statusMsg %></span></td>
<td>
@@ -1,14 +1,15 @@
<h1><%= owner %>/<%= name %></h1>
-<table id="pull-requests" class="table">
- <tr>
+<table id="pull-requests" class="table sortable">
+ <thead>
<th>Pull Request</th>
<th>Author</th>
- <th>Updated</th>
+ <th data-defaultsort="desc">Updated</th>
<th>Build Status</th>
<th>JIRA Status</th>
<th></th>
- </tr>
+ </thead>
+ <tbody></tbody>
</table>
@@ -16,7 +16,7 @@ class Chrysalis.Views.Repos.ShowView extends Backbone.View
addPullRequest: (pullRequest) =>
view = new Chrysalis.Views.PullRequests.PullRequestView({model : pullRequest})
- @$("#pull-requests tr th").parent().eq(0).after(view.render().el)
+ @$("#pull-requests tbody").prepend(view.render().el)
render: ->
$(@el).html(@template(@model.toJSON() ))
@@ -10,5 +10,6 @@
*
*= require_self
*= require bootstrap_and_overrides
+ *= require sortable
*= require_tree .
*/

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,34 @@
+table.sortable span.arrow {
+ border-style: solid;
+ border-width: 5px;
+ display: block;
+ position: absolute;
+ top: 50%;
+ right: 5px;
+ font-size: 0;
+ border-color: #ccc transparent transparent transparent;
+ line-height: 0;
+ height: 0;
+ width: 0;
+ margin-top: -2px;
+}
+
+ table.sortable span.arrow.up {
+ border-color: transparent transparent #ccc transparent;
+ margin-top: -7px;
+ }
+
+table.sortable thead th {
+ cursor: pointer;
+ position: relative;
+ top: 0;
+ left: 0;
+}
+
+ table.sortable thead th:hover:not([data-defaultsort=disabled]) {
+ background: #efefef;
+ }
+
+ table.sortable thead th div.mozilla {
+ position: relative;
+ }

0 comments on commit 0ce3533

Please sign in to comment.