From 2d8deba9d4215d327c8216423e42b1d555e857c9 Mon Sep 17 00:00:00 2001
From: Alexander Purr <purr@ub.uni-leipzig.de>
Date: Tue, 18 Feb 2020 18:33:26 +0100
Subject: [PATCH] refs #16833 [fid_adlr] remove save search icon by disabled
 one if save request succeeded

---
 themes/fid_adlr/js/lightbox.js                 |  7 +++++++
 themes/fid_adlr/languages/de.ini               |  4 +++-
 themes/fid_adlr/languages/en.ini               |  4 +++-
 themes/fid_adlr/scss/compiled.scss             |  4 ++++
 themes/fid_adlr/templates/search/results.phtml | 15 ++++++++++-----
 5 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/themes/fid_adlr/js/lightbox.js b/themes/fid_adlr/js/lightbox.js
index 143c6bb720c..c0fb1c8c97a 100644
--- a/themes/fid_adlr/js/lightbox.js
+++ b/themes/fid_adlr/js/lightbox.js
@@ -189,6 +189,13 @@ VuFind.register('lightbox', function Lightbox() {
           VuFind.refreshPage();
           return;
         }
+
+        /* remove save search icon by disabled one if save request succeeded */
+        if (_originalUrl.match(/SaveSearch\?save=/)) {
+          $("#save-search").toggleClass("hidden");
+          $("#saved-search").toggleClass("hidden");
+        }
+
         render(content);
       })
       .fail(function lbAjaxFail(deferred, errorType, msg) {
diff --git a/themes/fid_adlr/languages/de.ini b/themes/fid_adlr/languages/de.ini
index da5d3236add..7a2e7bd072f 100644
--- a/themes/fid_adlr/languages/de.ini
+++ b/themes/fid_adlr/languages/de.ini
@@ -90,4 +90,6 @@ email_search_information = "Sie können hier die aktuelle Suche per E-Mail verse
 
 #16750 SwitchTab recommendation
 nohit_change_tab = Sie haben nur in der Kategorie <b>%%activeTab%%</b> gesucht. Wählen Sie bei Bedarf eine andere Kategorie oder nutzen Sie die Facettierung:
-switchtab_headline = "Kategorie"
\ No newline at end of file
+switchtab_headline = "Kategorie"
+
+save_search_saved_in_account = Diese Suchanfrage ist bereits in Ihrem Konto gespeichert.
\ No newline at end of file
diff --git a/themes/fid_adlr/languages/en.ini b/themes/fid_adlr/languages/en.ini
index 66ba6dd89e3..c4b081b5461 100644
--- a/themes/fid_adlr/languages/en.ini
+++ b/themes/fid_adlr/languages/en.ini
@@ -92,4 +92,6 @@ email_search_information = "Here you can send the current search by e-mail. Opti
 
 #16750 SwitchTab recommendation
 nohit_change_tab = You have searched only in the category <b>%%activeTab%%</b>. If necessary, choose another category or use the faceting:
-switchtab_headline = "Category"
\ No newline at end of file
+switchtab_headline = "Category"
+
+save_search_saved_in_account = This search request is already saved in your account.
\ No newline at end of file
diff --git a/themes/fid_adlr/scss/compiled.scss b/themes/fid_adlr/scss/compiled.scss
index f7d074068a3..2a967e1bccf 100644
--- a/themes/fid_adlr/scss/compiled.scss
+++ b/themes/fid_adlr/scss/compiled.scss
@@ -427,6 +427,10 @@ a {
     float: right;
     font-size: calc(#{$font-size-base} * 1.5);
   }
+
+  &.disabled {
+    color: $asphalt-dark;
+  }
 }
 
 // ICONS - END
diff --git a/themes/fid_adlr/templates/search/results.phtml b/themes/fid_adlr/templates/search/results.phtml
index 0973736e4bf..267ac43e055 100644
--- a/themes/fid_adlr/templates/search/results.phtml
+++ b/themes/fid_adlr/templates/search/results.phtml
@@ -98,13 +98,18 @@ $this->headScript()->appendFile("check_save_statuses_adlr.js");
           </span>
           <span>
             <?php if ($this->accountCapabilities()->getSavedSearchSetting() === 'enabled'): ?>
-                <?php if (is_numeric($this->results->getSearchId())): ?>
-                    <?php if ($this->results->isSavedSearch()): ?>
-                  <a data-lightbox href="<?=$this->url('myresearch-savesearch')?>?delete=<?=urlencode($this->results->getSearchId())?>"><i class="fa fa-remove" aria-hidden="true"></i></a>
-                    <?php else: ?>
+              <?php if (is_numeric($this->results->getSearchId())): ?>
+                <?php if($this->auth()->isLoggedIn()): ?>
+                  <?php if ($this->results->isSavedSearch()): ?>
+                    <i class="icon icon-download icon-1.5x disabled" title="<?=$this->transEsc('save_search_saved_in_account')?>" aria-hidden="true"></i>
+                  <?php else: ?>
+                    <a id="save-search" data-lightbox href="<?=$this->url('myresearch-savesearch')?>?save=<?=urlencode($this->results->getSearchId())?>"><i class="icon icon-download icon-1.5x" aria-hidden="true"></i></a>
+                    <i id="saved-search" class="icon icon-download icon-1.5x disabled hidden" title="<?=$this->transEsc('save_search_saved_in_account')?>" aria-hidden="true"></i>
+                  <?php endif; ?>
+                <?php else: ?>
                   <a data-lightbox href="<?=$this->url('myresearch-savesearch')?>?save=<?=urlencode($this->results->getSearchId())?>"><i class="icon icon-download icon-1.5x" aria-hidden="true"></i></a>
-                    <?php endif; ?>
                 <?php endif; ?>
+              <?php endif; ?>
             <?php endif; ?>
           </span>
           <span>
-- 
GitLab