[Rt-commit] [rtir] 03/03: Replace EditCustomFieldSelect shim with a very simple select list

Kevin Falcone falcone at bestpractical.com
Thu Dec 4 18:39:01 EST 2014


This is an automated email from the git hooks/post-receive script.

falcone pushed a commit to branch 3.4/constituency-external-cf
in repository rtir.

commit b5e0b66e2b24597108bbf628d26f9dfa92ae5abd
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Thu Dec 4 17:38:47 2014 -0500

    Replace EditCustomFieldSelect shim with a very simple select list
    
    This is essentially EditCustomFieldSelect with all of the category code
    deleted, which renders it quite short.
    
    The only strange things here are:
    
    $PropagationObject and $QueueObj which come in from RTIR code via %ARGS passing.
        This is RTIR's Default override logic.  If you select something and
        resubmit the form, we'll keep it, but otherwise the value is picked
        based on RTIR's complex Constituency system.
    Using %default rather than looping over @Default
---
 html/Elements/EditCustomFieldConstituency | 43 ++++++++++++++++++++++++++++---
 1 file changed, 40 insertions(+), 3 deletions(-)

diff --git a/html/Elements/EditCustomFieldConstituency b/html/Elements/EditCustomFieldConstituency
index c5f51ca..3a005e0 100644
--- a/html/Elements/EditCustomFieldConstituency
+++ b/html/Elements/EditCustomFieldConstituency
@@ -45,6 +45,43 @@
 %# those contributions and any derivatives thereof.
 %#
 %# END BPS TAGGED BLOCK }}}
-<%INIT>
-return $m->comp( 'EditCustomFieldSelect', %ARGS );
-</%INIT>
+<select name="<%$name%>" id="<%$name%>" class="CF-<%$CustomField->id%>-Edit">
+% my $CFVs = $CustomField->Values;
+% while ( my $value = $CFVs->Next ) { my $cfv_name = $value->Name;
+    <option value="<% $cfv_name %>" <% $default{ lc $cfv_name } ? 'selected="selected"' : '' %>>
+        <% $cfv_name %>
+    </option>
+% }
+</select>
+<%init>
+ at Default = grep defined && length, @Default;
+
+unless (@Default) {
+    my $default = $PropagationObject->FirstCustomFieldValue('Constituency') if $PropagationObject;
+    $default ||= RT::IR::DefaultConstituency( $QueueObj ) if $QueueObj;
+    $default ||= scalar RT->Config->Get('RTIR_CustomFieldsDefaults')->{'Constituency'};
+    push @Default, $default;
+}
+
+if ( !@Default && $Values ) {
+    @Default = map $_->Content, @{ $Values->ItemsArrayRef };
+}
+my %default = map {lc $_ => 1} @Default;
+my $name =  $Name || $NamePrefix . $CustomField->Id . '-Values';
+</%init>
+<%ARGS>
+$Object => undef
+$CustomField => undef
+$NamePrefix => undef
+$Name => undef
+$BasedOnName => undef
+ at Default => ()
+$Values => undef
+$Multiple => 0
+$Rows => undef
+$HideCategory => 0
+$RenderType => undef
+$MaxValues => 1
+$PropagationObject => undef
+$QueueObj => undef
+</%ARGS>

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the rt-commit mailing list