[Rt-commit] rt branch, 5.0/add-assets-autocomplete, created. rt-5.0.0-52-g9745b724ea
Craig Kaiser
craig at bestpractical.com
Sun Oct 11 09:30:33 EDT 2020
The branch, 5.0/add-assets-autocomplete has been created
at 9745b724ea9a9ec6b1f5d789d20b9e6c30b94328 (commit)
- Log -----------------------------------------------------------------
commit d35b70944ff37d5c900a47702e89f992970de465
Author: craig kaiser <craig at bestpractical.com>
Date: Tue Sep 15 11:23:03 2020 -0400
Add 'enctype=multipart/form-data' to custom field inline edit form
Without this form attribute, when submitting a file for a custom field
the browser will complain:
Form contains a file input, but is missing method=POST and enctype=multipart/form-data
on the form. The file will not be sent.
diff --git a/share/html/Elements/ShowCustomFieldCustomGroupings b/share/html/Elements/ShowCustomFieldCustomGroupings
index 9b6876042c..ee3c1af60c 100644
--- a/share/html/Elements/ShowCustomFieldCustomGroupings
+++ b/share/html/Elements/ShowCustomFieldCustomGroupings
@@ -92,7 +92,7 @@ for my $group ( @Groupings ) {
</div>
% }
% if ($modify_behavior ne 'hide') {
- <form class="inline-edit" action="<%RT->Config->Get('WebPath')%>/Ticket/Display.html" method="post">
+ <form class="inline-edit" action="<%RT->Config->Get('WebPath')%>/Ticket/Display.html" method="post" enctype="multipart/form-data">
<input type="hidden" class="hidden" name="id" value="<% $Object->id %>" />
<& /Elements/EditCustomFields, Object => $Object, Grouping => $group, InTable => 0 &>
<div class="form-row">
diff --git a/share/html/Ticket/Elements/ShowSummary b/share/html/Ticket/Elements/ShowSummary
index 760664df74..7bdac31843 100644
--- a/share/html/Ticket/Elements/ShowSummary
+++ b/share/html/Ticket/Elements/ShowSummary
@@ -74,7 +74,7 @@ my $modify_behavior = $InlineEdit ? ($inline_edit_behavior{Basics} || $inline_ed
</div>
% }
% if ($modify_behavior ne 'hide') {
- <form class="inline-edit" action="<%RT->Config->Get('WebPath')%>/Ticket/Display.html" method="post">
+ <form class="inline-edit" action="<%RT->Config->Get('WebPath')%>/Ticket/Display.html" method="post" enctype="multipart/form-data">
<input type="hidden" class="hidden" name="id" value="<% $Ticket->id %>" />
<& /Ticket/Elements/EditBasics, TicketObj => $Ticket, InTable => 1, ExcludeOwner => 1, ExcludeCustomRoles => 1 &>
<& /Elements/EditCustomFields, Object => $Ticket, Grouping => 'Basics', InTable => 1 &>
commit 9745b724ea9a9ec6b1f5d789d20b9e6c30b94328
Author: craig kaiser <craig at bestpractical.com>
Date: Thu Oct 8 15:25:27 2020 -0400
Add autocomplete for assets
diff --git a/share/html/Helpers/Autocomplete/Assets b/share/html/Helpers/Autocomplete/Assets
new file mode 100644
index 0000000000..09ddc36663
--- /dev/null
+++ b/share/html/Helpers/Autocomplete/Assets
@@ -0,0 +1,87 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2020 Best Practical Solutions, LLC
+%# <sales at bestpractical.com>
+%#
+%# (Except where explicitly superseded by other copyright notices)
+%#
+%#
+%# LICENSE:
+%#
+%# This work is made available to you under the terms of Version 2 of
+%# the GNU General Public License. A copy of that license should have
+%# been provided with this software, but in any event can be snarfed
+%# from www.gnu.org.
+%#
+%# This work 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, write to the Free Software
+%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# CONTRIBUTION SUBMISSION POLICY:
+%#
+%# (The following paragraph is not intended to limit the rights granted
+%# to you to modify and distribute this software under the terms of
+%# the GNU General Public License and is only of importance to you if
+%# you choose to contribute your changes and enhancements to the
+%# community by submitting them to Best Practical Solutions, LLC.)
+%#
+%# By intentionally submitting any modifications, corrections or
+%# derivatives to this work, or any other work intended for use with
+%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+%# you are the copyright holder for those contributions and you grant
+%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
+%# royalty-free, perpetual, license to use, copy, create derivative
+%# works based on those contributions, and sublicense and distribute
+%# those contributions and any derivatives thereof.
+%#
+%# END BPS TAGGED BLOCK }}}
+% $r->content_type('application/json; charset=utf-8');
+<% JSON( \@suggestions ) |n %>
+% $m->abort;
+<%ARGS>
+$term => undef
+$max => 10
+$op => 'STARTSWITH'
+$right => 'ShowAsset'
+$return => 'id'
+</%ARGS>
+<%INIT>
+# Only allow certain return fields
+$return = 'Name'
+ unless $return =~ /^(?:id|Name)$/;
+
+$m->abort unless defined $return
+ and defined $term
+ and length $term;
+
+# Sanity check the operator
+$op = 'STARTSWITH' unless $op =~ /^(?:LIKE|(?:START|END)SWITH|=|!=)$/i;
+
+my $assets = RT::Assets->new( $session{CurrentUser} );
+
+$assets->RowsPerPage( $max );
+$assets->Limit(
+ FIELD => 'Name',
+ OPERATOR => $op,
+ VALUE => $term,
+ ENTRYAGGREGATOR => 'OR',
+ CASESENSITIVE => 0,
+);
+
+my @suggestions;
+while (my $a = $assets->Next) {
+ next if $right and not $a->CurrentUserHasRight($right);
+ my $value = $a->$return;
+ push @suggestions, { label => $a->Name, value => $value };
+}
+</%INIT>
diff --git a/share/html/Ticket/Elements/ShowAssets b/share/html/Ticket/Elements/ShowAssets
index bebb094ec0..f031bc9989 100644
--- a/share/html/Ticket/Elements/ShowAssets
+++ b/share/html/Ticket/Elements/ShowAssets
@@ -213,7 +213,7 @@ if ($ShowRelatedTickets) {
<label><&|/l&>Add an asset to this ticket:</&></label>
<div class="form-row">
<div class="form-group mx-sm-3 mb-2">
- <input class="form-control mb-2" size="10" name="<% $Ticket->id %>-RefersTo" placeholder="<&|/l&>Asset #</&>" type="text">
+ <input class="form-control mb-2" size="10" name="<% $Ticket->id %>-RefersTo" placeholder="<&|/l&>Asset #</&>" type="text" data-autocomplete="Assets">
</div>
<button type="submit" name="AddAsset" value="Add" class="button btn btn-primary form-control mb-2">Add</button>
</div>
diff --git a/share/static/js/autocomplete.js b/share/static/js/autocomplete.js
index c56ea33218..1744aacb1c 100644
--- a/share/static/js/autocomplete.js
+++ b/share/static/js/autocomplete.js
@@ -7,7 +7,8 @@ window.RT.Autocomplete.Classes = {
Groups: 'group',
Tickets: 'tickets',
Queues: 'queues',
- Articles: 'articles'
+ Articles: 'articles',
+ Assets: 'Assets'
};
Selectize.define('rt_drag_drop', function(options) {
-----------------------------------------------------------------------
More information about the rt-commit
mailing list