[rt-users] Anyone modify StockAnswers for use in the SelfService page?

Michael K Brown michael.k.brown at alcatel.com
Mon Apr 29 17:17:40 EDT 2002


Hi Aaron!

I've put

<& Elements/ShowStock/Requests &>
<& /Elements/MessageBox, Name=> "Content" &>

into an otherwise unmodified Create.html copied to
/usr/local/rt2/local/WebRT/html/SelfService/

I've modified StockAnswers0.2 to create StockRequests in
/usr/local/rt2/local/WebRT/html/SelfService/Elements/

I'll include the modified StockAnswers below.  My problem is that I don't
get anything into the drop down list.  I'm not a programmer, so I'd
appreciate any advise you can give me!

Thanks!

Mike

<%doc>
  $Id: ShowStockRequests,v 1.0 2002/04/29 15:52:33 mkbrown Exp $
</%doc>
<%args>
 $Queue => ""
</%args>

<SCRIPT LANGUAGE='JavaScript'>
<!--

var dat = new Array(<% scalar @data %>);
% my $i=0;
% for (@data) {
% my ($n,$t) = @$_;
% $t =~ s/'/\\'/g;
% $t =~ s/\n/\\n/g;
% $m->out("dat[$i] = '$t';\n"); $i++;
% }
dat[<% $i %>] = '';

function insertData( x )
{
    // insert the data indexed by 'x' at the head of the textarea
    var n = dat[x];
    var old = document.Content.value;
    document.Content.value = n + old;
}

function doStockRequest()
{
    var x = document.StockRequests.selectedIndex;
    insertData(document.StockRequests.options[x].value);
}

// -->
</SCRIPT>
<select name="StockRequests" onChange="javascript:doStockRequest()">
<OPTION VALUE="<% $#data + 1 %>">Stock Requests...</OPTION>
% $i = 0;
% for (@data) {
% my ($n,$t) = @$_;
<OPTION VALUE="<% $i++ %>"><% $n %></OPTION>
%}
</select>

<%init>

my
$templateDir="$RT::MasonLocalComponentRoot/../../templates/StockRequests";
my @templates = ();
my @data;
push (@templates, glob( $templateDir . $Queue . "/*" ))
  if ($Queue && -d $templateDir . $Queue );
# special case for the global directory
push (@templates, glob( $templateDir . "global/*" ))
  if (-d $templateDir . "global");
@templates = grep { !/(?:\/|,v|~)$/ } @templates;

for my $n (@templates) {
 open(IN,"<$n") or next;
 local $/ = "";
 my $t = join('', <IN>); $t =~ s/\n/\\n/gs; $t =~ s/\'/\\\'/gs;
 $n =~ m{^.+/(.+?)/(.+?)$}; my ($dir,$name) = ($1,$2);
 if ($t =~ s/^\$title:\s*(.+?)\\n//) { $name = $1; }
 $n = "$dir:$name";
 push @data, [$n,$t];
}

</%init>



-----Original Message-----
From: Aaron T Porter [mailto:atporter at primate.net]
Sent: April 29, 2002 17:04
To: Michael K Brown
Cc: rt-users at lists.fsck.com
Subject: Re: [rt-users] Anyone modify StockAnswers for use in the
SelfService page?


On Mon, Apr 29, 2002 at 04:49:15PM -0400, Michael K Brown wrote:

> I'm trying to modify the Stock Answers contrib to make a "Stock Requests";
a
> way for users creating tickets to enter pre-formatted text.  I'm not
having
> much luck so far... I can't seem to get it working.  I'm just wondering if
> anyone else has done this yet?  Am I breaking new ground that makes the
> hairpulling worth while?  ;-)

	Michael, could you tell us specifically which URL you're trying to
insert the questions into? From there it should be quite simple to insert
the text.





More information about the rt-users mailing list