Skip to content

Commit

Permalink
small adjusments
Browse files Browse the repository at this point in the history
  • Loading branch information
cedric-anne committed Jan 11, 2024
1 parent 46e3a34 commit 12c56f0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
22 changes: 12 additions & 10 deletions src/SavedSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -861,35 +861,37 @@ public function getMine(string $itemtype = null, bool $inverse = false, bool $en

$iterator = $DB->request($criteria);
foreach ($iterator as $data) {
$error = false;

if ($_SESSION['glpishow_count_on_tabs']) {
$this->fields = $data;
$count = null;
$search_data = null;
try {
$search_data = $this->execute(false, $enable_partial_warnings);
} catch (\RuntimeException $e) {
ErrorHandler::getInstance()->handleException($e);
$search_data = false;
} catch (\Throwable $e) {
ErrorHandler::getInstance()->handleException($e);
$error = true;
}

if ($error) {
$info_message = __s('A fatal error occurred while executing this saved search. It is not able to be used.');
$count = "<span class='ti ti-alert-triangle-filled' title='$info_message'></span>";
$data['_error'] = true;
}
if (isset($search_data['data']['totalcount'])) {
} elseif (isset($search_data['data']['totalcount'])) {
$count = $search_data['data']['totalcount'];
} else {
$info_message = ($this->fields['do_count'] == self::COUNT_NO)
? __s('Count for this saved search has been disabled.')
: __s('Counting this saved search would take too long, it has been skipped.');
if ($count === null) {
//no count, just inform the user
$count = "<span class='ti ti-info-circle' title='$info_message'></span>";
}
// no count, just inform the user
$count = "<span class='ti ti-info-circle' title='$info_message'></span>";
}

$data['count'] = $count;
}

$data['_error'] = $error;

$searches[$data['id']] = $data;
}

Expand Down
4 changes: 2 additions & 2 deletions templates/layout/parts/saved_searches_list.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
{% for search in saved_searches %}
<div class="savedsearches-item grip-savedsearch list-group-item search-line d-flex align-items-center pe-1 {{ active == search['id'] ? 'active' : '' }}"
data-id="{{ search['id'] }}">
{% if search['_error'] is not defined or search['_error'] == false %}
{% if not search['_error'] %}
<a href="{{ 'SavedSearch'|itemtype_search_path }}?action=load&amp;id={{ search['id'] }}"
class="d-block saved-searches-link text-truncate">
{{ search['name']|verbatim_value }}
Expand All @@ -52,7 +52,7 @@
</span>
{% endif %}
<div class="{{ search['is_default'] > 0 ? '' : 'list-group-item-actions' }} ms-auto default-ctrl">
{% if search['_error'] is not defined or search['_error'] == false %}
{% if not search['_error'] %}
<i class="{{ search['is_default'] > 0 ? 'fas' : 'far' }} fa-star fa-xs mark-default me-1"
title="{{ search['is_default'] > 0 ? __('Default search') : __('mark as default') }}"
data-bs-toggle="tooltip" data-bs-placement="right"
Expand Down

0 comments on commit 12c56f0

Please sign in to comment.