Skip to content

Commit

Permalink
Automatically hide inline edit links/buttons if there are no fields t…
Browse files Browse the repository at this point in the history
…o edit

E.g. there are no editable fields on asset Dates widget, but if there are
custom fields grouped there and current user can edit them, we should show
inline edit links. With this auto hide feature, we don't need to check if
there are editable fields in widget content in advance when building widget
meta links.
  • Loading branch information
sunnavy committed Apr 24, 2024
1 parent a5b80f5 commit 8ba0cc4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion share/html/Asset/Elements/ShowSummary
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ my $cancel_label = $m->interp->apply_escapes( loc("Cancel"), 'h' );

my %inline_edit_behavior;
if (RT->Config->Get('InlineEditPanelBehavior')) {
%inline_edit_behavior = %{ RT->Config->Get('InlineEditPanelBehavior')->{'RT::Asset'} || { Dates => 'hide' } };
%inline_edit_behavior = %{ RT->Config->Get('InlineEditPanelBehavior')->{'RT::Asset'} || {} };
}

my $modify_inline
Expand Down
15 changes: 15 additions & 0 deletions share/static/js/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -1433,6 +1433,21 @@ jQuery(function () {
});

/* inline edit on ticket display */
jQuery('.titlebox[data-inline-edit-behavior="link"], .titlebox[data-inline-edit-behavior="click"]').each(function() {
// If there are only id/submit, there are no fields to edit
if ( jQuery(this).find('form.inline-edit :input').length <= 2 ) {
jQuery(this).data('inline-edit-behavior', 'hide');
jQuery(this).find('.inline-edit-toggle').addClass('hide');
}
});

jQuery('.titlebox[data-inline-edit-behavior="always"]').each(function() {
// If there are only id/submit, there are no fields to edit
if ( jQuery(this).find('form.inline-edit :input').length <= 2 ) {
jQuery(this).find('form.inline-edit :input[type=submit]').closest('div.form-row').addClass('hide');
}
});

var toggle_inline_edit = function (link) {
link.siblings('.inline-edit-toggle').removeClass('hidden');
link.addClass('hidden');
Expand Down

0 comments on commit 8ba0cc4

Please sign in to comment.