[Rt-commit] r2201 - in experiments/Bamboo: . lib/Bamboo/View lib/Bamboo/View/ObjectType lib/Bamboo/View/Renderer lib/Bamboo/View/Validator lib/Bamboo/View/mason lib/Bamboo/View/mason/ObjectType lib/Bamboo/View/mason/Renderer lib/Bamboo/View/mason/Renderer/Display lib/Bamboo/View/mason/Renderer/Display/RT lib/Bamboo/View/mason/Renderer/Edit lib/Bamboo/View/mason/Renderer/Edit/RT lib/Bamboo/View/mason/Renderer/Label lib/Bamboo/View/mason/Validator

jesse at bestpractical.com jesse at bestpractical.com
Thu Feb 10 00:37:24 EST 2005


Author: jesse
Date: Thu Feb 10 00:37:23 2005
New Revision: 2201

Added:
   experiments/Bamboo/lib/Bamboo/View/mason/ObjectSelect
   experiments/Bamboo/lib/Bamboo/View/mason/ObjectType/
   experiments/Bamboo/lib/Bamboo/View/mason/ObjectType/RT__Attachment
   experiments/Bamboo/lib/Bamboo/View/mason/ObjectType/RT__GroupMember
   experiments/Bamboo/lib/Bamboo/View/mason/ObjectType/RT__Queue
   experiments/Bamboo/lib/Bamboo/View/mason/ObjectType/RT__Ticket
   experiments/Bamboo/lib/Bamboo/View/mason/ObjectType/RT__Transaction
   experiments/Bamboo/lib/Bamboo/View/mason/ObjectType/RT__User
   experiments/Bamboo/lib/Bamboo/View/mason/Renderer/
   experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Display/
   experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Display/Date
   experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Display/EmailMessage
   experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Display/HREF
   experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Display/Minutes
   experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Display/RT/
   experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Display/RT/GroupMembers
   experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Display/RT/Queue
   experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Display/RT/User
   experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Display/datetime
   experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Display/integer
   experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Display/scalar
   experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Display/varchar
   experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Edit/
   experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Edit/Date
   experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Edit/Minutes
   experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Edit/RT/
   experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Edit/RT/Queue
   experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Edit/_attribute_name
   experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Edit/checkbox
   experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Edit/int
   experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Edit/integer
   experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Edit/scalar
   experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Edit/varchar
   experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Label/
   experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Label/Label
   experiments/Bamboo/lib/Bamboo/View/mason/Update
   experiments/Bamboo/lib/Bamboo/View/mason/Validator/
   experiments/Bamboo/lib/Bamboo/View/mason/Validator/Boolean
   experiments/Bamboo/lib/Bamboo/View/mason/Validator/Date
   experiments/Bamboo/lib/Bamboo/View/mason/WebMethodCall
Removed:
   experiments/Bamboo/lib/Bamboo/View/ObjectSelect
   experiments/Bamboo/lib/Bamboo/View/ObjectType/
   experiments/Bamboo/lib/Bamboo/View/Renderer/
   experiments/Bamboo/lib/Bamboo/View/Update
   experiments/Bamboo/lib/Bamboo/View/Validator/
   experiments/Bamboo/lib/Bamboo/View/WebMethodCall
Modified:
   experiments/Bamboo/   (props changed)
Log:
 r4648 at hualien:  jesse | 2005-02-09T16:44:04.437035Z
 moving around the mason items
 


Added: experiments/Bamboo/lib/Bamboo/View/mason/ObjectSelect
==============================================================================
--- (empty file)
+++ experiments/Bamboo/lib/Bamboo/View/mason/ObjectSelect	Thu Feb 10 00:37:23 2005
@@ -0,0 +1,36 @@
+<select  <& ObjectInputName, Name => $Name, Object => $Object, Attribute => $Attribute&>>
+% foreach my $option (@Values) {
+% if (UNIVERSAL::isa($option, 'DBIx::SearchBuilder::Record')) {
+<option value="<%$option->Id%>" <%$option eq $Default && 'SELECTED'%>>
+%       if (UNIVERSAL::can($option, 'Name' )){
+<%$option->Name%>
+% } else {
+<%$option->id%>
+% }
+</option>
+% } else {
+<option value="<%$option%>" <%$option eq $Default && 'SELECTED'%>><%$option%></option>
+% }
+%}
+</select>
+<%init>
+
+
+unless ($Attribute) {
+        Abort("Bad call to ObjectInput - no attribute");
+}
+
+unless ($Default) {
+        $Default = $Object->$Attribute();
+}
+
+
+</%init>
+
+<%args>
+$Name => undef
+$Object => undef
+$Attribute => undef
+$Default=> undef
+ at Values => undef
+</%args>

