From: helge Date: Mon, 3 Oct 2005 21:29:02 +0000 (+0000) Subject: improved WODisplayGroup X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2f9cc52294892b6ac6ed628a6bf6310c42cef3de;p=sope improved WODisplayGroup git-svn-id: http://svn.opengroupware.org/SOPE/trunk@1150 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- diff --git a/sope-appserver/NGObjWeb/ChangeLog b/sope-appserver/NGObjWeb/ChangeLog index df658e8b..af6c1430 100644 --- a/sope-appserver/NGObjWeb/ChangeLog +++ b/sope-appserver/NGObjWeb/ChangeLog @@ -1,3 +1,9 @@ +2005-10-03 Helge Hess + + * WODisplayGroup.m: added -qualifyDataSourceAndReturnDisplayCount + method to support qualification via .wod, make use of -isNotEmpty + (v4.5.204) + 2005-09-29 Marcus Mueller * DynamicElements/_WOComplexHyperlink.m: changed diff --git a/sope-appserver/NGObjWeb/Version b/sope-appserver/NGObjWeb/Version index 8f2506ec..46ce5de7 100644 --- a/sope-appserver/NGObjWeb/Version +++ b/sope-appserver/NGObjWeb/Version @@ -1,6 +1,6 @@ # version file -SUBMINOR_VERSION:=203 +SUBMINOR_VERSION:=204 # v4.5.122 requires libNGExtensions v4.5.153 # v4.5.91 requires libNGExtensions v4.5.134 diff --git a/sope-appserver/NGObjWeb/WODirectActionRequestHandler.m b/sope-appserver/NGObjWeb/WODirectActionRequestHandler.m index e9b1e930..94b29305 100644 --- a/sope-appserver/NGObjWeb/WODirectActionRequestHandler.m +++ b/sope-appserver/NGObjWeb/WODirectActionRequestHandler.m @@ -110,7 +110,6 @@ static Class NSDateClass = Nil; inContext:context]; [context setPage:(id)component]; - /* TODO: why was that commented out? */ if ([component shouldTakeValuesFromRequest:[context request] inContext:context]) [app takeValuesFromRequest:[context request] inContext:context]; diff --git a/sope-appserver/NGObjWeb/WODisplayGroup.m b/sope-appserver/NGObjWeb/WODisplayGroup.m index 31f7710e..ae3e58ef 100644 --- a/sope-appserver/NGObjWeb/WODisplayGroup.m +++ b/sope-appserver/NGObjWeb/WODisplayGroup.m @@ -324,10 +324,10 @@ static NSArray *uint0Array = nil; - (id)selectNext { unsigned int idx; - if ([self->displayObjects count] == 0) + if (![self->displayObjects isNotEmpty]) return nil; - if ([self->selectionIndexes count] == 0) { + if (![self->selectionIndexes isNotEmpty]) { [self setSelectionIndexes:uint0Array]; return nil; } @@ -348,10 +348,10 @@ static NSArray *uint0Array = nil; - (id)selectPrevious { unsigned int idx; - if ([self->displayObjects count] == 0) + if (![self->displayObjects isNotEmpty]) return nil; - if ([self->selectionIndexes count] == 0) { + if (![self->selectionIndexes isNotEmpty]) { [self setSelectionIndexes:uint0Array]; return nil; } @@ -511,9 +511,8 @@ static NSArray *uint0Array = nil; /* should try to restore selection */ [self clearSelection]; - if ([_objects count] > 0 && [self selectsFirstObjectAfterFetch]) { + if ([_objects isNotEmpty] && [self selectsFirstObjectAfterFetch]) [self setSelectionIndexes:uint0Array]; - } } - (NSArray *)allObjects { @@ -543,11 +542,11 @@ static NSArray *uint0Array = nil; } [self updateDisplayedObjects]; - + if ([self selectsFirstObjectAfterFetch]) { [self clearSelection]; - if ([objs count] > 0) + if ([objs isNotEmpty]) [self setSelectedObject:[objs objectAtIndex:0]]; } @@ -700,7 +699,7 @@ static NSArray *uint0Array = nil; [q release]; } - if ([quals count] == 0) + if (![quals isNotEmpty]) return nil; if ([quals count] == 1) return [quals objectAtIndex:0]; @@ -809,36 +808,64 @@ static NSArray *uint0Array = nil; - (void)qualifyDataSource { EODataSource *ds; EOQualifier *q; + NSDictionary *bindings; - ds = [self dataSource]; + if ((ds = [self dataSource]) == nil) + [self warnWithFormat:@"no datasource set: %@", NSStringFromSelector(_cmd)]; + + /* build qualifier */ if ((q = [self qualifierFromQueryValues]) != nil) [self setQualifier:q]; - if ([ds respondsToSelector:@selector(setAuxiliaryQualifier:)]) + /* set qualifier in datasource */ + + if ([ds respondsToSelector:@selector(setAuxiliaryQualifier:)]) { [ds setAuxiliaryQualifier:[self qualifier]]; + //[self logWithFormat:@"set aux qualifier in %@: %@", ds,[self qualifier]]; + } else if ([ds respondsToSelector:@selector(setQualifier:)]) [ds setQualifier:[self qualifier]]; else { /* could not qualify ds */ + [self warnWithFormat:@"could not qualify datasource: %@", ds]; } - if ([ds respondsToSelector:@selector(setQualifierBindings:)]) - [ds setQualifierBindings:[self queryBindings]]; + /* set bindings in datasource */ + + if ([(bindings = [self queryBindings]) isNotEmpty]) { + if ([ds respondsToSelector:@selector(setQualifierBindings:)]) + [ds setQualifierBindings:bindings]; + else { + [self warnWithFormat:@"could not set bindings in datasource %@: %@", + ds, bindings]; + } + } + + /* perform fetch */ + /* action method, returns 'nil' to stay on page */ [self fetch]; if ([self inQueryMode]) [self setInQueryMode:NO]; } +- (id)qualifyDataSourceAndReturnDisplayCount { + /* + This is a 'hack' created because we can't bind (and therefore 'call') + 'void' methods in .wod files. + */ + [self qualifyDataSource]; + return [NSNumber numberWithUnsignedInt:[[self displayedObjects] count]]; +} /* object creation */ - (id)insert { unsigned idx; - idx = [self->selectionIndexes count] > 0 + idx = [self->selectionIndexes isNotEmpty] ? ([[self->selectionIndexes objectAtIndex:0] unsignedIntValue] + 1) : [self->objects count];