diff --git a/src/Controller/InstanceController.php b/src/Controller/InstanceController.php
index d42d703..c84ee1c 100644
--- a/src/Controller/InstanceController.php
+++ b/src/Controller/InstanceController.php
@@ -30,12 +30,12 @@ class InstanceController extends AppController
return $this->RestResponse->viewData($data, 'json');
}
- public function searchAll()
+ public function searchAll($limit = 5)
{
$searchValue = $this->request->getQuery('search');
$data = [];
if (!empty($searchValue)) {
- $data = $this->Instance->searchAll($searchValue);
+ $data = $this->Instance->searchAll($searchValue, $limit);
}
if ($this->ParamHandler->isRest()) {
return $this->RestResponse->viewData($data, 'json');
diff --git a/src/Model/Table/InstanceTable.php b/src/Model/Table/InstanceTable.php
index ef4ef24..8c23731 100644
--- a/src/Model/Table/InstanceTable.php
+++ b/src/Model/Table/InstanceTable.php
@@ -24,7 +24,7 @@ class InstanceTable extends AppTable
return $validator;
}
- public function searchAll($value)
+ public function searchAll($value, $limit=5)
{
$results = [];
foreach ($this->seachAllTables as $tableName) {
@@ -41,12 +41,12 @@ class InstanceTable extends AppTable
if (!empty($containFields)) {
$query->contain($containFields);
}
- $result = $query->limit(5)->all()->toList();
+ $results[$tableName]['amount'] = $query->count();
+ $result = $query->limit($limit)->all()->toList();
if (!empty($result)) {
- $results[$tableName] = $result;
+ $results[$tableName]['entries'] = $result;
}
}
-
return $results;
}
diff --git a/templates/Instance/search_all.php b/templates/Instance/search_all.php
index 7cffa3e..d49a3e3 100644
--- a/templates/Instance/search_all.php
+++ b/templates/Instance/search_all.php
@@ -1,6 +1,9 @@
$tableResult) {
+ if (empty($tableResult['amount'])) {
+ continue;
+ }
$section = '';
$table = Cake\ORM\TableRegistry::get($tableName);
$fieldPath = !empty($table->getDisplayField()) ? $table->getDisplayField() : 'id';
@@ -11,7 +14,7 @@
', h($tableName));
- foreach ($tableResult as $entry) {
+ foreach ($tableResult['entries'] as $entry) {
$section .= sprintf('%s',
Cake\Routing\Router::URL([
'controller' => Cake\Utility\Inflector::pluralize($entry->getSource()),
@@ -21,6 +24,13 @@
h($entry[$fieldPath])
);
}
+ $remaining = $tableResult['amount'] - count($tableResult['entries']);
+ if ($remaining > 0) {
+ $section .= sprintf('%s%s',
+ $remaining,
+ __('more results')
+ );
+ }
$sections[] = $section;
}
diff --git a/webroot/css/layout.css b/webroot/css/layout.css
index 658f3a2..6e116aa 100644
--- a/webroot/css/layout.css
+++ b/webroot/css/layout.css
@@ -139,6 +139,16 @@ main.content {
margin: auto 0;
}
+.global-search-result-container .total-found {
+ font-size: 0.75rem;
+ padding-top: 0rem;
+ text-align: end;
+}
+
+.global-search-result-container .total-found .total-found-number {
+ font-size: 0.9rem;
+}
+
.global-search-result-container .search-container-model .model-text {
font-size: 0.75rem;
font-weight: 600;