Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

- Assigning default points = 0 to new Feature

- Trying to figure out why KO is firing updateFeature twice on points change
  • Loading branch information...
commit 154da293de01b9e2fefda4cd298f110e62810f4f 1 parent 69beb90
Arafat Mohamed authored
3  model.rb
@@ -31,7 +31,8 @@ def self.create(user, title)
31 31 f = Feature.new(:title => title,
32 32 :status => "Backlog",
33 33 :state => "Ready",
34   - :complete => false)
  34 + :complete => false,
  35 + :points => 0)
35 36 f.comments << Comment.new(:user => user,
36 37 :comment => "Created Feature")
37 38 if f.save
31 public/css/kokanban.css
@@ -60,14 +60,13 @@ div {
60 60 font-weight: 900;
61 61 border: 1px solid black;
62 62 margin-right: .5em;
63   - }
64   - input.points {
65   - width: 3em;
  63 + padding: 0.1em;
66 64 }
67 65 a.complete {
68 66 background-color: #F33;
69 67 border: 1px solid black;
70   - padding: 5px;
  68 + padding: .1em;
  69 + margin: 1em;
71 70 }
72 71 a.swim {
73 72 color: blue;
@@ -76,6 +75,7 @@ div {
76 75 }
77 76 input.newComment {
78 77 width: 100%;
  78 + height: 5em;
79 79 }
80 80 /* README */
81 81 table#readme {
@@ -91,24 +91,11 @@ div {
91 91 margin-left: 1em;
92 92 padding-left: 1em;
93 93 }
94   - .container::after {
95   - content: ".";
96   - display: block;
97   - height: 0;
98   - clear: both;
99   - visibility: hidden;
100   -}
101   -.container .left {
102   - float: left;
103   -}
104   -.container .right {
105   - float: right;
106   -}
107 94 /* HEADER */
108 95 div#header {
109 96 background-color: #03889C;
110 97 color: #FFF;
111   - padding: 2em;
  98 + padding: 0.5em;
112 99 }
113 100 div#header div#logout a {
114 101 color: #FFF;
@@ -117,10 +104,14 @@ div {
117 104 div#newfeature {
118 105 background-color: #00C322;
119 106 color: #FFF;
120   - padding: 1em;
  107 + padding: 0.5em;
  108 + }
  109 + div#newfeature label {
  110 + width: 15%;
  111 + text-align: right
121 112 }
122 113 div#newfeature input#newfeature {
123   - width: 50%;
  114 + width: 85%;
124 115 }
125 116 /* Login */
126 117 form#login {
17 public/js/kokanban.js
... ... @@ -1,5 +1,6 @@
1 1 var statuses = [ "Backlog", "Analysis", "Dev", "Verify", "Release" ];
2 2 var states = [ "Ready", "Progress", "Impeded" ];
  3 +var pointss = ["0", "1", "2", "3", "5", "8", "13"]
3 4
4 5 var Comment = function(comment, user, created_at) {
5 6 this.comment = comment;
@@ -13,20 +14,22 @@ var Feature = function(id, title, status, state, complete, points) {
13 14 self.id = id;
14 15 self.title = ko.observable(title);
15 16 self.status = ko.observable(status);
16   - self.state = ko.observable(state);
17 17 self.points = ko.observable(points);
18 18 self.points.edit = ko.dependentObservable({
19 19 read: self.points,
20 20 write: function(newpoints) {
21   - self.updateFeature('/feature/'+self.id+'/points',
22   - { "points": newpoints });
  21 + console.log("updating points from "+self.points()+"to "+newpoints);
  22 + self.updateFeature('/feature/'+self.id+'/points',
  23 + { "points": newpoints });
23 24 }
24 25 });
  26 + self.state = ko.observable(state);
25 27 self.state.edit = ko.dependentObservable({
26 28 read: self.state,
27 29 write: function(newstate) {
28   - self.updateFeature('/feature/'+self.id+'/state',
29   - { "state": newstate });
  30 + console.log("updating state");
  31 + self.updateFeature('/feature/'+self.id+'/state',
  32 + { "state": newstate });
30 33 }
31 34 });
32 35 self.complete = ko.observable(complete);
@@ -56,6 +59,7 @@ var Feature = function(id, title, status, state, complete, points) {
56 59 data: { "comment": newComment },
57 60 dataType: 'json',
58 61 success: function(f) {
  62 + console.log(url +": "+data);
59 63 self.title(f.title);
60 64 self.status(f.status);
61 65 self.state(f.state);
@@ -81,6 +85,7 @@ var Feature = function(id, title, status, state, complete, points) {
81 85 data: data,
82 86 dataType: 'json',
83 87 success: function(f) {
  88 + console.log(url+": "+ko.toJSON(data));
84 89 self.title(f.title);
85 90 self.status(f.status);
86 91 self.state(f.state);
@@ -155,6 +160,7 @@ var viewModel = {
155 160 data: { "feature": newFeature },
156 161 dataType: 'json',
157 162 success: function(feature) {
  163 + console.log(url);
158 164 var f = new Feature(feature.id, feature.title, feature.status,
159 165 feature.state, feature.complete, feature.points);
160 166 var cm = feature.comments[0];
@@ -199,6 +205,7 @@ $(document).ajaxStart(function(){
199 205 $('#dialog-progress').show();
200 206 }).ajaxStop(function(){
201 207 $('#dialog-progress').hide();
  208 + $(".details").hide();
202 209 });
203 210
204 211 /*
1  public/js/seed.js
@@ -3,6 +3,7 @@ $.getJSON("/features/working", function(data) {
3 3 $.each(data, function(fk, fv) {
4 4 var f = new Feature(fv.id, fv.title, fv.status,
5 5 fv.state, fv.complete, fv.points);
  6 + console.log(ko.toJSON(f));
6 7 $.each(fv.comments, function(ck, cv) {
7 8 f.comments.unshift(new Comment(cv.comment, cv.user, cv.created_at));
8 9 });
5 views/index.erb
@@ -46,12 +46,11 @@
46 46
47 47 <script id="features" type="text/html">
48 48 <div data-bind="attr:{ 'class': state }">
49   - <span class="points" data-bind="text: points" />
50 49 <a class="showComment" data-bind="text: title, click: function(e) { showDetails(e) }" />
51 50 <div class="details" data-bind="visible: false">
52   - <input class="points" data-bind="value: points.edit" />
  51 + <select data-bind="options: pointss, value: points.edit" />
53 52 <select data-bind="options: states, value: state.edit" />
54   - <a class="clear complete" data-bind="click: completion">Complete</a>
  53 + <a class="complete" data-bind="click: completion">Complete</a>
55 54 <form data-bind="submit: addComment">
56 55 <input id="newComment" class='newComment' />
57 56 </form>

0 comments on commit 154da29

Please sign in to comment.
Something went wrong with that request. Please try again.