Added: experiments/Bamboo/lib/Bamboo/View/mason/ObjectType/RT__Attachment
==============================================================================
--- (empty file)
+++ experiments/Bamboo/lib/Bamboo/View/mason/ObjectType/RT__Attachment	Thu Feb 10 00:37:23 2005
@@ -0,0 +1,15 @@
+<%args>
+$Object => undef
+</%args>
+<%init>
+
+
+return({ 
+        id => { Render => 'integer' },
+        BriefDescription => {Render => 'scalar'},
+        Created => {  Render => 'Date' },
+        Creator => {    RenderAs => 'Attribute', Object => $Object->CreatorObj, Attribute => 'Name'  },
+        Content =>  {Render => 'Scalar' }
+
+});
+</%init>

Added: experiments/Bamboo/lib/Bamboo/View/mason/ObjectType/RT__GroupMember
==============================================================================
--- (empty file)
+++ experiments/Bamboo/lib/Bamboo/View/mason/ObjectType/RT__GroupMember	Thu Feb 10 00:37:23 2005
@@ -0,0 +1,10 @@
+<%args>
+$Object => undef
+</%args>
+<%init>
+return ( { 
+        id => { Render => 'integer' },
+        Name => { RenderAs => 'Attribute', Object => $Object->MemberObj->Object, Attribute => 'Name' },
+
+});
+</%init>

Added: experiments/Bamboo/lib/Bamboo/View/mason/ObjectType/RT__Queue
==============================================================================
--- (empty file)
+++ experiments/Bamboo/lib/Bamboo/View/mason/ObjectType/RT__Queue	Thu Feb 10 00:37:23 2005
@@ -0,0 +1,11 @@
+<%args>
+$Object => undef
+</%args>
+<%init>
+return ( { 
+        id => { Render => 'integer' },
+        Name => { Render => 'scalar', Edit => undef, },
+        Disabled => { Render => 'checkbox', Validator => 'Boolean' },
+
+});
+</%init>

Added: experiments/Bamboo/lib/Bamboo/View/mason/ObjectType/RT__Ticket
==============================================================================
--- (empty file)
+++ experiments/Bamboo/lib/Bamboo/View/mason/ObjectType/RT__Ticket	Thu Feb 10 00:37:23 2005
@@ -0,0 +1,54 @@
+<%args>
+$Object => undef
+</%args>
+<%init>
+
+
+my $params = { 
+        id => { Render => 'integer', Immutable => 1 },
+        EffectiveId => { Render => 'integer', Immutable => 1 },
+        Priority => { Render => 'integer' },
+        FinalPriority => { Render => 'integer' },
+        InitialPriority => { Render => 'integer' },
+        Queue => { Render=> 'RT/Queue'},
+        Status => { Render => 'scalar' },
+        Subject => { Render => 'scalar', Edit => undef, },
+        Type => { Render => 'scalar', Edit => undef, },
+
+        TimeWorked => { Render => 'Minutes'},
+        TimeLeft => { Render => 'Minutes'},
+        TimeEstimated => { Render => 'Minutes'},
+        
+        LastUpdated => {  Render => 'Date', Immutable => 1 },
+        Created => {  Render => 'Date' ,  Immutable => 1},
+        Starts => {  Render => 'Date', Validator => 'Date'},
+        Started => {  Render => 'Date', Validator => 'Date'},
+        Told => {  Render => 'Date', Validator => 'Date'},
+        Resolved => {  Render => 'Date', Validator => 'Date'},
+        Due => {  Render => 'Date', Validator => 'Date'},
+        Owner => {  RenderAs => 'Attribute', Object => $Object->OwnerObj, Attribute => 'Name' },
+        Creator => {    RenderAs => 'Attribute', Object => $Object->CreatorObj, Attribute => 'Name' , Immutable => 1 },
+        LastUpdatedBy =>    {  RenderAs => 'Attribute', Object => $Object->LastUpdatedByObj, Attribute => 'Name' , Immutable => 1 },
+        Requestors => {  RenderAs => 'CollectionAsList' , Object => $Object->Requestors->MembersObj, Attribute => { Name => 'Name' }},
+        Ccs => {  Render => 'RT/GroupMembers', Value => sub { $Object->Cc } },
+        Cc => {  Render => 'RT/GroupMembers', Value => sub { $Object->Cc } },
+        AdminCcs => {  Render => 'RT/GroupMembers', Value => sub { $Object->AdminCc } },
+        AdminCc => {  Render => 'RT/GroupMembers', Value => sub { $Object->AdminCc } },
+        RefersTo =>  {RenderAs => 'CollectionAsList' , Object => $Object->RefersTo, Attribute => 'Target'},
+        DependsOn =>  {RenderAs => 'CollectionAsList' , Object => $Object->DependsOn, Attribute => 'Target'},
+        ReferredToBy =>  {RenderAs => 'CollectionAsList' , Object => $Object->ReferredToBy, Attribute => 'Target'},
+        MemberOf =>  {RenderAs => 'CollectionAsList' , Object => $Object->MemberOf, Attribute => 'Target'},
+        DependedOnBy =>  {RenderAs => 'CollectionAsList' , Object => $Object->DependedOnBy, Attribute => 'Target'},
+        Members =>  {RenderAs => 'CollectionAsList' , Object => $Object->Members, Attribute => 'Target'}
+
+};
+
+
+        my $cfs = $Object->QueueObj->CustomFields();
+        while (my $cf = $cfs->Next) {
+                $params->{$cf->Name} = { Label => $cf->Name, RenderAs => 'CollectionAsList', Object => $Object->CustomFieldValues($cf->id), Attribute => 'Content'};
+                $params->{'CustomField-'.$cf->id} = { Label => $cf->Name, RenderAs => 'CollectionAsList', Object => $Object->CustomFieldValues($cf->id), Attribute => 'Content'};
+        }
+
+        return ($params );
+</%init>

