Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

a few fixes in the models/todo app

  • Loading branch information...
commit 303fbbf0886a47a7cd4a015fe735fdadfcb2bdf0 1 parent 8003576
@tonylukasavage tonylukasavage authored
View
1  test/apps/models/todo/alloy.js
@@ -0,0 +1 @@
+Alloy.Collections.todo = Alloy.createCollection('todo');
View
2  test/apps/models/todo/controllers/row.js
@@ -1,4 +1,4 @@
-var moment = require('moment');
+var moment = require('alloy/moment');
var todos = Alloy.Collections.todo;
var id;
View
39 test/apps/models/todo/models/todo.js
@@ -1,4 +1,4 @@
-var moment = require('moment');
+var moment = require('alloy/moment');
exports.definition = {
config: {
@@ -39,43 +39,10 @@ exports.definition = {
extendCollection : function(Collection) {
_.extend(Collection.prototype, {
- comparator: function(todo) {
+ comparator: function(todo) {
return todo.get('done');
- },
-
- /**
- * returns all objects that were completed today
- */
- completedToday : function(_options) { debugger;
- var self = this;
-
- // this can be more elegant, but kept it simple for demo purposes
- //
- // db.execute("SELECT FROM " + table + " " + opts.query.sql, opts.query.params);
- //
- var yesterday, tomorrow, today;
-
- // get today and reset to midnight
- yesterday = moment().hours(0).minutes(0).seconds(1).subtract('days', 1);
- tomorrow = moment().hours(0).minutes(0).seconds(1).add('days', 1);
-
- // debug information
- Ti.API.info("today " + moment().hours(0).minutes(0).seconds(1).calendar());
- Ti.API.info("yesterday " + yesterday.calendar());
- Ti.API.info("tomorrow " + tomorrow.calendar());
-
- var p = [];
- p.push(yesterday.unix() +"");
- p.push(tomorrow.unix() +"");
- // pass params
- _options['query'] = {
- "sql" : 'WHERE date_completed between ? AND ?',
- "params" : p
- };
- self.fetch(_options);
- },
+ }
});
- // end extend
return Collection;
}
View
3  test/apps/models/todo/views/index.xml
@@ -1,7 +1,4 @@
<Alloy>
- <!-- Todo collection for binding (singleton) -->
- <Collection src="todo"/>
-
<!-- Main Window -->
<Window id="todoWin" title="Todo">
Please sign in to comment.
Something went wrong with that request. Please try again.