[Rt-commit] [svn] r1327 - in rtfm/branches/2.1-TESTING: etc html/Callbacks/RTFM/Elements/Header html/NoAuth html/RTFM/Admin/Classes html/RTFM/Article/Elements lib/RT/FM

alexmv at pallas.eruditorum.org alexmv at pallas.eruditorum.org
Tue Aug 10 16:12:08 EDT 2004


Author: alexmv
Date: Tue Aug 10 16:12:07 2004
New Revision: 1327

Added:
   rtfm/branches/2.1-TESTING/html/Callbacks/RTFM/Elements/Header/
   rtfm/branches/2.1-TESTING/html/Callbacks/RTFM/Elements/Header/Head
   rtfm/branches/2.1-TESTING/html/NoAuth/
   rtfm/branches/2.1-TESTING/html/NoAuth/webrtfm.css
Modified:
   rtfm/branches/2.1-TESTING/etc/schema.Oracle
   rtfm/branches/2.1-TESTING/etc/schema.Pg
   rtfm/branches/2.1-TESTING/etc/schema.mysql
   rtfm/branches/2.1-TESTING/html/RTFM/Admin/Classes/CustomFields.html
   rtfm/branches/2.1-TESTING/html/RTFM/Article/Elements/EditCustomField
   rtfm/branches/2.1-TESTING/html/RTFM/Article/Elements/ShowCustomFields
   rtfm/branches/2.1-TESTING/lib/RT/FM/Article_Overlay.pm
   rtfm/branches/2.1-TESTING/lib/RT/FM/ClassCustomField.pm
Log:
 * Fixes for empty CustomFields
 * Allow emphasis, de-emphasis, hidden, or hidden when empty display of CustomFields


Modified: rtfm/branches/2.1-TESTING/etc/schema.Oracle
==============================================================================
--- rtfm/branches/2.1-TESTING/etc/schema.Oracle	(original)
+++ rtfm/branches/2.1-TESTING/etc/schema.Oracle	Tue Aug 10 16:12:07 2004
@@ -23,6 +23,7 @@
 Creator NUMBER(11,0) DEFAULT 0 NOT NULL,
 Created DATE,
 SortOrder NUMBER(11,0) DEFAULT 0 NOT NULL,
+Display varchar2(255) DEFAULT 'normal' NOT NULL,
 LastUpdatedBy NUMBER(11,0) DEFAULT 0 NOT NULL,
 LastUpdated DATE
 );

Modified: rtfm/branches/2.1-TESTING/etc/schema.Pg
==============================================================================
--- rtfm/branches/2.1-TESTING/etc/schema.Pg	(original)
+++ rtfm/branches/2.1-TESTING/etc/schema.Pg	Tue Aug 10 16:12:07 2004
@@ -20,6 +20,7 @@
 Creator integer NOT NULL DEFAULT 0,
 Created TIMESTAMP NULL,
 SortOrder smallint not null default '0',
+Display varchar(255) not null default 'normal',
 LastUpdatedBy integer NOT NULL DEFAULT 0,
 LastUpdated TIMESTAMP NULL,
 PRIMARY KEY (id)

Modified: rtfm/branches/2.1-TESTING/etc/schema.mysql
==============================================================================
--- rtfm/branches/2.1-TESTING/etc/schema.mysql	(original)
+++ rtfm/branches/2.1-TESTING/etc/schema.mysql	Tue Aug 10 16:12:07 2004
@@ -20,6 +20,7 @@
 Creator integer NOT NULL DEFAULT 0,
 Created DATETIME NULL,
 SortOrder int(2) not null default '0',
+Display varchar(255) not null default 'normal',
 LastUpdatedBy integer NOT NULL DEFAULT 0,
 LastUpdated DATETIME NULL,
 PRIMARY KEY (id)

Added: rtfm/branches/2.1-TESTING/html/Callbacks/RTFM/Elements/Header/Head
==============================================================================
--- (empty file)
+++ rtfm/branches/2.1-TESTING/html/Callbacks/RTFM/Elements/Header/Head	Tue Aug 10 16:12:07 2004
@@ -0,0 +1,18 @@
+%# BEGIN LICENSE BLOCK
+%# 
+%#  Copyright (c) 2002-2003 Jesse Vincent <jesse at bestpractical.com>
+%#  
+%#  This program is free software; you can redistribute it and/or modify
+%#  it under the terms of version 2 of the GNU General Public License 
+%#  as published by the Free Software Foundation.
+%# 
+%#  A copy of that license should have arrived with this
+%#  software, but in any event can be snarfed from www.gnu.org.
+%# 
+%#  This program 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.
+%# 
+%# END LICENSE BLOCK
+<link rel="stylesheet" href="<%$RT::WebPath%>/NoAuth/webrtfm.css" type="text/css">