Added: experiments/Bamboo/lib/Bamboo/View/mason/ObjectType/RT__Transaction
==============================================================================
--- (empty file)
+++ experiments/Bamboo/lib/Bamboo/View/mason/ObjectType/RT__Transaction	Thu Feb 10 00:37:23 2005
@@ -0,0 +1,15 @@
+<%args>
+$Object => undef
+</%args>
+<%init>
+
+
+return({ 
+        id => { Render => 'integer' },
+        BriefDescription => {Render => 'scalar'},
+        Created => {  Render => 'Date' },
+        Creator => {    RenderAs => 'Attribute', Object => $Object->CreatorObj, Attribute => 'Name'  },
+        Content =>  {RenderAs => 'CollectionAsList' , Object => $Object->Attachments, Attribute => 'Content'}
+
+});
+</%init>

Added: experiments/Bamboo/lib/Bamboo/View/mason/ObjectType/RT__User
==============================================================================
--- (empty file)
+++ experiments/Bamboo/lib/Bamboo/View/mason/ObjectType/RT__User	Thu Feb 10 00:37:23 2005
@@ -0,0 +1,10 @@
+<%args>
+$Object => undef
+</%args>
+<%init>
+return ( { 
+        id => { Render => 'integer' },
+        Name => { Render => 'scalar', Edit => undef, },
+
+});
+</%init>

Added: experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Display/Date
==============================================================================
--- (empty file)
+++ experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Display/Date	Thu Feb 10 00:37:23 2005
@@ -0,0 +1,19 @@
+<%args>
+$Value => undef
+$Attribute => undef
+$Object => undef
+$AttributeName => undef
+</%args>
+<%init>
+# someday we may want to treat it differently
+ my $date_obj = RT::Date->new($session{'CurrentUser'});
+
+if ($Object && $AttributeName) {
+ $date_obj->Set( Format => 'ISO', Value => $Object->$AttributeName() );
+} else {
+ $date_obj->Set( Format => 'ISO', Value =>  $Value);
+}
+$m->out('<span class="date">');
+$m->comp('scalar', Value => $date_obj->AsString);
+$m->out('</span>');
+</%init>

