Skip to content

Commit

Permalink
Simplify ticket page on helpdesk
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrienClairembault authored Jan 30, 2025
1 parent a503e22 commit 3f230ed
Show file tree
Hide file tree
Showing 8 changed files with 131 additions and 117 deletions.
2 changes: 1 addition & 1 deletion css/includes/components/itilobject/_layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
}
}

.horizontal-layout {
.central.horizontal-layout {
.itil-object {
@include media-breakpoint-up(lg) {
height: calc(100vh - 257px);
Expand Down
28 changes: 14 additions & 14 deletions phpunit/functional/TicketTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1691,20 +1691,20 @@ public function testFormPostOnly()

$this->checkFormOutput(
$ticket,
$name = false,
$textarea = true,
$priority = false,
$save = true,
$assign = false,
$openDate = false,
$timeOwnResolve = false,
$type = false,
$status = false,
$urgency = true,
$impact = false,
$category = true,
$requestSource = false,
$location = false
name: false,
textarea: true,
priority: false,
save: false,
assign: false,
openDate: false,
timeOwnResolve: false,
type: false,
status: false,
urgency: false,
impact: false,
category: false,
requestSource: false,
location: false,
);

$uid = getItemByTypeName('User', TU_USER, true);
Expand Down
42 changes: 18 additions & 24 deletions src/Ticket.php
Original file line number Diff line number Diff line change
Expand Up @@ -831,35 +831,29 @@ public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $

public function defineTabs($options = [])
{
$ong = [];
$this->addDefaultFormTab($ong);
$this->addStandardTab(__CLASS__, $ong, $options);
$this->addStandardTab('TicketValidation', $ong, $options);
$this->addStandardTab('KnowbaseItem_Item', $ong, $options);
$this->addStandardTab('Item_Ticket', $ong, $options);

if ($this->hasImpactTab()) {
$this->addStandardTab('Impact', $ong, $options);
}

$this->addStandardTab('TicketCost', $ong, $options);
$this->addStandardTab('Itil_Project', $ong, $options);
$this->addStandardTab('ProjectTask_Ticket', $ong, $options);
$this->addStandardTab('Problem_Ticket', $ong, $options);
$this->addStandardTab('Change_Ticket', $ong, $options);
$tabs = [];
$this->addDefaultFormTab($tabs);

if (Session::getCurrentInterface() == 'central') {
$this->addStandardTab(Ticket_Contract::class, $ong, $options);
}
$this->addStandardTab(__CLASS__, $tabs, $options);
$this->addStandardTab('TicketValidation', $tabs, $options);
$this->addStandardTab('KnowbaseItem_Item', $tabs, $options);
$this->addStandardTab('Item_Ticket', $tabs, $options);

if (
Entity::getAnonymizeConfig($this->getEntityID()) == Entity::ANONYMIZE_DISABLED
|| Session::getCurrentInterface() == 'central'
) {
$this->addStandardTab('Log', $ong, $options);
if ($this->hasImpactTab()) {
$this->addStandardTab('Impact', $tabs, $options);
}

$this->addStandardTab('TicketCost', $tabs, $options);
$this->addStandardTab('Itil_Project', $tabs, $options);
$this->addStandardTab('ProjectTask_Ticket', $tabs, $options);
$this->addStandardTab('Problem_Ticket', $tabs, $options);
$this->addStandardTab('Change_Ticket', $tabs, $options);
$this->addStandardTab(Ticket_Contract::class, $tabs, $options);
$this->addStandardTab('Log', $tabs, $options);
}

return $ong;
return $tabs;
}


Expand Down
144 changes: 80 additions & 64 deletions templates/components/itilobject/footer.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
# ---------------------------------------------------------------------
#}

{% set is_helpdesk = get_current_interface() == 'helpdesk' %}
{% set timeline_btns_cls = left_regular_cls %}
{% set form_btns_cls = is_expanded ? right_expanded_cls : "col-lg" %}
{% set timeline_btn_layout = session('glpitimeline_action_btn_layout') %}
Expand All @@ -43,7 +44,7 @@

<div class="mx-n2 mb-n2 itil-footer itil-footer p-0 border-top" id="itil-footer">
<div class="buttons-bar d-flex py-2">
<div class="col {{ timeline_btns_cls }} ps-3 timeline-buttons d-flex">
<div class="col {{ not is_helpdesk ? timeline_btns_cls : '' }} ps-3 timeline-buttons d-flex">
{% if not item.isNewItem() %}
{% set main_actions_itemtypes = timeline_itemtypes|filter((v, k) => v.hide_in_menu is not defined or v.hide_in_menu != true) %}

Expand All @@ -58,7 +59,7 @@
<div class="main-actions" style="display:inline-flex">
{% endif %}
<button
class="btn btn-primary answer-action mb-2 {{ default_action != "answer" ? "action-" ~ default_action : "" }}"
class="btn btn-primary answer-action {{ default_action != "answer" ? "action-" ~ default_action : "" }}"
data-bs-toggle="collapse"
data-bs-target="#new-{{ default_action_data.class }}-block"
>
Expand All @@ -70,7 +71,7 @@
{% if timeline_btn_layout == constant('Config::TIMELINE_ACTION_BTN_SPLITTED') %}
{% for action, timeline_itemtype in main_actions_itemtypes %}
{% if loop.index0 > 0 %}
<button class="ms-2 mb-2 btn btn-primary answer-action action-{{ action }}" data-bs-toggle="collapse" data-bs-target="#new-{{ timeline_itemtype.class }}-block">
<button class="ms-2 btn btn-primary answer-action action-{{ action }}" data-bs-toggle="collapse" data-bs-target="#new-{{ timeline_itemtype.class }}-block">
<i class="{{ timeline_itemtype.icon }}"></i>
<span>{{ timeline_itemtype.short_label }}</span>
</button>
Expand All @@ -79,7 +80,7 @@
{% else %}
<button
type="button"
class="btn btn-primary dropdown-toggle dropdown-toggle-split mb-2 {{ default_action != "answer" ? "action-" ~ default_action : "" }}"
class="btn btn-primary dropdown-toggle dropdown-toggle-split {{ default_action != "answer" ? "action-" ~ default_action : "" }}"
data-bs-toggle="dropdown"
aria-expanded="false"
>
Expand All @@ -104,74 +105,89 @@
<ul class="legacy-timeline-actions">
{{ legacy_timeline_actions|default('')|raw }}
</ul>
{{ include('components/itilobject/timeline/filter_timeline.html.twig') }}

<div class="ms-auto"></div>

{% if item.canDeleteItem() %}
<button class="btn btn-ghost-danger" type="submit" name="delete" form="itil-form">
<i class="ti ti-trash me-1"></i>
<span>{{ __("Cancel ticket") }}</span>
</button>
{% endif %}

{% if not is_helpdesk %}
{{ include('components/itilobject/timeline/filter_timeline.html.twig') }}
{% endif %}
{% endif %}
</div>

<div class="form-buttons {{ form_btns_cls }} d-flex justify-content-between ms-auto ms-lg-0 my-n2 py-2 pe-3 card-footer border-top-0 position-relative">
<span class="d-none d-lg-block ms-n3"
data-bs-toggle="tooltip" data-bs-placement="top" title="{{ __('Toggle panels width') }}">
<button type="button" class="switch-panel-width btn btn-icon btn-ghost-secondary px-0">
<i class="{{ switch_btn_cls }}"></i>
</button>
<button type="button" class="collapse-panel btn btn-icon btn-ghost-secondary px-0 mr-1">
<i class="ti ti-caret-right-filled"></i>
</button>
</span>

<span>
{% if item.isNewItem() %}
<button class="btn btn-primary" type="submit" name="add" form="itil-form"
title="{{ _x('button', 'Add') }}">
<i class="ti ti-plus"></i>
<span class="d-none d-lg-block">{{ _x('button', 'Add') }}</span>
</button>
{% else %}

<div class="btn-group" role="group" id="right-actions">
{% set is_locked = params['locked'] is defined and params['locked'] %}
{% set display_save_btn = not is_locked and (canupdate or can_requester or canpriority or canassign or canassigntome) %}
{% if display_save_btn %}
<button class="btn btn-primary" type="submit" name="update" form="itil-form"
title="{{ _x('button', 'Save') }}">
<i class="ti ti-device-floppy"></i>
<span class="d-none d-xl-block">{{ _x('button', 'Save') }}</span>
</button>
{% endif %}

{% if item.canDeleteItem() %}
{% if item.isDeleted() %}
<button class="btn btn-outline-secondary" type="submit" name="restore" form="itil-form"
title="{{ _x('button', 'Restore') }}">
<i class="ti ti-trash-off"></i>
<span class="d-none d-lg-block">{{ _x('button', 'Restore') }}</span>
{% if not is_helpdesk %}
<div class="form-buttons {{ form_btns_cls }} d-flex justify-content-between ms-auto ms-lg-0 my-n2 py-2 pe-3 card-footer border-top-0 position-relative">
<span class="d-none d-lg-block ms-n3"
data-bs-toggle="tooltip" data-bs-placement="top" title="{{ __('Toggle panels width') }}">
<button type="button" class="switch-panel-width btn btn-icon btn-ghost-secondary px-0">
<i class="{{ switch_btn_cls }}"></i>
</button>
<button type="button" class="collapse-panel btn btn-icon btn-ghost-secondary px-0 mr-1">
<i class="ti ti-caret-right-filled"></i>
</button>
</span>

<span>
{% if item.isNewItem() %}
<button class="btn btn-primary" type="submit" name="add" form="itil-form"
title="{{ _x('button', 'Add') }}">
<i class="ti ti-plus"></i>
<span class="d-none d-lg-block">{{ _x('button', 'Add') }}</span>
</button>
{% else %}

<div class="btn-group" role="group" id="right-actions">
{% set is_locked = params['locked'] is defined and params['locked'] %}
{% set display_save_btn = not is_locked and (canupdate or can_requester or canpriority or canassign or canassigntome) %}
{% if display_save_btn %}
<button class="btn btn-primary" type="submit" name="update" form="itil-form"
title="{{ _x('button', 'Save') }}">
<i class="ti ti-device-floppy"></i>
<span class="d-none d-xl-block">{{ _x('button', 'Save') }}</span>
</button>
{% endif %}

<button class="btn btn-outline-danger" type="submit" name="purge" form="itil-form"
title="{{ _x('button', 'Delete permanently') }}"
onclick="return confirm('{{ __('Confirm the final deletion?') }}');">
<i class="ti ti-trash"></i>
<span class="d-none d-lg-block">{{ _x('button', 'Delete permanently') }}</span>
</button>
{% else %}
<button class="btn btn-outline-danger" type="submit" name="delete" form="itil-form"
title="{{ _x('button', 'Put in trashbin') }}"
data-bs-toggle="tooltip" data-bs-placement="top">
<i class="ti ti-trash"></i>
</button>
{% if item.canDeleteItem() %}
{% if item.isDeleted() %}
<button class="btn btn-outline-secondary" type="submit" name="restore" form="itil-form"
title="{{ _x('button', 'Restore') }}">
<i class="ti ti-trash-off"></i>
<span class="d-none d-lg-block">{{ _x('button', 'Restore') }}</span>
</button>

<button class="btn btn-outline-danger" type="submit" name="purge" form="itil-form"
title="{{ _x('button', 'Delete permanently') }}"
onclick="return confirm('{{ __('Confirm the final deletion?') }}');">
<i class="ti ti-trash"></i>
<span class="d-none d-lg-block">{{ _x('button', 'Delete permanently') }}</span>
</button>
{% else %}
<button class="btn btn-outline-danger" type="submit" name="delete" form="itil-form"
title="{{ _x('button', 'Put in trashbin') }}"
data-bs-toggle="tooltip" data-bs-placement="top">
<i class="ti ti-trash"></i>
</button>
{% endif %}
{% endif %}
{% endif %}

{% if canupdate %}
{{ include('components/form/single-action.html.twig', {
'onlyicon': true
}) }}
{% endif %}
</div>
{% if canupdate %}
{{ include('components/form/single-action.html.twig', {
'onlyicon': true
}) }}
{% endif %}
</div>

{% endif %}
</span>
</div>
{% endif %}

{% endif %}
</span>
</div>
</div>
</div>

Expand Down
23 changes: 13 additions & 10 deletions templates/components/itilobject/layout.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

{% set rand = random() %}
{% set main_rand = rand %}
{% set is_helpdesk = get_current_interface() == 'helpdesk' %}

{% set itil_layout = user_pref('itil_layout', true) %}
{% set is_collapsed = itil_layout['collapsed'] == "true" %}
Expand Down Expand Up @@ -63,22 +64,24 @@
<div class="row d-flex flex-column alin-items-stretch itil-object">
{% set is_timeline_reversed = user_pref('timeline_order') == constant('CommonITILObject::TIMELINE_ORDER_REVERSE') %}
{% set fl_direction = (item.isNewItem() or is_timeline_reversed ? 'flex-column' : 'flex-column-reverse') %}
<div class="itil-left-side col-12 {{ left_side_cls }} order-last order-lg-first pt-2 pe-2 pe-lg-4 d-flex {{ fl_direction }} border-top border-4">
<div class="itil-left-side col-12 {{ left_side_cls }} order-last order-lg-first pt-2 pe-2 pe-lg-4 d-flex {{ fl_direction }} border-top border-4 {{ is_helpdesk ? "w-100" : "" }}">
{% if item.isNewItem() %}
{{ include('components/itilobject/timeline/new_form.html.twig') }}
{% else %}
{{ include('components/itilobject/timeline/timeline.html.twig') }}
{% endif %}
</div>
<div class="itil-right-side col-12 {{ right_side_cls }} mt-0 mt-lg-n1 card-footer p-0 rounded-0">
{% if not item.isNewItem() %}
{{ include('components/itilobject/mainform_open.html.twig') }}
{% endif %}
{{ include('components/itilobject/fields_panel.html.twig') }}
{% if not item.isNewItem() %}
{{ include('components/itilobject/mainform_close.html.twig') }}
{% endif %}
</div>
{% if not is_helpdesk %}
<div class="itil-right-side col-12 {{ right_side_cls }} mt-0 mt-lg-n1 card-footer p-0 rounded-0">
{% if not item.isNewItem() %}
{{ include('components/itilobject/mainform_open.html.twig') }}
{% endif %}
{{ include('components/itilobject/fields_panel.html.twig') }}
{% if not item.isNewItem() %}
{{ include('components/itilobject/mainform_close.html.twig') }}
{% endif %}
</div>
{% endif %}
</div>

{% if not params['template_preview'] %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@
}) %}
{% endif %}

<div class="filter-timeline position-relative ms-auto">
<div class="filter-timeline position-relative">
<span data-bs-toggle="tooltip" data-bs-placement="top" title="{{ __('Timeline filter') }}">
<button type="button"
class="btn btn-icon btn-ghost-secondary open-timeline-filter-popover"
class="btn btn-icon btn-ghost-secondary open-timeline-filter-popover me-2"
data-bs-toggle="collapse"
data-bs-target="#filter-timeline-popover"
data-bs-trigger="click">
Expand Down
3 changes: 2 additions & 1 deletion templates/components/itilobject/timeline/timeline.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@
#}

{% set is_timeline_reversed = user_pref('timeline_order') == constant('CommonITILObject::TIMELINE_ORDER_REVERSE') %}
{% set is_helpdesk = get_current_interface() == 'helpdesk' %}

<div class="itil-timeline d-flex flex-column align-items-start mb-auto">
<div class="itil-timeline d-flex flex-column align-items-start mb-auto {{ is_helpdesk ? "px-3 py-2" : '' }}">
{% if not is_timeline_reversed %}
{{ include('components/itilobject/timeline/main_description.html.twig') }}
{% else %}
Expand Down
2 changes: 1 addition & 1 deletion templates/layout/parts/page_header.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
{% set is_horizontal = not is_vertical %}
{% set is_helpdesk = get_current_interface() == 'helpdesk' %}

<body class="{{ user_pref('fold_menu') and is_vertical ? 'navbar-collapsed' : '' }} {{ is_vertical ? 'vertical-layout' : 'horizontal-layout' }} {{ is_debug_active ? 'debug-active' : '' }}">
<body class="{{ user_pref('fold_menu') and is_vertical ? 'navbar-collapsed' : '' }} {{ is_vertical ? 'vertical-layout' : 'horizontal-layout' }} {{ is_debug_active ? 'debug-active' : '' }} {{ is_helpdesk ? 'helpdesk' : 'central' }}">
{% if call('DBConnection::isDbAvailable') and constant('SKIP_UPDATES') is defined and not call('Update::isDbUpToDate') %}
<div class="banner-need-update">
{{ __("You are bypassing a needed update") }}
Expand Down

0 comments on commit 3f230ed

Please sign in to comment.