[Rt-commit] rt branch, 4.4/cf-default-values, created. rt-4.2.3-208-g7fe79d6
? sunnavy
sunnavy at bestpractical.com
Sun Jun 15 11:14:04 EDT 2014
The branch, 4.4/cf-default-values has been created
at 7fe79d62293ceecd22f205a4daf37177be813c12 (commit)
- Log -----------------------------------------------------------------
commit bab107fba8e6383cb78c49b328f2b8a3389feae0
Author: sunnavy <sunnavy at bestpractical.com>
Date: Wed Jun 11 00:01:02 2014 +0800
added ticket cf global default values support
diff --git a/lib/RT/CustomField.pm b/lib/RT/CustomField.pm
index 49e386f..a22a0fa 100644
--- a/lib/RT/CustomField.pm
+++ b/lib/RT/CustomField.pm
@@ -1884,9 +1884,65 @@ sub BasedOnObj {
}
+sub SupportDefaultValues {
+ my $self = shift;
+ return 0 unless $self->id;
+ return 0 unless $self->LookupType =~ /RT::Ticket$/;
+ return $self->Type !~ /^(?:Image|Binary)$/;
+}
+
+sub DefaultValues {
+ my $self = shift;
+ my %args = (
+ Object => RT->System,
+ @_,
+ );
+ my $attr = $args{Object}->FirstAttribute('CustomFieldDefaultValues');
+ return $attr->Content->{$self->id} if $attr && $attr->Content;
+ return undef;
+}
+
+sub SetDefaultValues {
+ my $self = shift;
+ my %args = (
+ Object => RT->System,
+ Values => undef,
+ @_,
+ );
+ my $attr = $args{Object}->FirstAttribute( 'CustomFieldDefaultValues' );
+ my ( $old_content, $old_values );
+ $old_content = $attr->Content if $attr && $attr->Content;
+ $old_values = $old_content->{ $self->id } if $old_content;
+
+ my $ret = $args{Object}->SetAttribute(
+ Name => 'CustomFieldDefaultValues',
+ Content => {
+ %{ $old_content || {} }, $self->id => $args{Values},
+ },
+ );
+ if ( defined $old_values && length $old_values ) {
+ $old_values = join ', ', @$old_values if ref $old_values eq 'ARRAY';
+ }
+ else {
+ $old_values = $self->loc('(no value)');
+ }
+ my $new_values = $args{Values};
+ if ( defined $new_values && length $new_values ) {
+ $new_values = join ', ', @$new_values if ref $new_values eq 'ARRAY';
+ }
+ else {
+ $new_values = $self->loc( '(no value)' );
+ }
+ if ( $ret ) {
+ return ( $ret, $self->loc( 'Default values changed from [_1] to [_2]', $old_values, $new_values ) );
+ }
+ else {
+ return ( $ret, $self->loc( "Can't change default values from [_1] to [_2]", $old_values, $new_values ) );
+ }
+}
=head2 id
diff --git a/lib/RT/Ticket.pm b/lib/RT/Ticket.pm
index 42abbca..f9e901c 100644
--- a/lib/RT/Ticket.pm
+++ b/lib/RT/Ticket.pm
@@ -468,11 +468,13 @@ sub Create {
}
# 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} ) )
@@ -495,6 +497,25 @@ sub Create {
}
}
+ 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
index eea4532..0d6bf9c 100644
--- a/share/html/Admin/CustomFields/Modify.html
+++ b/share/html/Admin/CustomFields/Modify.html
@@ -127,6 +127,14 @@ jQuery( function() {
Values => \@CFvalidations,
&></td></tr>
+% if ( $CustomFieldObj->SupportDefaultValues ) {
+<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>
+</tr>
+% }
+
<tr><td class="label"><&|/l&>Link values to</&></td><td>
<input size="60" name="LinkValueTo" value="<% $CustomFieldObj->LinkValueTo || $LinkValueTo || '' %>" />
<div class="hints">
@@ -267,6 +275,14 @@ 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 ) {
diff --git a/share/html/Elements/EditCustomField b/share/html/Elements/EditCustomField
index 0b36592..585c048 100644
--- a/share/html/Elements/EditCustomField
+++ b/share/html/Elements/EditCustomField
@@ -90,6 +90,10 @@ if ( ( !defined $Default || !length $Default ) && $DefaultsFromTopArguments ) {
}
}
+if ( (!$Object || !$Object->id) && ( !defined $Default || !length $Default ) && $CustomField->SupportDefaultValues ) {
+ $Default = $CustomField->DefaultValues;
+}
+
my $MaxValues = $CustomField->MaxValues;
if ($MaxValues == 1 && $Values) {
# what exactly is this doing? Without the "unless" it breaks RTFM
commit b4303c6d67ddb71d297b8f0202606599ae9deb8f
Author: sunnavy <sunnavy at bestpractical.com>
Date: Sun Jun 15 11:54:35 2014 +0800
queue-level default custom fields
diff --git a/lib/RT/CustomField.pm b/lib/RT/CustomField.pm
index a22a0fa..8e0be32 100644
--- a/lib/RT/CustomField.pm
+++ b/lib/RT/CustomField.pm
@@ -1898,7 +1898,15 @@ sub DefaultValues {
@_,
);
my $attr = $args{Object}->FirstAttribute('CustomFieldDefaultValues');
- return $attr->Content->{$self->id} if $attr && $attr->Content;
+ my $values;
+ $values = $attr->Content->{$self->id} if $attr && $attr->Content;
+ return $values if defined $values;
+
+ if ( !$args{Object}->isa( 'RT::System' ) ) {
+ my $system_attr = RT::System->FirstAttribute( 'CustomFieldDefaultValues' );
+ $values = $system_attr->Content->{$self->id} if $system_attr && $system_attr->Content;
+ return $values if defined $values;
+ }
return undef;
}
@@ -1910,16 +1918,18 @@ sub SetDefaultValues {
@_,
);
my $attr = $args{Object}->FirstAttribute( 'CustomFieldDefaultValues' );
- my ( $old_content, $old_values );
- $old_content = $attr->Content if $attr && $attr->Content;
- $old_values = $old_content->{ $self->id } if $old_content;
+ my ( $old_values, $old_content, $new_values );
+ if ( $attr && $attr->Content ) {
+ $old_content = $attr->Content;
+ $old_values = $old_content->{ $self->id };
+ }
- my $ret = $args{Object}->SetAttribute(
- Name => 'CustomFieldDefaultValues',
- Content => {
- %{ $old_content || {} }, $self->id => $args{Values},
- },
- );
+ if ( !$args{Object}->isa( 'RT::System' ) && !defined $old_values ) {
+ my $system_attr = RT::System->FirstAttribute( 'CustomFieldDefaultValues' );
+ if ( $system_attr && $system_attr->Content ) {
+ $old_values = $system_attr->Content->{ $self->id };
+ }
+ }
if ( defined $old_values && length $old_values ) {
$old_values = join ', ', @$old_values if ref $old_values eq 'ARRAY';
@@ -1928,7 +1938,7 @@ sub SetDefaultValues {
$old_values = $self->loc('(no value)');
}
- my $new_values = $args{Values};
+ $new_values = $args{Values};
if ( defined $new_values && length $new_values ) {
$new_values = join ', ', @$new_values if ref $new_values eq 'ARRAY';
}
@@ -1936,6 +1946,15 @@ sub SetDefaultValues {
$new_values = $self->loc( '(no value)' );
}
+ return 1 if $new_values eq $old_values;
+
+ my $ret = $args{Object}->SetAttribute(
+ Name => 'CustomFieldDefaultValues',
+ Content => {
+ %{ $old_content || {} }, $self->id => $args{Values},
+ },
+ );
+
if ( $ret ) {
return ( $ret, $self->loc( 'Default values changed from [_1] to [_2]', $old_values, $new_values ) );
}
diff --git a/lib/RT/Ticket.pm b/lib/RT/Ticket.pm
index f9e901c..bc14fdb 100644
--- a/lib/RT/Ticket.pm
+++ b/lib/RT/Ticket.pm
@@ -500,7 +500,7 @@ sub Create {
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
+ my $values = $cf->DefaultValues(Object => $self->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
index 0000000..c6f2a1d
--- /dev/null
+++ b/share/html/Admin/Queues/DefaultValues.html
@@ -0,0 +1,84 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2014 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="<% $queue->id %>" />
+<h2><&|/l&>Ticket Custom Fields</&></h2>
+<& /Elements/EditCustomFields, CustomFields => $ticket_cfs, NamePrefix => 'Default-', Object => RT::Ticket->new($session{CurrentUser}), QueueObj => $queue &>
+
+<& /Elements/Submit, Name => 'Update', Label => loc('Save Changes') &>
+</form>
+
+<%INIT>
+my $queue = RT::Queue->new( $session{CurrentUser} );
+$queue->Load($id) || Abort( loc( "Couldn't load object [_1]", $id ) );
+
+my $title = loc( 'Default Values for queue [_1]', $queue->Name );
+my $ticket_cfs = $queue->TicketCustomFields;
+
+my @results;
+if ( $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 => $queue,
+ Values => $ARGS{'Default-' . $cf->id . '-Value'} // $ARGS{'Default-' . $cf->id . '-Values'},
+ );
+ push @results, $msg;
+ }
+ }
+}
+</%INIT>
+<%ARGS>
+$id => undef
+</%ARGS>
diff --git a/share/html/Elements/AddLinks b/share/html/Elements/AddLinks
index 74b2372..fddb331 100644
--- a/share/html/Elements/AddLinks
+++ b/share/html/Elements/AddLinks
@@ -95,6 +95,7 @@ $exclude .= qq| data-autocomplete-exclude="$id"| if $Object->id;
<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
index 585c048..b97d5db 100644
--- a/share/html/Elements/EditCustomField
+++ b/share/html/Elements/EditCustomField
@@ -91,7 +91,7 @@ if ( ( !defined $Default || !length $Default ) && $DefaultsFromTopArguments ) {
}
if ( (!$Object || !$Object->id) && ( !defined $Default || !length $Default ) && $CustomField->SupportDefaultValues ) {
- $Default = $CustomField->DefaultValues;
+ $Default = $CustomField->DefaultValues(Object => $ARGS{DefaultValuesFromObject} || RT->System);
}
my $MaxValues = $CustomField->MaxValues;
diff --git a/share/html/Elements/Tabs b/share/html/Elements/Tabs
index 0b3a50e..fb435b4 100644
--- a/share/html/Elements/Tabs
+++ b/share/html/Elements/Tabs
@@ -307,6 +307,7 @@ my $build_admin_menu = sub {
$queue->child( 'group-rights' => title => loc('Group Rights'), path => "/Admin/Queues/GroupRights.html?id=".$id );
$queue->child( 'user-rights' => title => loc('User Rights'), path => "/Admin/Queues/UserRights.html?id=" . $id );
$queue->child( 'history' => title => loc('History'), path => "/Admin/Queues/History.html?id=" . $id );
+ $queue->child( 'default-values' => title => loc('Default Values'), path => "/Admin/Queues/DefaultValues.html?id=" . $id );
$m->callback( CallbackName => 'PrivilegedQueue', queue_id => $id, page_menu => $queue);
}
diff --git a/share/html/Ticket/Create.html b/share/html/Ticket/Create.html
index 57e66df..66fbad6 100644
--- a/share/html/Ticket/Create.html
+++ b/share/html/Ticket/Create.html
@@ -105,6 +105,7 @@
CustomFields => $QueueObj->TicketCustomFields,
Grouping => 'Basics',
InTable => 1,
+ DefaultValuesFromObject => $QueueObj,
&>
<& /Ticket/Elements/EditTransactionCustomFields, %ARGS, QueueObj => $QueueObj, InTable => 1 &>
</table>
@@ -115,6 +116,7 @@
%ARGS,
Object => $ticket,
CustomFieldGenerator => sub { $QueueObj->TicketCustomFields },
+ DefaultValuesFromObject => $QueueObj,
&>
</div>
@@ -169,6 +171,7 @@
CustomFields => $QueueObj->TicketCustomFields,
Grouping => 'People',
InTable => 1,
+ DefaultValuesFromObject => $QueueObj,
&>
<tr>
@@ -263,6 +266,7 @@
CustomFields => $QueueObj->TicketCustomFields,
Grouping => 'Dates',
InTable => 1,
+ DefaultValuesFromObject => $QueueObj,
&>
</table>
</&>
@@ -278,6 +282,7 @@
Object => $ticket,
CustomFields => $QueueObj->TicketCustomFields,
ARGSRef => \%ARGS,
+ DefaultValuesFromObject => $QueueObj,
&>
</&>
</div>
commit 9869252fbaf89285e13c3dd871683a2d8d28e4cf
Author: sunnavy <sunnavy at bestpractical.com>
Date: Thu Jun 12 19:15:43 2014 +0800
queue-level default values for priority/starts/due
with this, we can drop the old InitialPriority/FinalPriority/DefaultDueIn
diff --git a/configure.ac b/configure.ac
index cd55c3e..a6c7bba 100755
--- a/configure.ac
+++ b/configure.ac
@@ -432,6 +432,7 @@ AC_CONFIG_FILES([
etc/upgrade/split-out-cf-categories
etc/upgrade/generate-rtaddressregexp
etc/upgrade/upgrade-articles
+ etc/upgrade/upgrade-queue-defaults
etc/upgrade/vulnerable-passwords
etc/upgrade/switch-templates-to
sbin/rt-attributes-viewer
diff --git a/docs/UPGRADING-4.4 b/docs/UPGRADING-4.4
index 85f2aa2..a1e60c2 100644
--- a/docs/UPGRADING-4.4
+++ b/docs/UPGRADING-4.4
@@ -11,6 +11,12 @@ before you upgrade and look for changes to features you currently use.
=item *
+Please run C<etc/upgrade/upgrade-queue-defaults> on old RT before upgrading.
+In 4.4, we dropped some columns in Queues table, the script is to migrate the
+column values into other places.
+
+=item *
+
The support for C<jsmin> (via the C<$JSMinPath> configuration) has been
removed in favor of a built-in solution.
diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index 2876d90..bddfc2d 100755
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -2905,7 +2905,7 @@ Set(%AdminSearchResultFormat,
Queues =>
q{'<a href="__WebPath__/Admin/Queues/Modify.html?id=__id__">__id__</a>/TITLE:#'}
.q{,'<a href="__WebPath__/Admin/Queues/Modify.html?id=__id__">__Name__</a>/TITLE:Name'}
- .q{,__Description__,__Address__,__Priority__,__DefaultDueIn__,__Disabled__,__Lifecycle__},
+ .q{,__Description__,__Address__,__Disabled__,__Lifecycle__},
Groups =>
q{'<a href="__WebPath__/Admin/Groups/Modify.html?id=__id__">__id__</a>/TITLE:#'}
diff --git a/etc/schema.Oracle b/etc/schema.Oracle
index 58665c7..847adfa 100755
--- a/etc/schema.Oracle
+++ b/etc/schema.Oracle
@@ -29,9 +29,6 @@ CREATE TABLE Queues (
CommentAddress VARCHAR2(120),
Lifecycle VARCHAR2(32),
SubjectTag VARCHAR2(120),
- InitialPriority NUMBER(11,0) DEFAULT 0 NOT NULL,
- FinalPriority NUMBER(11,0) DEFAULT 0 NOT NULL,
- DefaultDueIn NUMBER(11,0) DEFAULT 0 NOT NULL,
Creator NUMBER(11,0) DEFAULT 0 NOT NULL,
Created DATE,
LastUpdatedBy NUMBER(11,0) DEFAULT 0 NOT NULL,
diff --git a/etc/schema.Pg b/etc/schema.Pg
index 356441b..c1ef22f 100755
--- a/etc/schema.Pg
+++ b/etc/schema.Pg
@@ -52,9 +52,6 @@ CREATE TABLE Queues (
CommentAddress varchar(120) NULL ,
Lifecycle varchar(32) NULL,
SubjectTag varchar(120) NULL ,
- InitialPriority integer NOT NULL DEFAULT 0 ,
- FinalPriority integer NOT NULL DEFAULT 0 ,
- DefaultDueIn integer NOT NULL DEFAULT 0 ,
Creator integer NOT NULL DEFAULT 0 ,
Created TIMESTAMP NULL ,
LastUpdatedBy integer NOT NULL DEFAULT 0 ,
diff --git a/etc/schema.SQLite b/etc/schema.SQLite
index 7ba11f7..b748d85 100755
--- a/etc/schema.SQLite
+++ b/etc/schema.SQLite
@@ -30,9 +30,6 @@ CREATE TABLE Queues (
CommentAddress varchar(120) collate NOCASE NULL ,
Lifecycle varchar(32) collate NOCASE NULL ,
SubjectTag varchar(120) collate NOCASE NULL ,
- InitialPriority integer NULL DEFAULT 0 ,
- FinalPriority integer NULL DEFAULT 0 ,
- DefaultDueIn integer NULL DEFAULT 0 ,
Creator integer NULL DEFAULT 0 ,
Created DATETIME NULL ,
LastUpdatedBy integer NULL DEFAULT 0 ,
diff --git a/etc/schema.mysql b/etc/schema.mysql
index 1030eb2..b91696a 100755
--- a/etc/schema.mysql
+++ b/etc/schema.mysql
@@ -26,9 +26,6 @@ CREATE TABLE Queues (
CommentAddress varchar(120) NULL,
Lifecycle varchar(32) NULL,
SubjectTag varchar(120) NULL,
- InitialPriority integer NOT NULL DEFAULT 0 ,
- FinalPriority integer NOT NULL DEFAULT 0 ,
- DefaultDueIn integer NOT NULL DEFAULT 0 ,
Creator integer NOT NULL DEFAULT 0 ,
Created DATETIME NULL ,
LastUpdatedBy integer NOT NULL DEFAULT 0 ,
diff --git a/etc/upgrade/4.3.2/schema.Oracle b/etc/upgrade/4.3.2/schema.Oracle
new file mode 100644
index 0000000..5271e25
--- /dev/null
+++ b/etc/upgrade/4.3.2/schema.Oracle
@@ -0,0 +1,3 @@
+ALTER TABLE Queues DROP COLUMN InitialPriority;
+ALTER TABLE Queues DROP COLUMN FinalPriority;
+ALTER TABLE Queues DROP COLUMN DefaultDueIn;
diff --git a/etc/upgrade/4.3.2/schema.Pg b/etc/upgrade/4.3.2/schema.Pg
new file mode 100644
index 0000000..5271e25
--- /dev/null
+++ b/etc/upgrade/4.3.2/schema.Pg
@@ -0,0 +1,3 @@
+ALTER TABLE Queues DROP COLUMN InitialPriority;
+ALTER TABLE Queues DROP COLUMN FinalPriority;
+ALTER TABLE Queues DROP COLUMN DefaultDueIn;
diff --git a/etc/upgrade/4.3.2/schema.SQLite b/etc/upgrade/4.3.2/schema.SQLite
new file mode 100644
index 0000000..5271e25
--- /dev/null
+++ b/etc/upgrade/4.3.2/schema.SQLite
@@ -0,0 +1,3 @@
+ALTER TABLE Queues DROP COLUMN InitialPriority;
+ALTER TABLE Queues DROP COLUMN FinalPriority;
+ALTER TABLE Queues DROP COLUMN DefaultDueIn;
diff --git a/etc/upgrade/4.3.2/schema.mysql b/etc/upgrade/4.3.2/schema.mysql
new file mode 100644
index 0000000..5271e25
--- /dev/null
+++ b/etc/upgrade/4.3.2/schema.mysql
@@ -0,0 +1,3 @@
+ALTER TABLE Queues DROP COLUMN InitialPriority;
+ALTER TABLE Queues DROP COLUMN FinalPriority;
+ALTER TABLE Queues DROP COLUMN DefaultDueIn;
diff --git a/etc/upgrade/upgrade-queue-defaults.in b/etc/upgrade/upgrade-queue-defaults.in
new file mode 100755
index 0000000..3514857
--- /dev/null
+++ b/etc/upgrade/upgrade-queue-defaults.in
@@ -0,0 +1,74 @@
+#!@PERL@
+# BEGIN BPS TAGGED BLOCK {{{
+#
+# COPYRIGHT:
+#
+# This software is Copyright (c) 1996-2014 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 }}}
+use strict;
+use warnings;
+
+use lib "@LOCAL_LIB_PATH@";
+use lib "@RT_LIB_PATH@";
+
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+my $queues = RT::Queues->new(RT->SystemUser);
+$queues->UnLimit;
+while ( my $queue = $queues->Next ) {
+ next if $queue->FirstAttribute('DefaultValues');
+ my %default;
+ for my $priority ( qw/InitialPriority FinalPriority/ ) {
+ $default{$priority} = $queue->$priority if $queue->$priority;
+ }
+ $default{Due} = $queue->DefaultDueIn . ' days' if $queue->DefaultDueIn;
+ if ( %default ) {
+ print "upgrading default values for queue " . $queue->Name . "\n";
+ $queue->SetAttribute( Name => 'DefaultValues', Content => \%default );
+ }
+}
+
+print "done.\n";
diff --git a/lib/RT/Queue.pm b/lib/RT/Queue.pm
index 6ca78c4..cd7fca0 100644
--- a/lib/RT/Queue.pm
+++ b/lib/RT/Queue.pm
@@ -146,9 +146,6 @@ Arguments: ARGS is a hash of named parameters. Valid parameters are:
Description
CorrespondAddress
CommentAddress
- InitialPriority
- FinalPriority
- DefaultDueIn
If you pass the ACL check, it creates the queue and returns its queue id.
@@ -164,9 +161,6 @@ sub Create {
CommentAddress => '',
Lifecycle => 'default',
SubjectTag => undef,
- InitialPriority => 0,
- FinalPriority => 0,
- DefaultDueIn => 0,
Sign => undef,
SignAuto => undef,
Encrypt => undef,
@@ -943,60 +937,6 @@ Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
=cut
-=head2 InitialPriority
-
-Returns the current value of InitialPriority.
-(In the database, InitialPriority is stored as int(11).)
-
-
-
-=head2 SetInitialPriority VALUE
-
-
-Set InitialPriority to VALUE.
-Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
-(In the database, InitialPriority will be stored as a int(11).)
-
-
-=cut
-
-
-=head2 FinalPriority
-
-Returns the current value of FinalPriority.
-(In the database, FinalPriority is stored as int(11).)
-
-
-
-=head2 SetFinalPriority VALUE
-
-
-Set FinalPriority to VALUE.
-Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
-(In the database, FinalPriority will be stored as a int(11).)
-
-
-=cut
-
-
-=head2 DefaultDueIn
-
-Returns the current value of DefaultDueIn.
-(In the database, DefaultDueIn is stored as int(11).)
-
-
-
-=head2 SetDefaultDueIn VALUE
-
-
-Set DefaultDueIn to VALUE.
-Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
-(In the database, DefaultDueIn will be stored as a int(11).)
-
-
-=cut
-
-
=head2 Creator
Returns the current value of Creator.
@@ -1069,12 +1009,6 @@ sub _CoreAccessible {
{read => 1, write => 1, sql_type => 12, length => 120, is_blob => 0, is_numeric => 0, type => 'varchar(120)', default => ''},
Lifecycle =>
{read => 1, write => 1, sql_type => 12, length => 32, is_blob => 0, is_numeric => 0, type => 'varchar(32)', default => 'default'},
- InitialPriority =>
- {read => 1, write => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => '0'},
- FinalPriority =>
- {read => 1, write => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => '0'},
- DefaultDueIn =>
- {read => 1, write => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => '0'},
Creator =>
{read => 1, auto => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => '0'},
Created =>
@@ -1155,6 +1089,56 @@ sub PreInflate {
return 1;
}
+sub DefaultValue {
+ my $self = shift;
+ my $field = shift;
+ return undef unless $field =~ /^(?:(?:Initial|Final)Priority|Due|Starts)$/;
+ my $attr = $self->FirstAttribute('DefaultValues');
+ return undef unless $attr && $attr->Content;
+ return $attr->Content->{$field};
+}
+
+sub SetDefaultValue {
+ my $self = shift;
+ my %args = (
+ Name => undef,
+ Value => undef,
+ @_
+ );
+ my $field = shift;
+ my $attr = $self->FirstAttribute('DefaultValues');
+
+ my ($old_value, $old_content, $new_value);
+ if ( $attr && $attr->Content ) {
+ $old_content = $attr->Content;
+ $old_value = $old_content->{$args{Name}};
+ }
+
+ unless ( defined $old_value && length $old_value ) {
+ $old_value = $self->loc('(no value)');
+ }
+
+ $new_value = $args{Value};
+ unless ( defined $new_value && length $new_value ) {
+ $new_value = $self->loc( '(no value)' );
+ }
+
+ return 1 if $new_value eq $old_value;
+
+ my $ret = $self->SetAttribute(
+ Name => 'DefaultValues',
+ Content => {
+ %{ $old_content || {} }, $args{Name} => $args{Value},
+ },
+ );
+
+ if ( $ret ) {
+ return ( $ret, $self->loc( 'Default value of [_1] changed from [_2] to [_3]', $args{Name}, $old_value, $new_value ) );
+ }
+ else {
+ return ( $ret, $self->loc( "Can't change default value of [_1] from [_2] to [_3]", $args{Name}, $old_value, $new_value ) );
+ }
+}
RT::Base->_ImportOverlays();
diff --git a/lib/RT/Ticket.pm b/lib/RT/Ticket.pm
index bc14fdb..a766d00 100644
--- a/lib/RT/Ticket.pm
+++ b/lib/RT/Ticket.pm
@@ -300,12 +300,12 @@ sub Create {
#Initial Priority
# If there's no queue default initial priority and it's not set, set it to 0
- $args{'InitialPriority'} = $QueueObj->InitialPriority || 0
+ $args{'InitialPriority'} = $QueueObj->DefaultValue('InitialPriority') || 0
unless defined $args{'InitialPriority'};
#Final priority
# If there's no queue default final priority and it's not set, set it to 0
- $args{'FinalPriority'} = $QueueObj->FinalPriority || 0
+ $args{'FinalPriority'} = $QueueObj->DefaultValue('FinalPriority') || 0
unless defined $args{'FinalPriority'};
# Priority may have changed from InitialPriority, for the case
@@ -322,15 +322,17 @@ sub Create {
if ( defined $args{'Due'} ) {
$Due->Set( Format => 'ISO', Value => $args{'Due'} );
}
- elsif ( my $due_in = $QueueObj->DefaultDueIn ) {
- $Due->SetToNow;
- $Due->AddDays( $due_in );
+ elsif ( my $default = $QueueObj->DefaultValue('Due') ) {
+ $Due->Set( Format => 'unknown', Value => $default );
}
my $Starts = RT::Date->new( $self->CurrentUser );
if ( defined $args{'Starts'} ) {
$Starts->Set( Format => 'ISO', Value => $args{'Starts'} );
}
+ elsif ( my $default = $QueueObj->DefaultValue('Starts') ) {
+ $Starts->Set( Format => 'unknown', Value => $default );
+ }
my $Started = RT::Date->new( $self->CurrentUser );
if ( defined $args{'Started'} ) {
diff --git a/share/html/Admin/Queues/DefaultValues.html b/share/html/Admin/Queues/DefaultValues.html
index c6f2a1d..28b389a 100644
--- a/share/html/Admin/Queues/DefaultValues.html
+++ b/share/html/Admin/Queues/DefaultValues.html
@@ -51,6 +51,23 @@
<form method="post" action="DefaultValues.html" name="ModifyDefaultValues" id="ModifyDefaultValues">
<input type="hidden" name="id" value="<% $queue->id %>" />
+
+<h2><&|/l&>Core Fields</&></h2>
+<table border="0">
+<tr><td class="label"><&|/l&>Priority</&>:</td>
+<td><& /Elements/SelectPriority,
+ Name => "InitialPriority",
+ Default => $queue->DefaultValue('InitialPriority'),
+&></td></tr>
+<tr><td class="label"><&|/l&>Final Priority</&>:</td>
+<td><& /Elements/SelectPriority,
+ Name => "FinalPriority",
+ Default => $queue->DefaultValue('FinalPriority'),
+&><br /><span><em><&|/l&>requires running rt-crontool</&></em></span></td></tr>
+<tr><td class="label"><&|/l&>Starts</&>:</td><td><& /Elements/SelectDate, Name => "Starts", Default => $queue->DefaultValue('Starts') || '' &></td></tr>
+<tr><td class="label"><&|/l&>Due</&>:</td><td><& /Elements/SelectDate, Name => "Due", Default => $queue->DefaultValue('Due') || '' &></td></tr>
+</table>
+
<h2><&|/l&>Ticket Custom Fields</&></h2>
<& /Elements/EditCustomFields, CustomFields => $ticket_cfs, NamePrefix => 'Default-', Object => RT::Ticket->new($session{CurrentUser}), QueueObj => $queue &>
@@ -66,6 +83,14 @@ my $ticket_cfs = $queue->TicketCustomFields;
my @results;
if ( $ARGS{Update} ) {
+ for my $field ( qw/InitialPriority FinalPriority Starts Due/ ) {
+ my ($ret, $msg) = $queue->SetDefaultValue(
+ Name => $field,
+ Value => $ARGS{$field},
+ );
+ push @results, $msg;
+ }
+
for my $cf_id ( map { /^Default-(\d+)-/ ? $1 : () } keys %ARGS ) {
my $cf = RT::CustomField->new($session{CurrentUser});
$cf->Load($cf_id);
diff --git a/share/html/Admin/Queues/Modify.html b/share/html/Admin/Queues/Modify.html
index f497e6c..f89a376 100644
--- a/share/html/Admin/Queues/Modify.html
+++ b/share/html/Admin/Queues/Modify.html
@@ -92,22 +92,6 @@
<br /><span><em><&|/l , RT->Config->Get('CommentAddress')&>(If left blank, will default to [_1])</&></em></span></td>
</tr>
-<tr><td align="right"><&|/l&>Priority starts at</&>:</td>
-<td><& /Elements/SelectPriority,
- Name => "InitialPriority",
- Default => $Create? 0: $QueueObj->InitialPriority || $InitialPriority,
-&></td>
-<td align="right"><&|/l&>Over time, priority moves toward</&>:</td>
-<td><& /Elements/SelectPriority,
- Name => "FinalPriority",
- Default => $Create? 0: $QueueObj->FinalPriority || $FinalPriority,
-&><br /><span><em><&|/l&>requires running rt-crontool</&></em></span></td>
-</tr>
-
-<tr><td align="right"><&|/l&>Requests should be due in</&>:</td>
-<td colspan="3"><input name="DefaultDueIn" value="<% ($Create) ? "" : $QueueObj->DefaultDueIn || $DefaultDueIn || "" %>" /> <&|/l&>days</&>.</td>
-</tr>
-
% my $CFs = $QueueObj->CustomFields;
% while (my $CF = $CFs->Next) {
<tr valign="top"><td align="right">
@@ -192,7 +176,7 @@ unless ($Create) {
if ( $QueueObj->Id ) {
$title = loc('Configuration for queue [_1]', $QueueObj->Name );
my @attribs= qw(Description CorrespondAddress CommentAddress Name
- InitialPriority FinalPriority DefaultDueIn Sign SignAuto Encrypt Lifecycle SubjectTag Disabled);
+ Sign SignAuto Encrypt Lifecycle SubjectTag Disabled);
# we're asking about enabled on the web page but really care about disabled
if ( $SetEnabled ) {
@@ -260,9 +244,6 @@ $Create => undef
$Description => undef
$CorrespondAddress => undef
$CommentAddress => undef
-$InitialPriority => undef
-$FinalPriority => undef
-$DefaultDueIn => undef
$SetEnabled => undef
$SetCrypt => undef
$Enabled => undef
diff --git a/share/html/Admin/Queues/index.html b/share/html/Admin/Queues/index.html
index 2957465..e0f5c64 100644
--- a/share/html/Admin/Queues/index.html
+++ b/share/html/Admin/Queues/index.html
@@ -76,7 +76,7 @@
% }
<select name="QueueField">
-% foreach my $col (qw(Name Description CorrespondAddress CommentAddress InitialPriority FinalPriority DefaultDueIn)) {
+% foreach my $col (qw(Name Description CorrespondAddress CommentAddress FinalPriority )) {
<option <% $QueueField eq $col ? 'selected="selected"' : '' |n %> value="<% $col %>"><% loc($col) %></option>
% }
</select>
diff --git a/share/html/Elements/RT__Queue/ColumnMap b/share/html/Elements/RT__Queue/ColumnMap
index 7183871..266dce8 100644
--- a/share/html/Elements/RT__Queue/ColumnMap
+++ b/share/html/Elements/RT__Queue/ColumnMap
@@ -57,10 +57,6 @@ my $COLUMN_MAP = {
attribute => 'Disabled',
value => sub { return $_[0]->Disabled? $_[0]->loc('Disabled'): $_[0]->loc('Enabled') },
},
- Priority => {
- title => 'Priority', # loc
- value => sub { return $_[0]->InitialPriority .'-'. $_[0]->FinalPriority },
- },
Address => {
title => 'Address', # loc
value => sub { return ($_[0]->CorrespondAddress||'-') .'/'. ($_[0]->CommentAddress||'-') },
@@ -98,7 +94,6 @@ my $COLUMN_MAP = {
foreach my $field (qw(
Name Description CorrespondAddress CommentAddress
- InitialPriority FinalPriority DefaultDueIn
)) {
$COLUMN_MAP->{$field} = {
title => $field,
diff --git a/share/html/REST/1.0/Forms/queue/default b/share/html/REST/1.0/Forms/queue/default
index cef67cd..3c21411 100644
--- a/share/html/REST/1.0/Forms/queue/default
+++ b/share/html/REST/1.0/Forms/queue/default
@@ -60,7 +60,7 @@ my %data = %$changes;
my $queue = RT::Queue->new($session{CurrentUser});
my @fields =
- qw(Name Description CorrespondAddress CommentAddress InitialPriority FinalPriority DefaultDueIn Disabled);
+ qw(Name Description CorrespondAddress CommentAddress Disabled);
if ( $fields && %$fields ) {
@fields = grep { exists $fields->{ lc $_ } } @fields;
}
@@ -84,9 +84,6 @@ else {
Description => "",
CommentAddress => "",
CorrespondAddress => "",
- InitialPriority => "",
- FinalPriority => "",
- DefaultDueIn => "",
},
0
];
diff --git a/share/html/REST/1.0/Forms/ticket/default b/share/html/REST/1.0/Forms/ticket/default
index fd3e3c0..a3658f6 100644
--- a/share/html/REST/1.0/Forms/ticket/default
+++ b/share/html/REST/1.0/Forms/ticket/default
@@ -104,7 +104,9 @@ else {
my $starts = RT::Date->new($session{CurrentUser});
$queue->Load(1);
$due->SetToNow;
- $due->AddDays($queue->DefaultDueIn) if $queue->DefaultDueIn;
+ if ( $queue->DefaultValue('Due') ) {
+ $due->Set( Format => 'ISO', Value => $queue->DefaultValue('Due') );
+ }
$starts->SetToNow;
return [
@@ -120,9 +122,9 @@ else {
AdminCc => [],
Owner => "",
Status => "new",
- Priority => $queue->InitialPriority,
- InitialPriority => $queue->InitialPriority,
- FinalPriority => $queue->FinalPriority,
+ Priority => $queue->DefaultValue('InitialPriority'),
+ InitialPriority => $queue->DefaultValue('InitialPriority'),
+ FinalPriority => $queue->DefaultValue('FinalPriority'),
TimeEstimated => 0,
Starts => $starts->ISO,
Due => $due->ISO,
diff --git a/share/html/Ticket/Create.html b/share/html/Ticket/Create.html
index 66fbad6..0df5d85 100644
--- a/share/html/Ticket/Create.html
+++ b/share/html/Ticket/Create.html
@@ -228,12 +228,12 @@
<tr><td class="label"><&|/l&>Priority</&>:</td>
<td><& /Elements/SelectPriority,
Name => "InitialPriority",
- Default => $ARGS{InitialPriority} ? $ARGS{InitialPriority} : $QueueObj->InitialPriority,
+ Default => $ARGS{InitialPriority} ? $ARGS{InitialPriority} : $QueueObj->DefaultValue('InitialPriority'),
&></td></tr>
<tr><td class="label"><&|/l&>Final Priority</&>:</td>
<td><& /Elements/SelectPriority,
Name => "FinalPriority",
- Default => $ARGS{FinalPriority} ? $ARGS{FinalPriority} : $QueueObj->FinalPriority,
+ Default => $ARGS{FinalPriority} ? $ARGS{FinalPriority} : $QueueObj->DefaultValue('FinalPriority'),
&></td></tr>
<tr><td class="label"><&|/l&>Time Estimated</&>:</td>
<td>
@@ -258,8 +258,8 @@
color => "#663366" &>
<table>
-<tr><td class="label"><&|/l&>Starts</&>:</td><td><& /Elements/SelectDate, Name => "Starts", Default => $ARGS{Starts} || '' &></td></tr>
-<tr><td class="label"><&|/l&>Due</&>:</td><td><& /Elements/SelectDate, Name => "Due", Default => $ARGS{Due} || '' &></td></tr>
+<tr><td class="label"><&|/l&>Starts</&>:</td><td><& /Elements/SelectDate, Name => "Starts", Default => $ARGS{Starts} || $QueueObj->DefaultValue('Starts') || '' &></td></tr>
+<tr><td class="label"><&|/l&>Due</&>:</td><td><& /Elements/SelectDate, Name => "Due", Default => $ARGS{Due} || $QueueObj->DefaultValue('Due') || '' &></td></tr>
<& /Elements/EditCustomFields,
%ARGS,
Object => $ticket,
diff --git a/share/html/m/ticket/create b/share/html/m/ticket/create
index af25bd0..fa760c6 100644
--- a/share/html/m/ticket/create
+++ b/share/html/m/ticket/create
@@ -342,12 +342,12 @@ $showrows->(
loc("Priority") => $m->scomp(
"/Elements/SelectPriority",
Name => "InitialPriority",
- Default => $ARGS{InitialPriority} ? $ARGS{InitialPriority} : $QueueObj->InitialPriority,
+ Default => $ARGS{InitialPriority} ? $ARGS{InitialPriority} : $QueueObj->DefaultValue('InitialPriority'),
),
loc("Final Priority") => $m->scomp(
"/Elements/SelectPriority",
Name => "FinalPriority",
- Default => $ARGS{FinalPriority} ? $ARGS{FinalPriority} : $QueueObj->FinalPriority,
+ Default => $ARGS{FinalPriority} ? $ARGS{FinalPriority} : $QueueObj->DefaultValue('FinalPriority'),
),
loc("Time Estimated") => '<span class="timefield">'.$m->scomp(
commit 528396393700b0faf37135b8f0ce7a38effc762d
Author: sunnavy <sunnavy at bestpractical.com>
Date: Sun Jun 15 19:31:15 2014 +0800
make default values page be like ticket create or display pages
i.e. split fields into various widgets(including custom groupings)
diff --git a/share/html/Admin/Queues/DefaultValues.html b/share/html/Admin/Queues/DefaultValues.html
index 28b389a..2ee8555 100644
--- a/share/html/Admin/Queues/DefaultValues.html
+++ b/share/html/Admin/Queues/DefaultValues.html
@@ -52,24 +52,84 @@
<form method="post" action="DefaultValues.html" name="ModifyDefaultValues" id="ModifyDefaultValues">
<input type="hidden" name="id" value="<% $queue->id %>" />
-<h2><&|/l&>Core Fields</&></h2>
-<table border="0">
-<tr><td class="label"><&|/l&>Priority</&>:</td>
-<td><& /Elements/SelectPriority,
- Name => "InitialPriority",
- Default => $queue->DefaultValue('InitialPriority'),
-&></td></tr>
-<tr><td class="label"><&|/l&>Final Priority</&>:</td>
-<td><& /Elements/SelectPriority,
- Name => "FinalPriority",
- Default => $queue->DefaultValue('FinalPriority'),
-&><br /><span><em><&|/l&>requires running rt-crontool</&></em></span></td></tr>
-<tr><td class="label"><&|/l&>Starts</&>:</td><td><& /Elements/SelectDate, Name => "Starts", Default => $queue->DefaultValue('Starts') || '' &></td></tr>
-<tr><td class="label"><&|/l&>Due</&>:</td><td><& /Elements/SelectDate, Name => "Due", Default => $queue->DefaultValue('Due') || '' &></td></tr>
-</table>
+<div class="ticket-info-basics">
+ <&| /Widgets/TitleBox, title => loc('Basics') &>
+ <table border="0">
+ <tr><td class="label"><&|/l&>Priority</&>:</td>
+ <td><& /Elements/SelectPriority,
+ Name => "InitialPriority",
+ Default => $queue->DefaultValue('InitialPriority'),
+ &></td></tr>
+ <tr><td class="label"><&|/l&>Final Priority</&>:</td>
+ <td><& /Elements/SelectPriority,
+ Name => "FinalPriority",
+ Default => $queue->DefaultValue('FinalPriority'),
+ &><br /><span><em><&|/l&>requires running rt-crontool</&></em></span></td></tr>
+ <& /Elements/EditCustomFields,
+ NamePrefix => 'Default-',
+ Object => RT::Ticket->new($session{CurrentUser}),
+ CustomFields => $queue->TicketCustomFields,
+ Grouping => 'Basics',
+ InTable => 1,
+ QueueObj => $queue,
+ &>
+ </table>
+ </&>
+</div>
-<h2><&|/l&>Ticket Custom Fields</&></h2>
-<& /Elements/EditCustomFields, CustomFields => $ticket_cfs, NamePrefix => 'Default-', Object => RT::Ticket->new($session{CurrentUser}), QueueObj => $queue &>
+<div class="ticket-info-dates">
+ <&|/Widgets/TitleBox, title => loc("Dates") &>
+ <table>
+ <tr><td class="label"><&|/l&>Starts</&>:</td><td><& /Elements/SelectDate, Name => "Starts", Default => $queue->DefaultValue('Starts') || '' &></td></tr>
+ <tr><td class="label"><&|/l&>Due</&>:</td><td><& /Elements/SelectDate, Name => "Due", Default => $queue->DefaultValue('Due') || '' &></td></tr>
+ <& /Elements/EditCustomFields,
+ NamePrefix => 'Default-',
+ Object => RT::Ticket->new($session{CurrentUser}),
+ CustomFields => $queue->TicketCustomFields,
+ Grouping => 'Dates',
+ InTable => 1,
+ QueueObj => $queue,
+ &>
+ </table>
+ </&>
+</div>
+
+% my $groupings = RT->Config->Get('CustomFieldGroupings');
+% if ( $groupings && $groupings->{'RT::Ticket'} && grep { $_ eq 'People' } @{$groupings->{'RT::Ticket'}} ) {
+<div class="ticket-info-people">
+ <&|/Widgets/TitleBox, title => loc("People") &>
+ <table>
+ <& /Elements/EditCustomFields,
+ NamePrefix => 'Default-',
+ Object => RT::Ticket->new($session{CurrentUser}),
+ CustomFields => $queue->TicketCustomFields,
+ Grouping => 'People',
+ InTable => 1,
+ QueueObj => $queue,
+ &>
+ </table>
+ </&>
+</div>
+% }
+
+% if ( $groupings && $groupings->{'RT::Ticket'} && grep { $_ eq 'Links' } @{$groupings->{'RT::Ticket'}} ) {
+<div class="ticket-info-links">
+ <&|/Widgets/TitleBox, title => loc("Links") &>
+ <table>
+ <& /Elements/EditCustomFields,
+ NamePrefix => 'Default-',
+ Object => RT::Ticket->new($session{CurrentUser}),
+ CustomFields => $queue->TicketCustomFields,
+ Grouping => 'Links',
+ InTable => 1,
+ QueueObj => $queue,
+ &>
+ </table>
+ </&>
+</div>
+% }
+
+<& /Elements/EditCustomFieldCustomGroupings, CustomFieldGenerator => sub { $queue->TicketCustomFields }, NamePrefix => 'Default-', Object => RT::Ticket->new($session{CurrentUser}), QueueObj => $queue &>
<& /Elements/Submit, Name => 'Update', Label => loc('Save Changes') &>
</form>
commit f743962c6aec3b8aa135ed77833a42007cd4b9ac
Author: sunnavy <sunnavy at bestpractical.com>
Date: Sun Jun 15 20:58:17 2014 +0800
make datepicker less zealous
don't show datepicker if there are relative strings there
diff --git a/share/static/js/util.js b/share/static/js/util.js
index 003109b..13da46b 100644
--- a/share/static/js/util.js
+++ b/share/static/js/util.js
@@ -186,8 +186,15 @@ jQuery(function() {
changeMonth: true,
changeYear: true,
showOtherMonths: true,
+ showOn: 'none',
selectOtherMonths: true
};
+ jQuery(".datepicker").focus(function() {
+ var val = jQuery(this).val();
+ if ( !val.match(/[a-z]/i) ) {
+ jQuery(this).datepicker('show');
+ }
+ });
jQuery(".datepicker:not(.withtime)").datepicker(opts);
jQuery(".datepicker.withtime").datetimepicker( jQuery.extend({}, opts, {
stepHour: 1,
commit 7fe79d62293ceecd22f205a4daf37177be813c12
Author: sunnavy <sunnavy at bestpractical.com>
Date: Sun Jun 15 22:14:35 2014 +0800
remove outdated default values when a cfv is updated/deleted
diff --git a/lib/RT/CustomField.pm b/lib/RT/CustomField.pm
index 8e0be32..d3b9ee9 100644
--- a/lib/RT/CustomField.pm
+++ b/lib/RT/CustomField.pm
@@ -564,6 +564,7 @@ sub DeleteValue {
unless ( $retval ) {
return (0, $self->loc("Custom field value could not be deleted"));
}
+ $self->CleanupDefaultValues;
return ($retval, $self->loc("Custom field value deleted"));
}
@@ -1963,6 +1964,40 @@ sub SetDefaultValues {
}
}
+sub CleanupDefaultValues {
+ my $self = shift;
+ return unless $self->Type eq 'Select' && $self->SupportDefaultValues;
+
+ my @values = map { $_->Name } @{$self->Values->ItemsArrayRef || []};
+ my $attrs = RT::Attributes->new( $self->CurrentUser );
+ $attrs->Limit( FIELD => 'Name', VALUE => 'CustomFieldDefaultValues' );
+ while ( my $attr = $attrs->Next ) {
+ my $content = $attr->Content;
+ next unless $content;
+ my $default_values = $content->{ $self->id };
+ return unless $default_values;
+ my $changed;
+ if ( ref $default_values eq 'ARRAY' ) {
+ my @new_defaults;
+ for my $default ( @$default_values ) {
+ if ( grep { $_ eq $default } @values ) {
+ push @new_defaults, $default;
+ }
+ else {
+ $changed ||= 1;
+ }
+ }
+
+ $content->{$self->id} = \@new_defaults if $changed;
+ }
+ elsif ( ! grep { $_ eq $default_values } @values ) {
+ delete $content->{ $self->id };
+ $changed = 1;
+ }
+ $attr->SetContent( $content ) if $changed;
+ }
+}
+
=head2 id
Returns the current value of id.
diff --git a/lib/RT/CustomFieldValue.pm b/lib/RT/CustomFieldValue.pm
index 1ba73ef..25287ad 100644
--- a/lib/RT/CustomFieldValue.pm
+++ b/lib/RT/CustomFieldValue.pm
@@ -119,6 +119,17 @@ sub _Set {
return $self->SUPER::_Set( @_ );
}
+sub SetName {
+ my $self = shift;
+ my $value = shift;
+ my ( $ret, $msg ) = $self->_Set(
+ Field => 'Name',
+ Value => $value,
+ );
+
+ $self->CustomFieldObj->CleanupDefaultValues if $self->CustomFieldObj && $self->CustomFieldObj->SupportDefaultValues;
+ return ( $ret, $msg );
+}
=head2 id
-----------------------------------------------------------------------
More information about the rt-commit
mailing list