]> err.no Git - sope/commitdiff
use WODisplayGroup/.woo
authorhelge <helge@e4a50df8-12e2-0310-a44c-efbce7f8a7e3>
Fri, 5 Aug 2005 10:32:06 +0000 (10:32 +0000)
committerhelge <helge@e4a50df8-12e2-0310-a44c-efbce7f8a7e3>
Fri, 5 Aug 2005 10:32:06 +0000 (10:32 +0000)
git-svn-id: http://svn.opengroupware.org/SOPE/trunk@977 e4a50df8-12e2-0310-a44c-efbce7f8a7e3

sope-appserver/samples/CoreDataBlog/ChangeLog
sope-appserver/samples/CoreDataBlog/Main.m
sope-appserver/samples/CoreDataBlog/Main.wo/Main.html
sope-appserver/samples/CoreDataBlog/Main.wo/Main.wod
sope-appserver/samples/CoreDataBlog/Main.wo/Main.woo [new file with mode: 0644]
sope-appserver/samples/CoreDataBlog/Session.m

index db972003f48bf125f99ecb68cb6cfdfdbd3cdad8..2a7d436c9b5e6970baf58e9f3914d4b9cc74303f 100644 (file)
@@ -1,3 +1,7 @@
+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
index 1c4eef72fd21c518af424abbea6f068d50a51b49..3e3026c33adfd987f5e72f86907cf538e872f514 100644 (file)
 
 /* 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 */
index 7632fe12d3a680c3c31ebd24b2ca01e37b165553..37f198fd2d61910579479eb4a67c136e2e201737 100644 (file)
@@ -5,20 +5,73 @@
   </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>
index 434174089794ebf9e1ff1f5b844d21c37f15b7a9..41aafcba93468af517e7d98187ab07c61e747c66 100644 (file)
@@ -13,12 +13,77 @@ Entity: WOString {
   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;
 }
diff --git a/sope-appserver/samples/CoreDataBlog/Main.wo/Main.woo b/sope-appserver/samples/CoreDataBlog/Main.wo/Main.woo
new file mode 100644 (file)
index 0000000..0d66ebe
--- /dev/null
@@ -0,0 +1,77 @@
+{
+  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:";
+        }
+      ); 
+    }; 
+  };
+}
index c65254704f186d16a24e2f6a071002cc0d5758b0..06cf2955b6b4121535b344c5b72656dea8e7f25d 100644 (file)
@@ -39,7 +39,7 @@
   
   [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];