[Rt-commit] rt branch, 4.4/assets-cfs-default-values, created. rt-4.4.1rc1-3-g87519dd

Dustin Graves dustin at bestpractical.com
Fri May 27 17:00:09 EDT 2016


The branch, 4.4/assets-cfs-default-values has been created
        at  87519dd1077488e1fb6c361877ae7d90c91eb714 (commit)

- Log -----------------------------------------------------------------
commit 1d7453248c53083313fbbd3b9f48990f226098e4
Author: Dustin Graves <dustin at bestpractical.com>
Date:   Fri May 27 19:49:03 2016 +0000

    add Assets to type of CustomField object that supports DefaultValues

diff --git a/lib/RT/CustomField.pm b/lib/RT/CustomField.pm
index ee56a25..2481be7 100644
--- a/lib/RT/CustomField.pm
+++ b/lib/RT/CustomField.pm
@@ -2038,7 +2038,7 @@ sub BasedOnObj {
 sub SupportDefaultValues {
     my $self = shift;
     return 0 unless $self->id;
-    return 0 unless $self->LookupType =~ /RT::(?:Ticket|Transaction)$/;
+    return 0 unless $self->LookupType =~ /RT::(?:Ticket|Transaction|Asset)$/;
     return $self->Type !~ /^(?:Image|Binary)$/;
 }
 

commit b0a3ef3987fd189cdaf7a3a45d6f5795b8bc06c5
Author: Dustin Graves <dustin at bestpractical.com>
Date:   Fri May 27 20:12:09 2016 +0000

    add DefaultValues functionality for Catalogs in Web UI

diff --git a/share/html/Admin/Assets/Catalogs/DefaultValues.html b/share/html/Admin/Assets/Catalogs/DefaultValues.html
new file mode 100644
index 0000000..8a00e16
--- /dev/null
+++ b/share/html/Admin/Assets/Catalogs/DefaultValues.html
@@ -0,0 +1,103 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2016 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 }}}
+<& /Admin/Elements/Header, Title => $title &>
+<& /Elements/Tabs &>
+<& /Elements/ListActions, actions => \@results &>
+
+<form method="post" action="DefaultValues.html" name="ModifyDefaultValues" id="ModifyDefaultValues">
+<input type="hidden" name="id" value="<% $catalog->id %>" />
+
+<& /Elements/EditCustomFieldCustomGroupings,
+    CustomFieldGenerator => sub {
+        $catalog->AssetCustomFields->LimitToDefaultValuesSupportedTypes
+    },
+    TitleBoxARGS => { title_class => "inverse" },
+    NamePrefix => 'Default-',
+    Object => RT::Asset->new($session{CurrentUser})
+&>
+
+<& /Elements/Submit, Name => 'Update', Label => loc('Save Changes') &>
+<& /Elements/Submit, Name => 'Reset', Label => loc('Reset Custom Field Values to Default') &>
+</form>
+
+<%INIT>
+my $catalog = RT::Catalog->new( $session{CurrentUser} );
+$catalog->Load($id) || Abort( loc( "Couldn't load asset [_1]", $id ) );
+
+my $title = loc( 'Default Values for catalog [_1]', $catalog->Name );
+
+my @results;
+if ( $ARGS{Reset} ) {
+    my $attr = $catalog->FirstAttribute( 'CustomFieldDefaultValues' );
+    if ( $attr ) {
+        $attr->Delete;
+        push @results, "Custom Field default values are reset";
+    }
+}
+elsif ( $ARGS{Update} ) {
+    for my $cf_id ( map { /^Default-(\d+)-/ ? $1 : ()  } keys %ARGS ) {
+        my $cf = RT::CustomField->new($session{CurrentUser});
+        $cf->Load($cf_id);
+        if ( $cf->id && $cf->SupportDefaultValues ) {
+            my ($ret, $msg) = $cf->SetDefaultValues(
+                Object => $catalog,
+                Values => $ARGS{'Default-' . $cf->id . '-Value'} // $ARGS{'Default-' . $cf->id . '-Values'},
+            );
+            push @results, $msg;
+        }
+    }
+}
+
+MaybeRedirectForResults(
+    Actions   => \@results,
+    Arguments => { id => $catalog->id },
+);
+</%INIT>
+<%ARGS>
+$id => undef
+</%ARGS>
diff --git a/share/html/Elements/Tabs b/share/html/Elements/Tabs
index 866e8f2..f4ac8a9 100644
--- a/share/html/Elements/Tabs
+++ b/share/html/Elements/Tabs
@@ -1087,6 +1087,8 @@ my $build_main_nav = sub {
 
             $page->child("group-rights", title => loc("Group Rights"), path => "/Admin/Assets/Catalogs/GroupRights.html?$query");
             $page->child("user-rights",  title => loc("User Rights"),  path => "/Admin/Assets/Catalogs/UserRights.html?$query");
+
+            $page->child("default-values", title => loc('Default Values'), path => "/Admin/Assets/Catalogs/DefaultValues.html?$query");
         }
     }
 

commit 87519dd1077488e1fb6c361877ae7d90c91eb714
Author: Dustin Graves <dustin at bestpractical.com>
Date:   Fri May 27 20:57:48 2016 +0000

    set Asset default value in Create method

diff --git a/lib/RT/Asset.pm b/lib/RT/Asset.pm
index b2e75bb..5ff3dc8 100644
--- a/lib/RT/Asset.pm
+++ b/lib/RT/Asset.pm
@@ -303,6 +303,10 @@ sub Create {
         }
     }
 
+    # Add CF default values
+    my ( $status, @msgs ) = $self->AddCustomFieldDefaultValues;
+    push @non_fatal_errors, @msgs unless $status;
+
     # Create transaction
     my ( $txn_id, $txn_msg, $txn ) = $self->_NewTransaction( Type => 'Create' );
     unless ($txn_id) {

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


More information about the rt-commit mailing list