[Rt-commit] rt branch, 4.4/cf-default-values, repushed
? sunnavy
sunnavy at bestpractical.com
Sun Jun 15 11:14:07 EDT 2014
The branch 4.4/cf-default-values was deleted and repushed:
was de87aa304132574045362baa2d798b4cffb32e2e
now 7fe79d62293ceecd22f205a4daf37177be813c12
1: 782b3fd ! 1: bab107f added ticket cf global default values support
@@ -1,6 +1,6 @@
Author: sunnavy <sunnavy at bestpractical.com>
- added cf global default values support
+ added ticket cf global default values support
diff --git a/lib/RT/CustomField.pm b/lib/RT/CustomField.pm
--- a/lib/RT/CustomField.pm
@@ -12,6 +12,7 @@
+sub SupportDefaultValues {
+ my $self = shift;
+ return 0 unless $self->id;
++ return 0 unless $self->LookupType =~ /RT::Ticket$/;
+ return $self->Type !~ /^(?:Image|Binary)$/;
+}
+
@@ -71,6 +72,50 @@
=head2 id
+diff --git a/lib/RT/Ticket.pm b/lib/RT/Ticket.pm
+--- a/lib/RT/Ticket.pm
++++ b/lib/RT/Ticket.pm
+@@
+ }
+
+ # Add all the custom fields
++ my %cf_added;
+ foreach my $arg ( keys %args ) {
+ next unless $arg =~ /^CustomField-(\d+)$/i;
+ my $cfid = $1;
+ my $cf = $self->LoadCustomFieldByIdentifier($cfid);
+ next unless $cf->ObjectTypeFromLookupType->isa(ref $self);
++ $cf_added{$cfid}++;
+
+ foreach my $value (
+ UNIVERSAL::isa( $args{$arg} => 'ARRAY' ) ? @{ $args{$arg} } : ( $args{$arg} ) )
+@@
+ }
+ }
+
++ my $cfs = $self->QueueObj->TicketCustomFields;
++ while ( my $cf = $cfs->Next ) {
++ next if $cf_added{$cf->id} || !$cf->SupportDefaultValues;
++ my $values = $cf->DefaultValues(Object => RT->System); # TODO support queue-level default values
++ foreach my $value ( UNIVERSAL::isa( $values => 'ARRAY' ) ? @$values : $values ) {
++ next if $self->CustomFieldValueIsEmpty(
++ Field => $cf->id,
++ Value => $value,
++ );
++
++ my ( $status, $msg ) = $self->_AddCustomFieldValue(
++ Field => $cf->id,
++ Value => $value,
++ RecordTransaction => 0,
++ );
++ push @non_fatal_errors, $msg unless $status;
++ }
++ }
++
+ # Deal with setting up links
+
+ # TODO: Adding link may fire scrips on other end and those scrips
+
diff --git a/share/html/Admin/CustomFields/Modify.html b/share/html/Admin/CustomFields/Modify.html
--- a/share/html/Admin/CustomFields/Modify.html
+++ b/share/html/Admin/CustomFields/Modify.html
@@ -79,7 +124,7 @@
&></td></tr>
+% if ( $CustomFieldObj->SupportDefaultValues ) {
-+<tr class="edit_default_values"><td class="label"><&|/l&>Default Value(s)</&></td>
++<tr class="edit_default_values"><td class="label"><&|/l, $CustomFieldObj->MaxValues &>Default [numerate,_1,value,values]</&></td>
+<td>
+<& /Elements/EditCustomField, NamePrefix => 'Default-', CustomField => $CustomFieldObj, Default => $CustomFieldObj->DefaultValues(Object => RT->System) &>
+</td>
@@ -112,7 +157,7 @@
}
}
-+if ( ( !defined $Default || !length $Default ) && $CustomField->SupportDefaultValues ) {
++if ( (!$Object || !$Object->id) && ( !defined $Default || !length $Default ) && $CustomField->SupportDefaultValues ) {
+ $Default = $CustomField->DefaultValues;
+}
+
2: d49c274 < -: ------- allow default values for Ticket/Txn cfs only for now
3: 655a063 < -: ------- fill default custom field values on ticket/txn creation
4: 4f67026 ! 2: b4303c6 queue-level default custom fields
@@ -89,19 +89,6 @@
next if $self->CustomFieldValueIsEmpty(
Field => $cf->id,
-diff --git a/lib/RT/Transaction.pm b/lib/RT/Transaction.pm
---- a/lib/RT/Transaction.pm
-+++ b/lib/RT/Transaction.pm
-@@
- my $cfs = $self->Object->TransactionCustomFields;
- while ( my $cf = $cfs->Next ) {
- next if $cf_added{$cf->id} || !$cf->SupportDefaultValues;
-- my $values = $cf->DefaultValues(Object => RT->System); # TODO support queue-level default values
-+ my $values = $cf->DefaultValues(Object => $self->Object->QueueObj);
- foreach my $value ( UNIVERSAL::isa( $values => 'ARRAY' ) ? @$values : $values ) {
- next if $self->CustomFieldValueIsEmpty(
- Field => $cf->id,
-
diff --git a/share/html/Admin/Queues/DefaultValues.html b/share/html/Admin/Queues/DefaultValues.html
new file mode 100644
--- /dev/null
@@ -163,9 +150,6 @@
+<h2><&|/l&>Ticket Custom Fields</&></h2>
+<& /Elements/EditCustomFields, CustomFields => $ticket_cfs, NamePrefix => 'Default-', Object => RT::Ticket->new($session{CurrentUser}), QueueObj => $queue &>
+
-+<h2><&|/l&>Transaction Custom Fields</&></h2>
-+<& /Elements/EditCustomFields, CustomFields => $txn_cfs, NamePrefix => 'Default-', Object => RT::Transaction->new($session{CurrentUser}), QueueObj => $queue &>
-+
+<& /Elements/Submit, Name => 'Update', Label => loc('Save Changes') &>
+</form>
+
@@ -175,7 +159,6 @@
+
+my $title = loc( 'Default Values for queue [_1]', $queue->Name );
+my $ticket_cfs = $queue->TicketCustomFields;
-+my $txn_cfs = $queue->TicketTransactionCustomFields;
+
+my @results;
+if ( $ARGS{Update} ) {
@@ -196,15 +179,27 @@
+$id => undef
+</%ARGS>
+diff --git a/share/html/Elements/AddLinks b/share/html/Elements/AddLinks
+--- a/share/html/Elements/AddLinks
++++ b/share/html/Elements/AddLinks
+@@
+ <td class="entry"> <input name="RefersTo-<%$id%>" value="<% $ARGSRef->{"RefersTo-$id"} || '' %>" <% $exclude |n%>/></td>
+ </tr>
+ <& /Elements/EditCustomFields,
++ %ARGS,
+ Object => $Object,
+ Grouping => 'Links',
+ InTable => 1,
+
diff --git a/share/html/Elements/EditCustomField b/share/html/Elements/EditCustomField
--- a/share/html/Elements/EditCustomField
+++ b/share/html/Elements/EditCustomField
@@
}
- if ( ( !defined $Default || !length $Default ) && $CustomField->SupportDefaultValues ) {
+ if ( (!$Object || !$Object->id) && ( !defined $Default || !length $Default ) && $CustomField->SupportDefaultValues ) {
- $Default = $CustomField->DefaultValues;
-+ $Default = $CustomField->DefaultValues( Object => $ARGS{QueueObj} || RT->System );
++ $Default = $CustomField->DefaultValues(Object => $ARGS{DefaultValuesFromObject} || RT->System);
}
my $MaxValues = $CustomField->MaxValues;
@@ -228,7 +223,7 @@
CustomFields => $QueueObj->TicketCustomFields,
Grouping => 'Basics',
InTable => 1,
-+ QueueObj => $QueueObj,
++ DefaultValuesFromObject => $QueueObj,
&>
<& /Ticket/Elements/EditTransactionCustomFields, %ARGS, QueueObj => $QueueObj, InTable => 1 &>
</table>
@@ -236,7 +231,7 @@
%ARGS,
Object => $ticket,
CustomFieldGenerator => sub { $QueueObj->TicketCustomFields },
-+ QueueObj => $QueueObj,
++ DefaultValuesFromObject => $QueueObj,
&>
</div>
@@ -244,7 +239,7 @@
CustomFields => $QueueObj->TicketCustomFields,
Grouping => 'People',
InTable => 1,
-+ QueueObj => $QueueObj,
++ DefaultValuesFromObject => $QueueObj,
&>
<tr>
@@ -252,20 +247,16 @@
CustomFields => $QueueObj->TicketCustomFields,
Grouping => 'Dates',
InTable => 1,
-+ QueueObj => $QueueObj,
++ DefaultValuesFromObject => $QueueObj,
&>
</table>
</&>
-
-diff --git a/share/html/Ticket/Elements/EditTransactionCustomFields b/share/html/Ticket/Elements/EditTransactionCustomFields
---- a/share/html/Ticket/Elements/EditTransactionCustomFields
-+++ b/share/html/Ticket/Elements/EditTransactionCustomFields
-@@
- <& /Elements/EditCustomField,
- CustomField => $CF,
- Object => RT::Transaction->new( $session{'CurrentUser'} ),
-+ QueueObj => $QueueObj,
- &>
- % if (my $msg = $m->notes('InvalidField-' . $CF->Id)) {
- <br />
-
+@@
+ Object => $ticket,
+ CustomFields => $QueueObj->TicketCustomFields,
+ ARGSRef => \%ARGS,
++ DefaultValuesFromObject => $QueueObj,
+ &>
+ </&>
+ </div>
+
5: 734aa9e < -: ------- queue-level default values for priority/starts/due
6: de87aa3 < -: ------- remove deleted cf values from cf default values
-: ------- > 3: 9869252 queue-level default values for priority/starts/due
-: ------- > 4: 5283963 make default values page be like ticket create or display pages
-: ------- > 5: f743962 make datepicker less zealous
-: ------- > 6: 7fe79d6 remove outdated default values when a cfv is updated/deleted
More information about the rt-commit
mailing list