From 13415cf1f946d73b5ecef1d9fd131edeee649427 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Fri, 15 Aug 2008 02:51:26 +0000 Subject: [PATCH] fixed thingy so it displays all the data by default on the search screen --- docs/changelog/7.x.x.txt | 4 + ...emplates_thingy-default-search-thing.wgpkg | Bin 0 -> 2451 bytes lib/WebGUI/Asset/Wobject/Thingy.pm | 126 ++++++++---------- 3 files changed, 63 insertions(+), 67 deletions(-) create mode 100644 docs/upgrades/packages-7.5.21/templates_thingy-default-search-thing.wgpkg diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 4e3d80d85..82229f9e4 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -3,9 +3,13 @@ for assets are processed in addRevision() instead. - Changed update() so it can autodetect missing fields in asset tables and log them nicely instead of crashing. + - Changed Thingy so it defaultly searches the default thing when you view the + search screen for that thing. This way it displays everything and the user + isn't left wondering what happened to the data they just submitted. - Fixed a problem with the file upload control where you couldn't delete the file if you have multiple attached. + 7.5.20 - fixed: DataForm acknowledgement screen shows incorrect value for Date/Time fields - fixed: Some multipart mail messages have parts chosen incorrectly diff --git a/docs/upgrades/packages-7.5.21/templates_thingy-default-search-thing.wgpkg b/docs/upgrades/packages-7.5.21/templates_thingy-default-search-thing.wgpkg new file mode 100644 index 0000000000000000000000000000000000000000..dd38a308d3fccd132536b3c0a280c5dfad77ecf9 GIT binary patch literal 2451 zcmV;E32gQsiwFP!000001MOOEZ`(K$&gcCVS|6}Yv5jBSI8GclxaOs;7u}>yoGlJ@ z*N`pRW-3#vNG0_x`rmJ6D3O#bcfETJa5&Tj5=R^kpP6}PNRC?HdiYPX+3d92TU+>h zU;l3I?rm*(=F{A2wVLf#YroTm0j~w$o^E*{`tYArDn9{ew@NO!ny+0D#HQ1=qhuV| zXMcZ1^nYmxFgKem^Rw05qwjn5TN#OO1Qayx??JrbcSZam)O+nx{P*_uTU#D@^Wi@a z761CfL;n^l{P6=MVNI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_M zE$(Sm^F19yF91?!H9W<@6Ls{N+X1uIY|N0HXPKKUBwCq?oDi83KGljz+;~7U`ie=o zg_JT^Cq4Z%u_>$t+{$*7zPP3fOm&`RN$#ezYhxh+a{f>hH_~3<`kH{E){Vkv49$zY z>Q!Ay)?72R6FlurX>Jte9+9UA1v?K<{;(9L48U3jxD5SD)%Xi8+@KIvTpg+xpvrx+ zyrBz)vu{^RuO4W#oGYizhTbTZfhu-u*1)wjy8)Yo7>zE^&LEfXXIIhvrC@r1Djhu< z+(%BN^82z0qCGDaGHZ%kV==$%l){c-h?k8!MNmI+kiO_&RaCE%n0pUA^Oe0cS0hj_s$Q~s>3vz z=LE45BSj5ucU7%QI)N{thmke;TsRF8mSW*wOKDx=^MYI2CRdPc70p2w!&f=%;68^}&Gry!KUk5-K?vO@JZVRt-AE!{<6xlb{^i3Xi~=xaf$66WC@M5?1=oxk%8IS5}4=t(!X&DlZ{ZFu6*@uBRoRM@`9&x9tObM z!n6rKyojJ>xH1RMd)xe3^N9ECDptH6GBH#0BmVQxXq+)^2n4a%>vqC>{-Lh?88Y5` z_RNE(-ms?KqOm&eLF`p)qKZf?pfs>3RbU5wy-XE$OdKC=GXIVxpa6C;xB(8F(30QO z7i-WL{lq@V?4tmn9b;q@*kUDI^o6*IRCU~o@l_3+@vd{K?0B?{oJIXlM2XUeI-wcZRUnhMgC!Rc}`fyMK6a&}UkQ5n2j@vq?1*~go!gU_8ecf0K6RqNB>c@5uWe)-|cw|G(dUB`D1eD}b2 R5B#5b;6IAay|@4-007Erzk2`x literal 0 HcmV?d00001 diff --git a/lib/WebGUI/Asset/Wobject/Thingy.pm b/lib/WebGUI/Asset/Wobject/Thingy.pm index e5e46aed2..6b13849de 100644 --- a/lib/WebGUI/Asset/Wobject/Thingy.pm +++ b/lib/WebGUI/Asset/Wobject/Thingy.pm @@ -2342,14 +2342,13 @@ sub www_search { my $session = $self->session; my $dbh = $session->db->dbh; my $i18n = WebGUI::International->new($self->session,"Asset_Thingy"); - my ($var,$url,$doSearch,$orderBy); + my ($var,$url,$orderBy); my ($fields,@searchFields_loop,@displayInSearchFields_loop,$query,@constraints); my (@searchResult_loop,$searchResults,@searchResults,@displayInSearchFields,$paginatePage,$currentUrl,$p); my $thingProperties = $self->getThing($thingId); return $session->privilege->insufficient() unless $self->hasPrivileges($thingProperties->{groupIdSearch}); - $doSearch = $session->form->process("doSearch"); $orderBy = $session->form->process("orderBy") || $thingProperties->{sortBy}; $var = $self->get; $url = $self->getUrl; @@ -2359,7 +2358,7 @@ sub www_search { $var->{"manage_url"} = $session->url->append($url, 'func=manage'); $var->{"thing_label"} = $thingProperties->{label}; - if ($doSearch && $self->hasPrivileges($thingProperties->{groupIdExport})){ + if ($self->hasPrivileges($thingProperties->{groupIdExport})){ $var->{"export_url"} = $session->url->append($url, 'func=export;thingId='.$thingId); } if ($self->hasPrivileges($thingProperties->{groupIdImport})){ @@ -2404,79 +2403,72 @@ sequenceNumber'); "searchFields_textForm" => $searchTextForm, "searchFields_is".$fieldType => 1, }); - if ($doSearch){ - my $searchValue = $session->form->process("field_".$field->{fieldId}); - push(@constraints,$dbh->quote_identifier("field_".$field->{fieldId})." like '%".$searchValue."%'") if ($searchValue); - } + my $searchValue = $session->form->process("field_".$field->{fieldId}); + push(@constraints,$dbh->quote_identifier("field_".$field->{fieldId})." like '%".$searchValue."%'") if ($searchValue); } - if ($doSearch){ - if($field->{displayInSearch}){ - my $orderByUrl = $currentUrl.";orderBy=".$field->{fieldId}; - push(@displayInSearchFields_loop, { - "displayInSearchFields_fieldId" => $field->{fieldId}, - "displayInSearchFields_label" => $field->{label}, - "displayInSearchFields_orderByUrl" => $orderByUrl, - }); - push(@displayInSearchFields, { - fieldId => $field->{fieldId}, - properties => $field, - }); - } + if($field->{displayInSearch}){ + my $orderByUrl = $currentUrl.";orderBy=".$field->{fieldId}; + push(@displayInSearchFields_loop, { + "displayInSearchFields_fieldId" => $field->{fieldId}, + "displayInSearchFields_label" => $field->{label}, + "displayInSearchFields_orderByUrl" => $orderByUrl, + }); + push(@displayInSearchFields, { + fieldId => $field->{fieldId}, + properties => $field, + }); } } - if ($doSearch){ - $query = "select thingDataId, "; - $query .= join(", ",map {$dbh->quote_identifier('field_'.$_->{fieldId})} @displayInSearchFields); - $query .= " from ".$dbh->quote_identifier("Thingy_".$thingId); - $query .= " where ".join(" and ",@constraints) if (scalar(@constraints) > 0); - if ($orderBy){ - $query .= " order by ".$dbh->quote_identifier("field_".$orderBy); - } - - # store query in cache for thirty minutes - WebGUI::Cache->new($self->session,"query_".$thingId)->set($query,30*60); - - $paginatePage = $self->session->form->param('pn') || 1; - $currentUrl .= ";orderBy=".$orderBy if ($orderBy); - - $p = WebGUI::Paginator->new($self->session,$currentUrl,$thingProperties->{thingsPerPage}, undef, $paginatePage); - $p->setDataByQuery($query); - $searchResults = $p->getPageData($paginatePage); - foreach my $searchResult (@$searchResults){ - my (@field_loop); - foreach my $field (@displayInSearchFields){ - my $fieldId = $field->{fieldId}; - my $value = $self->getFieldValue($searchResult->{"field_".$fieldId},$field->{properties}); - push(@field_loop,{ - "field_value" => $value, - "field_id" => $fieldId, - }); - } - my $thingDataId = $searchResult->{thingDataId}; - my %templateVars = ( - "searchResult_id" => $thingDataId, - "searchResult_view_url" => $session->url->append($url, 'func=viewThingData;thingId=' - .$thingId.';thingDataId='.$thingDataId), - "searchResult_field_loop" => \@field_loop, - ); - if ($self->hasPrivileges($thingProperties->{groupIdEdit})){ - $templateVars{searchResult_delete_icon} = $session->icon->delete('func=deleteThingDataConfirm;thingId=' - .$thingId.';thingDataId='.$thingDataId,$self->get("url"),$i18n->get('delete thing data warning')); - $templateVars{searchResult_edit_icon} = $session->icon->edit('func=editThingData;thingId=' - .$thingId.';thingDataId='.$thingDataId,$self->get("url")); - } - push(@searchResult_loop,\%templateVars); - } - $var->{canEditThingData} = $self->hasPrivileges($thingProperties->{groupIdEdit}); - $var->{searchResult_loop} = \@searchResult_loop; - $p->appendTemplateVars($var); + $query = "select thingDataId, "; + $query .= join(", ",map {$dbh->quote_identifier('field_'.$_->{fieldId})} @displayInSearchFields); + $query .= " from ".$dbh->quote_identifier("Thingy_".$thingId); + $query .= " where ".join(" and ",@constraints) if (scalar(@constraints) > 0); + if ($orderBy){ + $query .= " order by ".$dbh->quote_identifier("field_".$orderBy); } + + # store query in cache for thirty minutes + WebGUI::Cache->new($self->session,"query_".$thingId)->set($query,30*60); + + $paginatePage = $self->session->form->param('pn') || 1; + $currentUrl .= ";orderBy=".$orderBy if ($orderBy); + + $p = WebGUI::Paginator->new($self->session,$currentUrl,$thingProperties->{thingsPerPage}, undef, $paginatePage); + $p->setDataByQuery($query); + $searchResults = $p->getPageData($paginatePage); + foreach my $searchResult (@$searchResults){ + my (@field_loop); + foreach my $field (@displayInSearchFields){ + my $fieldId = $field->{fieldId}; + my $value = $self->getFieldValue($searchResult->{"field_".$fieldId},$field->{properties}); + push(@field_loop,{ + "field_value" => $value, + "field_id" => $fieldId, + }); + } + my $thingDataId = $searchResult->{thingDataId}; + my %templateVars = ( + "searchResult_id" => $thingDataId, + "searchResult_view_url" => $session->url->append($url, 'func=viewThingData;thingId=' + .$thingId.';thingDataId='.$thingDataId), + "searchResult_field_loop" => \@field_loop, + ); + if ($self->hasPrivileges($thingProperties->{groupIdEdit})){ + $templateVars{searchResult_delete_icon} = $session->icon->delete('func=deleteThingDataConfirm;thingId=' + .$thingId.';thingDataId='.$thingDataId,$self->get("url"),$i18n->get('delete thing data warning')); + $templateVars{searchResult_edit_icon} = $session->icon->edit('func=editThingData;thingId=' + .$thingId.';thingDataId='.$thingDataId,$self->get("url")); + } + push(@searchResult_loop,\%templateVars); + } + $var->{canEditThingData} = $self->hasPrivileges($thingProperties->{groupIdEdit}); + $var->{searchResult_loop} = \@searchResult_loop; + $p->appendTemplateVars($var); $var->{"form_start"} = WebGUI::Form::formHeader($self->session,{action=>$self->getUrl}) .WebGUI::Form::hidden($self->session,{name=>"func",value=>"search"}); $var->{"form_start"} .= WebGUI::Form::hidden($self->session,{name=>"thingId",value=>$thingId}); - $var->{"form_start"} .= WebGUI::Form::hidden($self->session,{name=>"doSearch",value=>1}); $var->{"form_submit"} = WebGUI::Form::submit($self->session,{value=>$i18n->get("search button label")}); $var->{"form_end"} = WebGUI::Form::formFooter($self->session);