[rt-commit] [svn] r552 - in rt/branches: . autrijus-3.1/html/Admin/CustomFields autrijus-3.1/html/Admin/Elements

autrijus at fsck.com autrijus at fsck.com
Fri Mar 12 00:07:49 EST 2004


Author: autrijus
Date: Fri Mar 12 00:07:46 2004
New Revision: 552

Added:
   rt/branches/autrijus-3.1/html/Admin/CustomFields/Objects.html
   rt/branches/autrijus-3.1/html/Admin/Elements/PickObjects
Modified:
   rt/branches/   (props changed)
   rt/branches/autrijus-3.1/html/Admin/Elements/CustomFieldTabs
   rt/branches/autrijus-3.1/html/Admin/Elements/QueueTabs
Log:
* pick objects from the CFs side.


Added: rt/branches/autrijus-3.1/html/Admin/CustomFields/Objects.html
==============================================================================
--- (empty file)
+++ rt/branches/autrijus-3.1/html/Admin/CustomFields/Objects.html	Fri Mar 12 00:07:46 2004
@@ -0,0 +1,128 @@
+%# BEGIN LICENSE BLOCK
+%# 
+%# Copyright (c) 1996-2003 Jesse Vincent <jesse at bestpractical.com>
+%# 
+%# (Except where explictly superceded by other copyright notices)
+%# 
+%# 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.
+%# 
+%# Unless otherwise specified, all modifications, corrections or
+%# extensions to this work which alter its source code become the
+%# property of Best Practical Solutions, LLC when submitted for
+%# inclusion in the work.
+%# 
+%# 
+%# END LICENSE BLOCK
+<& /Admin/Elements/Header, Title => $title &>
+<& /Admin/Elements/CustomFieldTabs,
+    id => $id,
+    current_subtab => "Admin/CustomFields/Modify.html?id=".$id,
+    Title => $title
+    &>
+
+<& /Elements/ListActions, actions => \@results &>
+
+<TABLE>
+<TR>
+<TD VALIGN=TOP>
+<h2><%$caption%></h2>
+</TD></TR></TABLE>
+<FORM METHOD=GET ACTION="Objects.html">
+<INPUT TYPE=HIDDEN NAME="id" VALUE="<% $id %>">
+<input type="checkbox" name="FindDisabledObjects"> <&|/l&>Include disabled objects in listing.</&>
+<input type=submit value="<&|/l&>Go!</&>">
+</FORM>
+<hr>
+<FORM ACTION="Objects.html" METHOD=POST>
+<INPUT TYPE=HIDDEN NAME="id" VALUE="<% $id %>">
+<INPUT TYPE=HIDDEN NAME="UpdateObjs" VALUE="1">
+
+<h3><&|/l&>Assigned Objects (uncheck to remove)</&></h3>
+<& /Admin/Elements/PickObjects, Objects => \@AssignedObjs, id => $id, Checked => 1 &>
+<h3><&|/l&>Unassigned Objects (check to assign)</&></h3>
+<& /Admin/Elements/PickObjects, Objects => \@UnassignedObjs, id => $id &>
+
+<& /Elements/Submit &>
+</FORM>
+
+<%INIT>
+my $CF = RT::CustomField->new($session{'CurrentUser'});
+$CF->Load($id) or Abort(loc("Could not load CustomField [_1]"), $id);
+my $LookupType = $CF->LookupType;
+$LookupType =~ /^(RT::(\w+))/
+    or Abort(loc("Object of type [_1] cannot take custom fields", $LookupType));
+
+my $Type = $2;
+my $Class = $1;
+my $CollectionType = $2.'s';
+my $CollectionClass = $Class.'s';
+my $title = loc('Modify associated objects for [_1]', $CF->Name);
+
+my $Objects = $CollectionClass->new($session{'CurrentUser'});
+my ($caption, @results);
+my (@AssignedObjs, @UnassignedObjs);
+
+$Objects->UnLimit;
+$Objects->OrderBy( FIELD => 'Name' );
+
+if ($FindDisabledObjects) {
+    $caption = loc("All [_1]", loc($CollectionType));
+    $Objects->{'find_disabled_rows'} = 1;
+} else {
+    $caption = loc("Enabled [_1]", loc($CollectionType));
+}
+
+my $ObjectCFs;
+$ObjectCFs = RT::ObjectCustomFields->new($session{'CurrentUser'});
+$ObjectCFs->UnLimit;
+$ObjectCFs->LimitToCustomField($id);
+
+my %seen;
+while (my $OCF = $ObjectCFs->Next) {
+    $seen{$OCF->ObjectId}++;
+}
+
+while (my $obj = $Objects->Next) { 
+    my $obj_id = $obj->Id;
+
+    if ($UpdateObjs) {
+	# Go through and delete all the custom field relationships that this object
+	# no longer has
+	my $key = "Object-$obj_id-CF-$id";
+	if ($ARGS{$key}) {
+	    if (!$seen{$obj_id}) {
+		my ($val, $msg) = $CF->AddToObject($obj);
+		push (@results, $msg);
+		push @UnassignedObjs, $obj if !$val;
+	    }
+	}
+	else {
+	    push @UnassignedObjs, $obj;
+	    if ($seen{$obj_id}) {
+		my ($val, $msg) = $CF->RemoveFromObject($obj);
+		push (@results, $msg);
+		pop @UnassignedObjs if !$val;
+	    }
+	}
+    }
+    elsif (!$seen{$obj_id}) {
+	push @UnassignedObjs, $obj;
+    }
+    next if @UnassignedObjs and $UnassignedObjs[-1] == $obj;
+    push @AssignedObjs, $obj;
+}
+
+</%INIT>
+<%ARGS>
+$id => undef
+$FindDisabledObjects => 0
+$UpdateObjs => 0
+</%ARGS>

