Permalink
Browse files

Backlog: Add new story UI

Make a for-the-time-being UI for adding
a new story to the backlog.
  • Loading branch information...
1 parent 59451e9 commit ba3e9d98dffdcd232246c94c78332e5c24d741b1 @philip-morning committed Feb 28, 2014
Showing with 42 additions and 7 deletions.
  1. +7 −2 app/public/css/app.css
  2. +27 −5 app/public/js/controllers/home.js
  3. +8 −0 app/public/partials/home.html
View
@@ -55,6 +55,7 @@ h2, h3 {
/* home */
#backlog {
+ margin-top: 2.5em;
background-color: #eee;
}
.story {
@@ -72,15 +73,19 @@ h2, h3 {
}
-#backlog .selected input {
+#backlog .selected input, #new-story input {
margin: 0;
}
-#backlog .not-selected {
+#backlog .not-selected, #new-story {
padding-top: 1.1ex;
padding-bottom: 1.1ex;
}
+#new-story form {
+ margin: 0;
+}
+
/* admin */
#userList {
@@ -1,10 +1,23 @@
function HomeCtrl($scope, $timeout, $document) {
+ var nextStoryId = undefined;
+ var getNewStoryId = function() {
+ // TODO: Should move to the server, obvi,
+ // but works for now.
+ if (!nextStoryId) {
+ nextStoryId = 1;
+ }
+ else {
+ nextStoryId++;
+ }
+ return nextStoryId;
+ };
+
var selectedStory = undefined;
var stories = [];
for (var i=0; i < 10; i++) {
stories[i] = {
- id: i,
+ id: getNewStoryId(),
summary: "Story"
}
}
@@ -42,7 +55,16 @@ function HomeCtrl($scope, $timeout, $document) {
// }
};
- $scope.$on('$viewContentLoaded', function() {
+ $scope.create = function (newStory) {
+ newStory.id = getNewStoryId();
+ stories.unshift(newStory);
+
+ $scope.newStory = undefined;
+ // TODO:
+ // activateDragAndDrop();
+ };
+
+ var activateDragAndDrop = function () {
// Even though we're waiting for viewContentLoaded,
// I guess we need to yield to whatever else is happening.
$timeout(function () {
@@ -137,10 +159,10 @@ function HomeCtrl($scope, $timeout, $document) {
}
}
});
-
-
});
}, 0);
- });
+ };
+
+ $scope.$on('$viewContentLoaded', activateDragAndDrop);
}
HomeCtrl.$inject = ['$scope', '$timeout', '$document'];
@@ -1,5 +1,13 @@
<p>:-)</p>
+<div id="new-story" class="story">
+ <form>
+ <span>+</span>
+ <input type="text"
+ ng-model="newStory.summary"/>
+ <button class="btn" ng-click="create(newStory)">Add story</button>
+ </form>
+</div>
<div id="backlog" ng-click="deselectAll()">
<div class="story" ng-repeat="story in stories" ng-click="select(story)"
ng-class="{

0 comments on commit ba3e9d9

Please sign in to comment.