Browse Source

Show information if nothing was found in SearchInDocument tool.

pull/513/head
Alexander Bigga 2 years ago
parent
commit
94a631297b
  1. 1
      Classes/Plugin/Tools/SearchInDocumentTool.php
  2. 2
      Resources/Private/Language/SearchInDocumentTool.xml
  3. 1
      Resources/Private/Templates/SearchInDocumentTool.tmpl
  4. 16
      Resources/Public/Javascript/Search/SearchInDocument.js

1
Classes/Plugin/Tools/SearchInDocumentTool.php

@ -106,6 +106,7 @@ class SearchInDocumentTool extends \Kitodo\Dlf\Common\AbstractPlugin
'###LABEL_NEXT###' => $this->pi_getLL('label.next'),
'###LABEL_PREVIOUS###' => $this->pi_getLL('label.previous'),
'###LABEL_PAGE###' => $this->pi_getLL('label.logicalPage'),
'###LABEL_NORESULT###' => $this->pi_getLL('label.noresult'),
'###CURRENT_DOCUMENT###' => $this->doc->uid,
'###SOLR_ENCRYPTED###' => isset($encryptedSolr['encrypted']) ? $encryptedSolr['encrypted'] : '',
'###SOLR_HASH###' => isset($encryptedSolr['hash']) ? $encryptedSolr['hash'] : '',

2
Resources/Private/Language/SearchInDocumentTool.xml

@ -22,6 +22,7 @@
<label index="label.delete_search">Delete Search</label>
<label index="label.next">next</label>
<label index="label.previous">previous</label>
<label index="label.noresult">No result found in currenct document.</label>
<label index="search">Search</label>
</languageKey>
<languageKey index="de" type="array">
@ -32,6 +33,7 @@
<label index="label.delete_search">Suche löschen</label>
<label index="label.next">weiter</label>
<label index="label.previous">zurück</label>
<label index="label.noresult">Kein Ergebnis im aktuellen Dokument gefunden.</label>
<label index="search">Suche</label>
</languageKey>
</data>

1
Resources/Private/Templates/SearchInDocumentTool.tmpl

@ -27,5 +27,6 @@
<span id="tx-dlf-search-in-document-label-next">###LABEL_NEXT###</span>
<span id="tx-dlf-search-in-document-label-previous">###LABEL_PREVIOUS###</span>
<span id="tx-dlf-search-in-document-label-page">###LABEL_PAGE###</span>
<span id="tx-dlf-search-in-document-label-noresult">###LABEL_NORESULT###</span>
</div>
<!-- ###TEMPLATE### -->

16
Resources/Public/Javascript/Search/SearchInDocument.js

@ -70,7 +70,7 @@ $(document).ready(function() {
var resultItems = [];
var resultList = '<div class="results-active-indicator"></div><ul>';
if (data.error) {
resultList += '<li>' + data.error + '</li>';
resultList += '<li class="error">' + data.error + '</li>';
} else {
for (var i=0; i < data.response.docs.length; i++) {
@ -97,11 +97,15 @@ $(document).ready(function() {
resultItems[data.response.docs[i].page] = '<span class="structure">' + $('#tx-dlf-search-in-document-label-page').text() + ' ' + data.response.docs[i].page + '</span><br /><span ="textsnippet"><a href=\"' + newlink + '\">' + data.highlighting[data.response.docs[i].id].fulltext + '</a></span>';
}
}
// sort by page as this cannot be done with current solr schema
resultItems.sort(function(a, b){return a-b});
resultItems.forEach(function(item, index){
resultList += '<li>' + item + '</li>';
});
if (resultItems.length > 0) {
// sort by page as this cannot be done with current solr schema
resultItems.sort(function(a, b){return a-b});
resultItems.forEach(function(item, index){
resultList += '<li>' + item + '</li>';
});
} else {
resultList += '<li class="noresult">' + $('#tx-dlf-search-in-document-label-noresult').text() + '</li>';
}
}
resultList += '</ul>';
if (parseInt(data.response.start) > 0) {

Loading…
Cancel
Save