Skip to content

Commit

Permalink
Switch widget arguments to ...Obj like TicketObj to indicate they are…
Browse files Browse the repository at this point in the history
… objects

We are going to stick to this naming convention for new code.
  • Loading branch information
sunnavy committed Jan 13, 2025
1 parent d13d0e0 commit 448827e
Show file tree
Hide file tree
Showing 44 changed files with 234 additions and 234 deletions.
4 changes: 2 additions & 2 deletions share/html/Asset/Widgets/Create/Basics
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@
% $m->callback( %ARGS, CallbackName => 'BeforeWidget' );

<&| /Widgets/TitleBox, title => loc("Basics"), class => "asset-basics" &>
<& /Asset/Elements/EditBasics, %ARGS, Catalog => $Catalog->Id, AssetObj => RT::Asset->new( $session{CurrentUser} ), CatalogObj => $Catalog, AutoSubmit => 1 &>
<& /Asset/Elements/EditBasics, %ARGS, Catalog => $CatalogObj->Id, AssetObj => RT::Asset->new( $session{CurrentUser} ), CatalogObj => $CatalogObj, AutoSubmit => 1 &>
</&>

% $m->callback( %ARGS, CallbackName => 'AfterWidget' );

<%ARGS>
$Catalog
$CatalogObj
</%ARGS>
6 changes: 3 additions & 3 deletions share/html/Asset/Widgets/Create/CustomFieldCustomGroupings
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@

<& /Elements/EditCustomFieldCustomGroupings,
Object => RT::Asset->new( $session{CurrentUser} ),
CategoryObj => $Catalog,
CategoryObj => $CatalogObj,
KeepValue => 1,
CustomFieldGenerator => sub { $Catalog->AssetCustomFields },
CustomFieldGenerator => sub { $CatalogObj->AssetCustomFields },
ForCreation => 1,
&>

% $m->callback( %ARGS, CallbackName => 'AfterWidget' );

<%ARGS>
$Catalog
$CatalogObj
</%ARGS>
4 changes: 2 additions & 2 deletions share/html/Asset/Widgets/Create/Links
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@
<&| /Widgets/TitleBox, title => loc("Links"), class => "asset-links" &>
<& /Elements/AddLinks,
Object => RT::Asset->new( $session{CurrentUser} ),
CustomFields => $Catalog->AssetCustomFields,
CustomFields => $CatalogObj->AssetCustomFields,
&>
</&>

% $m->callback( %ARGS, CallbackName => 'AfterWidget' );

<%ARGS>
$Catalog
$CatalogObj
</%ARGS>
4 changes: 2 additions & 2 deletions share/html/Asset/Widgets/Create/People
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@
% $m->callback( %ARGS, CallbackName => 'BeforeWidget' );

<&| /Widgets/TitleBox, title => loc("People"), class => "asset-people" &>
<& /Asset/Elements/EditPeople, %ARGS, AssetObj => RT::Asset->new( $session{CurrentUser} ), CatalogObj => $Catalog &>
<& /Asset/Elements/EditPeople, %ARGS, AssetObj => RT::Asset->new( $session{CurrentUser} ), CatalogObj => $CatalogObj &>
</&>

% $m->callback( %ARGS, CallbackName => 'AfterWidget' );

<%ARGS>
$Catalog
$CatalogObj
</%ARGS>
2 changes: 1 addition & 1 deletion share/html/Asset/Widgets/Create/Submit
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@
% $m->callback( %ARGS, CallbackName => 'AfterWidget' );

<%ARGS>
$Catalog
$CatalogObj
</%ARGS>
16 changes: 8 additions & 8 deletions share/html/Asset/Widgets/Display/Basics
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,20 @@
% $m->callback( %ARGS, CallbackName => 'BeforeWidget' );

