show number of occurances in subtitle of options

This commit is contained in:
Uwe Steinmann 2023-03-06 10:03:28 +01:00
parent 0e712c1554
commit 742929002b

View File

@ -854,9 +854,12 @@ function typeahead() { /* {{{ */
foreach($values as $v=>$c) { foreach($values as $v=>$c) {
$uu = $dms->getUserByLogin($v); $uu = $dms->getUserByLogin($v);
if($uu) { if($uu) {
$option = array($uu->getId(), $v.' ('.$c.')'); $option = array($uu->getId(), $v/*.' ('.$c.')'*/);
if(isset(${$facetname}) && in_array($uu->getId(), ${$facetname})) if(isset(${$facetname}) && in_array($uu->getId(), ${$facetname}))
$option[] = true; $option[] = true;
else
$option[] = false;
$option[] = array(array('data-subtitle', $c.' ×'));
$options[] = $option; $options[] = $option;
} }
} }
@ -864,35 +867,48 @@ function typeahead() { /* {{{ */
foreach($values as $v=>$c) { foreach($values as $v=>$c) {
$cat = $dms->getDocumentCategoryByName($v); $cat = $dms->getDocumentCategoryByName($v);
if($cat) { if($cat) {
$option = array($cat->getId(), $v.' ('.$c.')'); $option = array($cat->getId(), $v/*.' ('.$c.')'*/);
if(isset(${$facetname}) && in_array($cat->getId(), ${$facetname})) if(isset(${$facetname}) && in_array($cat->getId(), ${$facetname}))
$option[] = true; $option[] = true;
else
$option[] = false;
$option[] = array(array('data-subtitle', $c.' ×'));
$options[] = $option; $options[] = $option;
} }
} }
} elseif($facetname == 'status') { } elseif($facetname == 'status') {
foreach($values as $v=>$c) { foreach($values as $v=>$c) {
$option = array($v, getOverallStatusText($v).' ('.$c.')'); $option = array($v, getOverallStatusText($v)/*.' ('.$c.')'*/);
if(isset(${$facetname}) && in_array($v, ${$facetname})) if(isset(${$facetname}) && in_array($v, ${$facetname}))
$option[] = true; $option[] = true;
$options[] = $option; else
$option[] = false;
$option[] = array(array('data-subtitle', $c.' ×'));
$options[] = $option;
} }
} elseif(substr($facetname, 0, 5) == 'attr_') { } elseif(substr($facetname, 0, 5) == 'attr_') {
foreach($values as $v=>$c) { foreach($values as $v=>$c) {
$option = array($v, $v.' ('.$c.')'); $option = array($v, $v/*.' ('.$c.')'*/);
if(isset($attributes[$facetname]) && in_array($v, $attributes[$facetname])) if(isset($attributes[$facetname]) && in_array($v, $attributes[$facetname]))
$option[] = true; $option[] = true;
$options[] = $option; else
$option[] = false;
$option[] = array(array('data-subtitle', $c.' ×'));
$options[] = $option;
} }
} else { } else {
foreach($values as $v=>$c) { foreach($values as $v=>$c) {
$option = array($v, $v.' ('.$c.')'); $option = array($v, $v.' ('.$c.')');
if(isset(${$facetname}) && in_array($v, ${$facetname})) if(isset(${$facetname}) && in_array($v, ${$facetname}))
$option[] = true; $option[] = true;
else
$option[] = false;
$option[] = array(array('data-subtitle', $c.' ×'));
$options[] = $option; $options[] = $option;
} }
} }
if(substr($facetname, 0, 5) == 'attr_') { if(substr($facetname, 0, 5) == 'attr_') {
if($options) {
$tmp = explode('_', $facetname); $tmp = explode('_', $facetname);
if($attrdef = $dms->getAttributeDefinition($tmp[1])) if($attrdef = $dms->getAttributeDefinition($tmp[1]))
$dispname = $attrdef->getName(); $dispname = $attrdef->getName();
@ -910,6 +926,7 @@ function typeahead() { /* {{{ */
'multiple'=>$multiple 'multiple'=>$multiple
) )
); );
}
} else { } else {
$this->formField( $this->formField(
getMLText($facetname), getMLText($facetname),