Added: rtfm/branches/2.1-TESTING/html/NoAuth/webrtfm.css
==============================================================================
--- (empty file)
+++ rtfm/branches/2.1-TESTING/html/NoAuth/webrtfm.css	Tue Aug 10 16:12:07 2004
@@ -0,0 +1,2 @@
+.emphasized td { font-weight: bolder; color: #c00}
+.de-emphasized td { color: #999; }

Modified: rtfm/branches/2.1-TESTING/html/RTFM/Admin/Classes/CustomFields.html
==============================================================================
--- rtfm/branches/2.1-TESTING/html/RTFM/Admin/Classes/CustomFields.html	(original)
+++ rtfm/branches/2.1-TESTING/html/RTFM/Admin/Classes/CustomFields.html	Tue Aug 10 16:12:07 2004
@@ -46,8 +46,15 @@
 <i><%$cf->Description%></i>
 </td>
 <td>
-<input size="3" 
-name="Class-<%$ClassObj->Id%>-CF-<%$cf->Id%>-SortOrder" value="<%$class_cf->Id ? $class_cf->SortOrder : ''%>">
+<input size="3" name="Class-<%$ClassObj->Id%>-CF-<%$cf->Id%>-SortOrder" <%$class_cf->Id ? 'value="'.$class_cf->SortOrder.'"' : 'disabled="1"' |n%>>
+</td>
+<td>
+<select name="Class-<% $ClassObj->Id %>-CF-<% $cf->Id %>-Display" <% $class_cf->Id ? '' : 'disabled="1"' |n%>>
+% for (qw/Normal Emphasized De-emphasized Hidden/, "Hidden when empty") {
+<option <% $_ eq $class_cf->Display and "selected" %>><% $_ %></option>
+% }
+</select>
+</td>
 </td>
 </tr>
 % }
@@ -94,6 +101,9 @@
     }
     if (defined $ARGS{"Class-".$ClassObj->Id."-CF-".$cf->Id}  ) {
         
+        my $class_cf = RT::FM::ClassCustomField->new($session{'CurrentUser'});
+        $class_cf->LoadByCols(Class => $ClassObj->Id, CustomField => $cf->Id);
+        $class_cf->SetDisplay($ARGS{"Class-".$ClassObj->Id."-CF-".$cf->Id."-Display"} || "Normal");
         my ($val, $msg) =  $cf->SetSortOrderForClass(Class => $ClassObj->Id, SortOrder => $ARGS{"Class-".$ClassObj->Id."-CF-".$cf->Id."-SortOrder"});
     }
 }

