mirror of
https://github.com/cincheo/jsweet.git
synced 2026-02-07 14:06:35 +00:00
enable again backbone candy test
This commit is contained in:
parent
9e67490474
commit
aa1af6ad6c
@ -244,6 +244,14 @@
|
||||
<scope>test</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jsweet.candies.ext</groupId>
|
||||
<artifactId>backbone</artifactId>
|
||||
<version>1.3.0-SNAPSHOT</version>
|
||||
<scope>test</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- <dependency>
|
||||
<groupId>org.jsweet.candies</groupId>
|
||||
@ -252,13 +260,6 @@
|
||||
<scope>test</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jsweet.candies</groupId>
|
||||
<artifactId>j4ts</artifactId>
|
||||
<version>0.1.0</version>
|
||||
<scope>test</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jsweet.candies</groupId>
|
||||
<artifactId>node</artifactId>
|
||||
@ -280,20 +281,6 @@
|
||||
<scope>test</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jsweet.candies</groupId>
|
||||
<artifactId>jquery</artifactId>
|
||||
<version>1.10.0-SNAPSHOT</version>
|
||||
<scope>test</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jsweet.candies</groupId>
|
||||
<artifactId>jqueryui</artifactId>
|
||||
<version>1.9.0-SNAPSHOT</version>
|
||||
<scope>test</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jsweet.candies</groupId>
|
||||
<artifactId>angular</artifactId>
|
||||
@ -308,13 +295,6 @@
|
||||
<scope>test</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jsweet.candies</groupId>
|
||||
<artifactId>backbone</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<scope>test</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jsweet.candies</groupId>
|
||||
<artifactId>threejs-three</artifactId>
|
||||
|
||||
@ -1,118 +1,118 @@
|
||||
package source.candies;
|
||||
|
||||
//import static jsweet.util.Globals.function;
|
||||
//import static jsweet.util.Globals.union;
|
||||
//
|
||||
//import java.util.function.Function;
|
||||
//
|
||||
//import def.backbone.backbone.Collection;
|
||||
//import def.backbone.backbone.Model;
|
||||
//import def.backbone.backbone.ObjectHash;
|
||||
//import jsweet.util.Globals;
|
||||
import static jsweet.util.Globals.function;
|
||||
import static jsweet.util.Globals.union;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import def.backbone.backbone.Collection;
|
||||
import def.backbone.backbone.Model;
|
||||
import def.backbone.backbone.ObjectHash;
|
||||
import jsweet.util.Globals;
|
||||
|
||||
public class BackboneCandy {
|
||||
|
||||
}
|
||||
|
||||
//class TodoStruct extends ObjectHash {
|
||||
// public String content;
|
||||
// public int order;
|
||||
// public boolean done;
|
||||
//}
|
||||
//
|
||||
//// Our basic **Todo** model has `content`, `order`, and `done` attributes.
|
||||
//class Todo extends Model {
|
||||
//
|
||||
// // Default attributes for the todo.
|
||||
// @Override
|
||||
// public TodoStruct defaults() {
|
||||
// return new TodoStruct() {
|
||||
// {
|
||||
// content = "empty todo...";
|
||||
// done = false;
|
||||
// }
|
||||
// };
|
||||
// }
|
||||
//
|
||||
// // Ensure that each todo created has `content`.
|
||||
// @Override
|
||||
// public void initialize() {
|
||||
// if (this.get("content") == null) {
|
||||
// this.set(new TodoStruct() {
|
||||
// {
|
||||
// content = defaults().content;
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Toggle the `done` state of this todo item.
|
||||
// public void toggle() {
|
||||
// this.save(new TodoStruct() {
|
||||
// {
|
||||
// done = !(boolean) get("done");
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// // Remove this Todo from *localStorage* and delete its view.
|
||||
// @Override
|
||||
// public Object clear() {
|
||||
// return this.destroy();
|
||||
// }
|
||||
//
|
||||
//}
|
||||
//
|
||||
//class TodoList extends Collection<Todo> {
|
||||
//
|
||||
// // Reference to this collection's model.
|
||||
// Class<Todo> model = Todo.class;
|
||||
//
|
||||
// Function<String, String> test;
|
||||
//
|
||||
// // Save all of the todo items under the `"todos"` namespace.
|
||||
// // TODO: the Store class in backbone does not define any parameter in the
|
||||
// // constructor... maybe a mistake in the original TypeScript exammle, which
|
||||
// // declare the Store class as an "any" variable...
|
||||
// // Store localStorage = new Store("todos-backbone");
|
||||
// // Store localStorage = new Store("todos-backbone");
|
||||
//
|
||||
// // Filter down the list of all todo items that are finished.
|
||||
// Todo[] done() {
|
||||
// return this.filter((todo, i, __) -> {
|
||||
// return (Boolean) todo.get("done");
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// // Filter down the list to only todo items that are still not finished.
|
||||
// // TODO: this is wrong... there is a problem with varargs... to be
|
||||
// // investigated
|
||||
// Todo[] remaining() {
|
||||
// return this.without(Globals.any(this.done()));
|
||||
// }
|
||||
//
|
||||
// // We keep the Todos in sequential order, despite being saved by unordered
|
||||
// // GUID in the database. This generates the next order number for new items.
|
||||
// int nextOrder() {
|
||||
// if (this.length == 0)
|
||||
// return 1;
|
||||
// return (Integer) this.last().get("order") + 1;
|
||||
// }
|
||||
//
|
||||
// {
|
||||
// comparator = union(function((Todo todo) -> {
|
||||
// return (Integer) todo.get("order");
|
||||
// }));
|
||||
// }
|
||||
//
|
||||
//}
|
||||
//
|
||||
//class Child extends TodoList {
|
||||
//
|
||||
// {
|
||||
// test = (String s) -> {
|
||||
// return "";
|
||||
// };
|
||||
// }
|
||||
//
|
||||
//}
|
||||
class TodoStruct extends ObjectHash {
|
||||
public String content;
|
||||
public int order;
|
||||
public boolean done;
|
||||
}
|
||||
|
||||
// Our basic **Todo** model has `content`, `order`, and `done` attributes.
|
||||
class Todo extends Model {
|
||||
|
||||
// Default attributes for the todo.
|
||||
@Override
|
||||
public TodoStruct defaults() {
|
||||
return new TodoStruct() {
|
||||
{
|
||||
content = "empty todo...";
|
||||
done = false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Ensure that each todo created has `content`.
|
||||
@Override
|
||||
public void initialize() {
|
||||
if (this.get("content") == null) {
|
||||
this.set(new TodoStruct() {
|
||||
{
|
||||
content = defaults().content;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Toggle the `done` state of this todo item.
|
||||
public void toggle() {
|
||||
this.save(new TodoStruct() {
|
||||
{
|
||||
done = !(boolean) get("done");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Remove this Todo from *localStorage* and delete its view.
|
||||
@Override
|
||||
public Object clear() {
|
||||
return this.destroy();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class TodoList extends Collection<Todo> {
|
||||
|
||||
// Reference to this collection's model.
|
||||
Class<Todo> model = Todo.class;
|
||||
|
||||
Function<String, String> test;
|
||||
|
||||
// Save all of the todo items under the `"todos"` namespace.
|
||||
// TODO: the Store class in backbone does not define any parameter in the
|
||||
// constructor... maybe a mistake in the original TypeScript exammle, which
|
||||
// declare the Store class as an "any" variable...
|
||||
// Store localStorage = new Store("todos-backbone");
|
||||
// Store localStorage = new Store("todos-backbone");
|
||||
|
||||
// Filter down the list of all todo items that are finished.
|
||||
Todo[] done() {
|
||||
return this.filter((todo, i, __) -> {
|
||||
return (Boolean) todo.get("done");
|
||||
});
|
||||
}
|
||||
|
||||
// Filter down the list to only todo items that are still not finished.
|
||||
// TODO: this is wrong... there is a problem with varargs... to be
|
||||
// investigated
|
||||
Todo[] remaining() {
|
||||
return this.without(Globals.any(this.done()));
|
||||
}
|
||||
|
||||
// We keep the Todos in sequential order, despite being saved by unordered
|
||||
// GUID in the database. This generates the next order number for new items.
|
||||
int nextOrder() {
|
||||
if (this.length == 0)
|
||||
return 1;
|
||||
return (Integer) this.last().get("order") + 1;
|
||||
}
|
||||
|
||||
{
|
||||
comparator = union(function((Todo todo) -> {
|
||||
return (Integer) todo.get("order");
|
||||
}));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Child extends TodoList {
|
||||
|
||||
{
|
||||
test = (String s) -> {
|
||||
return "";
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user