Skip to content

Commit f144954

Browse files
Merge branch '6.0/selfservice-page-layouts' into 6.0-trunk
2 parents ac3ebec + 2bf53f2 commit f144954

File tree

25 files changed

+1270
-168
lines changed

25 files changed

+1270
-168
lines changed

etc/RT_Config.pm.in

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2534,6 +2534,38 @@ E.g.
25342534
},
25352535
],
25362536
},
2537+
'SelfService Display' => {
2538+
Default => [
2539+
{
2540+
Layout => 'col-md-6',
2541+
Title => 'Ticket metadata', # loc
2542+
Elements => [
2543+
[ 'Basics', 'CustomFieldCustomGroupings' ],
2544+
[ 'Dates', 'Assets', ],
2545+
],
2546+
},
2547+
{
2548+
Layout => 'col-12',
2549+
Elements => ['History'],
2550+
}
2551+
],
2552+
},
2553+
'SelfService Create' => {
2554+
Default => [
2555+
{
2556+
Layout => 'col-12',
2557+
Elements => ['Default'],
2558+
}
2559+
],
2560+
},
2561+
'SelfService Update' => {
2562+
Default => [
2563+
{
2564+
Layout => 'col-12',
2565+
Elements => ['Default'],
2566+
}
2567+
],
2568+
},
25372569
},
25382570
'RT::Asset' => {
25392571
Display => {
@@ -2579,6 +2611,18 @@ E.g.
25792611
},
25802612
],
25812613
},
2614+
'SelfService Display' => {
2615+
Default => [
2616+
{
2617+
Layout => 'col-md-4',
2618+
Elements => [
2619+
[ 'Basics', 'Links' ],
2620+
[ 'People', 'CustomFieldCustomGroupings' ],
2621+
[ 'Dates' ],
2622+
],
2623+
},
2624+
],
2625+
},
25822626
}
25832627
);
25842628

@@ -2636,6 +2680,38 @@ Set(
26362680
},
26372681
],
26382682
},
2683+
'SelfService Display' => {
2684+
Default => [
2685+
{
2686+
Layout => 'col-md-6',
2687+
Title => 'Ticket metadata', # loc
2688+
Elements => [
2689+
[ 'Basics', 'CustomFieldCustomGroupings' ],
2690+
[ 'Dates', 'Assets', ],
2691+
],
2692+
},
2693+
{
2694+
Layout => 'col-12',
2695+
Elements => ['History'],
2696+
}
2697+
],
2698+
},
2699+
'SelfService Create' => {
2700+
Default => [
2701+
{
2702+
Layout => 'col-12',
2703+
Elements => ['Default'],
2704+
}
2705+
],
2706+
},
2707+
'SelfService Update' => {
2708+
Default => [
2709+
{
2710+
Layout => 'col-12',
2711+
Elements => ['Default'],
2712+
}
2713+
],
2714+
},
26392715
},
26402716
'RT::Asset' => {
26412717
Display => {
@@ -2666,6 +2742,18 @@ Set(
26662742
},
26672743
],
26682744
},
2745+
'SelfService Display' => {
2746+
Default => [
2747+
{
2748+
Layout => 'col-md-4',
2749+
Elements => [
2750+
[ 'Basics', 'Links' ],
2751+
[ 'People', 'CustomFieldCustomGroupings' ],
2752+
[ 'Dates' ],
2753+
],
2754+
},
2755+
],
2756+
},
26692757
},
26702758
);
26712759

@@ -2717,6 +2805,24 @@ values. RT checks each rule one by one until it finds the match. E.g.
27172805
Layout => 'Default',
27182806
}
27192807
],
2808+
'SelfService Display' => [
2809+
{
2810+
Type => 'Default',
2811+
Layout => 'Default',
2812+
}
2813+
],
2814+
'SelfService Create' => [
2815+
{
2816+
Type => 'Default',
2817+
Layout => 'Default',
2818+
}
2819+
],
2820+
'SelfService Update' => [
2821+
{
2822+
Type => 'Default',
2823+
Layout => 'Default',
2824+
}
2825+
],
27202826
},
27212827
'RT::Asset' => {
27222828
Display => [
@@ -2738,6 +2844,12 @@ values. RT checks each rule one by one until it finds the match. E.g.
27382844
Layout => 'Default',
27392845
}
27402846
],
2847+
'SelfService Display' => [
2848+
{
2849+
Type => 'Default',
2850+
Layout => 'Default',
2851+
}
2852+
],
27412853
},
27422854
);
27432855

