+2005-08-05 Helge Hess <helge.hess@opengroupware.org>
+
+ * changed to use WODisplayGroup and .woo to access database
+
2005-08-03 Helge Hess <helge.hess@opengroupware.org>
* moved reusable objects to sope-core/EOCoreData
/* accessors */
+/* actions */
+
+- (id)selectPost {
+ [[self valueForKey:@"postDisplayGroup"]
+ selectObject:[self valueForKey:@"post"]];
+
+#if 0 // this is not a detail ds
+ [[self valueForKey:@"authorDisplayGroup"]
+ setMasterObject:[self valueForKey:@"post"]];
+#endif
+ return nil;
+}
@end /* Main */
</head>
<body>
- <h1>SOPE CoreData Test</h1>
+ <table border="0" width="100%">
+ <tr>
+ <td valign="top" width="30%">
+ <fieldset style="height: 400px;">
+ <legend><#PostCount/> Posts</legend>
+ <#Posts>
+ <#IsPostSelected><b><#PostTitle/></b></#IsPostSelected>
+ <#IsPostNotSelected>
+ <#PostSelectLink><#PostTitle/></#PostSelectLink>
+ </#IsPostNotSelected>
+ <br />
+ </#Posts>
+ </fieldset>
+ <#AddPost >add</#AddPost> |
+ <#DeletePost>delete</#DeletePost> |
+ <#RefetchPosts>reload</#RefetchPosts>
+ </td>
-Ctx: <#Test/><br />
+ <td valign="top">
+ <fieldset style="height: 400px;">
+ <legend>Post: <#SelectedPostTitle/></legend>
+ <#PostForm>
+ <table border="0" width="100%" cellspacing="4">
+ <tr>
+ <td width="25%" valign="top">Title</td>
+ <td valign="top">
+ <#TitleEditField/>
+ </td>
+ </tr>
+ <tr>
+ <td width="25%" valign="top">Author</td>
+ <td valign="top">
+ <#AuthorEditField/>
+ </td>
+ </tr>
+ <tr>
+ <td width="25%" valign="top">Topic</td>
+ <td valign="top">
+ <#TopicEditField/>
+ </td>
+ </tr>
-<hr />
- <#Entities>
- <li><#Entity/></li>
- </#Entities>
-<hr />
- <#Posts>
- <li><#Post/></li>
- </#Posts>
+ <tr>
+ <td valign="top" colspan="2">Body</td>
+ </tr>
+ <tr>
+ <td valign="top" colspan="2">
+ <#BodyEditField/>
+ </td>
+ </tr>
+ </table>
+ </#PostForm>
+ </fieldset>
+ </td>
+ </tr>
+ </table>
- <hr>
+
+ <hr />
+ <small>
+ Ctx: <#Test/><br />
+ <#Entities>
+ <#Entity/><br />
+ </#Entities>
+ </small>
+
+ <hr/>
<address
><a href="mailto:helge.hess@opengroupware.org">Helge Hess</a></address>
</body>
value = item.name;
}
-
+PostCount: WOString {
+ value = postDisplayGroup.allObjects.@count;
+}
Posts: WORepetition {
- list = session.posts;
- item = item;
+ list = postDisplayGroup.displayedObjects;
+ item = post;
+}
+
+PostSelectLink: WOHyperlink {
+ action = selectPost;
+}
+
+PostTitle: WOString {
+ value = post.title;
+ valueWhenEmpty = "[no title]";
+}
+
+IsPostSelected: WOConditional {
+ condition = postDisplayGroup.selectedObject;
+ value = post;
+}
+IsPostNotSelected: WOConditional {
+ condition = postDisplayGroup.selectedObject;
+ value = post;
+ negate = YES;
+}
+
+// form
+
+PostForm: WOForm {
}
-Post: WOString {
- value = item.title;
+SelectedPostTitle: WOString {
+ value = postDisplayGroup.selectedObject.title;
+}
+
+TitleEditField: WOTextField {
+ value = postDisplayGroup.selectedObject.title;
+ style = "width: 100%;";
+}
+
+AuthorEditField: WOPopUpButton {
+ list = authorDisplayGroup.allObjects;
+ item = author;
+ string = author.name;
+ selection = postDisplayGroup.selectedObject.author;
+ style = "width: 100%;";
+}
+
+TopicEditField: WOPopUpButton {
+ list = topicDisplayGroup.allObjects;
+ item = topic;
+ string = topic.title;
+ selection = postDisplayGroup.selectedObject.topic;
+ style = "width: 100%;";
+}
+
+BodyEditField: WOText {
+ rows = 12;
+ style = "height: 200px; width: 100%;";
+ value = postDisplayGroup.selectedObject.body;
+}
+
+// posts
+
+AddPost: WOHyperlink {
+ action = postDisplayGroup.insert;
+}
+DeletePost: WOHyperlink {
+ action = postDisplayGroup.delete;
+}
+RefetchPosts: WOHyperlink {
+ action = postDisplayGroup.fetch;
}
--- /dev/null
+{
+ variables = {
+ postDisplayGroup = {
+ class = WODisplayGroup;
+ dataSource = {
+ class = EOCoreDataSource;
+ editingContext = session.defaultManagedObjectContext;
+ fetchSpecification = {
+ class = EOFetchSpecification;
+ entityName = Post;
+ fetchLimit = 0;
+ isDeep = YES;
+ sortOrderings = (
+ { class = EOSortOrdering;
+ key = "title";
+ selector = "compareAscending:";
+ /* Tiger?: selector = "compareCaseInsensitiveAscending:"; */
+ }
+ );
+ };
+ };
+ formatForLikeQualifier = "%@*";
+ localKeys = ();
+ numberOfObjectsPerBatch = 0;
+ selectsFirstObjectAfterFetch = YES;
+ fetchesOnLoad = YES;
+ };
+
+ authorDisplayGroup = {
+ class = WODisplayGroup;
+ dataSource = {
+ class = EOCoreDataSource;
+ editingContext = session.defaultManagedObjectContext;
+ fetchSpecification = {
+ class = EOFetchSpecification;
+ entityName = Author;
+ };
+ };
+ fetchesOnLoad = YES;
+ formatForLikeQualifier = "*%@*";
+ localKeys = ();
+ numberOfObjectsPerBatch = 30;
+ selectsFirstObjectAfterFetch = YES;
+ sortOrdering = ( // proper position?
+ {
+ class = EOSortOrdering;
+ key = name;
+ selectorName = "compareAscending:";
+ }
+ );
+ };
+
+ topicDisplayGroup = {
+ class = WODisplayGroup;
+ dataSource = {
+ class = EOCoreDataSource;
+ editingContext = session.defaultManagedObjectContext;
+ fetchSpecification = {
+ class = EOFetchSpecification;
+ entityName = Topic;
+ };
+ };
+ fetchesOnLoad = YES;
+ formatForLikeQualifier = "*%@*";
+ localKeys = ();
+ numberOfObjectsPerBatch = 30;
+ selectsFirstObjectAfterFetch = YES;
+ sortOrdering = ( // proper position?
+ {
+ class = EOSortOrdering;
+ key = title;
+ selectorName = "compareAscending:";
+ }
+ );
+ };
+ };
+}
[fs setEntity:[[[[self application] managedObjectModel]
entitiesByName] objectForKey:@"Post"]];
- [self logWithFormat:@"entity: %@", [fs entity]];
+ // [self logWithFormat:@"entity: %@", [fs entity]];
a = [[self defaultManagedObjectContext] executeFetchRequest:fs error:&error];
[self logWithFormat:@"a: %@", a];