Added: experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Display/EmailMessage
==============================================================================
--- (empty file)
+++ experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Display/EmailMessage	Thu Feb 10 00:37:23 2005
@@ -0,0 +1,51 @@
+<%args>
+$Object => undef
+</%args>
+<%init>
+
+
+return unless ( $Object->ContentLength || $Object->Children->Count );
+
+my $content = $Object->Content;
+RT::Interface::Web::EscapeUTF8( \$content );
+
+my ( $headers, $quoted );
+if ( 0)  {
+    $headers = $Object->Headers;
+}
+else {
+    $headers = $Object->NiceHeaders;
+}
+chomp $headers;
+if ($headers) {
+    # localize the common headers (like 'Subject:'), too.
+    eval {
+        $headers =~ s/^([^:]+)(?=:)/loc($1)/em;
+      }    # we eval here to catch errors when 5.6 panics
+}
+
+# 13456 is a random # of about the biggest size we want to see inline text
+# It's here to catch anyone who hasn't updated RT_Config.pm since this
+# constant was moved out there.
+my $MAX_INLINE_BODY = $RT::MaxInlineBody || 13456;
+if (   $Object->ContentType =~ m{^(text/plain|Object|text$)}i
+    && $Object->ContentLength < $MAX_INLINE_BODY ) {
+    require Text::Quoted;
+    $quoted = Text::Quoted::extract( $Object->Content );
+}
+        
+$m->comp('/Elements/Callback', Name => 'MassageHeaders',  Headers => \$headers, %ARGS);
+</%init>
+<span class="Object">
+<table>
+% $headers =~ s/^\s+//gm;
+<span class="message-headers">
+% foreach my $header (split(/\n/,$headers)) {
+<%$header%><br>
+%}
+</span class="message-headers">
+</table>
+<PRE>
+<%$Object->Content%>
+</PRE>
+</span>

Added: experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Display/HREF
==============================================================================
--- (empty file)
+++ experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Display/HREF	Thu Feb 10 00:37:23 2005
@@ -0,0 +1,20 @@
+<%ARGS>
+$Attribute => undef
+$Object => undef
+</%ARGS>
+<%init>
+unless (ref($Attribute) && $Attribute->{Link}) {
+        $m->out($m->content);
+        return
+}
+my $href = $Attribute->{'Link'};
+
+my $id = $Object->id;
+$href =~ s/##id##/$id/i;
+
+if ($href =~ /^\//) {
+        $href = $RT::WebPath .$href;
+}
+
+</%init>
+<A HREF="<%$href%>"><%$m->content|n%></A>

Added: experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Display/Minutes
==============================================================================
--- (empty file)
+++ experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Display/Minutes	Thu Feb 10 00:37:23 2005
@@ -0,0 +1,11 @@
+<%args>
+$Value => undef
+$Object => undef
+$Attribute => undef
+</%args>
+<%init>
+if (!$Value && ref($Object) && $Attribute && UNIVERSAL::can($Object, $Attribute)) {
+        $Value = $Object->$Attribute() ;
+}
+</%init>
+<&|/l, int($Value) &>[_1] minutes</&>

Added: experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Display/RT/GroupMembers
==============================================================================
--- (empty file)
+++ experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Display/RT/GroupMembers	Thu Feb 10 00:37:23 2005
@@ -0,0 +1,15 @@
+<%args>
+$Object => undef
+$Attribute => undef
+$Value => undef
+</%args>
+% my $Group = &$Value;
+% my $Users = $Group->UserMembersObj;
+<ul>
+% while (my $user = $Users->Next) { 
+<li><%$user->Name%> 
+% if ($user->EmailAddress) {
+(<%$user->EmailAddress%>)
+% }
+% }
+</ul>

Added: experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Display/RT/Queue
==============================================================================
--- (empty file)
+++ experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Display/RT/Queue	Thu Feb 10 00:37:23 2005
@@ -0,0 +1,9 @@
+<%args>
+$Object => undef
+$Attribute => undef
+</%args>
+<%init>
+my $Queue = RT::Queue->new($session{'CurrentUser'});
+$Queue->Load($Object->$Attribute());
+</%init>
+<%$Queue->Name%> 

Added: experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Display/RT/User
==============================================================================
--- (empty file)
+++ experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Display/RT/User	Thu Feb 10 00:37:23 2005
@@ -0,0 +1,12 @@
+<%args>
+$Object => undef
+$Attribute => undef
+</%args>
+<%init>
+my $user = RT::User->new($session{'CurrentUser'});
+$user->Load($Object->$Attribute());
+</%init>
+<%$user->Name%> 
+% if ($user->EmailAddress) {
+(<%$user->EmailAddress%>)
+% }