@@ -2764,6 +2876,24 @@ Set(
27642876
Layout => 'Default',
27652877
}
27662878
],
2879+
'SelfService Display' => [
2880+
{
2881+
Type => 'Default',
2882+
Layout => 'Default',
2883+
}
2884+
],
2885+
'SelfService Create' => [
2886+
{
2887+
Type => 'Default',
2888+
Layout => 'Default',
2889+
}
2890+
],
2891+
'SelfService Update' => [
2892+
{
2893+
Type => 'Default',
2894+
Layout => 'Default',
2895+
}
2896+
],
27672897
},
27682898
'RT::Asset' => {
27692899
Display => [
@@ -2778,6 +2908,12 @@ Set(
27782908
Layout => 'Default',
27792909
}
27802910
],
2911+
'SelfService Display' => [
2912+
{
2913+
Type => 'Default',
2914+
Layout => 'Default',
2915+
}
2916+
],
27812917
},
27822918
);
27832919

lib/RT/Interface/Web.pm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6682,7 +6682,10 @@ sub GetAvailableWidgets {
66826682
}
66836683

66846684
my $widget_path;
6685-
$widget_path = "/$1/Widgets/$args{Page}/" if $args{Class} =~ /RT::(.+)/;
6685+
if ( $args{Page} =~ s/^SelfService // ) {
6686+
$widget_path = '/SelfService';
6687+
}
6688+
$widget_path .= "/$1/Widgets/$args{Page}/" if $args{Class} =~ /RT::(.+)/;
66866689
my %widget;
66876690
for my $root ( $m->interp->comp_root_array ) {
66886691
for my $path ( $m->interp->resolver->glob_path( "$widget_path*", $root->[1] ) ) {

lib/RT/Interface/Web/MenuBuilder.pm

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,7 +1266,9 @@ sub _BuildAdminTopMenu {
12661266

12671267
my $config = RT->Config->Get('PageLayouts');
12681268
my $ticket = $layout->child( ticket => title => loc('Ticket') );
1269-
for my $page ( sort keys %{ $config->{'RT::Ticket'} } ) {
1269+
1270+
# Put SelfService page links last
1271+
for my $page ( sort( grep { ! /^SelfService / } keys %{ $config->{'RT::Ticket'} } ), sort( grep { /^SelfService / } keys %{ $config->{'RT::Ticket'} } ) ) {
12701272
$layout->path("/Admin/PageLayouts/?Class=RT::Ticket&Page=$page") unless $layout->path;
12711273
$ticket->path("/Admin/PageLayouts/?Class=RT::Ticket&Page=$page") unless $ticket->path;
12721274
$ticket->child(
@@ -1948,7 +1950,9 @@ sub _BuildAdminPageMenu {
19481950
elsif ( $request_path =~ m{^/Admin/PageLayouts/} ) {
19491951
my $config = RT->Config->Get('PageLayoutMapping');
19501952
my $ticket = $page->child( ticket => title => loc('Ticket') );
1951-
for my $page ( sort keys %{ $config->{'RT::Ticket'} } ) {
1953+
1954+
# Put SelfService page links last
1955+
for my $page ( sort( grep { ! /^SelfService / } keys %{ $config->{'RT::Ticket'} } ), sort( grep { /^SelfService / } keys %{ $config->{'RT::Ticket'} } ) ) {
19521956
$ticket->child(
19531957
lc $page,
19541958
title => loc( '[_1] Layouts', $page ),

share/html/Elements/EditPageLayout

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
<% GetSVGImage( Name => 'info', Title => ' ' ) |n %>
9292
<a href="#" class="edit" data-bs-toggle="modal" data-bs-target="#pagelayout-widget-<% $item %>-modal">
9393
<% GetSVGImage( Name => 'pencil', Title => loc('Edit') ) |n %></a>
94-
% } elsif ( $item eq 'History' || ( $Class eq 'RT::Ticket' && ( $item =~ /^(?:People|Basics)$/ || ( $Page eq 'Create' && $item eq 'Message' ) ) ) ) {
94+
% } elsif ( ( $item eq 'History' && $Page !~ /^SelfService / ) || ( $Class eq 'RT::Ticket' && ( $item =~ /^(?:People|Basics)$/ || ( $Page eq 'Create' && $item eq 'Message' ) ) ) ) {
9595
<a href="#" class="edit" data-bs-toggle="modal" data-bs-target="#pagelayout-widget-<% $item %>-modal">
9696
<% GetSVGImage( Name => 'pencil', Title => loc('Edit') ) |n %></a>
9797
% }
@@ -109,7 +109,7 @@
109109
<& SELF:EditWidgetPeople, Widget => $item, Class => $Class, Page => $Page &>
110110
% } elsif ( $item eq 'Basics' && $Class eq 'RT::Ticket' ) {
111111
<& SELF:EditWidgetBasics, Widget => $item, Class => $Class, Page => $Page &>
112-
% } elsif ( $item eq 'History' ) {
112+
% } elsif ( $item eq 'History' && $Page !~ /^SelfService / ) {
113113
<& SELF:EditWidgetHistory, Widget => $item, Class => $Class &>
114114
% }
115115
% }
@@ -220,7 +220,7 @@
220220
<div class="row">
221221
% for my $index ( 0 .. $#{$row->{Elements}} ) {
222222
<div class="<% $row->{Classes}[$index % @{$row->{Classes} }] %>">
223-
<& SELF:EditWidget, Widget => $row->{Elements}[$index], Index => $i, Groupings => \@groupings, Class => $Class &>
223+
<& SELF:EditWidget, Widget => $row->{Elements}[$index], Index => $i, Groupings => \@groupings, Class => $Class, Page => $Page &>
224224
</div>
225225
% $i++;
226226
% }
@@ -384,7 +384,7 @@ $Content => []
384384
<% GetSVGImage( Name => 'info', $Widget =~ /.*:(.+)/ ? ( Title => $1 ) : ( Title => ' ', ExtraClasses => 'hidden' ) ) |n %>
385385
<a href="#" class="edit" data-bs-toggle="modal" data-bs-target="#pagelayout-widget-<% $Index %>-modal">
386386
<% GetSVGImage( Name => 'pencil', Title => loc('Edit') ) |n %></a>
387-
% } elsif ( $widget_name eq 'History' || ( $Class eq 'RT::Ticket' && ( $widget_name =~ /^(?:People|Basics)$/ || ( $Page eq 'Create' && $widget_name eq 'Message' ) ) ) ) {
387+
% } elsif ( ( $widget_name eq 'History' && $Page !~ /^SelfService / ) || ( $Class eq 'RT::Ticket' && ( $widget_name =~ /^(?:People|Basics)$/ || ( $Page eq 'Create' && $widget_name eq 'Message' ) ) ) ) {
388388
<a href="#" class="edit" data-bs-toggle="modal" data-bs-target="#pagelayout-widget-<% $Index %>-modal">
389389
<% GetSVGImage( Name => 'pencil', Title => loc('Edit') ) |n %></a>
390390
% }
@@ -395,7 +395,7 @@ $Content => []
395395
</p>
396396
% if ( $widget_name =~ /^CustomFieldCustomGroupings\b/ ) {
397397
<& SELF:EditWidgetCustomFieldCustomGroupings, %ARGS &>
398-
% } elsif ( $widget_name eq 'History' ) {
398+
% } elsif ( $widget_name eq 'History' && $Page !~ /^SelfService / ) {
399399
<& SELF:EditWidgetHistory, %ARGS, Class => $Class &>
400400
% } elsif ( $Class eq 'RT::Ticket' && $Page eq 'Create' && $widget_name eq 'Message' ) {
401401
<& SELF:EditWidgetMessage, %ARGS, Class => $Class, Page => $Page &>

share/html/Elements/ShowWidgets

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
% $path = $path_prefix . ( ref $widget ? $widget->{Name} : $widget );
7676
% }
7777
% ( $path, my $argument ) = split /:/, $path, 2;
78+
% $path = '/SelfService' . $path if $Page =~ /^SelfService / && $path =~ /Widgets/;
7879
% if ( $m->comp_exists( $path ) ) {
7980
% # Disable lazy load for wrapper and mechanize tests
8081
% if ( ( ref $widget eq 'HASH' && $widget->{Elements} ) || !RT::Interface::Web->ModernClient() ) {
@@ -115,8 +116,9 @@
115116
% }
116117
%
117118
% if ( $show_widget ) {
119+
% my $view_path = $path =~ m{^/SelfService/(.+)} ? "/SelfService/Views/$1" : "/Views$path";
118120
<& /Widgets/HTMXLoadStart,
119-
$Page =~ /Create|Update/ ? 'htmx_post' : 'htmx_get' => RT->Config->Get('WebPath') . "/Views$path",
121+
$Page =~ /Create|Update/ ? 'htmx_post' : 'htmx_get' => RT->Config->Get('WebPath') . $view_path,
120122
htmx_values => {
121123
defined $argument ? ( Argument => $argument ) : (),
122124
ref $widget ? map( { $_ eq 'Name' ? () : ( $_ => $widget->{$_} ) } keys %$widget ) : (),
@@ -156,7 +158,11 @@ if ( !$Content ) {
156158
return unless $Content && @$Content;
157159

158160
my @column_classes = split /\s*,\s*/, $Layout // '';
159-
my $path_prefix = $Object->isa('RT::Queue') || $Object->isa('RT::Ticket') ? "/Ticket/Widgets/$Page/" : ( $Object->isa('RT::Catalog') || $Object->isa('RT::Asset') ? "/Asset/Widgets/$Page/" : '' );
161+
162+
my $page_type = $Page;
163+
$page_type =~ s!SelfService !!;
164+
165+
my $path_prefix = $Object->isa('RT::Queue') || $Object->isa('RT::Ticket') ? "/Ticket/Widgets/$page_type/" : ( $Object->isa('RT::Catalog') || $Object->isa('RT::Asset') ? "/Asset/Widgets/$page_type/" : '' );
160166
</%INIT>
161167

162168
<%ARGS>

share/html/SelfService/Asset/Display.html

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -47,40 +47,7 @@
4747
%# END BPS TAGGED BLOCK }}}
4848
<& /SelfService/Elements/Header, Title => loc("Asset #[_1]: [_2]", $asset->id, $asset->Name) &>
4949

50-
<div class="asset-metadata">
51-
<div class="row mt-2">
52-
<div class="col-4">
53-
<&| /Widgets/TitleBox, title => loc('Basics'), title_class => "inverse", class => "asset-basics" &>
54-
<& /Asset/Elements/ShowBasics, AssetObj => $asset &>
55-
</&>
56-
</div>
57-
58-
<div class="col-4">
59-
<&| /Widgets/TitleBox, title => loc('People'), title_class => "inverse", class => "asset-people" &>
60-
<& /Asset/Elements/ShowPeople, AssetObj => $asset &>
61-
</&>
62-
</div>
63-
64-
<div class="col-4">
65-
<&| /Widgets/TitleBox, title => loc('Dates'), title_class => "inverse", class => "asset-dates" &>
66-
<& /Asset/Elements/ShowDates, AssetObj => $asset &>
67-
</&>
68-
</div>
69-
70-
<div class="col-4">
71-
<&| /Widgets/TitleBox, title => loc('Links'), title_class => "inverse", class => "asset-links" &>
72-
<& /Asset/Elements/ShowLinks, AssetObj => $asset &>
73-
</&>
74-
</div>
75-
76-
<& /Elements/ShowCustomFieldCustomGroupings,
77-
Object => $asset,
78-
TitleBoxARGS => { title_class => "inverse" },
79-
GroupingClass => 'col-4',
80-
&>
81-
</div>
82-
</div>
83-
50+
<& /Elements/ShowWidgets, Object => $asset, Page => 'SelfService Display', ARGSRef => \%ARGS, &>
8451
<%args>
8552
$id => undef
8653
</%args>

0 commit comments

Comments
 (0)