From 4bbf6ddecf2b2fc5bd4386d51aa4d7f020810e00 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Fri, 19 Aug 2022 10:06:27 +0200 Subject: [PATCH] output additional filters only if attributes exists --- views/bootstrap/class.Search.php | 62 ++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 26 deletions(-) diff --git a/views/bootstrap/class.Search.php b/views/bootstrap/class.Search.php index 85e7f226e..d347972f0 100644 --- a/views/bootstrap/class.Search.php +++ b/views/bootstrap/class.Search.php @@ -286,7 +286,7 @@ function typeahead() { /* {{{ */
-
+ contentContainerEnd(); + // Seach options for documents and folders {{{ /* First check if any of the folder/document filters are set. If it is, * open the accordion. */ $openfilterdlg = false; + $hasattrs = false; if($attrdefs) { foreach($attrdefs as $attrdef) { if($attrdef->getObjType() == SeedDMS_Core_AttributeDefinition::objtype_all) { /* Do not check dates because they always have 'from' and 'to' element * even if it is empty. FIXME should be also checked. */ + $hasattrs = true; if($attrdef->getType() != SeedDMS_Core_AttributeDefinition::type_date) if(!empty($attributes[$attrdef->getID()])) $openfilterdlg = true; } } } - ob_start(); - if($attrdefs) { - foreach($attrdefs as $attrdef) { - if($attrdef->getObjType() == SeedDMS_Core_AttributeDefinition::objtype_all) { - if($attrdef->getType() == SeedDMS_Core_AttributeDefinition::type_date) { - $this->formField(htmlspecialchars($attrdef->getName().' ('.getMLText('from').')'), $this->getAttributeEditField($attrdef, !empty($attributes[$attrdef->getID()]['from']) ? getReadableDate(makeTsFromDate($attributes[$attrdef->getID()]['from'])) : '', 'attributes', true, 'from')); - $this->formField(htmlspecialchars($attrdef->getName().' ('.getMLText('to').')'), $this->getAttributeEditField($attrdef, !empty($attributes[$attrdef->getID()]['to']) ? getReadableDate(makeTsFromDate($attributes[$attrdef->getID()]['to'])) : '', 'attributes', true, 'to')); - } else - $this->formField(htmlspecialchars($attrdef->getName()), $this->getAttributeEditField($attrdef, isset($attributes[$attrdef->getID()]) ? $attributes[$attrdef->getID()] : '', 'attributes', true)); + if($hasattrs) { + ob_start(); + if($attrdefs) { + foreach($attrdefs as $attrdef) { + if($attrdef->getObjType() == SeedDMS_Core_AttributeDefinition::objtype_all) { + if($attrdef->getType() == SeedDMS_Core_AttributeDefinition::type_date) { + $this->formField(htmlspecialchars($attrdef->getName().' ('.getMLText('from').')'), $this->getAttributeEditField($attrdef, !empty($attributes[$attrdef->getID()]['from']) ? getReadableDate(makeTsFromDate($attributes[$attrdef->getID()]['from'])) : '', 'attributes', true, 'from')); + $this->formField(htmlspecialchars($attrdef->getName().' ('.getMLText('to').')'), $this->getAttributeEditField($attrdef, !empty($attributes[$attrdef->getID()]['to']) ? getReadableDate(makeTsFromDate($attributes[$attrdef->getID()]['to'])) : '', 'attributes', true, 'to')); + } else + $this->formField(htmlspecialchars($attrdef->getName()), $this->getAttributeEditField($attrdef, isset($attributes[$attrdef->getID()]) ? $attributes[$attrdef->getID()] : '', 'attributes', true)); + } } } + $content = ob_get_clean(); + $this->printAccordion(getMLText('filter_for_documents_and_folders'), $content, $openfilterdlg); } - $content = ob_get_clean(); - $this->printAccordion(getMLText('filter_for_documents_and_folders'), $content, $openfilterdlg); + // }}} // Seach options for documents {{{ /* First check if any of the folder filters are set. If it is, @@ -515,39 +521,43 @@ function typeahead() { /* {{{ */ } } } + + $content = ob_get_clean(); + $this->printAccordion(getMLText('filter_for_documents'), $content, $openfilterdlg); // }}} // Seach options for folders {{{ - $content = ob_get_clean(); - $this->printAccordion(getMLText('filter_for_documents'), $content, $openfilterdlg); /* First check if any of the folder filters are set. If it is, * open the accordion. */ $openfilterdlg = false; + $hasattrs = false; if($attrdefs) { foreach($attrdefs as $attrdef) { if($attrdef->getObjType() == SeedDMS_Core_AttributeDefinition::objtype_folder) { + $hasattrs = true; if($attrdef->getType() != SeedDMS_Core_AttributeDefinition::type_date) if(!empty($attributes[$attrdef->getID()])) $openfilterdlg = true; } } } - ob_start(); - if($attrdefs) { - foreach($attrdefs as $attrdef) { - if($attrdef->getObjType() == SeedDMS_Core_AttributeDefinition::objtype_folder) { - if($attrdef->getType() == SeedDMS_Core_AttributeDefinition::type_date) { - $this->formField(htmlspecialchars($attrdef->getName().' ('.getMLText('from').')'), $this->getAttributeEditField($attrdef, !empty($attributes[$attrdef->getID()]['from']) ? getReadableDate(makeTsFromDate($attributes[$attrdef->getID()]['from'])) : '', 'attributes', true, 'from')); - $this->formField(htmlspecialchars($attrdef->getName().' ('.getMLText('to').')'), $this->getAttributeEditField($attrdef, !empty($attributes[$attrdef->getID()]['to']) ? getReadableDate(makeTsFromDate($attributes[$attrdef->getID()]['to'])) : '', 'attributes', true, 'to')); - } else - $this->formField(htmlspecialchars($attrdef->getName()), $this->getAttributeEditField($attrdef, isset($attributes[$attrdef->getID()]) ? $attributes[$attrdef->getID()] : '', 'attributes', true)); + if($hasattrs) { + ob_start(); + if($attrdefs) { + foreach($attrdefs as $attrdef) { + if($attrdef->getObjType() == SeedDMS_Core_AttributeDefinition::objtype_folder) { + if($attrdef->getType() == SeedDMS_Core_AttributeDefinition::type_date) { + $this->formField(htmlspecialchars($attrdef->getName().' ('.getMLText('from').')'), $this->getAttributeEditField($attrdef, !empty($attributes[$attrdef->getID()]['from']) ? getReadableDate(makeTsFromDate($attributes[$attrdef->getID()]['from'])) : '', 'attributes', true, 'from')); + $this->formField(htmlspecialchars($attrdef->getName().' ('.getMLText('to').')'), $this->getAttributeEditField($attrdef, !empty($attributes[$attrdef->getID()]['to']) ? getReadableDate(makeTsFromDate($attributes[$attrdef->getID()]['to'])) : '', 'attributes', true, 'to')); + } else + $this->formField(htmlspecialchars($attrdef->getName()), $this->getAttributeEditField($attrdef, isset($attributes[$attrdef->getID()]) ? $attributes[$attrdef->getID()] : '', 'attributes', true)); + } } } - } - $content = ob_get_clean(); - if($content) + $content = ob_get_clean(); $this->printAccordion(getMLText('filter_for_folders'), $content, $openfilterdlg); + } // }}} $this->formSubmit(" ".getMLText('search'));