[Rt-commit] rt branch, master, updated. rt-4.4.0rc2-26-ge38da00

Shawn Moore shawn at bestpractical.com
Mon Dec 28 13:01:39 EST 2015


The branch, master has been updated
       via  e38da008b13b1e163fe3800035c4debfc3eecfff (commit)
       via  b16c120e24d1f2ac58768d2a68c587ff26b5d6ec (commit)
      from  79895e3ea85994f95fbcec28c97bc68e3b6d3f16 (commit)

Summary of changes:
 share/html/Admin/CustomFields/Modify.html          | 34 ++++------
 share/html/Admin/Elements/AddCustomFieldValue      | 34 +++++++++-
 share/html/Admin/Elements/EditCustomFieldValues    | 22 ++++++-
 .../Groups => Admin/EditCustomFieldValue}          | 75 +++++++++++-----------
 t/web/cf_select_one.t                              |  4 +-
 5 files changed, 102 insertions(+), 67 deletions(-)
 copy share/html/Helpers/{Autocomplete/Groups => Admin/EditCustomFieldValue} (62%)

- Log -----------------------------------------------------------------
commit e38da008b13b1e163fe3800035c4debfc3eecfff
Merge: 79895e3 b16c120
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Mon Dec 28 17:58:55 2015 +0000

    Merge branch '4.4/ajax-admin-custom-field-values'

diff --cc share/html/Admin/CustomFields/Modify.html
index 446975e,1751a63..4e8f570
--- a/share/html/Admin/CustomFields/Modify.html
+++ b/share/html/Admin/CustomFields/Modify.html
@@@ -275,23 -269,8 +277,16 @@@ if ( $ARGS{'Update'} && $id ne 'new' ) 
          push @results, $msg;
      }
  
 +    if ( $CustomFieldObj->SupportDefaultValues ) {
 +        my ($ret, $msg) = $CustomFieldObj->SetDefaultValues(
 +            Object => RT->System,
 +            Values => $ARGS{'Default-' . $CustomFieldObj->id . '-Value'} // $ARGS{'Default-' . $CustomFieldObj->id . '-Values'},
 +        );
 +        push @results, $msg;
 +    }
 +
-     my $paramtag = "CustomField-". $CustomFieldObj->Id ."-Value";
-     # Delete any fields that want to be deleted
-     foreach my $key ( keys %ARGS ) {
-         next unless $key =~ /^Delete-$paramtag-(\d+)$/;
-         my ($val, $msg) = $CustomFieldObj->DeleteValue( $1 );
-         push (@results, $msg);
-     }
- 
      # Update any existing values
+     my $paramtag = "CustomField-". $CustomFieldObj->Id ."-Value";
      my $values = $CustomFieldObj->ValuesObj;
      while ( my $value = $values->Next ) {
          foreach my $attr (qw(Name Description SortOrder Category)) {
@@@ -314,15 -298,9 +314,9 @@@ if ( $ARGS{'AddValue'} ) 
              map { 
                  $ARGS{$paramtag."-new-$_"} =~ s/^\s+//;
                  $ARGS{$paramtag."-new-$_"} =~ s/\s+$//;
 -                $_ => $ARGS{ $paramtag ."-new-$_" } } qw/ Name Description SortOrder Category/
 +                $_ => $ARGS{ $paramtag ."-new-$_" } } grep { defined $ARGS{ $paramtag ."-new-$_" } } qw/ Name Description SortOrder Category/
          );
          push (@results, $msg);
-         $added_cfv = 1 if $id;
- 
-         my $cfv = RT::CustomFieldValue->new( $session{CurrentUser} );
-         $cfv->Load($id);
-         $m->callback(CallbackName => 'AfterCreateCustomFieldValue',
- CustomFieldObj => $CustomFieldObj, CustomFieldValueObj => $cfv, ARGSRef => \%ARGS );
      }
  }
  
diff --cc share/html/Admin/Elements/AddCustomFieldValue
index 2b5ce4e,4cb2ce1..7ef5b8e
--- a/share/html/Admin/Elements/AddCustomFieldValue
+++ b/share/html/Admin/Elements/AddCustomFieldValue
@@@ -53,9 -54,10 +54,10 @@@
  <th><&|/l&>Sort</&></th>
  <th><&|/l&>Name</&></th>
  <th><&|/l&>Description</&></th>
 -% if ( $CustomField->Type ne 'Combobox' ) {
 +% if ( $CustomField->Type ne 'Combobox' && $Categories ) {
  <th class="categoryheader"><&|/l&>Category</&></th>
  % }
+ <th></th>
  </tr>
  
  % my $paramtag = "CustomField-". $CustomField->Id ."-Value-new";
@@@ -77,15 -85,34 +79,41 @@@
  </tr>
  
  </table>
+ </form>
 +
+ <script type="text/javascript">
+ jQuery( function() {
+     jQuery('form[name=AddCustomFieldValue]').submit(function() {
+         jQuery.post('<% RT->Config->Get('WebPath') %>/Helpers/Admin/EditCustomFieldValue', {
+             action: 'add',
+             cf_id: <% $CustomField->id %>,
+             sort_order: jQuery('input[name=CustomField-<% $CustomField->id %>-Value-new-SortOrder]').val(),
+             name: jQuery('input[name=CustomField-<% $CustomField->id %>-Value-new-Name]').val(),
+             description: jQuery('input[name=CustomField-<% $CustomField->id %>-Value-new-Description]').val(),
+             category: jQuery('[name=CustomField-<% $CustomField->id %>-Value-new-Category]').val()
+         }, function(data) {
+             if ( data.status != 0 ) {
+                 jQuery('div.edit_custom_field_values').html(data.html);
+                 jQuery('input[name=CustomField-<% $CustomField->id %>-Value-new-SortOrder]').val(''),
+                 jQuery('input[name=CustomField-<% $CustomField->id %>-Value-new-Name]').val('').focus(),
+                 jQuery('input[name=CustomField-<% $CustomField->id %>-Value-new-Description]').val(''),
+                 jQuery('[name=CustomField-<% $CustomField->id %>-Value-new-Category]').val('');
+             }
+             else {
+                 alert(data.message);
+             }
+         }, 'json');
+         return false;
+     });
+ });
+ </script>
 -
 +<%init>
 +my $BasedOnObj = $CustomField->BasedOnObj;
 +my $Categories;
 +if ($BasedOnObj and $BasedOnObj->Id) {
 +    $Categories = $BasedOnObj->Values;
 +}
 +</%init>
- 
  <%args>
  $CustomField => undef
  </%args>
diff --cc share/html/Admin/Elements/EditCustomFieldValues
index 075a660,90db3be..8839f47
--- a/share/html/Admin/Elements/EditCustomFieldValues
+++ b/share/html/Admin/Elements/EditCustomFieldValues
@@@ -56,10 -56,10 +56,10 @@@
  <th><&|/l&>Sort</&></th>
  <th><&|/l&>Name</&></th>
  <th><&|/l&>Description</&></th>
 -% if ($CustomField->Type ne 'Combobox') {
 +% if ( $CustomField->Type ne 'Combobox' && $Categories ) {
  <th class="categoryheader"><&|/l&>Category</&></th>
  % }
+ <th></th>
  </tr>
  
  % while ( my $value = $values->Next ) {

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


More information about the rt-commit mailing list