From 0826f09f32ce861af45c80ab59cb779c2625e1fd Mon Sep 17 00:00:00 2001 From: Martin Kamerbeek Date: Thu, 28 May 2009 07:58:07 +0000 Subject: [PATCH] Thingy bug fixes. --- docs/changelog/7.x.x.txt | 9 +++++ lib/WebGUI/Asset/Wobject/Thingy.pm | 64 +++++++++++++++++++++++------- 2 files changed, 58 insertions(+), 15 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index fd59802da..6dd7020a4 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -9,6 +9,15 @@ - fixed #10396: Syndicated Content wobject not displaying edit controls - fixed #10386: Template override missing in nav shortcut - fixed #10436: Story Manager - Story Edit/Delete links are Admin Only + - fixed a bug in Thingy where fields with list type form elements wouldn't + show up in Thingy search results ( Martin Kamerbeek / Oqapi ) + - fixed a bug in Thingy where the search form would lose part of its contents + when searching. ( Martin Kamerbeek / Oqapi ) + - fixed a bug in Thingy where debug information would show up in the Thing + editor when adding/editing fields. ( Martin Kamerbeek / Oqapi ) + - fixed a bug in Thingy where when searching using multi value search form + elements (eg. check lists) only one of the selected elements was taken into + account in the search query. ( Martin Kamerbeek / Oqapi ) 7.7.7 - Added EMS Schedule table diff --git a/lib/WebGUI/Asset/Wobject/Thingy.pm b/lib/WebGUI/Asset/Wobject/Thingy.pm index a1e62ddd8..ef4c623e2 100644 --- a/lib/WebGUI/Asset/Wobject/Thingy.pm +++ b/lib/WebGUI/Asset/Wobject/Thingy.pm @@ -848,6 +848,7 @@ sub getEditForm { my $self = shift; my $i18n = WebGUI::International->new($self->session, 'Asset_Thingy'); + my $tabform = $self->SUPER::getEditForm(); my $things = $self->session->db->buildHashRef('select thingId, label from Thingy_things where assetId = ?',[$self->get("assetId")]); @@ -860,6 +861,7 @@ sub getEditForm { -options=>$things, ); } + return $tabform; } @@ -896,6 +898,9 @@ sub getFieldValue { elsif ($field->{fieldType} eq "dateTime"){ $processedValue = $self->session->datetime->epochToHuman($value,$dateTimeFormat); } + # TODO: The otherThing field type is probably also handled by getFormPlugin, so the elsif below can probably be + # safely removed. However, this requires more testing than I can provide right now, so for now this stays the + # way it was. elsif ($field->{fieldType} =~ m/^otherThing/x) { my $otherThingId = $field->{fieldType}; $otherThingId =~ s/^otherThing_//x; @@ -910,15 +915,13 @@ sub getFieldValue { } } else { - my %fieldProperties = %$field; - $fieldProperties{options} = $field->{possibleValues}; - $processedValue - = WebGUI::Form::DynamicField->new( $self->session, %fieldProperties, defaultValue => $value ) - ->getValueAsHtml; + $field->{ value } = $value; + $field->{ defaultValue } = $value; + my $plugin = $self->getFormPlugin( $field ); + $processedValue = $plugin->getValueAsHtml; } return $processedValue; - } #------------------------------------------------------------------- @@ -934,7 +937,24 @@ A hashref containing the properties of this field. =cut sub getFormElement { + my $self = shift; + return $self->getFormPlugin( @_ )->toHtml; +} + +#------------------------------------------------------------------- + +=head2 getFormPlugin ( properties ) + +Returns an instanciated WebGUI::Form::* plugin. + +=head3 proeprties + +The properties to configure the form plugin with. The fieldType key should contain the type of the form plugin. + +=cut + +sub getFormPlugin { my $self = shift; my $data = shift; my %param; @@ -961,10 +981,10 @@ sub getFormElement { } } - if (WebGUI::Utility::isIn($data->{fieldType},qw(SelectList CheckList SelectBox Attachments))) { + if ( WebGUI::Utility::isIn( $data->{fieldType}, qw(SelectList CheckList SelectBox Attachments) ) ) { my @defaultValues; - if ($self->session->form->param($name)) { - @defaultValues = $session->form->selectList($name); + if ( $self->session->form->param($name) && !$data->{value} ) { + @defaultValues = $session->form->process( $name, $data->{fieldType} ); } else { foreach (split(/\n/x, $data->{value})) { @@ -974,6 +994,9 @@ sub getFormElement { } $param{value} = \@defaultValues; } + elsif ( $self->session->form->param($name) && !$data->{value} ) { + $param{value} = $session->form->process( $name, $data->{fieldType} ); + } my $class = 'WebGUI::Form::'. ucfirst $data->{fieldType}; eval { WebGUI::Pluggable::load($class) }; @@ -1032,8 +1055,7 @@ sub getFormElement { } my $formElement = eval { WebGUI::Pluggable::instanciate($class, "new", [$session, \%param ])}; - return $formElement->toHtml(); - + return $formElement; } #------------------------------------------------------------------- @@ -2157,6 +2179,10 @@ sub www_editField { $properties{label} = $properties{label}.' (copy)'; } $dialogBody = $self->getEditFieldForm(\%properties); + + # Make sure we send debug information along with the field edit screen. + $session->log->preventDebugOutput; + $self->session->output->print($dialogBody->print); return "chunked"; } @@ -2245,6 +2271,9 @@ sub www_editFieldSave { ."session->url->page()."','".$newFieldId ."','".$properties{thingId}."')\" value='".$i18n->get('Delete','Icon')."' type='button'>\n\n"; + # Make sure we send debug information along with the field. + $session->log->preventDebugOutput; + $session->output->print($newFieldId.$listItemHTML); return "chunked"; } @@ -3212,9 +3241,14 @@ sequenceNumber'); "searchFields_textForm" => $searchTextForm, "searchFields_is".$fieldType => 1, }); - my $searchValue = $session->form->process("field_".$field->{fieldId}); - push @constraints, $dbh->quote_identifier("field_".$field->{fieldId}) . " LIKE " - . $dbh->quote('%'.$searchValue.'%') if ($searchValue); + + my @searchValue = $session->form->process("field_".$field->{fieldId}); + my $constraint = + join ' OR ', + map { $dbh->quote_identifier("field_".$field->{fieldId}) . " LIKE " . $dbh->quote('%'.$_.'%') } + @searchValue ; + + push @constraints, " ( $constraint ) " if @searchValue; } if($field->{displayInSearch}){ my $orderByUrl = $self->session->url->append($currentUrl,"orderBy=".$field->{fieldId}); @@ -3249,7 +3283,7 @@ sequenceNumber'); $self->session->errorHandler->warn("The default Thing has no fields selected to display in the search."); $noFields = 1; } - + # store query in cache for thirty minutes WebGUI::Cache->new($self->session,"query_".$thingId)->set($query,30*60);