From: helge Date: Tue, 27 Sep 2005 12:31:31 +0000 (+0000) Subject: fixed a bug in selection management X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2bea39a205e96920d2a6946baf3995cb6a4aab06;p=sope fixed a bug in selection management git-svn-id: http://svn.opengroupware.org/SOPE/trunk@1130 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- diff --git a/sope-appserver/NGObjWeb/ChangeLog b/sope-appserver/NGObjWeb/ChangeLog index 842a98b4..de2a8e7d 100644 --- a/sope-appserver/NGObjWeb/ChangeLog +++ b/sope-appserver/NGObjWeb/ChangeLog @@ -1,3 +1,10 @@ +2005-09-27 Helge Hess + + * DynamicElements/WOPopUpButton.m: fixed a bug in the 'selection' which + occurred when the element is being used with the 'value' binding + (returned the last item instead of nil for 'noSelectionString') + (v4.5.202) + 2005-09-18 Helge Hess * GNUmakefile.preamble: added missing linking path to NGMail (required diff --git a/sope-appserver/NGObjWeb/DynamicElements/WOPopUpButton.m b/sope-appserver/NGObjWeb/DynamicElements/WOPopUpButton.m index 99ee76ae..3c9127f7 100644 --- a/sope-appserver/NGObjWeb/DynamicElements/WOPopUpButton.m +++ b/sope-appserver/NGObjWeb/DynamicElements/WOPopUpButton.m @@ -66,6 +66,7 @@ static Class NSDateClass = Nil; @implementation WOPopUpButton static NSNumber *yesNum = nil; +static BOOL debugPopUp = NO; + (int)version { return [super version] + 0 /* v2 */; @@ -172,12 +173,14 @@ static NSNumber *yesNum = nil; return; formValue = [_rq formValueForKey:OWFormElementName(self, _ctx)]; -#if 0 - [self logWithFormat:@"%@: value=%@ ..", [self elementID], formValue]; -#endif - + if (debugPopUp) { + [self logWithFormat:@"%@ / %@: value=%@ ..", OWFormElementName(self, _ctx), + [_ctx elementID], formValue]; + } + if (formValue == nil) { /* nothing changed, or not in submitted form */ + if (debugPopUp) [self logWithFormat:@"found no form value!"]; return; } @@ -187,7 +190,9 @@ static NSNumber *yesNum = nil; if (self->value != nil) { /* has a value binding, walk list to find object */ unsigned i, toGo; - + + if (debugPopUp) [self logWithFormat:@"scan value: %@", self->value]; + for (i = 0, toGo = [objects count]; i < toGo; i++) { NSString *cv; @@ -200,6 +205,9 @@ static NSNumber *yesNum = nil; if ([cv isEqualToString:formValue]) break; + + // important, reset object otherwise the last item will be preselected! + object = nil; } } else if (![formValue isEqualToString:WONoSelectionString]) { @@ -224,7 +232,7 @@ static NSNumber *yesNum = nil; if ([self->selection isValueSettable]) { NSArray *sel; - if (object) { + if (object != nil) { sel = [object retain]; } else /* nil item selected */ diff --git a/sope-appserver/NGObjWeb/Version b/sope-appserver/NGObjWeb/Version index 9a8640a1..e7507ced 100644 --- a/sope-appserver/NGObjWeb/Version +++ b/sope-appserver/NGObjWeb/Version @@ -1,6 +1,6 @@ # version file -SUBMINOR_VERSION:=201 +SUBMINOR_VERSION:=202 # v4.5.122 requires libNGExtensions v4.5.153 # v4.5.91 requires libNGExtensions v4.5.134