From b5bf89a6a8d3f012465bb45e11ad2aba009536ce Mon Sep 17 00:00:00 2001 From: Vitali Peil Date: Fri, 18 Sep 2020 09:04:59 +0200 Subject: [PATCH 1/9] display project acronym in autocomplete if available --- lib/LibreCat/App/Search/Route/ajax.pm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/LibreCat/App/Search/Route/ajax.pm b/lib/LibreCat/App/Search/Route/ajax.pm index 2172de975..0f31c043d 100644 --- a/lib/LibreCat/App/Search/Route/ajax.pm +++ b/lib/LibreCat/App/Search/Route/ajax.pm @@ -128,7 +128,12 @@ ajax '/get_project' => sub { if ($hits->{total}) { my $map; @$map - = map {{id => $_->{_id}, label => $_->{name}};} @{$hits->{hits}}; + = map { + my $label; + $label .= "$_->{acronym}: " if $_->{acronym}; + $label .= $_->{name}; + return {id => $_->{_id}, label => $_->{name}}; + } @{$hits->{hits}}; return to_json $map; } else { From bd5018b92389109f4dc50cf599cf7bab93cf9f98 Mon Sep 17 00:00:00 2001 From: Vitali Peil Date: Fri, 18 Sep 2020 09:05:45 +0200 Subject: [PATCH 2/9] tidy --- lib/LibreCat/App/Search/Route/ajax.pm | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/LibreCat/App/Search/Route/ajax.pm b/lib/LibreCat/App/Search/Route/ajax.pm index 0f31c043d..55db81770 100644 --- a/lib/LibreCat/App/Search/Route/ajax.pm +++ b/lib/LibreCat/App/Search/Route/ajax.pm @@ -93,7 +93,7 @@ ajax '/authority_user/:id' => sub { ajax '/get_alias/:id/:alias' => sub { my $term = params->{'alias'} || ""; - my $id = params->{'id'}; + my $id = params->{'id'}; my %search_params = (cql => ["alias=$term", "id<>$id"]); h->log->debug("executing user->search: " . to_dumper(\%search_params)); @@ -127,13 +127,12 @@ ajax '/get_project' => sub { if ($hits->{total}) { my $map; - @$map - = map { - my $label; - $label .= "$_->{acronym}: " if $_->{acronym}; - $label .= $_->{name}; - return {id => $_->{_id}, label => $_->{name}}; - } @{$hits->{hits}}; + @$map = map { + my $label; + $label .= "$_->{acronym}: " if $_->{acronym}; + $label .= $_->{name}; + return {id => $_->{_id}, label => $_->{name}}; + } @{$hits->{hits}}; return to_json $map; } else { @@ -146,7 +145,7 @@ ajax '/get_project' => sub { =cut ajax '/get_department' => sub { - my $term = params->{term} // ''; + my $term = params->{term} // ''; my $limit = length($term) ? 100 : 1000; my @terms = split('\s', $term); From 23e1e24851be70ed97312f7245ccb792f4f042fb Mon Sep 17 00:00:00 2001 From: Petra Kohorst Date: Fri, 23 Apr 2021 12:43:03 +0200 Subject: [PATCH 3/9] Fix permissions bug in edit links (search result list) for reviewers. --- lib/LibreCat/App/Catalogue/Controller/Permission.pm | 2 +- views/links.tt | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/LibreCat/App/Catalogue/Controller/Permission.pm b/lib/LibreCat/App/Catalogue/Controller/Permission.pm index 9dae5d037..fabed43b5 100644 --- a/lib/LibreCat/App/Catalogue/Controller/Permission.pm +++ b/lib/LibreCat/App/Catalogue/Controller/Permission.pm @@ -63,7 +63,7 @@ sub _can_do_action { return 0 unless defined($user_id) && defined($role); - my $pub = $opts->{live} ? h->main_publication->get($id) : get_cached_publication($id); + my $pub = $opts->{live} ? h->publication->get($id) : get_cached_publication($id); is_hash_ref($pub) or return 0; diff --git a/views/links.tt b/views/links.tt index dadf56fe6..0afe0da30 100644 --- a/views/links.tt +++ b/views/links.tt @@ -19,7 +19,7 @@ [% IF backend %]
- [% IF p.can_edit( entry._id, user_id = session.user_id, role = session.role ) %] + [% IF p.can_edit( entry._id, user_id = session.user_id, role = session.role, live = 1 ) %] [% h.loc("main_page.links.edit") %] [% ELSE %] [% h.loc("main_page.links.edit") %] @@ -38,10 +38,10 @@ [% LAST %] [% END %] [% END %] - [% IF p.can_make_public( entry._id, user_id = session.user_id, role = session.role ) %] + [% IF p.can_make_public( entry._id, user_id = session.user_id, role = session.role, live = 1 ) %] | [% h.loc("main_page.links.publish") %] [% END %] - [% IF p.can_return( entry._id, user_id = session.user_id, role = session.role ) %] + [% IF p.can_return( entry._id, user_id = session.user_id, role = session.role, live = 1 ) %] | [% h.loc("main_page.links.return") %] [% END %] [% IF session.role == "super_admin" %] From a65febe72eb5d2c020d4a11b95d70589396323ae Mon Sep 17 00:00:00 2001 From: Nicolas Franck Date: Thu, 29 Apr 2021 16:13:43 +0200 Subject: [PATCH 4/9] revert back to older version of views/links.tt --- views/links.tt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/views/links.tt b/views/links.tt index 0afe0da30..dadf56fe6 100644 --- a/views/links.tt +++ b/views/links.tt @@ -19,7 +19,7 @@ [% IF backend %]
- [% IF p.can_edit( entry._id, user_id = session.user_id, role = session.role, live = 1 ) %] + [% IF p.can_edit( entry._id, user_id = session.user_id, role = session.role ) %] [% h.loc("main_page.links.edit") %] [% ELSE %] [% h.loc("main_page.links.edit") %] @@ -38,10 +38,10 @@ [% LAST %] [% END %] [% END %] - [% IF p.can_make_public( entry._id, user_id = session.user_id, role = session.role, live = 1 ) %] + [% IF p.can_make_public( entry._id, user_id = session.user_id, role = session.role ) %] | [% h.loc("main_page.links.publish") %] [% END %] - [% IF p.can_return( entry._id, user_id = session.user_id, role = session.role, live = 1 ) %] + [% IF p.can_return( entry._id, user_id = session.user_id, role = session.role ) %] | [% h.loc("main_page.links.return") %] [% END %] [% IF session.role == "super_admin" %] From fe0ea39933ad5a008a2af0ec6749571782cfc38d Mon Sep 17 00:00:00 2001 From: Nicolas Franck Date: Thu, 29 Apr 2021 16:15:57 +0200 Subject: [PATCH 5/9] use h->publication instead of h->main_publication in order to use extra fields --- lib/LibreCat/App/Catalogue/Controller/Permission.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/LibreCat/App/Catalogue/Controller/Permission.pm b/lib/LibreCat/App/Catalogue/Controller/Permission.pm index fabed43b5..1f3ed27f2 100644 --- a/lib/LibreCat/App/Catalogue/Controller/Permission.pm +++ b/lib/LibreCat/App/Catalogue/Controller/Permission.pm @@ -26,7 +26,7 @@ sub get_cached_publication { my $pub = cache()->get( "RECORD_${id}" ); my $set_cache = !$pub; - $pub //= h->main_publication->get($id); + $pub //= h->publication->get($id); cache()->set( "RECORD_${id}", $pub) if $set_cache; @@ -238,7 +238,7 @@ sub can_download { is_string($id) or return (0, ""); is_hash_ref($opts) or return (0, ""); - my $pub = $opts->{live} ? h->main_publication->get($id) : get_cached_publication($id); + my $pub = $opts->{live} ? h->publication->get($id) : get_cached_publication($id); is_hash_ref($pub) or return (0,""); From 4dfb023e59c7fe08ebca28f1e91086af0ac6ee7f Mon Sep 17 00:00:00 2001 From: Nicolas Franck Date: Fri, 30 Apr 2021 18:38:33 +0200 Subject: [PATCH 6/9] fix #923: anchors should not influence layout --- views/filters.tt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/views/filters.tt b/views/filters.tt index b0ed69885..51eef9524 100644 --- a/views/filters.tt +++ b/views/filters.tt @@ -4,8 +4,9 @@ [%- USE JSON.Escape %] -
-
+ + + From 1c92e89b325c2ec4c2a85c40f002d36d81c413a7 Mon Sep 17 00:00:00 2001 From: Vitali Peil Date: Tue, 4 May 2021 12:31:23 +0200 Subject: [PATCH 7/9] version up deps --- cpanfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cpanfile b/cpanfile index 002f7c8cb..ded9b8d00 100644 --- a/cpanfile +++ b/cpanfile @@ -25,7 +25,7 @@ requires 'Catmandu', '>=1.2002'; requires 'Catmandu::FileStore', '1.16'; requires 'Catmandu::ArXiv', '0.211'; requires 'Catmandu::BagIt' , '0.234'; -requires 'Catmandu::BibTeX', '>=0.14'; +requires 'Catmandu::BibTeX', '>=0.20'; requires 'Catmandu::DBI', '>=0.09'; requires 'Catmandu::Exporter::Table'; requires 'Catmandu::Fix::Date'; @@ -46,8 +46,8 @@ requires 'Search::Elasticsearch::Client::6_0'; requires 'Dancer'; requires 'Dancer::Plugin'; requires 'Dancer::FileUtils'; -requires 'Dancer::Plugin::Catmandu::OAI', '>=0.0504'; -requires 'Dancer::Plugin::Catmandu::SRU', '0.0403'; +requires 'Dancer::Plugin::Catmandu::OAI', '>=0.0508'; +requires 'Dancer::Plugin::Catmandu::SRU', '>=0.0504'; requires 'Dancer::Plugin::Auth::Tiny'; requires 'Dancer::Plugin::StreamData'; requires 'Dancer::Logger::Log4perl'; @@ -127,4 +127,4 @@ requires 'Tie::IxHash', '1.23'; requires 'Module::Find','0.15'; #LWP::UserAgent has method "patch" since version 6.42 -requires "LWP::UserAgent","6.42"; \ No newline at end of file +requires "LWP::UserAgent","6.42"; From 40b9d8cd7c8be650629925686fc05866f1168f30 Mon Sep 17 00:00:00 2001 From: Vitali Peil Date: Wed, 12 May 2021 09:17:38 +0200 Subject: [PATCH 8/9] rm tmp key in license fix --- fixes/licenses.fix | 1 + 1 file changed, 1 insertion(+) diff --git a/fixes/licenses.fix b/fixes/licenses.fix index c33d74010..c062d78e3 100644 --- a/fixes/licenses.fix +++ b/fixes/licenses.fix @@ -4,4 +4,5 @@ if exists(license) move(license, tmp) lookup_in_config(tmp, locale.en.licenses) move(tmp.deed_url, license) + rm(tmp) end From 46cf07e6be551129ab8efa38bc2e9508367b7d0a Mon Sep 17 00:00:00 2001 From: Nicolas Franck Date: Mon, 17 May 2021 16:15:56 +0200 Subject: [PATCH 9/9] fix warnings about undefined values; use label --- lib/LibreCat/App/Search/Route/ajax.pm | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/LibreCat/App/Search/Route/ajax.pm b/lib/LibreCat/App/Search/Route/ajax.pm index 55db81770..a69ef8bbf 100644 --- a/lib/LibreCat/App/Search/Route/ajax.pm +++ b/lib/LibreCat/App/Search/Route/ajax.pm @@ -7,7 +7,7 @@ LibreCat::App::Search::Route::ajax - handles routes for asynchronous requests =cut use Catmandu::Sane; -use Catmandu::Util qw(join_path); +use Catmandu::Util qw(join_path :is); use Dancer qw/:syntax/; use Dancer::Plugin::Ajax; use HTML::Entities; @@ -126,14 +126,12 @@ ajax '/get_project' => sub { h->log->debug($hits->{total} . " hits"); if ($hits->{total}) { - my $map; - @$map = map { - my $label; - $label .= "$_->{acronym}: " if $_->{acronym}; - $label .= $_->{name}; - return {id => $_->{_id}, label => $_->{name}}; + my @map = map { + my $label = $_->{name}; + $label = "$_->{acronym}: $label" if is_string($_->{acronym}); + +{ id => $_->{_id}, label => $label }; } @{$hits->{hits}}; - return to_json $map; + return to_json \@map; } else { return to_json [];