Added: experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Display/datetime
==============================================================================
--- (empty file)
+++ experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Display/datetime	Thu Feb 10 00:37:23 2005
@@ -0,0 +1,11 @@
+<%args>
+$Value => undef
+$Attribute => undef
+$Object => undef
+</%args>
+%# someday we may want to treat it differently
+% my $date_obj = RT::Date->new($session{'CurrentUser'});
+% $date_obj->Set( Format => 'ISO', Value => ($Object->$Attribute() || $Value));
+%$m->out('<span class="date">');
+%$m->comp('scalar', Value => $date_obj->AsString);
+%$m->out('</span>');

Added: experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Display/integer
==============================================================================
--- (empty file)
+++ experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Display/integer	Thu Feb 10 00:37:23 2005
@@ -0,0 +1,4 @@
+%# someday we may want to treat it differently
+%$m->out('<span class="integer">');
+%$m->comp('scalar', %ARGS);
+%$m->out('</span>');

Added: experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Display/scalar
==============================================================================
--- (empty file)
+++ experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Display/scalar	Thu Feb 10 00:37:23 2005
@@ -0,0 +1,19 @@
+<%args>
+$Value => undef
+$Object => undef
+$Attribute => undef
+$AttributeName => undef
+</%args>
+<%init>
+if ( ref($Object) && $Attribute && UNIVERSAL::can($Object, $AttributeName)) {
+        eval {$Value = $Object->$AttributeName()};
+        if ($@) {
+                $Value = $@;
+        } 
+
+ } 
+</%init>
+<&| HREF, %ARGS&><%$Value%></&>
+% if (1) {#$session{'DEBUG'}) {
+<!-- Rendering <%$Value%> as a scalar. Object was <%ref($Object)%> <%UNIVERSAL::can($Object, 'id') && $Object->id%> and Attribute was <%$AttributeName%> <%$Object && $AttributeName && $Object->$AttributeName()%> -->
+%}

Added: experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Display/varchar
==============================================================================
--- (empty file)
+++ experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Display/varchar	Thu Feb 10 00:37:23 2005
@@ -0,0 +1,18 @@
+<%args>
+$Value => undef
+$Object => undef
+$Attribute => undef
+</%args>
+<%init>
+if ( ref($Object) && $Attribute && UNIVERSAL::can($Object, $Attribute)) {
+        eval {$Value = $Object->$Attribute()};
+        if ($@) {
+                $Value = $@;
+        } 
+
+ } 
+</%init>
+<%$Value%>
+% if ($session{'DEBUG'}) {
+<!-- Rendering <%$Value%> as a scalar. Object was <%ref($Object)%> <%UNIVERSAL::can($Object, 'id') && $Object->id%> and Attribute was <%$Attribute%> -->
+%}

Added: experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Edit/Date
==============================================================================
--- (empty file)
+++ experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Edit/Date	Thu Feb 10 00:37:23 2005
@@ -0,0 +1,34 @@
+<input size="<%$Size%>"  <& _attribute_name, Name => $Name, Object => $Object, Attribute => $Attribute&> value="<%$Default%>">
+<%init>
+
+
+unless ($Attribute) {
+    Abort("Bad call to ObjectDateInput - no attribute");
+}
+
+unless ($Default) {
+
+    # someday we may want to treat it differently
+    my $date_obj = RT::Date->new( $session{'CurrentUser'} );
+
+    if ( $Object && $AttributeName ) {
+        $date_obj->Set( Format => 'ISO', Value => $Object->$AttributeName() );
+    }
+    elsif($Value) {
+        $date_obj->Set( Format => 'ISO', Value => $Value );
+    }
+   if ($date_obj->Unix >= 0) {    
+        $Default = $date_obj->ISO;
+   }
+}
+
+</%init>
+<%args>
+$Name => undef
+$Object => undef
+$Attribute => undef
+$Default=> undef
+$Size => 30
+$AttributeName => undef
+$Value => undef
+</%args>

