From: helge Date: Fri, 5 Aug 2005 10:32:06 +0000 (+0000) Subject: use WODisplayGroup/.woo X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e13bc6e3d6549e0ee2de7b461d0e6e1ac6d94ac8;p=sope use WODisplayGroup/.woo git-svn-id: http://svn.opengroupware.org/SOPE/trunk@977 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- diff --git a/sope-appserver/samples/CoreDataBlog/ChangeLog b/sope-appserver/samples/CoreDataBlog/ChangeLog index db972003..2a7d436c 100644 --- a/sope-appserver/samples/CoreDataBlog/ChangeLog +++ b/sope-appserver/samples/CoreDataBlog/ChangeLog @@ -1,3 +1,7 @@ +2005-08-05 Helge Hess + + * changed to use WODisplayGroup and .woo to access database + 2005-08-03 Helge Hess * moved reusable objects to sope-core/EOCoreData diff --git a/sope-appserver/samples/CoreDataBlog/Main.m b/sope-appserver/samples/CoreDataBlog/Main.m index 1c4eef72..3e3026c3 100644 --- a/sope-appserver/samples/CoreDataBlog/Main.m +++ b/sope-appserver/samples/CoreDataBlog/Main.m @@ -45,5 +45,17 @@ /* 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 */ diff --git a/sope-appserver/samples/CoreDataBlog/Main.wo/Main.html b/sope-appserver/samples/CoreDataBlog/Main.wo/Main.html index 7632fe12..37f198fd 100644 --- a/sope-appserver/samples/CoreDataBlog/Main.wo/Main.html +++ b/sope-appserver/samples/CoreDataBlog/Main.wo/Main.html @@ -5,20 +5,73 @@ -

SOPE CoreData Test

+ + + -Ctx: <#Test/>
+ + +
+
+ <#PostCount/> Posts + <#Posts> + <#IsPostSelected><#PostTitle/> + <#IsPostNotSelected> + <#PostSelectLink><#PostTitle/> + +
+ +
+ <#AddPost >add | + <#DeletePost>delete | + <#RefetchPosts>reload +
+
+ Post: <#SelectedPostTitle/> + <#PostForm> + + + + + + + + + + + + + -
- <#Entities> -
  • <#Entity/>
  • - -
    - <#Posts> -
  • <#Post/>
  • - + + + + + + +
    Title + <#TitleEditField/> +
    Author + <#AuthorEditField/> +
    Topic + <#TopicEditField/> +
    Body
    + <#BodyEditField/> +
    + +
    +
    -
    + +
    + + Ctx: <#Test/>
    + <#Entities> + <#Entity/>
    + +
    + +
    Helge Hess
    diff --git a/sope-appserver/samples/CoreDataBlog/Main.wo/Main.wod b/sope-appserver/samples/CoreDataBlog/Main.wo/Main.wod index 43417408..41aafcba 100644 --- a/sope-appserver/samples/CoreDataBlog/Main.wo/Main.wod +++ b/sope-appserver/samples/CoreDataBlog/Main.wo/Main.wod @@ -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 index 00000000..0d66ebef --- /dev/null +++ b/sope-appserver/samples/CoreDataBlog/Main.wo/Main.woo @@ -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:"; + } + ); + }; + }; +} diff --git a/sope-appserver/samples/CoreDataBlog/Session.m b/sope-appserver/samples/CoreDataBlog/Session.m index c6525470..06cf2955 100644 --- a/sope-appserver/samples/CoreDataBlog/Session.m +++ b/sope-appserver/samples/CoreDataBlog/Session.m @@ -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];