[Rt-commit] rt branch, 4.4/select-cf-hide-invalid-empty-values, updated. rt-4.2.3-204-gbd000e6

? sunnavy sunnavy at bestpractical.com
Wed Jul 2 10:29:58 EDT 2014


The branch, 4.4/select-cf-hide-invalid-empty-values has been updated
       via  bd000e6b4f0817b96ea238558205bc3d63ac18c9 (commit)
      from  3155be6e61ca7bfeef22a96da84e38e630728931 (commit)

Summary of changes:
 docs/UPGRADING-4.4                        | 7 +++++++
 share/html/Elements/EditCustomFieldSelect | 9 ++++++---
 2 files changed, 13 insertions(+), 3 deletions(-)

- Log -----------------------------------------------------------------
commit bd000e6b4f0817b96ea238558205bc3d63ac18c9
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Jul 2 20:20:59 2014 +0800

    automatically select first option if no default values exist for mandatory select cfs
    
    to make sure there is at least one value being selected

diff --git a/docs/UPGRADING-4.4 b/docs/UPGRADING-4.4
index 85f2aa2..1d66163 100644
--- a/docs/UPGRADING-4.4
+++ b/docs/UPGRADING-4.4
@@ -16,4 +16,11 @@ removed in favor of a built-in solution.
 
 =back
 
+=item *
+
+For mandatory select custom fields, "(no value)" options have been removed
+and the first option will be selected automatically.
+
+=back
+
 =cut
diff --git a/share/html/Elements/EditCustomFieldSelect b/share/html/Elements/EditCustomFieldSelect
index c3418de..19028b8 100644
--- a/share/html/Elements/EditCustomFieldSelect
+++ b/share/html/Elements/EditCustomFieldSelect
@@ -112,13 +112,15 @@ jQuery(  function () {
 % }
 %   }
 %   my $CFVs = $CustomField->Values;
+%   my $is_first = 1;
 %   while ( my $value = $CFVs->Next ) {
 %     my $content = $value->Name;
 %     my $labelid = "$name-". $value->id;
 <div data-name="<% $value->Category || '' %>">
-  <input type="<% $checktype %>" name="<% $name %>" id="<% $labelid %>" value="<% $content %>" <% $default{ lc $content }? ' checked="checked"' : '' |n%> />
+  <input type="<% $checktype %>" name="<% $name %>" id="<% $labelid %>" value="<% $content %>" <% ($is_first && !keys %default && !$CustomField->MatchPattern('')) || $default{ lc $content } ? ' checked="checked"' : '' |n%> />
   <label for="<% $labelid %>"><% $content %></label><br />
 </div>
+%     $is_first = 0 if $is_first;
 %   }
 </div>
 </fieldset>
@@ -191,6 +193,7 @@ $MaxValues => 1
 % my $selected;
 % my $CFVs = $CustomField->Values;
 % my @levels;
+% my $is_first = 1;
 % while ( my $value = $CFVs->Next ) {
 %       my $name = $value->Name;
 %       my $category = $value->Category || '';
@@ -212,12 +215,12 @@ $MaxValues => 1
 %           push @levels, $level;
 %       }
         <option value="<% $name %>"
-%       if ( grep $_ eq lc $name, @Default )
-%       {
+%       if ( ($is_first && !@Default && !$CustomField->MatchPattern('')) || ( grep $_ eq lc $name, @Default ) ) {
 %           $$SelectedRef = 1;
             selected="selected"
 %       }
         ><% $name %></option>
+%       $is_first = 0 if $is_first;
 % }
 % for (@levels) {
             </optgroup>

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


More information about the rt-commit mailing list