adjust css/js of global-search; added missing id fields for searchable entities

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2022-05-15 19:01:44 +02:00
parent e6916de532
commit a68db7c80d
6 changed files with 22 additions and 9 deletions

View File

@@ -187,7 +187,7 @@ class GlobalSearch
'result_format' => [
'title' => ['self', 'getFieldFromResult'],
'title_args' => 'name',
'href' => 'admin_plans.php?page=overview&action=edit&id='
'href' => 'admin_plans.php?page=overview&searchfield=id&searchtext='
]
],
// PHP configs

View File

@@ -34,6 +34,10 @@ return [
'icon' => 'fa-brands fa-php',
'self_overview' => ['section' => 'phpsettings', 'page' => 'overview'],
'columns' => [
'c.id' => [
'label' => 'ID',
'field' => 'id',
],
'c.description' => [
'label' => lng('admin.phpsettings.description'),
'field' => 'description',

View File

@@ -31,6 +31,10 @@ return [
'title' => lng('admin.plans.plans'),
'icon' => 'fa-solid fa-clipboard-list',
'columns' => [
'p.id' => [
'label' => 'ID',
'field' => 'id',
],
'p.name' => [
'label' => lng('admin.plans.name'),
'field' => 'name',

View File

@@ -10,12 +10,14 @@ $(function() {
let dropdown = $('#search .search-results');
// Hide search if query is empty
if (!query.length) {
dropdown.hide().html('');
dropdown.html('');
dropdown.parent().hide();
return;
}
// Show notification for short search query
if (query.length && query.length < 3) {
dropdown.show().html('<li class="list-group-item text-muted">Please enter more than 2 characters</li>');
dropdown.html('<li class="list-group-item text-muted">Please enter more than 2 characters</li>');
dropdown.parent().show();
return;
}
// Search
@@ -29,12 +31,14 @@ $(function() {
success: data => {
// Show notification if we got no results
if (Object.keys(data).length === 0) {
dropdown.show().html('<li class="list-group-item text-muted">Nothing found!</li>');
dropdown.html('<li class="list-group-item text-muted">Nothing found!</li>');
dropdown.parent().show();
return;
}
// Clear dropdown and show results
dropdown.show().html('');
dropdown.html('');
dropdown.parent().show();
Object.keys(data).forEach(key => {
dropdown.append('<li class="list-group-item text-muted text-capitalize">' + key + '</li>');
data[key].forEach(item => {
@@ -44,7 +48,8 @@ $(function() {
},
error: function (a, b) {
console.log(a, b);
dropdown.show().html('<li class="list-group-item text-muted">Whoops we got some errors!</li>');
dropdown.html('<li class="list-group-item text-muted">Whoops we got some errors!</li>');
dropdown.parent().show();
}
});
});

View File

@@ -23,7 +23,7 @@
border-radius: 0 0 $border-radius $border-radius;
.search-results {
width: 70vh; /** same as .search-results-box **/
width: 100%; /** same as .search-results-box **/
max-height: calc(50vh - 2px); /** same as .search-results-box - border (top/bottom) **/
overflow: auto;
border-radius: $border-radius;

View File

@@ -36,8 +36,8 @@
<i class="fa fa-search text-muted"></i>
<input title="search" type="search" class="search-input" placeholder="Search for ...">
</div>
<div class="search-results-box">
<div class="search-results list-group-flush" style="display: none"></div>
<div class="search-results-box" style="display:none;">
<div class="search-results list-group-flush"></div>
</div>
</form>
<ul class="navbar-nav ms-auto">