[Rt-commit] rt branch, 4.2/pluggable-cf-types, updated. rt-4.0.1rc1-46-geceab20
Chia-liang Kao
clkao at bestpractical.com
Wed Jun 15 07:26:42 EDT 2011
The branch, 4.2/pluggable-cf-types has been updated
via eceab20680202278d06d34447c77c18790868c0b (commit)
via 0f061d397600bf8a88d9ae6866bb794d90156384 (commit)
via 0e9364b936b158d0c48472d8fe1138cf3a53ce98 (commit)
from a0b0b5c1e9f85efc7987f67eb1865401f14f5331 (commit)
Summary of changes:
lib/RT/CustomField/Type.pm | 20 ++++++++++++++++
lib/RT/CustomField/Type/Date.pm | 16 +++++++++++++
lib/RT/CustomField/Type/DateTime.pm | 16 +++++++++++++
lib/RT/CustomField/Type/IPAddress.pm | 10 ++++++++
share/html/Search/Elements/PickCFs | 42 +---------------------------------
5 files changed, 63 insertions(+), 41 deletions(-)
- Log -----------------------------------------------------------------
commit 0e9364b936b158d0c48472d8fe1138cf3a53ce98
Author: Chia-liang Kao <clkao at bestpractical.com>
Date: Wed Jun 15 19:15:27 2011 +0800
move search builder ui cf hook into CF::Type
diff --git a/lib/RT/CustomField/Type.pm b/lib/RT/CustomField/Type.pm
index 0b8f1f9..3b2d6fd 100644
--- a/lib/RT/CustomField/Type.pm
+++ b/lib/RT/CustomField/Type.pm
@@ -70,4 +70,52 @@ sub Limit {
return;
}
+sub SearchBuilderUIArguments {
+ my ($self, $cf) = @_;
+ my %line;
+
+ if ($cf->Type =~ /^Date(Time)?$/ ) {
+ $line{'Op'} = {
+ Type => 'component',
+ Path => '/Elements/SelectDateRelation',
+ Arguments => {},
+ };
+ }
+ elsif ($cf->Type =~ /^IPAddress(Range)?$/ ) {
+ $line{'Op'} = {
+ Type => 'component',
+ Path => '/Elements/SelectIPRelation',
+ Arguments => {},
+ };
+ } else {
+ $line{'Op'} = {
+ Type => 'component',
+ Path => '/Elements/SelectCustomFieldOperator',
+ Arguments => { True => $cf->loc("is"),
+ False => $cf->loc("isn't"),
+ TrueVal=> '=',
+ FalseVal => '!=',
+ },
+ };
+ }
+
+ # Value
+ if ($cf->Type =~ /^Date(Time)?$/) {
+ my $is_datetime = $1 ? 1 : 0;
+ $line{'Value'} = {
+ Type => 'component',
+ Path => '/Elements/SelectDate',
+ Arguments => { $is_datetime ? (ShowTime => 1) : (ShowTime => 0), },
+ };
+ } else {
+ $line{'Value'} = {
+ Type => 'component',
+ Path => '/Elements/SelectCustomFieldValue',
+ Arguments => { CustomField => $cf },
+ };
+ }
+
+ return %line;
+}
+
1;
diff --git a/share/html/Search/Elements/PickCFs b/share/html/Search/Elements/PickCFs
index f3ae629..3bf6bed 100644
--- a/share/html/Search/Elements/PickCFs
+++ b/share/html/Search/Elements/PickCFs
@@ -80,47 +80,7 @@ while ( my $CustomField = $CustomFields->Next ) {
$line{'Field'} = $CustomField->Name;
# Op
- if ($CustomField->Type =~ /^Date(Time)?$/ ) {
- $line{'Op'} = {
- Type => 'component',
- Path => '/Elements/SelectDateRelation',
- Arguments => {},
- };
- }
- elsif ($CustomField->Type =~ /^IPAddress(Range)?$/ ) {
- $line{'Op'} = {
- Type => 'component',
- Path => '/Elements/SelectIPRelation',
- Arguments => {},
- };
- } else {
- $line{'Op'} = {
- Type => 'component',
- Path => '/Elements/SelectCustomFieldOperator',
- Arguments => { True => loc("is"),
- False => loc("isn't"),
- TrueVal=> '=',
- FalseVal => '!=',
- },
- };
- }
-
- # Value
- if ($CustomField->Type =~ /^Date(Time)?$/) {
- my $is_datetime = $1 ? 1 : 0;
- $line{'Value'} = {
- Type => 'component',
- Path => '/Elements/SelectDate',
- Arguments => { $is_datetime ? (ShowTime => 1) : (ShowTime => 0), },
- };
- } else {
- $line{'Value'} = {
- Type => 'component',
- Path => '/Elements/SelectCustomFieldValue',
- Arguments => { CustomField => $CustomField },
- };
- }
-
+ %line = ( %line, $CustomField->GetTypeClass->SearchBuilderUIArguments($CustomField) );
push @lines, \%line;
}
commit 0f061d397600bf8a88d9ae6866bb794d90156384
Author: Chia-liang Kao <clkao at bestpractical.com>
Date: Wed Jun 15 19:18:51 2011 +0800
move datetime ui spec into their classes.
diff --git a/lib/RT/CustomField/Type.pm b/lib/RT/CustomField/Type.pm
index 3b2d6fd..b0a5361 100644
--- a/lib/RT/CustomField/Type.pm
+++ b/lib/RT/CustomField/Type.pm
@@ -74,14 +74,7 @@ sub SearchBuilderUIArguments {
my ($self, $cf) = @_;
my %line;
- if ($cf->Type =~ /^Date(Time)?$/ ) {
- $line{'Op'} = {
- Type => 'component',
- Path => '/Elements/SelectDateRelation',
- Arguments => {},
- };
- }
- elsif ($cf->Type =~ /^IPAddress(Range)?$/ ) {
+ if ($cf->Type =~ /^IPAddress(Range)?$/ ) {
$line{'Op'} = {
Type => 'component',
Path => '/Elements/SelectIPRelation',
@@ -99,21 +92,11 @@ sub SearchBuilderUIArguments {
};
}
- # Value
- if ($cf->Type =~ /^Date(Time)?$/) {
- my $is_datetime = $1 ? 1 : 0;
- $line{'Value'} = {
- Type => 'component',
- Path => '/Elements/SelectDate',
- Arguments => { $is_datetime ? (ShowTime => 1) : (ShowTime => 0), },
- };
- } else {
- $line{'Value'} = {
- Type => 'component',
- Path => '/Elements/SelectCustomFieldValue',
- Arguments => { CustomField => $cf },
- };
- }
+ $line{'Value'} = {
+ Type => 'component',
+ Path => '/Elements/SelectCustomFieldValue',
+ Arguments => { CustomField => $cf },
+ };
return %line;
}
diff --git a/lib/RT/CustomField/Type/Date.pm b/lib/RT/CustomField/Type/Date.pm
index e0fce2a..13b0c7d 100644
--- a/lib/RT/CustomField/Type/Date.pm
+++ b/lib/RT/CustomField/Type/Date.pm
@@ -19,4 +19,20 @@ sub CanonicalizeForCreate {
return wantarray ? (1) : 1;
}
+sub SearchBuilderUIArguments {
+ my ($self, $cf) = @_;
+
+ return (
+ Op => {
+ Type => 'component',
+ Path => '/Elements/SelectDateRelation',
+ Arguments => {},
+ },
+ Value => {
+ Type => 'component',
+ Path => '/Elements/SelectDate',
+ Arguments => { ShowTime => 0 },
+ });
+}
+
1;
diff --git a/lib/RT/CustomField/Type/DateTime.pm b/lib/RT/CustomField/Type/DateTime.pm
index a8248fa..c415a69 100644
--- a/lib/RT/CustomField/Type/DateTime.pm
+++ b/lib/RT/CustomField/Type/DateTime.pm
@@ -59,4 +59,20 @@ sub Limit {
}
+sub SearchBuilderUIArguments {
+ my ($self, $cf) = @_;
+
+ return (
+ Op => {
+ Type => 'component',
+ Path => '/Elements/SelectDateRelation',
+ Arguments => {},
+ },
+ Value => {
+ Type => 'component',
+ Path => '/Elements/SelectDate',
+ Arguments => { ShowTime => 1 },
+ });
+}
+
1;
commit eceab20680202278d06d34447c77c18790868c0b
Author: Chia-liang Kao <clkao at bestpractical.com>
Date: Wed Jun 15 19:21:17 2011 +0800
move ipaddress ui spec into their classes.
diff --git a/lib/RT/CustomField/Type.pm b/lib/RT/CustomField/Type.pm
index b0a5361..45595f8 100644
--- a/lib/RT/CustomField/Type.pm
+++ b/lib/RT/CustomField/Type.pm
@@ -72,33 +72,22 @@ sub Limit {
sub SearchBuilderUIArguments {
my ($self, $cf) = @_;
- my %line;
- if ($cf->Type =~ /^IPAddress(Range)?$/ ) {
- $line{'Op'} = {
- Type => 'component',
- Path => '/Elements/SelectIPRelation',
- Arguments => {},
- };
- } else {
- $line{'Op'} = {
+ return (
+ Op => {
Type => 'component',
Path => '/Elements/SelectCustomFieldOperator',
Arguments => { True => $cf->loc("is"),
False => $cf->loc("isn't"),
TrueVal=> '=',
FalseVal => '!=',
- },
- };
- }
-
- $line{'Value'} = {
- Type => 'component',
- Path => '/Elements/SelectCustomFieldValue',
- Arguments => { CustomField => $cf },
- };
-
- return %line;
+ },
+ },
+ Value => {
+ Type => 'component',
+ Path => '/Elements/SelectCustomFieldValue',
+ Arguments => { CustomField => $cf },
+ });
}
1;
diff --git a/lib/RT/CustomField/Type/IPAddress.pm b/lib/RT/CustomField/Type/IPAddress.pm
index b7c2cc5..640f0db 100644
--- a/lib/RT/CustomField/Type/IPAddress.pm
+++ b/lib/RT/CustomField/Type/IPAddress.pm
@@ -101,4 +101,14 @@ sub ParseIP {
return;
}
+sub SearchBuilderUIArguments {
+ my ($self, $cf) = @_;
+ return (
+ Op => {
+ Type => 'component',
+ Path => '/Elements/SelectIPRelation',
+ Arguments => {},
+ });
+}
+
1;
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list