Modified: rtfm/branches/2.1-TESTING/html/RTFM/Article/Elements/EditCustomField
==============================================================================
--- rtfm/branches/2.1-TESTING/html/RTFM/Article/Elements/EditCustomField	(original)
+++ rtfm/branches/2.1-TESTING/html/RTFM/Article/Elements/EditCustomField	Tue Aug 10 16:12:07 2004
@@ -1,21 +1,21 @@
 % if ($CustomFieldObj->Type eq 'FreeformSingle') {
 <input name="Article-<%$id%>-CustomField-<%$CustomFieldObj->Id%>-Values"
-       value="<%$Values->First && $Values->First->Content%>">
+       value="<%$Values->First && $Values->First->Content%>" />
 % }
 %  elsif ($CustomFieldObj->Type eq 'FreeformMultiple') {
-<textarea name="Article-<%$id%>-CustomField-<%$CustomFieldObj->Id%>-Values">
+<textarea name="Article-<%$id%>-CustomField-<%$CustomFieldObj->Id%>-Values">\
 %while (my $value = $Values->Next ) {
-<%$value->Content%>
+<%$value->Content%>\
 %}
 </textarea>
 % } 
 %  elsif ($CustomFieldObj->Type =~ /(?:Text)/) {
 % my $name = "Article-$id-CustomField-".$CustomFieldObj->Id."-Values";
-<textarea rows="25" cols="70" name="<%$name%>">
+<textarea rows="25" cols="70" name="<%$name%>">\
 %while (my $value = $Values->Next ) {
 % $Content .= $value->Content;
 %}
-<%$Content || $ARGS{$name}%>
+<%$Content || $ARGS{$name}%>\
 </textarea>
 % } 
 % elsif ($CustomFieldObj->Type =~ /^Select/) {

Modified: rtfm/branches/2.1-TESTING/html/RTFM/Article/Elements/ShowCustomFields
==============================================================================
--- rtfm/branches/2.1-TESTING/html/RTFM/Article/Elements/ShowCustomFields	(original)
+++ rtfm/branches/2.1-TESTING/html/RTFM/Article/Elements/ShowCustomFields	Tue Aug 10 16:12:07 2004
@@ -18,32 +18,37 @@
 
 <table>
 % while (my $cf = $cfs->Next) {
-% my $values = $article->CustomFieldValues($cf->Id);
-<tr>
+%   my $values = $article->CustomFieldValues($cf->Id);
+%   my $class_cf = RT::FM::ClassCustomField->new($session{'CurrentUser'});
+%   $class_cf->LoadByCols(Class => $article->ClassObj->Id, CustomField => $cf->Id);
+%   my $display = $class_cf->Display;
+%   next if $display eq "Hidden";
+%   next if $display eq "Hidden when empty" and not $values->Count;
+<tr class="<% (split(' ',$display))[-1] %>">
 <td valign=top><b><%$cf->Name%></b></td>
 <td>
 <% ($cf->Type !~ /Single$/) && '<ul>' |n%>
 <%perl>
-   while (my $value = $values->Next) {
-       my $content;
-       if ( $value) {
-        $content = $value->Content;
-
-    if ($cf->Type =~ /^WikiText/) {
-        $content = $value->WikiFormattedContent();
-    }
-      elsif ($cf->Type =~ /^(FreeForm|Text)/) {
-           $content = "<pre>".$content."</pre>" unless ($content =~ /<(.{1,5})>/);
-       }
+    while (my $value = $values->Next) {
+        my $content;
+        if ( $value) {
+            $content = $value->Content;
+            
+            if ($cf->Type =~ /^WikiText/) {
+                $content = $value->WikiFormattedContent();
+            } elsif ($cf->Type =~ /^(FreeForm|Text)/) {
+                $content = "<pre>".$content."</pre>" unless ($content =~ /<(.{1,5})>/);
+            }
         }
 </%perl>
 <%($cf->Type !~ /Single$/) && '<li>'|n%>
-<%$content|n%>
-% }
+<%      $content|n%>
+<%($cf->Type !~ /Single$/) && '</li>'|n%>
+%   }
 <%($cf->Type !~ /Single$/ )&& '</ul>'|n%>
-% }
 </td>
 </tr>
+% }
 </table>
 <%init>
 my $cfs = $article->ClassObj->CustomFields;

Modified: rtfm/branches/2.1-TESTING/lib/RT/FM/Article_Overlay.pm
==============================================================================
--- rtfm/branches/2.1-TESTING/lib/RT/FM/Article_Overlay.pm	(original)
+++ rtfm/branches/2.1-TESTING/lib/RT/FM/Article_Overlay.pm	Tue Aug 10 16:12:07 2004
@@ -982,6 +982,9 @@
 
         # }}}
 
+        return (1, $self->loc( "Custom field unchanged" )) if not $args{'Content'} and not $cf_values;
+        return (1, $self->loc( "Custom field value unset" )) unless $args{'Content'};
+
         # {{{ Add a new custom field value
         my $value = $cf->ValuesForArticle( $self->Id )->First;
         my $old_value;
@@ -1036,6 +1039,11 @@
         # }}}
     }
 
+    # If it's an empty value, we don't want to insert it
+    elsif (not $args{'Content'}) {
+        return ( 1, $self->loc( "Empty value skipped" ));
+    }
+
     # otherwise, just add a new value and record "new value added"
     else {
 
@@ -1105,7 +1113,7 @@
 
     my $values = RT::FM::ArticleCFValueCollection->new($self->CurrentUser);
     $values->LimitToArticle($self->id);
-    $values->LimitToCustomField($self->id);
+    $values->LimitToCustomField($cf->id);
     my $CFObjectValue = $values->HasEntryWithContent($args{'Content'}); 
 
     #if we can\'t find it, bail

Modified: rtfm/branches/2.1-TESTING/lib/RT/FM/ClassCustomField.pm
==============================================================================
--- rtfm/branches/2.1-TESTING/lib/RT/FM/ClassCustomField.pm	(original)
+++ rtfm/branches/2.1-TESTING/lib/RT/FM/ClassCustomField.pm	Tue Aug 10 16:12:07 2004
@@ -180,6 +180,24 @@
 =cut
 
 
+=item Display
+
+Returns the current value of Display. 
+(In the database, Display is stored as varchar(255).)
+
+
+
+=item SetDisplay VALUE
+
+
+Set Display to VALUE. 
+Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
+(In the database, Display will be stored as a varchar(255).)
+
+
+=cut
+
+
 =item LastUpdatedBy
 
 Returns the current value of LastUpdatedBy. 
@@ -214,6 +232,8 @@
 		{read => 1, auto => 1, type => 'datetime', default => ''},
         SortOrder => 
 		{read => 1, write => 1, type => 'int(2)', default => '0'},
+        Display => 
+		{read => 1, write => 1, type => 'varchar(255)', default => 'Normal'},
         LastUpdatedBy => 
 		{read => 1, auto => 1, type => 'int(11)', default => '0'},
         LastUpdated => 


More information about the Rt-commit mailing list