[Rt-commit] rt branch, 4.4-trunk, updated. rt-4.4.0-235-gc5f2cf1

Shawn Moore shawn at bestpractical.com
Thu Jun 9 14:21:26 EDT 2016


The branch, 4.4-trunk has been updated
       via  c5f2cf19d3fefa9c8bcc8130a50ae8f86ec9da9d (commit)
       via  25fdd951a6ec02ca5b64dc5e138555d11b0e479f (commit)
       via  04124a69f30c90d9a0d460ba9cc08e7e42a762bf (commit)
       via  5d851b77f275252578ce29c21a652c88a6663ab6 (commit)
      from  81c8d98645fc8aa677ae9111a3e56d2a0d8e3fb6 (commit)

Summary of changes:
 lib/RT/Asset.pm                                    |  4 ++
 lib/RT/CustomField.pm                              |  2 +-
 .../Catalogs/DefaultValues.html}                   | 59 +++++++++++++++-------
 share/html/Elements/Tabs                           |  2 +
 4 files changed, 49 insertions(+), 18 deletions(-)
 copy share/html/Admin/{CustomFields/GroupRights.html => Assets/Catalogs/DefaultValues.html} (57%)

- Log -----------------------------------------------------------------
commit 5d851b77f275252578ce29c21a652c88a6663ab6
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 1c0f715..3c4c745 100644
--- a/lib/RT/CustomField.pm
+++ b/lib/RT/CustomField.pm
@@ -2056,7 +2056,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 04124a69f30c90d9a0d460ba9cc08e7e42a762bf
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 25fdd951a6ec02ca5b64dc5e138555d11b0e479f
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) {

commit c5f2cf19d3fefa9c8bcc8130a50ae8f86ec9da9d
Merge: 81c8d98 25fdd95
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Thu Jun 9 18:21:18 2016 +0000

    Merge branch '4.4/assets-cfs-default-values' into 4.4-trunk


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


More information about the rt-commit mailing list