Modified: rt/branches/autrijus-3.1/html/Admin/Elements/CustomFieldTabs
==============================================================================
--- rt/branches/autrijus-3.1/html/Admin/Elements/CustomFieldTabs	(original)
+++ rt/branches/autrijus-3.1/html/Admin/Elements/CustomFieldTabs	Fri Mar 12 00:07:46 2004
@@ -19,6 +19,9 @@
                 C => { title => loc('Basics'),
                        path  => "Admin/CustomFields/Modify.html?id=" . $id,
                 },
+                D => { title => loc('Applies To'),
+                       path  => "Admin/CustomFields/Objects.html?id=" . $id,
+                },
 
                 F => { title => loc('Group Rights'),
                        path  => "Admin/CustomFields/GroupRights.html?id="

Added: rt/branches/autrijus-3.1/html/Admin/Elements/PickObjects
==============================================================================
--- (empty file)
+++ rt/branches/autrijus-3.1/html/Admin/Elements/PickObjects	Fri Mar 12 00:07:46 2004
@@ -0,0 +1,61 @@
+%# BEGIN LICENSE BLOCK
+%# 
+%# Copyright (c) 1996-2003 Jesse Vincent <jesse at bestpractical.com>
+%# 
+%# (Except where explictly superceded by other copyright notices)
+%# 
+%# 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.
+%# 
+%# Unless otherwise specified, all modifications, corrections or
+%# extensions to this work which alter its source code become the
+%# property of Best Practical Solutions, LLC when submitted for
+%# inclusion in the work.
+%# 
+%# 
+%# END LICENSE BLOCK
+% if (@Objects == 0) {
+<P><i><&|/l&>(No objects)</&></i></P>
+% } else {
+<TABLE cellspacing=0 cellpadding=2>
+% my $count;
+% foreach my $Object (@Objects) {
+<TR>
+%   if (!$ReadOnly) {
+  <TD valign="TOP">
+<input type="checkbox"
+name="Object-<%$Object->id%>-CF-<%$id%>"
+value="1" 
+<% $Checked && 'CHECKED' %>
+>
+  </TD>
+%   }
+  <TD valign="TOP">
+% if ($Object->Name) {
+    <b><%$Object->Name%></b><br>
+% } else {
+    <i>(<%loc("no name")%>)</i><br>
+% }
+    <%$Object->Description%>
+  </TD>
+%#  <TD valign="TOP">
+%#    <i><% $CustomFieldObj->FriendlyTypeComposite %></i>
+%#  </TD>
+  </TD>
+</TR>
+% }
+</TABLE>
+% }
+<%ARGS>
+ at Objects
+$id
+$ReadOnly => 0
+$Checked => 0
+</%ARGS>

Modified: rt/branches/autrijus-3.1/html/Admin/Elements/QueueTabs
==============================================================================
--- rt/branches/autrijus-3.1/html/Admin/Elements/QueueTabs	(original)
+++ rt/branches/autrijus-3.1/html/Admin/Elements/QueueTabs	Fri Mar 12 00:07:46 2004
@@ -72,14 +72,7 @@
 			   };
   $tabs->{"B"} = { title => loc('New queue'),
   		     	path => "Admin/Queues/Modify.html?Create=1",
-			   };
-  $tabs->{"C1"} = { title => loc('CF: Tickets'),
-  		     	path => "Admin/Queues/CustomFields.html?SubType=RT::Ticket",
-			   };
-  $tabs->{"C2"} = { title => loc('CF: TicketTxns'),
-  		     	path => "Admin/Queues/CustomFields.html?SubType=RT::Ticket-RT::Transaction",
-			separator => 1,
-			   };
+		 separator => 1, };
 }
 
   # Now let callbacks add their extra tabs



More information about the Rt-commit mailing list