Browse Source

Fixed remaining count.

Herbert Vojčík 12 years ago
parent
commit
e7285aed3f
3 changed files with 49 additions and 18 deletions
  1. 17 6
      js/Trapped-Demo.deploy.js
  2. 26 10
      js/Trapped-Demo.js
  3. 6 2
      st/Trapped-Demo.st

+ 17 - 6
js/Trapped-Demo.deploy.js

@@ -39,9 +39,7 @@ smalltalk.method({
 selector: "archive",
 fn: function (){
 var self=this;
-smalltalk.send(self,"_todos_",[smalltalk.send(smalltalk.send(self,"_todos",[]),"_reject_",[(function(each){
-return smalltalk.send(each,"_at_",["done"]);
-})])]);
+smalltalk.send(self,"_todos_",[smalltalk.send(self,"_todosNotDone",[])]);
 return self}
 }),
 smalltalk.AppModel);
@@ -53,9 +51,7 @@ selector: "remaining",
 fn: function (){
 var self=this;
 var $1;
-$1=smalltalk.send(smalltalk.send(smalltalk.send(self,"_todos",[]),"_select_",[(function(each){
-return smalltalk.send(each,"_at_",["done"]);
-})]),"_size",[]);
+$1=smalltalk.send(smalltalk.send(self,"_todosNotDone",[]),"_size",[]);
 return $1;
 }
 }),
@@ -127,6 +123,21 @@ return self}
 }),
 smalltalk.AppModel);
 
+smalltalk.addMethod(
+"_todosNotDone",
+smalltalk.method({
+selector: "todosNotDone",
+fn: function (){
+var self=this;
+var $1;
+$1=smalltalk.send(smalltalk.send(self,"_todos",[]),"_reject_",[(function(each){
+return smalltalk.send(each,"_at_",["done"]);
+})]);
+return $1;
+}
+}),
+smalltalk.AppModel);
+
 
 
 smalltalk.addClass('AppView', smalltalk.Widget, [], 'Trapped-Demo');

+ 26 - 10
js/Trapped-Demo.js

@@ -52,13 +52,11 @@ selector: "archive",
 category: 'action',
 fn: function (){
 var self=this;
-smalltalk.send(self,"_todos_",[smalltalk.send(smalltalk.send(self,"_todos",[]),"_reject_",[(function(each){
-return smalltalk.send(each,"_at_",["done"]);
-})])]);
+smalltalk.send(self,"_todos_",[smalltalk.send(self,"_todosNotDone",[])]);
 return self},
 args: [],
-source: "archive\x0a    self todos: (self todos reject: [ :each | each at: 'done' ])",
-messageSends: ["todos:", "reject:", "at:", "todos"],
+source: "archive\x0a    self todos: self todosNotDone",
+messageSends: ["todos:", "todosNotDone"],
 referencedClasses: []
 }),
 smalltalk.AppModel);
@@ -71,14 +69,12 @@ category: 'accessing',
 fn: function (){
 var self=this;
 var $1;
-$1=smalltalk.send(smalltalk.send(smalltalk.send(self,"_todos",[]),"_select_",[(function(each){
-return smalltalk.send(each,"_at_",["done"]);
-})]),"_size",[]);
+$1=smalltalk.send(smalltalk.send(self,"_todosNotDone",[]),"_size",[]);
 return $1;
 },
 args: [],
-source: "remaining\x0a    ^(self todos select: [ :each | each at: 'done' ]) size",
-messageSends: ["size", "select:", "at:", "todos"],
+source: "remaining\x0a    ^self todosNotDone size",
+messageSends: ["size", "todosNotDone"],
 referencedClasses: []
 }),
 smalltalk.AppModel);
@@ -179,6 +175,26 @@ referencedClasses: []
 }),
 smalltalk.AppModel);
 
+smalltalk.addMethod(
+"_todosNotDone",
+smalltalk.method({
+selector: "todosNotDone",
+category: 'accessing',
+fn: function (){
+var self=this;
+var $1;
+$1=smalltalk.send(smalltalk.send(self,"_todos",[]),"_reject_",[(function(each){
+return smalltalk.send(each,"_at_",["done"]);
+})]);
+return $1;
+},
+args: [],
+source: "todosNotDone\x0a    ^self todos reject: [ :each | each at: 'done' ]",
+messageSends: ["reject:", "at:", "todos"],
+referencedClasses: []
+}),
+smalltalk.AppModel);
+
 
 
 smalltalk.addClass('AppView', smalltalk.Widget, [], 'Trapped-Demo');

+ 6 - 2
st/Trapped-Demo.st

@@ -78,7 +78,7 @@ function TodoCtrl($scope) {
 !AppModel methodsFor: 'accessing'!
 
 remaining
-    ^(self todos select: [ :each | each at: 'done' ]) size
+    ^self todosNotDone size
 !
 
 title
@@ -103,6 +103,10 @@ todos
 
 todos: anArray
 	todos := anArray
+!
+
+todosNotDone
+    ^self todos reject: [ :each | each at: 'done' ]
 ! !
 
 !AppModel methodsFor: 'action'!
@@ -113,7 +117,7 @@ addTodo
 !
 
 archive
-    self todos: (self todos reject: [ :each | each at: 'done' ])
+    self todos: self todosNotDone
 ! !
 
 Widget subclass: #AppView