Added: experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Edit/Minutes
==============================================================================
--- (empty file)
+++ experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Edit/Minutes	Thu Feb 10 00:37:23 2005
@@ -0,0 +1,28 @@
+<input size="<%$Size%>" 
+        <& _attribute_name, Name => $Name, Object => $Object, Attribute => $Attribute&> 
+        value="<%$Default%>"> <&|/l&>minutes</&>
+%#XXX TODO: this component should be loced more cleverly, as this totally breaks
+%#XXX        in cases where "minutes" comes before the input
+<%init>
+
+unless ($Attribute) {
+        Abort("Bad call to ObjectInput - no attribute");
+}
+unless (UNIVERSAL::can($Object, $Attribute)) {
+#        Abort("Bad call to ObjectInput - $Attribute is an invalid attribute");
+}
+unless ($Default) {
+        $Default = $Object->$Attribute();
+}
+
+$Size = length($Default)+3;
+
+
+</%init>
+<%args>
+$Name => undef
+$Object => undef
+$Attribute => undef
+$Default=> undef
+$Size => undef
+</%args>

Added: experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Edit/RT/Queue
==============================================================================
--- (empty file)
+++ experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Edit/RT/Queue	Thu Feb 10 00:37:23 2005
@@ -0,0 +1,50 @@
+
+% if ($Lite) {
+<INPUT <& ../_attribute_name, Name => $Name, Object => $Object, Attribute => $Attribute&> size=25 DEFAULT="<%$d->Name%>">
+% } else {
+<SELECT <& ../_attribute_name, Name => $Name, Object => $Object, Attribute => $Attribute&> >
+% if ($ShowNullOption) {
+<OPTION VALUE="">-</OPTION>
+% }
+% while (my $queue=$q->Next) {
+% if ($ShowAllQueues || $queue->CurrentUserHasRight('CreateTicket')) {
+<OPTION VALUE="<%$queue->Id%>" <%($Default && ($queue->Id == $Default)) && 'SELECTED'%>><%$queue->Name%>
+%   if (($Verbose) and ($queue->Description) ){
+(<%$queue->Description%>)
+%  }
+</OPTION>
+% }
+% }
+</SELECT>
+% }
+<%init>
+
+unless ($Attribute) {
+        Abort("Bad call to ObjectInput - no attribute");
+}
+unless (UNIVERSAL::can($Object, $Attribute)) {
+#        Abort("Bad call to ObjectInput - $Attribute is an invalid attribute");
+}
+unless ($Default) {
+        $Default = $Object->$AttributeName();
+}
+my $q=new RT::Queues($session{'CurrentUser'});
+$q->UnLimit;
+
+my $d = new RT::Queue($session{'CurrentUser'});
+$d->Load($Default);
+
+</%init>
+
+<%args>
+$Object => undef
+$Attribute => undef
+$Default=> undef
+$Size => 30
+$ShowNullOption => 1
+$ShowAllQueues => 1
+$Name => undef
+$Verbose => undef
+$Lite => 0
+$AttributeName => undef
+</%ARGS>

Added: experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Edit/_attribute_name
==============================================================================
--- (empty file)
+++ experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Edit/_attribute_name	Thu Feb 10 00:37:23 2005
@@ -0,0 +1,25 @@
+NAME="<%$Name%>"
+<%init>
+my $AttributeName = ref($Attribute)? $Attribute->{'Name'} :$Attribute;
+unless ($Name) {
+        if (UNIVERSAL::isa($Object, 'DBIx::SearchBuilder::Record')) {
+            if ($Object->id) {
+                $Name = ref($Object)."-".$Object->id."-Set".$AttributeName."-Value";
+            } else {
+                $Name = ref($Object)."-new-".($Object+0)."-Create-".$AttributeName;
+            }
+        } else {
+                $Name = $AttributeName;
+        }        
+}
+if ($Suffix) {
+        $Name .= $Suffix;
+}
+
+</%init>
+<%args>
+$Name => undef
+$Object => undef
+$Attribute => undef
+$Suffix => undef
+</%args>

Added: experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Edit/checkbox
==============================================================================
--- (empty file)
+++ experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Edit/checkbox	Thu Feb 10 00:37:23 2005
@@ -0,0 +1,23 @@
+<input type="Checkbox" <& _attribute_name, Name => $Name, Object => $Object, Attribute => $Attribute&> <%$state%>>
+<input type="hidden" <& _attribute_name, Name => $Name, Object => $Object, Attribute => $Attribute, Suffix => '-previous-value' &> value="<%$Object->$AttributeName()%>">
+<%init>
+my $state;
+
+if ($Default) {
+        $state = $Default;
+}
+elsif ($Object->$AttributeName) {
+        $state = 'CHECKED';
+} else {
+        $state = 'UNCHECKED';
+}
+
+</%init>
+
+<%args>
+$Name => undef
+$Object => undef
+$Attribute => undef
+$AttributeName => undef
+$Default=> undef
+</%args>

