use a stats array from fulltext search for min/max of facet value

This commit is contained in:
Uwe Steinmann 2023-12-15 17:13:28 +01:00
parent 62ff3da502
commit facd9f7a65
2 changed files with 9 additions and 3 deletions

View File

@ -356,10 +356,12 @@ if($fullsearch) {
$totalPages = 0;
$entries = array();
$facets = array();
$stats = array();
$searchTime = 0;
} else {
$entries = array();
$facets = $searchresult['facets'];
$stats = $searchresult['stats'] ?? null;
$dcount = 0;
$fcount = 0;
if($searchresult['hits']) {
@ -406,6 +408,7 @@ if($fullsearch) {
$totalPages = 0;
$entries = array();
$facets = array();
$stats = array();
$searchTime = 0;
}
}
@ -680,6 +683,7 @@ if($fullsearch) {
} else
$totalPages = 1;
$facets = array();
$stats = array();
// }}}
}
@ -700,6 +704,7 @@ if($settings->_showSingleSearchHit && count($entries) == 1) {
$accessop = new SeedDMS_AccessOperation($dms, null, $user, $settings);
if($view) {
$view->setParam('facets', $facets);
$view->setParam('stats', $stats);
$view->setParam('accessobject', $accessop);
$view->setParam('query', $query);
$view->setParam('includecontent', $includecontent);

View File

@ -393,6 +393,7 @@ $(document).ready(function() {
$orderby = $this->params['orderby'];
$entries = $this->params['searchhits'];
$facets = $this->params['facets'];
$stats = $this->params['stats'];
$totalpages = $this->params['totalpages'];
$pageNumber = $this->params['pagenumber'];
$searchTime = $this->params['searchtime'];
@ -1221,14 +1222,14 @@ $(document).ready(function() {
case SeedDMS_Core_AttributeDefinition::type_date:
if($values && (count($values) > 1 || reset($values) < $total)) {
if(empty($allparams['attributes'][$facetname]['from']) && empty($allparams['attributes'][$facetname]['to'])) {
$tt = array_keys($values);
$tt = isset($stats[$facetname]) ? $stats[$facetname] : [];//array_keys($values);
$content = '';
$content .= '<p><a href="'.$newrequest->getRequestUri().'&attributes['.$facetname.']=__notset__">'.getMLText('objects_without_attribute').'</a></p>';
$content .= '<div class="input-group">';
$content .= '<span class="input-group-text" style="border-right: 0;"> from </span>';
$content .= $this->getDateChooser('', "attributes[".$facetname."][from]", $this->params['session']->getLanguage(), '', getReadableDate(min($tt)), getReadableDate(max($tt)), null, '', true);
$content .= $this->getDateChooser('', "attributes[".$facetname."][from]", $this->params['session']->getLanguage(), '', $tt ? getReadableDate($tt['min']) : null, $tt ? getReadableDate($tt['max']) : null, null, '', true);
$content .= '<span class="input-group-text" style="border-left: 0; border-right: 0;"> to </span>';
$content .= $this->getDateChooser('', "attributes[".$facetname."][to]", $this->params['session']->getLanguage(), '', getReadableDate(min($tt)), getReadableDate(max($tt)), null, '', true);
$content .= $this->getDateChooser('', "attributes[".$facetname."][to]", $this->params['session']->getLanguage(), '', $tt ? getReadableDate($tt['min']) : null, $tt ? getReadableDate($tt['max']) : null, null, '', true);
$content .= '<button class="btn btn-primary" type="submit">Set</button>';
$content .= '</div>';
$this->printAccordion($dispname, $content);