Permalink
Browse files

Added ability to move a story to the top.

--HG--
branch : positions
  • Loading branch information...
tathamoddie committed Aug 30, 2011
1 parent 9f920fd commit 0f4bb8bb14d4321aca70e446ef382da799dca5ad
View
@@ -85,6 +85,16 @@ public void SetUserStoryColor(int storyId, string color)
});
}
+ public void SetUserStoryPosition(int storyId, int position)
+ {
+ ExecutePut(
+ string.Format("userstory/{0}", storyId),
+ x =>
+ {
+ x.Element("position").Value = position.ToString();
+ });
+ }
+
UserStory GetUserStory(int userStoryId)
{
return ExecuteRequest(
@@ -8,5 +8,6 @@ public interface IApiClient
IEnumerable<Project> GetAllProjects();
IEnumerable<UserStory> GetBacklog(int projectId);
void SetUserStoryColor(int storyId, string color);
+ void SetUserStoryPosition(int storyId, int position);
}
}
@@ -27,5 +27,13 @@ public ActionResult SetColor(int storyId, string color)
apiClient.SetUserStoryColor(storyId, color);
return new HttpStatusCodeResult((int) HttpStatusCode.OK);
}
+
+ [Authorize]
+ [HttpPost]
+ public ActionResult SetPosition(int storyId, int position)
+ {
+ apiClient.SetUserStoryPosition(storyId, position);
+ return new HttpStatusCodeResult((int)HttpStatusCode.OK);
+ }
}
}
View
@@ -31,6 +31,9 @@ public static void RegisterRoutes(RouteCollection routes)
routes.MapRoute(RouteNames.StorySetColor,
"projects/{projectId}/backlog/{storyId}/set-color",
new { controller = "Story", action = "SetColor" });
+ routes.MapRoute(RouteNames.StorySetPosition,
+ "projects/{projectId}/backlog/{storyId}/set-position",
+ new { controller = "Story", action = "SetPosition" });
}
protected void Application_Start()
View
@@ -8,5 +8,6 @@ public static class RouteNames
public const string ListProjects = "list-projects";
public const string Backlog = "backlog";
public const string StorySetColor = "story-set-color";
+ public const string StorySetPosition = "story-set-position";
}
}
View
@@ -15,6 +15,7 @@ $(function () {
contextMenu.append($('<li><a href="#color-red">Red</a></li>'));
contextMenu.append($('<li><a href="#color-green">Green</a></li>'));
contextMenu.append($('<li><a href="#color-blue">Blue</a></li>'));
+ contextMenu.append($('<li class="separator"><a href="#move-to-top">Move to Top</a></li>'));
contextMenu.insertAfter(backlogTable);
backlogTable
@@ -28,6 +29,8 @@ $(function () {
if (colorAction) {
var newColor = colorAction[1];
setStoryColor(element, storyId, newColor);
+ } else if (action === "move-to-top") {
+ setStoryPosition(element, storyId, 0);
}
}
);
@@ -47,4 +50,15 @@ function setStoryColor(storyElement, storyId, newColor) {
storyElement.addClass('story-color-' + newColor);
}
);
+}
+
+function setStoryPosition(storyElement, storyId, newPosition) {
+ storyElement = $(storyElement);
+ $.post(
+ 'backlog/' + storyId + '/set-position',
+ 'position=' + newPosition,
+ function () {
+ // TODO: need to move the actual element
+ }
+ );
}

0 comments on commit 0f4bb8b

Please sign in to comment.