<&| /Widgets/TitleBox, title => loc('The Basics'),
(($can_modify || $can_modify_cf) ? (title_href => RT->Config->Get('WebPath')."/Asset/Modify.html?id=".$Asset->Id) : ()),
(($can_modify || $can_modify_cf) ? (title_href => RT->Config->Get('WebPath')."/Asset/Modify.html?id=".$AssetObj->Id) : ()),
(($can_modify || $can_modify_cf) && $modify_behavior =~ /^(link|click)$/ ? (titleright_raw => $m->scomp('/Elements/InlineEditLink')) : ()),
class => (join " ", 'asset-basics', ($modify_behavior eq 'always' ? 'editing' : ())),
data => { 'inline-edit-behavior' => $modify_behavior },
&>
% unless ($modify_behavior eq 'always') {
<div class="inline-edit-display" hx-trigger="assetBasicsChanged from:body" hx-get="<% RT->Config->Get('WebPath') %>/Views/Asset/ShowBasics?id=<% $Asset->id %>">
<& /Asset/Elements/ShowBasics, AssetObj => $Asset &>
<div class="inline-edit-display" hx-trigger="assetBasicsChanged from:body" hx-get="<% RT->Config->Get('WebPath') %>/Views/Asset/ShowBasics?id=<% $AssetObj->id %>">
<& /Asset/Elements/ShowBasics, AssetObj => $AssetObj &>
</div>
% }
% if ($modify_behavior ne 'hide') {
<form hx-post="<%RT->Config->Get('WebPath')%>/Helpers/AssetUpdate" hx-swap="none" class="inline-edit" enctype="multipart/form-data">
<input type="hidden" class="hidden" name="id" value="<% $Asset->id %>" />
<& /Asset/Elements/EditBasics, AssetObj => $Asset &>
<input type="hidden" class="hidden" name="id" value="<% $AssetObj->id %>" />
<& /Asset/Elements/EditBasics, AssetObj => $AssetObj &>
<div class="row mt-2">
<div class="col-12 text-end">
<input type="submit" class="button btn btn-primary" value="<&|/l&>Save</&>" />
Expand All @@ -82,9 +82,9 @@ my $modify_behavior
? ( $inline_edit_behavior{Basics} || $inline_edit_behavior{_default} || 'link' )
: 'hide';

my $can_modify = $Asset->CurrentUserHasRight('ModifyAsset');
my $can_modify_cf = $Asset->CurrentUserHasRight('ModifyCustomField');
my $can_modify = $AssetObj->CurrentUserHasRight('ModifyAsset');
my $can_modify_cf = $AssetObj->CurrentUserHasRight('ModifyCustomField');
</%INIT>
<%ARGS>
$Asset
$AssetObj
</%ARGS>
8 changes: 4 additions & 4 deletions share/html/Asset/Widgets/Display/CustomFieldCustomGroupings
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
% $m->callback( %ARGS, CallbackName => 'BeforeWidget' );

<& /Elements/ShowCustomFieldCustomGroupings,
Object => $Asset,
Object => $AssetObj,
title_href => ( $can_modify || $can_modify_cf ) ? RT->Config->Get('WebPath') . "/Asset/Modify.html" : "",
InlineEdit => ( $can_modify || $can_modify_cf ) ? RT->Config->Get( 'InlineEdit', $session{CurrentUser} ) : 0,
ActionURL => RT->Config->Get('WebPath') . '/Helpers/AssetUpdate',
Expand All @@ -57,10 +57,10 @@
% $m->callback( %ARGS, CallbackName => 'AfterWidget' );

<%INIT>
my $can_modify = $Asset->CurrentUserHasRight('ModifyAsset');
my $can_modify_cf = $Asset->CurrentUserHasRight('ModifyCustomField');
my $can_modify = $AssetObj->CurrentUserHasRight('ModifyAsset');
my $can_modify_cf = $AssetObj->CurrentUserHasRight('ModifyCustomField');
</%INIT>

<%ARGS>
$Asset
$AssetObj
</%ARGS>
20 changes: 10 additions & 10 deletions share/html/Asset/Widgets/Display/Dates
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,21 @@
% $m->callback( %ARGS, CallbackName => 'BeforeWidget' );

<&| /Widgets/TitleBox, title => loc("Dates"),
($can_modify || $can_modify_cf ? (title_href => RT->Config->Get('WebPath')."/Asset/ModifyDates.html?id=".$Asset->Id) : ()),
($can_modify || $can_modify_cf ? (title_href => RT->Config->Get('WebPath')."/Asset/ModifyDates.html?id=".$AssetObj->Id) : ()),
class => (join " ", 'asset-dates', ($modify_behavior eq 'always' ? 'editing' : ())),
(($can_modify || $can_modify_cf) && $modify_behavior =~ /^(link|click)$/ ? (titleright_raw => $m->scomp('/Elements/InlineEditLink')) : ()),
data => { 'inline-edit-behavior' => $modify_behavior },
&>
% unless ($modify_behavior eq 'always') {
<div class="inline-edit-display" hx-trigger="actionsChanged from:body, assetDatesChanged from:body" hx-get="<% RT->Config->Get('WebPath') %>/Views/Asset/ShowDates?id=<% $Asset->id %>">
<& /Asset/Elements/ShowDates, AssetObj => $Asset &>
<div class="inline-edit-display" hx-trigger="actionsChanged from:body, assetDatesChanged from:body" hx-get="<% RT->Config->Get('WebPath') %>/Views/Asset/ShowDates?id=<% $AssetObj->id %>">
<& /Asset/Elements/ShowDates, AssetObj => $AssetObj &>
</div>
% }
% if ($modify_behavior ne 'hide') {
<form class="inline-edit" hx-post="<%RT->Config->Get('WebPath')%>/Helpers/AssetUpdate" hx-swap="none" enctype="multipart/form-data">
<input type="hidden" class="hidden" name="id" value="<% $Asset->id %>" />
<div hx-trigger="assetDatesChanged from:body" hx-get="<% RT->Config->Get('WebPath') %>/Views/Asset/EditDates?id=<% $Asset->id %>"hx-swap="innerHTML">
<& /Asset/Elements/EditDates, AssetObj => $Asset &>
<input type="hidden" class="hidden" name="id" value="<% $AssetObj->id %>" />
<div hx-trigger="assetDatesChanged from:body" hx-get="<% RT->Config->Get('WebPath') %>/Views/Asset/EditDates?id=<% $AssetObj->id %>"hx-swap="innerHTML">
<& /Asset/Elements/EditDates, AssetObj => $AssetObj &>
</div>
<div class="row mt-2">
<div class="col-12 text-end">
Expand Down Expand Up @@ -90,16 +90,16 @@ if ( !$inline_edit_behavior{Dates} ) {
my $cf_groupings = RT->Config->Get('CustomFieldGroupings');
if ( $cf_groupings && $cf_groupings->{'RT::Asset'} ) {
my %asset_cf_grouping
= @{$cf_groupings->{'RT::Asset'}{ $Asset->CatalogObj->__Value('Name') } || $cf_groupings->{'RT::Asset'}{Default} || []};
= @{$cf_groupings->{'RT::Asset'}{ $AssetObj->CatalogObj->__Value('Name') } || $cf_groupings->{'RT::Asset'}{Default} || []};
$hide = 0 if @{ $asset_cf_grouping{Dates} || [] };
}
$inline_edit_behavior{Dates} = 'hide' if $hide;
}

my $can_modify = $Asset->CurrentUserHasRight('ModifyAsset');
my $can_modify_cf = $Asset->CurrentUserHasRight('ModifyCustomField');
my $can_modify = $AssetObj->CurrentUserHasRight('ModifyAsset');
my $can_modify_cf = $AssetObj->CurrentUserHasRight('ModifyCustomField');
</%INIT>

<%ARGS>
$Asset
$AssetObj
</%ARGS>
6 changes: 3 additions & 3 deletions share/html/Asset/Widgets/Display/History
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@
% $m->callback( %ARGS, CallbackName => 'BeforeWidget' );

<& /Elements/ShowHistory,
Object => $Asset,
Object => $AssetObj,
ShowDisplayModes => 0,
DisplayPath => 'History.html',
&>

% $m->callback( %ARGS, CallbackName => 'AfterWidget' );
% $m->callback( ARGSRef => $DECODED_ARGS, Asset => $Asset, CallbackName => 'AfterShowHistory', CallbackPage => '/Asset/Display.html' );
% $m->callback( ARGSRef => $DECODED_ARGS, Asset => $AssetObj, CallbackName => 'AfterShowHistory', CallbackPage => '/Asset/Display.html' );
<%ARGS>
$Asset
$AssetObj
</%ARGS>
22 changes: 11 additions & 11 deletions share/html/Asset/Widgets/Display/Links
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,23 @@
% $m->callback( %ARGS, CallbackName => 'BeforeWidget' );

<&| /Widgets/TitleBox, title => loc('Links'),
($can_modify ? (title_href => RT->Config->Get('WebPath')."/Asset/ModifyLinks.html?id=".$Asset->Id) : ()),
($can_modify ? (title_href => RT->Config->Get('WebPath')."/Asset/ModifyLinks.html?id=".$AssetObj->Id) : ()),
class => (join " ", 'asset-links', ($modify_behavior eq 'always' ? 'editing' : ())),
data => { 'inline-edit-behavior' => $modify_behavior },
($can_modify || $can_modify_cf ? (title_href => RT->Config->Get('WebPath')."/Asset/ModifyLinks.html?id=".$Asset->Id) : ()),
($can_modify || $can_modify_cf ? (title_href => RT->Config->Get('WebPath')."/Asset/ModifyLinks.html?id=".$AssetObj->Id) : ()),
(($can_modify || $can_modify_cf) && $modify_behavior =~ /^(link|click)$/ ? (titleright_raw => $m->scomp('/Elements/InlineEditLink')) : ()),
&>
% unless ($modify_behavior eq 'always') {
<div class="inline-edit-display" hx-trigger="assetLinksChanged from:body" hx-get="<% RT->Config->Get('WebPath') %>/Views/Component/ShowLinks?ObjectType=RT::Asset&ObjectId=<% $Asset->id %>">
<& /Elements/ShowLinks, Object => $Asset &>
<div class="inline-edit-display" hx-trigger="assetLinksChanged from:body" hx-get="<% RT->Config->Get('WebPath') %>/Views/Component/ShowLinks?ObjectType=RT::Asset&ObjectId=<% $AssetObj->id %>">
<& /Elements/ShowLinks, Object => $AssetObj &>
</div>
% }
% if ($modify_behavior ne 'hide') {
<form class="inline-edit" hx-post="<% RT->Config->Get('WebPath') %>/Helpers/AssetUpdate" hx-swap="none" enctype="multipart/form-data">
<input type="hidden" class="hidden" name="id" value="<% $Asset->id %>" />
<div hx-trigger="assetLinksChanged from:body" hx-get="<% RT->Config->Get('WebPath') %>/Views/Component/EditLinks?ObjectType=RT::Asset&ObjectId=<% $Asset->id %>&TwoColumn=0" hx-swap="innerHTML">
<& /Elements/EditLinks, Object => $Asset, TwoColumn => 0 &>
<& /Elements/EditCustomFields, Object => $Asset, Grouping => 'Links', InTable => 1 &>
<input type="hidden" class="hidden" name="id" value="<% $AssetObj->id %>" />
<div hx-trigger="assetLinksChanged from:body" hx-get="<% RT->Config->Get('WebPath') %>/Views/Component/EditLinks?ObjectType=RT::Asset&ObjectId=<% $AssetObj->id %>&TwoColumn=0" hx-swap="innerHTML">
<& /Elements/EditLinks, Object => $AssetObj, TwoColumn => 0 &>
<& /Elements/EditCustomFields, Object => $AssetObj, Grouping => 'Links', InTable => 1 &>
</div>

<div class="row mt-2">
Expand All @@ -85,10 +85,10 @@ if ( RT->Config->Get('InlineEditPanelBehavior') ) {
}
my $modify_behavior
= RT->Config->Get( 'InlineEdit', $session{CurrentUser} ) ? ( $inline_edit_behavior{Links} || $inline_edit_behavior{_default} || 'link' ) : 'hide';
my $can_modify = $Asset->CurrentUserHasRight('ModifyAsset');
my $can_modify_cf = $Asset->CurrentUserHasRight('ModifyCustomField');
my $can_modify = $AssetObj->CurrentUserHasRight('ModifyAsset');
my $can_modify_cf = $AssetObj->CurrentUserHasRight('ModifyCustomField');
</%INIT>

<%ARGS>
$Asset
$AssetObj
</%ARGS>
18 changes: 9 additions & 9 deletions share/html/Asset/Widgets/Display/People
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,21 @@
% $m->callback( %ARGS, CallbackName => 'BeforeWidget' );

<&| /Widgets/TitleBox, title => loc('People'),
(($can_modify || $can_modify_cf) ? (title_href => RT->Config->Get('WebPath')."/Asset/ModifyPeople.html?id=".$Asset->Id) : ()),
(($can_modify || $can_modify_cf) ? (title_href => RT->Config->Get('WebPath')."/Asset/ModifyPeople.html?id=".$AssetObj->Id) : ()),
class => (join " ", 'asset-people', ($modify_behavior eq 'always' ? 'editing' : ())),
(($can_modify || $can_modify_cf) && $modify_behavior =~ /^(link|click)$/ ? (titleright_raw => $m->scomp('/Elements/InlineEditLink')) : ()),
data => { 'inline-edit-behavior' => $modify_behavior },
&>
% unless ($modify_behavior eq 'always') {
<div class="inline-edit-display" hx-trigger="assetPeopleChanged from:body" hx-get="<%RT->Config->Get('WebPath')%>/Views/Asset/ShowPeople?id=<% $Asset->id %>">
<& /Asset/Elements/ShowPeople, AssetObj => $Asset &>
<div class="inline-edit-display" hx-trigger="assetPeopleChanged from:body" hx-get="<%RT->Config->Get('WebPath')%>/Views/Asset/ShowPeople?id=<% $AssetObj->id %>">
<& /Asset/Elements/ShowPeople, AssetObj => $AssetObj &>
</div>
% }
% if ($modify_behavior ne 'hide') {
<form hx-post="<% RT->Config->Get('WebPath') %>/Helpers/AssetUpdate" hx-swap="none" class="inline-edit" enctype="multipart/form-data">
<input type="hidden" class="hidden" name="id" value="<% $Asset->id %>" />
<div hx-trigger="assetPeopleChanged from:body" hx-get="<% RT->Config->Get('WebPath') %>/Views/Asset/EditPeopleInline?id=<% $Asset->id %>" hx-swap="innerHTML">
<& /Asset/Elements/EditPeopleInline, AssetObj => $Asset &>
<input type="hidden" class="hidden" name="id" value="<% $AssetObj->id %>" />
<div hx-trigger="assetPeopleChanged from:body" hx-get="<% RT->Config->Get('WebPath') %>/Views/Asset/EditPeopleInline?id=<% $AssetObj->id %>" hx-swap="innerHTML">
<& /Asset/Elements/EditPeopleInline, AssetObj => $AssetObj &>
</div>
<div class="row mt-2">
<div class="col-12 text-end">
Expand All @@ -85,9 +85,9 @@ my $modify_behavior
? ( $inline_edit_behavior{People} || $inline_edit_behavior{_default} || 'link' )
: 'hide';

my $can_modify = $Asset->CurrentUserHasRight('ModifyAsset');
my $can_modify_cf = $Asset->CurrentUserHasRight('ModifyCustomField');
my $can_modify = $AssetObj->CurrentUserHasRight('ModifyAsset');
my $can_modify_cf = $AssetObj->CurrentUserHasRight('ModifyCustomField');
</%INIT>
<%ARGS>
$Asset
$AssetObj
</%ARGS>
8 changes: 4 additions & 4 deletions share/html/Elements/ShowWidgets
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@
% %args = %$DECODED_ARGS;
% $args{Argument} = $argument if defined $argument;
% if ( $Object->isa('RT::Ticket') ) {
% $args{Ticket} = $Object;
% $args{TicketObj} = $Object;
% } elsif ( $Object->isa('RT::Asset') ) {
% $args{Asset} = $Object;
% $args{AssetObj} = $Object;
% } elsif ( $Object->isa('RT::Queue') ) {
% $args{Queue} = $Object;
% $args{QueueObj} = $Object;
% } elsif ( $Object->isa('RT::Catalog') ) {
% $args{Catalog} = $Object;
% $args{CatalogObj} = $Object;
% }
% }
<& $path, %args &>
Expand Down
4 changes: 2 additions & 2 deletions share/html/Ticket/Widgets/Create/Assets
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@
%# END BPS TAGGED BLOCK }}}
% $m->callback( %ARGS, CallbackName => 'BeforeWidget' );

<& /Ticket/Elements/ShowAssetsOnCreate, QueueObj => $Queue, ARGSRef => \%ARGS &>
<& /Ticket/Elements/ShowAssetsOnCreate, QueueObj => $QueueObj, ARGSRef => \%ARGS &>

% $m->callback( %ARGS, CallbackName => 'AfterWidget' );

<%ARGS>
$Queue
$QueueObj
</%ARGS>
Loading

0 comments on commit 448827e

Please sign in to comment.