[Rt-commit] r3463 - in rtfm/branches/2.1-TESTING: . html/RTFM/Article html/RTFM/Article/Elements

alexmv at bestpractical.com alexmv at bestpractical.com
Mon Jul 11 21:30:48 EDT 2005


Author: alexmv
Date: Mon Jul 11 21:30:47 2005
New Revision: 3463

Modified:
   rtfm/branches/2.1-TESTING/   (props changed)
   rtfm/branches/2.1-TESTING/html/RTFM/Article/Edit.html
   rtfm/branches/2.1-TESTING/html/RTFM/Article/Elements/EditTopics
   rtfm/branches/2.1-TESTING/html/RTFM/Article/Elements/ShowSearchCriteria
   rtfm/branches/2.1-TESTING/html/RTFM/Article/ExtractIntoClass.html
   rtfm/branches/2.1-TESTING/html/RTFM/Article/ExtractIntoTopic.html
   rtfm/branches/2.1-TESTING/html/RTFM/Article/Search.html
Log:
 r4955 at zoq-fot-pik:  chmrr | 2005-07-11 21:32:01 -0400
  * RTFM article searching now forces user to choose class before going
    to full search
  * Multiple classes can be in the default topics
  * Topics selector is always 10 high (math was getting too complex)
  * Fix render bug in RTFM/Article/Edit.html


Modified: rtfm/branches/2.1-TESTING/html/RTFM/Article/Edit.html
==============================================================================
--- rtfm/branches/2.1-TESTING/html/RTFM/Article/Edit.html	(original)
+++ rtfm/branches/2.1-TESTING/html/RTFM/Article/Edit.html	Mon Jul 11 21:30:47 2005
@@ -27,9 +27,10 @@
        Title => loc('Create a new article') &>
 % }
 <& /Elements/ListActions, actions => \@results &>
+
+<form method="post action="Edit.html" name="EditArticle" id="EditArticle" enctype="multipart/form-data">
+<input type="hidden" name="id" value="<%$id%>"/>
 <table width="100%">
-<FORM METHOD=POST ACTION="Edit.html" name="EditArticle" id="EditArticle" enctype="multipart/form-data">
-<INPUT TYPE=HIDDEN NAME="id" VALUE="<%$id%>"/>
 <tr><td><h2><&|/l&>Basics</&></h2>
 </td><td></td></tr>
 <& Elements/EditBasics, ArticleObj => $ArticleObj,
@@ -61,16 +62,17 @@
 </td>
 <td>
 <& Elements/EditTopics, ArticleObj => $ArticleObj,
-                        ClassObj => $ArticleObj->Id ? $ArticleObj->ClassObj : $ClassObj,
+                        Classes => [$ArticleObj->Id ? $ArticleObj->ClassObj : $ClassObj],
                         OnlyThisClass => 1,
                         %ARGS,
                         id => $id
                         &>
 </td>
 </tr>
+</table>
 <& /Elements/Submit, Label => ($id eq 'new' ? loc('Create') : loc('Save Changes')), color => "#993333" &>
 </form>