Added: experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Edit/int
==============================================================================
--- (empty file)
+++ experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Edit/int	Thu Feb 10 00:37:23 2005
@@ -0,0 +1,4 @@
+<%init>
+$m->comp('integer', %ARGS);
+return;
+</%init>

Added: experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Edit/integer
==============================================================================
--- (empty file)
+++ experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Edit/integer	Thu Feb 10 00:37:23 2005
@@ -0,0 +1,26 @@
+<input size="<%$Size%>" <& _attribute_name, Name => $Name, Object => $Object, Attribute => $Attribute&> value="<%$Default%>">
+<%init>
+
+unless ($Attribute) {
+        Abort("Bad call to ObjectInput - no attribute");
+}
+unless (UNIVERSAL::can($Object, $Attribute)) {
+#        Abort("Bad call to ObjectInput - $Attribute is an invalid attribute");
+}
+unless ($Default) {
+        $Default = $Object->$Attribute();
+}
+
+$Size = length($Default)+3;
+
+
+</%init>
+
+<%args>
+$Name => undef
+$Object => undef
+$Attribute => undef
+$Default=> undef
+$Size => undef
+
+</%args>

Added: experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Edit/scalar
==============================================================================
--- (empty file)
+++ experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Edit/scalar	Thu Feb 10 00:37:23 2005
@@ -0,0 +1,24 @@
+<input size="<%$Size%>" <& _attribute_name, Name => $Name, Object => $Object, Attribute => $Attribute&> value="<%$Default%>">
+<%init>
+
+unless ($Attribute) {
+        Abort("Bad call to ObjectInput - no attribute");
+}
+unless (UNIVERSAL::can($Object, $AttributeName)) {
+#        Abort("Bad call to ObjectInput - $AttributeName is an invalid attribute");
+}
+if  (!$Default && $AttributeName) {
+        $Default = $Object->$AttributeName();
+}
+
+</%init>
+
+<%args>
+$Name => undef
+$Object => undef
+$Attribute => undef
+$AttributeName => undef
+$Default=> undef
+$Size => 30
+
+</%args>

Added: experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Edit/varchar
==============================================================================
--- (empty file)
+++ experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Edit/varchar	Thu Feb 10 00:37:23 2005
@@ -0,0 +1,4 @@
+<%init>
+$m->comp('scalar', %ARGS);
+return;
+</%init>

Added: experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Label/Label
==============================================================================
--- (empty file)
+++ experiments/Bamboo/lib/Bamboo/View/mason/Renderer/Label/Label	Thu Feb 10 00:37:23 2005
@@ -0,0 +1,4 @@
+<%args>
+$Value => undef
+</%args>
+<span class="label"><%loc($Value)%></span>

Added: experiments/Bamboo/lib/Bamboo/View/mason/Update
==============================================================================
--- (empty file)
+++ experiments/Bamboo/lib/Bamboo/View/mason/Update	Thu Feb 10 00:37:23 2005
@@ -0,0 +1,57 @@
+<%ARGS>
+$Object => undef
+</%ARGS>
+<%init>
+    unless ( $Object->id ) {
+        Abort("No such Object");
+    }
+
+    foreach my $attr ( $Object->WritableAttributes ) {
+        my $attr_uri_param_name = ref($Object) . "-" . $ARGS{'id'} . "-" . $attr;
+
+
+        my $value;
+        next unless ( exists $ARGS{$attr_uri_param_name}
+            || $ARGS{ $attr_uri_param_name . "-previous-value" } );
+
+   # If no value is set, but there was a value before, that means the user
+   # unclicked a checkbox. would be nice if html forms conveyed this information
+   # back to the server
+        if ( !exists $ARGS{$attr_uri_param_name} ) {
+            if ( $ARGS{ $attr_uri_param_name . "-previous-value" } == 1 ) {
+                $value = 0;
+            }
+
+        }
+        else {
+                $RT::Logger->debug("Found $attr_uri_param_name");
+             $value = $ARGS{$attr_uri_param_name};
+        }
+        my $AttributeMap = $m->comp( 'AttributeMap', Object => $Object );
+        if ( $AttributeMap->{$attr}->{Validator} ) {
+            if ( $m->comp_exists( "Validator/" . $AttributeMap->{$attr}->{Validator})) {
+                $value = $m->comp(
+                    "Validator/" . $AttributeMap->{$attr}->{Validator},
+                    Object        => $Object,
+                    AttributeName => $attr,
+                    Value         => $value
+                );
+            }
+            else {
+                $m->out( "Couldn't find " . $AttributeMap->{$attr}->{Validator} );
+            }
+        }
+        
+                $RT::Logger->debug("The value is finally $value");
+            next unless ( defined $value && ( $Object->$attr() ne $value ) );
+            my $set = "Set$attr";
+            my ( $val, $msg ) = $Object->$set($value);
+            if ($val) {
+                $_MESSAGES{$attr_uri_param_name} = $msg;
+            }
+            else {
+                $_ERRORS{$attr_uri_param_name} = $msg;
+            }
+
+    }
+</%init>

