Permalink
Browse files

adding drag to assign

  • Loading branch information...
rauhryan committed Dec 27, 2012
1 parent 4df1610 commit cc5b544a09137f3bfdb3d717222d9a5f2ebb71b3
View
@@ -30,6 +30,10 @@ class API < Sinatra::Base
json pebble.reorder_milestone params[:user], params[:repo], milestone["number"], params[:index], params[:status]
end
+ post '/:user/:repo/assigncard' do
+ publish "#{params[:user]}/#{params[:repo]}", "Assigned.#{params[:issue][:number]}", { issue:params[:issue], assignee: params[:assignee]}
+ json pebble.assign_card params[:user], params[:repo], params[:issue], params[:assignee]
+ end
post '/:user/:repo/movecard' do
publish "#{params[:user]}/#{params[:repo]}", "Moved.#{params[:issue][:number]}", { issue:params[:issue], index: params[:index]}
json pebble.move_card params[:user], params[:repo], params[:issue], params[:index]
@@ -95,6 +95,9 @@
background-color: #fff;
border: 1px solid #e5e5e5;
border-bottom-color: darken(#e5e5e5, 5%);
+ &.assignee-accept {
+ border-color: blue;
+ }
&.dim {
opacity: 0.5;
@include transition (opacity 0.6s, ease-out);
@@ -19,4 +19,18 @@
font-size: 24px;
}
}
+.assignee {
+ list-style: none;
+ line-height: 40px;
+ float:left;
+ margin:0 2px;
+}
+.page-header-wrapper {
+ ol {
+ margin: 0;
+ padding: 0;
+ float: right;
+ list-style: none;
+ }
+}
@@ -25,6 +25,16 @@ define(["../events/postal"],function(postal){
//console.log("closed issue", data.index);
});
},
+ assign: function(assignee){
+ this.attributes.assignee = assignee;
+ $.post("/api/" + this.attributes.repo.owner.login + "/" + this.attributes.repo.name + "/assigncard",{
+ issue: this.attributes,
+ assignee: assignee.login
+ }, function(response) {
+
+ });
+
+ },
reorder: function(data) {
$.post("/api/" + this.attributes.repo.owner.login + "/" + this.attributes.repo.name + "/reorderissue",{
index: data.order,
@@ -0,0 +1,3 @@
+<li class="assignee" data-login="<%= login %>">
+ <img src="https://secure.gravatar.com/avatar/<%= gravatar_id %>?s=24" title="<%=login %>" alt="<%= login %>"/>
+</li>
@@ -64,7 +64,7 @@ define(["../collections/issues","text!../templates/board.html", "./columnView","
noneColumn = _.first(data.labels),
rest = _.rest(data.labels),
sidebar = new sidebarView({data:data,params:this.params}),
- searchView = new headerView(),
+ searchView = new headerView({data:data, params: this.params}),
self = this;
$(noneBoard).append(new columnView({column: noneColumn, user:this.user,repo:this.repo}).render().el);
@@ -4,7 +4,7 @@ define(["text!../templates/card.html","../models/card", "../events/postal"],func
initialize: function ( params ) {
this.issue = new card({model:params.issue, user:params.user,repo: params.repo});
_.bind(this,'moved',this.moved);
- _.bind(this,'drop',this.drop);
+ _.bind(this,'reorder',this.drop);
postal.subscribe("Filter.Simple", $.proxy(this.simpleFilter, this));
postal.subscribe("Filter.Complex", $.proxy(this.complexFilter, this));
postal.socket(params.user + "/" + params.repo,"Moved." + params.issue.number, $.proxy(this.onMoved,this));
@@ -15,7 +15,8 @@ define(["text!../templates/card.html","../models/card", "../events/postal"],func
events: {
"moved" : "moved",
"click .close": "closed",
- "drop" : "drop"
+ "drop": "dropped",
+ "reorder" : "drop"
},
tagName:"li",
onMoved: function(data){
@@ -27,6 +28,7 @@ define(["text!../templates/card.html","../models/card", "../events/postal"],func
},
render: function(){
$(this.el).html( _.template(template, this.issue.attributes))
+ .droppable({scope:"assignee",hoverClass:"assignee-accept"})
.data("issue",this.issue.attributes);
if(this.issue.attributes.repo.color){
@@ -45,6 +47,14 @@ define(["text!../templates/card.html","../models/card", "../events/postal"],func
moved: function(ev,index){
this.issue.save({index: index});
},
+ dropped: function(ev, ui){
+ console.log("i got dropped yo!",ev, ui);
+ console.log($(ui.draggable).data("login"));
+ this.issue.assign($(ui.draggable).data("assignee"));
+ console.log(this.issue.attributes);
+ this.render();
+
+ },
closed: function(ev, index){
ev.preventDefault();
this.issue.close({index: index});
@@ -85,18 +85,18 @@ define(["text!../templates/column.html","./cardView","../events/postal"],functio
// dragged it to the top
currentData._data.order = (after || 1)/2;
currentElement
- .trigger("drop", currentData._data.order)
+ .trigger("reorder", currentData._data.order)
.data("issue", currentData);
} else if (last) {
// dragged to the bottom
currentData._data.order = (before + 1);
currentElement
- .trigger("drop", currentData._data.order)
+ .trigger("reorder", currentData._data.order)
.data("issue", currentData);
} else {
currentData._data.order = (((after + before) || 1)/2);
currentElement
- .trigger("drop", currentData._data.order)
+ .trigger("reorder", currentData._data.order)
.data("issue", currentData);
}
}
@@ -1,12 +1,13 @@
-define(["../events/postal"], function(postal){
+define(["../events/postal", "text!../templates/assignee.html"], function(postal, template){
return Backbone.View.extend({
- el: $(".header"),
+ el: $(".page-header-wrapper"),
events: {
"keyup input" : "onkeyup"
},
- initialize: function(){
+ initialize: function(options){
var self = this;
+ self.data = options.data;
this.publish = _.debounce(function() {
var val = $(self.el).find("input").val();
@@ -15,6 +16,16 @@ define(["../events/postal"], function(postal){
}, state:2});
}, 300);
+ self.render();
+ },
+ render: function() {
+ var list = $(this.el).find("ol");
+ var users = _(this.data.assignees).chain().map(function(assignee) {
+ return $(_.template(template, assignee)).data("assignee",assignee);
+ }).value();
+ list.append(users);
+ list.find("li").draggable({helper:"clone",scope: "assignee", zIndex:100, appendTo: 'body'});
+ return this;
},
onkeyup : function(ev){
this.publish();
@@ -44,6 +44,10 @@ def create_label(user_name, repo, params)
gh.repos(user_name, repo).labels.create(params)
end
+ def assignees(user_name, repo)
+ gh.repos(user_name,repo).assignees.all
+ end
+
def milestones(user_name, repo)
response = get_issues user_name, repo
reply = response.group_by { |issue| issue["milestone"] }.map do |milestone, issues|
@@ -83,6 +83,7 @@ def board(user_name, repo)
board[:other_labels] = board[:other_labels].group_by { |l| l["name"].downcase }.map{|k,v| v.first }
board[:milestones] = board[:milestones].group_by { |l| l["title"].downcase }.map{|k,v| v.first }
+ board[:assignees] = github.assignees(user_name, repo).map{|a| a}
return board
end
@@ -225,6 +226,10 @@ def push_card(user_name, repo, commit)
github.update_issue user_name, repo, {"number" => issue["number"],"labels" => issue["labels"]}
end
+ def assign_card(user_name, repo, the_issue, assignee)
+ github.update_issue user_name, repo, {"number" => the_issue["number"], "assignee" => assignee}
+ end
+
def move_card(user_name, repo, the_issue, index)
labels = github.labels user_name, repo
View
@@ -15,9 +15,9 @@
<% end %>
<% content_for :header do %>
- <ul class="assignees">
+ <ol class="assignees">
- </ul>
+ </ol>
<h1 class="header">
<span class="author"><%= h @parameters[:user] %></span>
/

0 comments on commit cc5b544

Please sign in to comment.