-</table>
+
 <%INIT>
 
 if ( exists $ARGS{'Topics'} ) {

Modified: rtfm/branches/2.1-TESTING/html/RTFM/Article/Elements/EditTopics
==============================================================================
--- rtfm/branches/2.1-TESTING/html/RTFM/Article/Elements/EditTopics	(original)
+++ rtfm/branches/2.1-TESTING/html/RTFM/Article/Elements/EditTopics	Mon Jul 11 21:30:47 2005
@@ -17,35 +17,35 @@
 %# END LICENSE BLOCK
 
 <input type="hidden" name="EditTopics" value="1" />
-<select multiple size="<% $rows > 10 ? 10 : $rows %>" name="Topics">
+<select multiple size="10" name="Topics">
 <%perl>
-if ($ClassObj->Id) {
-   $m->print("<optgroup label=\"Current class (".$ClassObj->Name.")\">")
-     unless $OnlyThisClass;
-   $inTree->traverse(sub {
-     my $tree = shift;
-     my $topic = $tree->getNodeValue;
-     $m->print("<option value=\"".$topic->Id."\""
-       .(exists $topics{$topic->Id} ? " selected" : "").">"
-       .("&nbsp;" x ($tree->getDepth*5)).$topic->Name."</option>\n");
-   });
- }
- unless ($OnlyThisClass) {
- my $class = $ClassObj->Id;
- $otherTree->traverse(sub {
-   my $tree = shift;
-   my $topic = $tree->getNodeValue;
-   if ($topic->ObjectId != $class) {
-     $class = $topic->ObjectId;
-     $m->print("</optgroup>\n");
-     my $c = new RT::FM::Class($session{'CurrentUser'});
-     $c->Load($topic->ObjectId);
-     $m->print("<optgroup label=\"".$c->Name."\">\n");
-   }
-   $m->print("<option value=\"".$topic->Id."\""
-     .(exists $topics{$topic->Id} ? " selected" : "").">"
-     .("&nbsp;" x ($tree->getDepth*5)).$topic->Name."</option>\n");
- });
+if (@Classes) {
+  $m->print("<optgroup label=\"Current classes (".join (' ',map {$_->Name} @Classes).")\">")
+    unless $OnlyThisClass;
+  $inTree->traverse(sub {
+    my $tree = shift;
+    my $topic = $tree->getNodeValue;
+    $m->print("<option value=\"".$topic->Id."\""
+      .(exists $topics{$topic->Id} ? " selected" : "").">"
+      .("&nbsp;" x ($tree->getDepth*5)).$topic->Name."</option>\n");
+  });
+}
+unless ($OnlyThisClass) {
+  my $class = $Classes[-1]->Id;
+  $otherTree->traverse(sub {
+    my $tree = shift;
+    my $topic = $tree->getNodeValue;
+    unless ($topic->ObjectId == $class) {
+      $class = $topic->ObjectId;
+      $m->print("</optgroup>\n");
+      my $c = new RT::FM::Class($session{'CurrentUser'});
+      $c->Load($topic->ObjectId);
+      $m->print("<optgroup label=\"".$c->Name."\">\n");
+    }
+    $m->print("<option value=\"".$topic->Id."\""
+      .(exists $topics{$topic->Id} ? " selected" : "").">"
+      .("&nbsp;" x ($tree->getDepth*5)).$topic->Name."</option>\n");
+  });
 </%perl>
 </optgroup>
 % }
@@ -55,14 +55,16 @@
 use Tree::Simple;
 
 my $inClass = new RT::FM::TopicCollection($session{'CurrentUser'});
-$inClass->LimitToObject($ClassObj);
+$inClass->LimitToObject($_) for @Classes;
 $inClass->OrderByCols({FIELD => 'Name'});
 my $inTree = buildTree($inClass);
 
 my $otherClass = new RT::FM::TopicCollection($session{'CurrentUser'});
-if ($ClassObj->Id) {
-    $otherClass->Limit(FIELD => 'ObjectType', VALUE => 'RT::FM::Class');
-    $otherClass->Limit(FIELD => 'ObjectId', OPERATOR => '!=', VALUE => $ClassObj->Id);
+if (@Classes) {
+  $otherClass->Limit(FIELD => 'ObjectType', VALUE => 'RT::FM::Class');
+  for (@Classes) {
+    $otherClass->Limit(FIELD => 'ObjectId', OPERATOR => '!=', VALUE => $_->Id);
+  }
 } else {
     $otherClass->UnLimit;
 }
@@ -76,20 +78,6 @@
 }
 $topics{$_} = 1 for @Topics;
 
-my $rows = 1;
-$inTree->traverse(sub {$rows++});
-unless ($OnlyThisClass) {
-  $rows++;
-  my $class = $ClassObj->Id;
-  $otherTree->traverse(sub {
-                         $rows++;
-                         if ($class != $_[0]->getNodeValue->ObjectId) {
-                           $rows++;
-                           $class = $_[0]->getNodeValue->ObjectId;
-                         }
-                       });
-}
-
 sub buildTree {
     my $query = shift;
     
@@ -122,7 +110,7 @@
 </%INIT>
 <%ARGS>
 $ArticleObj => new RT::FM::Article($session{'CurrentUser'})
-$ClassObj => new RT::FM::Class($session{'CurrentUser'})
+ at Classes => ()
 @Topics => undef
 $OnlyThisClass => undef
 </%ARGS>

Modified: rtfm/branches/2.1-TESTING/html/RTFM/Article/Elements/ShowSearchCriteria
==============================================================================
--- rtfm/branches/2.1-TESTING/html/RTFM/Article/Elements/ShowSearchCriteria	(original)
+++ rtfm/branches/2.1-TESTING/html/RTFM/Article/Elements/ShowSearchCriteria	Mon Jul 11 21:30:47 2005
@@ -111,7 +111,7 @@
 <h2><&|/l&>Topics</&></h2>
 </td></tr>
 <tr><td class="label"></td><td>
-<& /RTFM/Article/Elements/EditTopics, %ARGS &>
+<& /RTFM/Article/Elements/EditTopics, %ARGS, Classes => \@Classes, OnlyThisClass => 1 &>
 <br /><input type="checkbox" name="ExpandTopics" <% $ARGS{'ExpandTopics'} ? 'checked="checked"' : "" %> />
 <&|/l&>Include subtopics</&> 
 </td></tr>
@@ -119,8 +119,18 @@
 <&/Elements/TitleBoxEnd&>
 % }
 
-
+<%init>
+my @Classes =
+ ( ref $ARGS{'Class'} eq 'ARRAY' )
+      ? @{ $ARGS{'Class'} }
+      : ( $ARGS{'Class'} );
+for (@Classes) {
+  my $class = RT::FM::Class->new( $session{'CurrentUser'} );
+  $class->LoadById($_);
+  $_ = $class;
+}
 </%init>
+
 <%ARGS>
 $dates =>undef
 $RefersTo => undef

Modified: rtfm/branches/2.1-TESTING/html/RTFM/Article/ExtractIntoClass.html
==============================================================================
--- rtfm/branches/2.1-TESTING/html/RTFM/Article/ExtractIntoClass.html	(original)
+++ rtfm/branches/2.1-TESTING/html/RTFM/Article/ExtractIntoClass.html	Mon Jul 11 21:30:47 2005
@@ -31,7 +31,7 @@
 <input type="hidden" name="Ticket" value="<% $Ticket %>" />
 <input type="hidden" name="Class"  value="<% $Class->id %>" />
 <&|/l &>Select topics for this article</&>:<br/>
-<& Elements/EditTopics, ClassObj => $Class,
+<& Elements/EditTopics, Classes => [$Class],
                         OnlyThisClass => 1,
                         id => 'new',
                         &><br />

Modified: rtfm/branches/2.1-TESTING/html/RTFM/Article/ExtractIntoTopic.html
==============================================================================
--- rtfm/branches/2.1-TESTING/html/RTFM/Article/ExtractIntoTopic.html	(original)
+++ rtfm/branches/2.1-TESTING/html/RTFM/Article/ExtractIntoTopic.html	Mon Jul 11 21:30:47 2005
@@ -23,7 +23,7 @@
 <form action="ExtractFromTicket.html">
 <input type="hidden" name="Ticket" value="<% $Ticket %>" />
 <input type="hidden" name="Class"  value="<% $ClassObj->id %>" />
-<& Elements/EditTopics, ClassObj => $ClassObj,
+<& Elements/EditTopics, Classes => [$ClassObj],
                         OnlyThisClass => 1,
                         id => 'new',
                         &><br />

Modified: rtfm/branches/2.1-TESTING/html/RTFM/Article/Search.html
==============================================================================
--- rtfm/branches/2.1-TESTING/html/RTFM/Article/Search.html	(original)
+++ rtfm/branches/2.1-TESTING/html/RTFM/Article/Search.html	Mon Jul 11 21:30:47 2005
@@ -17,6 +17,21 @@
 %# END LICENSE BLOCK
 
 <& /RTFM/Article/Elements/Tabs, current_tab => "RTFM/Article/Search.html", Title => loc("Search for articles") &>
+
+% unless ($ARGS{'Class'}) {
+%   my $Classes=new RT::FM::ClassCollection($session{'CurrentUser'});
+%   $Classes->UnLimit;
+
+<&|/l&>Select a class to search:</&>
+<ul>
+% while (my $class = $Classes->Next) {
+<li><a href="<%$RT::WebPath%>/RTFM/Article/Search.html?<% $m->comp('/Elements/QueryString', %filtered, Class => $class->id) %>"><% $class->Name %></a></li>
+% }  
+</ul>
+
+%  return;
+% }
+
 <& /Elements/ListActions, actions => \@results &>
 <div style="float: right"><a href="#criteria"><&|/l&>Modify this search...</&></a></div>
 


More information about the Rt-commit mailing list