PopUpAlert

From Request Tracker Wiki
Jump to navigation Jump to search

PopUpAlert

In RT responses are generally to requestors however, on occasion one accidentally replies with an internal comment, forgetting that there are probably watchers set on the Queue...

While some users might like this to prevent themselves from accidentally sending messages to unintended recipients, for others it would be an annoyance.

3.6.4

$RT_HOME/local/html/Elements/Submit

% if ($Label_pop_up) {
  <span class="caption"><%$Caption%></span>
  <input type="submit" onClick="return confirmSubmit()" <% $Name && qq[name="$Name"] | n %> value="<%$Label_pop_up%>" class="button" />

% } elsif ($AlternateLabel) {
  <span class="caption"><%$AlternateCaption%></span>
  <input type="submit" <% $Name && qq[ name="$Name"] | n %> value="<%$AlternateLabel%>" class="button" />
% } else {
  <span class="caption"><%$Caption%></span>
  <input type="submit" <% $Name && qq[ name="$Name"] | n %> value="<%$Label%>" class="button" />
% }

$RT_HOME/local/html/Ticket/Update.html

<script type="text/javascript" src="<%$RT::WebPath%>/NoAuth/js/pop_up.js"></script>

% if ($CommentDefault eq "SELECTED") {
  <& /Elements/Submit, Label => loc('Update Ticket'), Name => 'SubmitTicket' &>
% } elsif ($ResponseDefault eq "SELECTED") {
<& /Elements/Submit, Label_pop_up => loc('Update Ticket'), Name => 'SubmitTicket' &>
% }

pop_up.js is just:

function confirmSubmit(){
var agree=confirm("Attention! This email bla bla bla....");
if (agree)
      return true ;
else
      return false ;
}

3.8.1

Below is a patch to implement the same functionality as above. What remains to be done, and would be more useful, would be to develop a JavaScript function in an external file that parses the current form state to display who the message is to be sent to. In addition, this should probably be a preference...

--- share/html/Ticket/Update.html       2008-08-30 19:22:14.000000000 -0400
+++ local/html/Ticket/Update.html       2008-10-10 23:50:05.000000000 -0400
@@ -147,8 +147,12 @@



-
+%if ( length($ResponseDefault) ){
+<& /Elements/Submit, Label => loc('Update Ticket'), Name => 'SubmitTicket', OnClick => qq(return confirm('Are you sure you want to send this message to:')?true:false) &>
+%} else {
 <& /Elements/Submit, Label => loc('Update Ticket'), Name => 'SubmitTicket' &>
+%}
+
 % if ($TicketObj->CurrentUserHasRight('ShowOutgoingEmail')) {
 <&|/Widgets/TitleBox, title => loc('Scrips and Recipients') &>
 <& /Ticket/Elements/PreviewScrips, TicketObj => $TicketObj, %ARGS &>


Alternately, it may be enough to simply colorize the non-preferred 'Update Type' list option to remind the user which they've selected:

--- share/html/Ticket/Update.html        2009-11-20 09:43:14.000000000 -0800
+++ local/html/Ticket/Update.html        2010-02-11 10:06:08.000000000 -0800
@@ -91,7 +91,7 @@
 <tr><td class="label"><&|/l&>Update Type</&>:</td>
 <td><select name="UpdateType">
 % if ($CanComment) {
-<option value="private" <% ($ARGS{'UpdateType'} &&  $ARGS{'UpdateType'} eq "private") ? qq[ selected="selected"] : !$ARGS{'UpdateType'}&&$CommentDefault |n %>><&|/l&>Comments (Not sent to requestors)</&></option>
+<option value="private" style="color:red" <% ($ARGS{'UpdateType'} &&  $ARGS{'UpdateType'} eq "private") ? qq[ selected="selected"] : !$ARGS{'UpdateType'}&&$CommentDefault |n %>><&|/l&>Comments (Not sent to requestors)</&></option>
 % }
 % if ($CanRespond) {
 <option value="response" <% ($ARGS{'UpdateType'} && $ARGS{'UpdateType'} eq "response") ? qq[ selected="selected"] : !$ARGS{'UpdateType'}&&$ResponseDefault |n %>><&|/l&>Reply to requestors</&></option>