[Rt-commit] rt branch 5.0/add-boolean-select-render-type created. rt-5.0.2-282-g77cb4637e5

BPS Git Server git at git.bestpractical.com
Mon Jun 27 20:15:02 UTC 2022


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".

The branch, 5.0/add-boolean-select-render-type has been created
        at  77cb4637e571cd8b766b7d5b04d1022179c037dd (commit)

- Log -----------------------------------------------------------------
commit 77cb4637e571cd8b766b7d5b04d1022179c037dd
Author: Brian Conry <bconry at bestpractical.com>
Date:   Mon Jun 27 15:08:18 2022 -0500

    Add the Checkbox RenderType for SelectSingle CFs
    
    This change adds a new RenderType, "Checkbox", Select CFs that accept
    only a single value.
    
    It is recommended, but not required, that only one value be configured
    for a Checkbox CF.

diff --git a/docs/initialdata.pod b/docs/initialdata.pod
index d2343349b0..39e6e091a2 100644
--- a/docs/initialdata.pod
+++ b/docs/initialdata.pod
@@ -217,11 +217,15 @@ common C<LookupType>.
 =item C<RenderType>
 
 Only valid when C<Type> is "Select".  Controls how the CF is displayed when
-editing it.  Valid values are: C<Select box>, C<List>, and C<Dropdown>.
+editing it.  Valid values are: C<Select box>, C<List>, C<Dropdown>, and C<Checkbox>.
 
 C<List> is either a list of radio buttons or a list of checkboxes depending on
 C<MaxValues>.
 
+C<Checkbox> is only available on a Single type CF.  The CF will render as a
+checkbox for editing and when set.  It is recommended to have only one entry in
+C<Values> for a Checkbox CF.
+
 =item C<MaxValues>
 
 Determines whether this CF is a Single or Multiple type.  0 means multiple.  1
diff --git a/lib/RT/CustomField.pm b/lib/RT/CustomField.pm
index c0112ae7da..59853d97cc 100644
--- a/lib/RT/CustomField.pm
+++ b/lib/RT/CustomField.pm
@@ -87,6 +87,7 @@ our %FieldTypes = (
             single => [ 'Dropdown',                # loc
                         'Select box',              # loc
                         'List',                    # loc
+                        'Checkbox',                # loc
                       ]
         },
 
diff --git a/share/html/Elements/EditCustomFieldSelect b/share/html/Elements/EditCustomFieldSelect
index acc8e9e5f3..29febf22c9 100644
--- a/share/html/Elements/EditCustomFieldSelect
+++ b/share/html/Elements/EditCustomFieldSelect
@@ -78,6 +78,11 @@
 %   }
 </div>
 </fieldset>
+% } elsif ( $RenderType eq 'Checkbox' ) {
+%   my $CFVs = CachedCustomFieldValues($CustomField);
+%   my $value = $CFVs->Next;
+%   $value = $value->Name if $value;
+  <input type="checkbox" id="<% $name %>" name="<% $name %>" class="custom-control" value="<% $value %>" <% scalar keys %default ? "checked" : "" %> />
 % } else {
 % if (@category) {
 %# this hidden select is to supply a full list of values,
diff --git a/share/html/Elements/ShowCustomFieldSelect b/share/html/Elements/ShowCustomFieldSelect
new file mode 100644
index 0000000000..d0e11d8ee2
--- /dev/null
+++ b/share/html/Elements/ShowCustomFieldSelect
@@ -0,0 +1,60 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2022 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 }}}
+<%INIT>
+my $cf = $Object->CustomFieldObj;
+my $content = $Object->Content;
+</%INIT>
+% if ( $cf->RenderType eq 'Checkbox' )  {
+    <input type="checkbox" disabled="disabled" class="custom-control" checked="<% ( defined $content and $content ne '' ) ? "checked" : "" %>" />
+% }
+% else {
+    <% $content |h %>
+% }
+<%ARGS>
+$Object => undef
+</%ARGS>

-----------------------------------------------------------------------


hooks/post-receive
-- 
rt


More information about the rt-commit mailing list