Last active
December 1, 2016 20:56
-
-
Save rsindlin/83b2079e7785aa70feb537f2cca9aee8 to your computer and use it in GitHub Desktop.
GCIS: Rough cut of Advanced Search paging, based on commit 6797978
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From b73c9636cefc879491b7c87150020852fdd81b63 Mon Sep 17 00:00:00 2001 | |
From: Randall Sindlinger <[email protected]> | |
Date: Thu, 1 Dec 2016 20:33:09 +0000 | |
Subject: [PATCH] Rough-cut of paging on Advanced Search page | |
Addresses issue #410. | |
Known bugs: In the pager bar, eg, | |
+--+--------+--+-------------------+-----------------------+ | |
|<<|page 5 v|>>| 1 to 0 of unknown | Search | | |
+--+--------+--+-------------------+-----------------------+ | |
1) text box of page that you are on continuously displays | |
"1 to 0 of unknown" | |
2) the Search does not do anything at all (would be best to suppress | |
this if possible on the Advanced Search page, since the Advanced Search | |
bar appears above the pager bar) | |
--- | |
lib/Tuba/Search.pm | 8 +++++++- | |
lib/Tuba/files/templates/search/keyword.html.ep | 4 ++++ | |
2 files changed, 11 insertions(+), 1 deletion(-) | |
diff --git a/lib/Tuba/Search.pm b/lib/Tuba/Search.pm | |
index 064d5b4..b376d8a 100644 | |
--- a/lib/Tuba/Search.pm | |
+++ b/lib/Tuba/Search.pm | |
@@ -34,6 +34,7 @@ sub keyword { | |
my @results; | |
my $result_count_text; | |
my $hit_max = 0; | |
+ my $meta; | |
for my $table (@tables) { | |
next if $table eq 'publication'; | |
next if $featured_only and $table ne 'report'; #ugly hack, only reports are currently featured | |
@@ -42,6 +43,7 @@ sub keyword { | |
my @these = $manager->dbgrep(query_string => $q, user => $c->user, all => $all, page => $c->page, per_page => $per_page, count_only => $count_only, featured_only => $featured_only); | |
$hit_max = 1 if @these==$per_page && @tables > 1; | |
push @results, @these; | |
+ $meta = $orm->{$table}{obj}->meta; #I don't really care which meta it grabs as the last one | |
} | |
$result_count_text = scalar @results; | |
@@ -58,9 +60,13 @@ sub keyword { | |
"To see more, chose a type in the form above."; | |
} | |
} | |
+ $c->stash(count=>'unknown'); | |
+ $c->stash(pages=>$c->page) if !$c->stash('pages'); | |
+ #$c->stash('pages') ? $c->stash(pages=>($c->stash('pages')++)) : 2 if $hit_max; | |
+ $c->stash(pages=>($c->stash('pages') + 1)) if $hit_max; | |
$c->stash(result_count_text => $result_count_text); | |
$c->respond_to( | |
- any => sub { shift->render(results => \@results); }, | |
+ any => sub { shift->render(results => \@results, meta => $meta); }, | |
json => sub { my $c = shift; $c->render(json => [ map $_->as_tree(c => $c, | |
bonsai => $bonsai, | |
with_files => $with_files, | |
diff --git a/lib/Tuba/files/templates/search/keyword.html.ep b/lib/Tuba/files/templates/search/keyword.html.ep | |
index fc21895..a286383 100644 | |
--- a/lib/Tuba/files/templates/search/keyword.html.ep | |
+++ b/lib/Tuba/files/templates/search/keyword.html.ep | |
@@ -11,6 +11,10 @@ match results. | |
%= submit_button 'search', class => "btn btn-search btn-primary" | |
%= end | |
+%if (my $page = stash 'page') { | |
+%= include 'pager', page => $page; | |
+% } | |
+ | |
% my @clone = @$results; | |
<p class='alert'> | |
% if (param 'q') { | |
-- | |
1.9.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment