[Rt-commit] rt branch, 4.0/apply-scrips-to-multiple-queues, updated. rt-4.0.4-227-gb940289

Ruslan Zakirov ruz at bestpractical.com
Wed Sep 12 11:37:52 EDT 2012


The branch, 4.0/apply-scrips-to-multiple-queues has been updated
       via  b9402897e2ece77e3e70f2b36f65374d31bb7723 (commit)
       via  adc03222eb0c5a9b37f1d703f74f6a077b125e57 (commit)
       via  2173598c907a9ad9c319f5749b0d51b7bb684725 (commit)
       via  f40cc62020e7b2b8fb85db94d9789c81500c1bd0 (commit)
      from  de9d10ee07462467c2c0d2af4e9d89507b3b0a51 (commit)

Summary of changes:
 lib/RT/CustomField.pm                     | 14 ++++++++++++++
 lib/RT/Scrip.pm                           | 10 +++++++++-
 share/html/Admin/CustomFields/Modify.html |  8 ++++++++
 share/html/Admin/Scrips/Modify.html       |  3 +--
 4 files changed, 32 insertions(+), 3 deletions(-)

- Log -----------------------------------------------------------------
commit f40cc62020e7b2b8fb85db94d9789c81500c1bd0
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Sat Sep 8 02:34:11 2012 +0400

    sync Scrip->IsAdded's return value with CustomField's

diff --git a/lib/RT/Scrip.pm b/lib/RT/Scrip.pm
index d8b7ebb..4499ecd 100644
--- a/lib/RT/Scrip.pm
+++ b/lib/RT/Scrip.pm
@@ -226,7 +226,8 @@ sub IsAdded {
     my $self = shift;
     my $record = RT::ObjectScrip->new( $self->CurrentUser );
     $record->LoadByCols( Scrip => $self->id, ObjectId => shift || 0 );
-    return $record->id;
+    return undef unless $record->id;
+    return $record;
 }
 
 sub AddedTo {

commit 2173598c907a9ad9c319f5749b0d51b7bb684725
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Sat Sep 8 02:37:04 2012 +0400

    Scrip->IsAddedToAny and CF->IsAppliedToAny methods

diff --git a/lib/RT/CustomField.pm b/lib/RT/CustomField.pm
index 2770f42..0f0f3ac 100644
--- a/lib/RT/CustomField.pm
+++ b/lib/RT/CustomField.pm
@@ -1247,6 +1247,20 @@ sub IsApplied {
     return $ocf;
 }
 
+=head2 IsAppliedToAny
+
+Returns true if custom field is applied to any object.
+
+=cut
+
+sub IsAppliedToAny {
+    my $self = shift;
+    my $id = shift;
+    my $ocf = RT::ObjectCustomField->new( $self->CurrentUser );
+    $ocf->LoadByCols( CustomField => $self->id );
+    return $ocf->id ? 1 : 0;
+}
+
 =head2 AddToObject OBJECT
 
 Add this custom field as a custom field for a single object, such as a queue or group.
diff --git a/lib/RT/Scrip.pm b/lib/RT/Scrip.pm
index 4499ecd..8f130e2 100644
--- a/lib/RT/Scrip.pm
+++ b/lib/RT/Scrip.pm
@@ -230,6 +230,13 @@ sub IsAdded {
     return $record;
 }
 
+sub IsAddedToAny {
+    my $self = shift;
+    my $record = RT::ObjectScrip->new( $self->CurrentUser );
+    $record->LoadByCols( Scrip => $self->id );
+    return $record->id ? 1 : 0;
+}
+
 sub AddedTo {
     my $self = shift;
     return RT::ObjectScrip->new( $self->CurrentUser )

commit adc03222eb0c5a9b37f1d703f74f6a077b125e57
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Wed Sep 12 19:28:55 2012 +0400

    keep return value of Disabled as boolean
    
    don't rely on Disabled to return undef if CF or Scrip
    is not applied. Use a method we have for that.

diff --git a/share/html/Admin/Scrips/Modify.html b/share/html/Admin/Scrips/Modify.html
index 866ba48..c588263 100755
--- a/share/html/Admin/Scrips/Modify.html
+++ b/share/html/Admin/Scrips/Modify.html
@@ -106,8 +106,7 @@ Abort(loc("Couldn't load scrip #[_1]", $id))
     unless $scrip->id;
 
 my $disabled = $scrip->Disabled;
-my $added_to_any = 0;
-$added_to_any = 1 if defined $disabled;
+my $added_to_any = $scrip->IsAddedToAny;
 
 if ( $Update ) {
     my @attribs = qw(

commit b9402897e2ece77e3e70f2b36f65374d31bb7723
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Wed Sep 12 19:32:11 2012 +0400

    CF disabling UI
    
    If CF is not applied to any object then Disabled is not defined
    and con not be set. We hide disabled UI on create and when CF
    is not applied.

diff --git a/share/html/Admin/CustomFields/Modify.html b/share/html/Admin/CustomFields/Modify.html
index 6881f41..10684a6 100644
--- a/share/html/Admin/CustomFields/Modify.html
+++ b/share/html/Admin/CustomFields/Modify.html
@@ -92,6 +92,12 @@
         Default => $CustomFieldObj->LookupType || $LookupType, &>
 </td></tr>
 
+% if ( $CustomFieldObj->id && !$CustomFieldObj->IsAppliedToAny ) {
+<tr><td></td>
+<td><i><&|/l&>Custom field is not added to any object.</&></i>
+</td></tr>
+% }
+
 <tr class="edit_validation"><td class="label"><&|/l&>Validation</&></td>
 <td><& /Widgets/ComboBox,
     Name    => 'Pattern',
@@ -130,11 +136,13 @@
 
 % $m->callback(CallbackName => 'BeforeEnabled', CustomField => $CustomFieldObj, CFvalidations => \@CFvalidations);
 
+% if ( $CustomFieldObj->id && $CustomFieldObj->IsAppliedToAny ) {
 <tr><td class="label"> </td><td>
 <input type="hidden" class="hidden" name="SetEnabled" value="1" />
 <input type="checkbox" class="checkbox" name="Enabled" value="1" <% $EnabledChecked |n%> />
 <&|/l&>Enabled (Unchecking this box disables this custom field)</&>
 </td></tr>
+% }
 
 % $m->callback(CallbackName => 'EndOfTable', CustomField => $CustomFieldObj, CFvalidations => \@CFvalidations);
 

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


More information about the Rt-commit mailing list