Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ticket): restores group's tooltip #17589

Merged
merged 5 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 29 additions & 4 deletions ajax/comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@

Session::checkLoginUser();

use Glpi\Application\View\TemplateRenderer;

if (
isset($_POST["itemtype"])
&& isset($_POST["value"])
) {
// Security
// Security
if (!is_subclass_of($_POST["itemtype"], "CommonDBTM")) {
exit();
}
Expand Down Expand Up @@ -81,7 +83,7 @@
}
}
}
echo ($tmpname["comment"] ?? '');
echo($tmpname["comment"] ?? '');

if (isset($_POST['withlink']) && isset($tmpname['link'])) {
echo "<script type='text/javascript' >\n";
Expand All @@ -90,6 +92,29 @@
}
break;

case Group::getType():
$tmpname = [
'comment' => "",
];
if ($_POST['value'] != 0) {
$group = new \Group();
if (!is_array($_POST["value"]) && $group->getFromDB($_POST['value']) && $group->canView()) {
$group_params = [
'id' => $group->getID(),
'group_name' => $group->fields['completename'],
'comment' => $group->fields['comment'],
];
$comment = TemplateRenderer::getInstance()->render('components/group/info_card.html.twig', [
'group' => $group_params,
]);
$tmpname = [
'comment' => $comment,
];
}
}
echo($tmpname["comment"] ?? '');
break;

default:
if ($_POST["value"] > 0) {
if (
Expand Down Expand Up @@ -123,12 +148,12 @@
$item = getItemForItemtype($_POST['itemtype']);
echo "<script type='text/javascript' >\n";

//if item have a DC position (reload url to it's rack)
//if item have a DC position (reload url to it's rack)
if ($rack = $item->isRackPart($_POST['itemtype'], $_POST["value"], true)) {
echo Html::jsGetElementbyID($_POST['with_dc_position']) . ".
html(\"&nbsp;<a class='fas fa-crosshairs' href='" . $rack->getLinkURL() . "'></a>\");";
} else {
//remove old dc position
//remove old dc position
echo Html::jsGetElementbyID($_POST['with_dc_position']) . ".empty();";
}
echo "</script>\n";
Expand Down
53 changes: 53 additions & 0 deletions templates/components/group/info_card.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{#
# ---------------------------------------------------------------------
#
# GLPI - Gestionnaire Libre de Parc Informatique
#
# http://glpi-project.org
#
# @copyright 2015-2024 Teclib' and contributors.
# @copyright 2003-2014 by the INDEPNET Development Team.
# @licence https://www.gnu.org/licenses/gpl-3.0.html
#
# ---------------------------------------------------------------------
#
# LICENSE
#
# This file is part of GLPI.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# ---------------------------------------------------------------------
#}

<div class="p-0 group-info-card">
AdrienClairembault marked this conversation as resolved.
Show resolved Hide resolved
<div class="row">
<h4 class="card-title mb-1">
{% if group['id'] %}
<a href="{{ 'Group'|itemtype_form_path(group['id']) }}">{{ group['group_name'] }}</a>
{% else %}
{{ group['group_name'] }}
{% endif %}
</h4>

<div class="text-muted">
{% if group['comment']|length > 0 %}
<div>
<i class="ti ti-notes"></i>
{{ group['comment'] }}
</div>
{% endif %}
</div>
</div>
</div>
28 changes: 28 additions & 0 deletions templates/components/itilobject/actors/field.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,23 @@
});
}

if (is_selection && itemtype == "Group") {
const unique_id = "group_opt_" + actor_select.attr('data-actor-type') + "Group" + items_id;
$.ajax({
url: '{{ path('/ajax/comments.php') }}',
type: 'POST',
data: {
'itemtype': 'Group',
'value': items_id,
}
}).then((result) => {
if (result) {
actor_select.parent().append('<' + `div id="content${unique_id}" style="display: none;">` + result + '<' + '/div>');
option_element.attr('data-glpi-popover-source', `content${unique_id}`);
}
});
}

// manage ticket information (number of assigned ticket for an actor)
if (is_selection && itemtype != "Email") {
var label = '';
Expand Down Expand Up @@ -291,6 +308,10 @@
if ($('.user-info-card:hover').length > 0) {
return false;
}
// prevent closing popover when group card is hover
if ($('.group-info-card:hover').length > 0) {
return false;
}
});
});

Expand All @@ -301,6 +322,13 @@
}, 300);
});

// when the mouse leave the group card in the popover, close it
$(document).on('mouseleave', '.group-info-card', function() {
setTimeout(() => {
$('.popover').popover('hide');
}, 300);
});

// manage actors change
var updateActors{{ rand }} = function() {
var data = $("#actor_{{ rand }}").select2('data');
Expand Down