Added: experiments/Bamboo/lib/Bamboo/View/mason/Validator/Boolean
==============================================================================
--- (empty file)
+++ experiments/Bamboo/lib/Bamboo/View/mason/Validator/Boolean	Thu Feb 10 00:37:23 2005
@@ -0,0 +1,12 @@
+<%args>
+$Value => undef
+$Object => undef
+$AttributeName => undef
+</%args>
+<%init>
+if ($Value =~ /on|1|true|yes/i) {
+        return(1);
+} else {
+        return(0);
+}
+</%init>

Added: experiments/Bamboo/lib/Bamboo/View/mason/Validator/Date
==============================================================================
--- (empty file)
+++ experiments/Bamboo/lib/Bamboo/View/mason/Validator/Date	Thu Feb 10 00:37:23 2005
@@ -0,0 +1,26 @@
+<%args>
+$Value => undef
+$Object => undef
+$AttributeName => undef
+</%args>
+<%init>
+my $value_iso;
+if ($Value) {
+        my $date_obj = RT::Date->new($session{'CurrentUser'});
+        $date_obj->Set(Format => 'Unknown', Value => $Value);
+        $value_iso = $date_obj->ISO(); 
+        $m->out("Setting $Value to ".$value_iso);
+}
+
+my $current_value;
+eval {$current_value = $Object->$AttributeName() };
+
+if (!$Value && !$current_value) {
+        return undef;
+} elsif ($value_iso  ne $current_value ) {
+        return ($value_iso);
+
+} else  {
+        return undef;
+}
+</%init>

Added: experiments/Bamboo/lib/Bamboo/View/mason/WebMethodCall
==============================================================================
--- (empty file)
+++ experiments/Bamboo/lib/Bamboo/View/mason/WebMethodCall	Thu Feb 10 00:37:23 2005
@@ -0,0 +1,62 @@
+<%ARGS>
+$Object => undef
+$FormTag => undef
+$Messages => undef
+$Errors => undef
+$NewObjectIdMap => undef
+</%ARGS>
+<%init>
+
+# objects we're creating
+my $creates = {};
+# method calls we're performing
+my $calls = {};
+
+# Iterate through %ARGS and slice and dice into
+# Object we're working on
+#   Method calls for those objects
+#     Params for  those method calls
+foreach my $attr (keys %ARGS) {
+
+        next unless ($attr =~ /^(.*?)-(.*?)-(.*?)-(.*?)/ );
+        my $object_type = $1;
+        my $object_id = $2;
+        my $method = $3;
+        my $param_name = $4;
+        my $param_value = $ARGS{$attr};
+
+
+        if ($method eq 'Create') {
+                push (@{$creates->{$object_type}->{$object_id}->{$method}->{$param_name}},         $param_value);
+ 
+        } else {
+
+        push (@{$calls->{$object_type}->{$object_id}->{$method}->{$param_name}},         $param_value);
+
+        }
+}
+
+
+# now that we have all the things we're doing, let's create the objects we need to and then perform all the updates to the other objects we're updating.
+
+# for each object type
+#  for each object identifier
+#   create the object with all its parameters
+
+# for each object type
+#  for each object identifier
+#   perform the method call with all its parameters
+
+
+my ( $id, $msg ) = $Object->Create(%attrs);
+if ($id) {
+    $msg ||= loc("Object created");
+    $Messages->{'create'} = $msg;
+    $NewObjectIdMap->{$FormTag} = $id;
+}
+else {
+    $RT::Logger->error("Object creation failed for $FormTag / $Object");
+    $_ERRORS{ $FormTag . "-Create" } = $msg;
+}
+
+</%init>


More information about the Rt-commit mailing list