[Rt-commit] rt branch, 3.9-trunk, updated. rt-3.8.8-194-g806ee09
Thomas Sibley
trs at bestpractical.com
Fri Jul 30 13:24:01 EDT 2010
The branch, 3.9-trunk has been updated
via 806ee09e8d6437d67aae5b64d6e5c7f973aa1d65 (commit)
from 73d5d63eda9d0f4d691bf5e2a34730de8bb4f10e (commit)
Summary of changes:
lib/RT/CustomField_Overlay.pm | 1 +
share/html/Elements/EditCustomFieldSelect | 33 ++++++++++++++++++++++++++++-
share/html/NoAuth/css/base/misc.css | 5 ++++
3 files changed, 38 insertions(+), 1 deletions(-)
- Log -----------------------------------------------------------------
commit 806ee09e8d6437d67aae5b64d6e5c7f973aa1d65
Author: Thomas Sibley <trs at bestpractical.com>
Date: Fri Jul 30 13:24:42 2010 -0400
Add a List render type for checkboxes or radio buttons
Most of this was taken, with a little mangling, from Ruslan's
RT-Extension-CustomField-Checkbox.
diff --git a/lib/RT/CustomField_Overlay.pm b/lib/RT/CustomField_Overlay.pm
index 6c661be..24ae33a 100755
--- a/lib/RT/CustomField_Overlay.pm
+++ b/lib/RT/CustomField_Overlay.pm
@@ -104,6 +104,7 @@ our %RenderTypes = (
# Default is the first one
'Select box', # loc
'Dropdown', # loc
+ 'List', # loc
],
);
diff --git a/share/html/Elements/EditCustomFieldSelect b/share/html/Elements/EditCustomFieldSelect
index 7f62657..f1ca1cb 100644
--- a/share/html/Elements/EditCustomFieldSelect
+++ b/share/html/Elements/EditCustomFieldSelect
@@ -92,6 +92,21 @@ doOnLoad( function () {
</select>
% }
+% if ( $RenderType eq 'List' ) {
+<fieldset>
+% if ( $checktype eq 'radio' ) {
+ <input type="<% $checktype %>" name="<% $name %>" id="<% $name %>-none" value="" <% keys %default ? '' : ' checked="checked"' |n%> />
+ <label for="<% $name %>-none"><&|/l&>(no value)</&><label><br />
+% }
+% my $CFVs = $CustomField->Values;
+% while ( my $value = $CFVs->Next ) {
+% my $content = $value->Name;
+% my $labelid = "$name-". $value->id;
+ <input type="<% $checktype %>" name="<% $name %>" id="<% $labelid %>" value="<% $content %>" <% $default{ lc $content }? ' checked="checked"' : '' |n%> />
+ <label for="<% $labelid %>"><% $content %><label><br />
+% }
+</fieldset>
+% } else {
<select
name="<%$id%>-Values" id="<%$id%>-Values" class="CF-<%$CustomField->id%>-Edit"
% if ( $Rows && ( $Multiple || !@category ) ) {
@@ -101,6 +116,7 @@ doOnLoad( function () {
<option value=""<% !$selected && qq[ selected="selected"] |n %>><&|/l&>(no value)</&></option>
% $m->out($out);
</select>
+% }
<%init>
# Handle render types
$RenderType ||= $CustomField->RenderType;
@@ -108,17 +124,32 @@ if ( $RenderType eq 'Dropdown' ) {
# Turn it into a dropdown
$Rows = 0;
}
+
+# The following is for rendering checkboxes / radio buttons only
+my ($checktype, $name);
+if ( $MaxValues == 1 ) {
+ ($checktype, $name) = ('radio', $NamePrefix . $CustomField->Id . '-Value');
+} else {
+ ($checktype, $name) = ('checkbox', $NamePrefix . $CustomField->Id . '-Values');
+}
+
+ at Default = grep defined && length, @Default;
+if ( !@Default && $Values ) {
+ @Default = map $_->Content, @{ $Values->ItemsArrayRef };
+}
+my %default = map {lc $_ => 1} @Default;
</%init>
<%ARGS>
$Object => undef
$CustomField => undef
$NamePrefix => undef
-$Default => undef
+ at Default => ()
$Values => undef
$Multiple => 0
$Rows => undef
$HideCategory => 0
$RenderType => undef
+$MaxValues
</%ARGS>
<%METHOD options>
diff --git a/share/html/NoAuth/css/base/misc.css b/share/html/NoAuth/css/base/misc.css
index 89e52d0..50d0e75 100644
--- a/share/html/NoAuth/css/base/misc.css
+++ b/share/html/NoAuth/css/base/misc.css
@@ -116,3 +116,8 @@ hr.clear {
.cflabel .name { font-weight: bold; }
.cflabel .type { font-style: italic; }
+.edit-custom-field .entry fieldset {
+ border: none;
+ padding: 0;
+ margin: 0;
+}
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list