Hi all,

About 4 years ago I wrote about a missing feature -- a way to specify that
a ticket is a blocker of another ticket. There was a useful suggestion from
Brian T...  time passed and recently this feature has become more and more
urgent to me, so I decided to implement it.
For those interested I report changes to the ticket table (below) and view
and edit pages (attached source). A remaining issue is that as there're no
hard db constraints on blockers there seems to be no way to verify that the
blocker to be added is actually a valid ticket uuid. Basically, user can
add any text as a blocker.

Any comments appreciated.

  Best regards,
  Jacek


Changes against Fossil version [d2e07756d9] 2013-02-16 00:04:35
In the ticket table (Admin/Tickets/Table) add an extra column:
CREATE TABLE ticket(
...
  comment TEXT,
  blockers TEXT
);
...
<th1>
  if {![info exists mutype]} {set mutype {[links only]}}
  if {![info exists icomment]} {set icomment {}}
  if {![info exists username]} {set username $login}
  if {[info exists submit]} {
    if {$mutype eq "Wiki"} {
      set mimetype text/x-fossil-wiki
    } elseif {$mutype eq "HTML"} {
      set mimetype text/html
    } elseif {$mutype eq {[links only]}} {
      set mimetype text/x-fossil-plain
    } else {
      set mimetype text/plain
    }

    # Set blockers according to the buffered new_blockers list
    set blockers $new_blockers

    submit_ticket
    set preview 1
  }
</th1>
<table cellpadding="5">
<tr><td class="tktDspLabel">Title:</td><td>
<input type="text" name="title" value="$<title>" size="60" />
</td></tr>

<tr><td class="tktDspLabel">Status:</td><td>
<th1>combobox status $status_choices 1</th1>
</td></tr>

<tr><td class="tktDspLabel">Type:</td><td>
<th1>combobox type $type_choices 1</th1>
</td></tr>

<tr><td class="tktDspLabel">Severity:</td><td>
<th1>combobox severity $severity_choices 1</th1>
</td></tr>

<tr><td class="tktDspLabel">Priority:</td><td>
<th1>combobox priority $priority_choices 1</th1>
</td></tr>

<tr><td class="tktDspLabel">Resolution:</td><td>
<th1>combobox resolution $resolution_choices 1</th1>
</td></tr>

<tr><td class="tktDspLabel">Subsystem:</td><td>
<th1>combobox subsystem $subsystem_choices 1</th1>
</td></tr>

<th1>enable_output [hascap e]</th1>
  <tr><td class="tktDspLabel">Contact:</td><td>
  <input type="text" name="private_contact" size="40"
   value="$<private_contact>" />
  </td></tr>
<th1>enable_output 1</th1>

<tr><td class="tktDspLabel">Version&nbsp;Found&nbsp;In:</td><td>
<input type="text" name="foundin" size="50" value="$<foundin>" />
</td></tr>

<tr>
<td class='tktDspLabel'>Blockers:</td>
<th1>
  if {! [info exists new_blockers]} {
    set new_blockers $blockers
  }

  if {[info exists addblckrbtn]} {
    if {[info exists new_blocker]} {
      # Check whether the added blocker is already in the list
      set add_new_blocker 1
      for {set b 0} {$b < [llength $new_blockers]} {set b [expr {$b + 1}]} {
        set to_check [lindex $new_blockers $b]
        if {![string compare $new_blocker $to_check]} {
          set add_new_blocker 0
          break
        }
      }
      if {$add_new_blocker} {
        set new_blockers "$new_blockers $new_blocker"
      }
    }
  } elseif {[info exists delblckrbtn]} {
    if {[info exists blocker_list]} {
      # Generate a list of blockers that is clear from the deleted blocker
      set cleared_blockers ""
      for {set b 0} {$b < [llength $new_blockers]} {set b [expr {$b + 1}]} {
        set to_check [lindex $new_blockers $b]
        if {[string compare $blocker_list $to_check]} {
          set cleared_blockers "$cleared_blockers $to_check"
        }
      }
      set new_blockers $cleared_blockers
    }
  }

  html "<input type='hidden' name='new_blockers' value='$new_blockers' />"
</th1>
  <td><th1>combobox blocker_list "$new_blockers" 3</th1>
      <input type="submit" name="delblckrbtn" value="Del blocker" /></td>
</tr>
<tr>
  <td></td>
  <td><input type="text" name="new_blocker" size="20" />
      <input type="submit" name="addblckrbtn" value="Add blocker" /></td>
</tr>

<tr><td colspan="2">
  Append Remark with format
  <th1>combobox mutype {Wiki HTML {Plain Text} {[links only]}} 1</th1>
  from
  <input type="text" name="username" value="$<username>" size="30" />:<br />
  <textarea name="icomment" cols="80" rows="15"
   wrap="virtual" class="wikiedit">$<icomment></textarea>
</td></tr>

<th1>enable_output [info exists preview]</th1>
<tr><td colspan="2">
Description Preview:<br><hr>
<th1>
if {$mutype eq "Wiki"} {
  wiki $icomment
} elseif {$mutype eq "Plain Text"} {
  set r [randhex]
  wiki "<verbatim-$r>\n[string trimright $icomment]\n</verbatim-$r>"
} elseif {$mutype eq {[links only]}} {
  set r [randhex]
  wiki "<verbatim-$r links>\n[string trimright $icomment]</verbatim-$r>"
} else {
  wiki "<nowiki>\n[string trimright $icomment]\n</nowiki>"
}
</th1>
<hr>
</td></tr>
<th1>enable_output 1</th1>

<tr>
<td align="right">
<input type="submit" name="preview" value="Preview" />
</td>
<td align="left">See how the description will appear after formatting.</td>
</tr>

<th1>enable_output [info exists preview]</th1>
<tr>
<td align="right">
<input type="submit" name="submit" value="Submit" />
</td>
<td align="left">Apply the changes shown above</td>
</tr>
<th1>enable_output 1</th1>

<tr>
<td align="right">
<input type="submit" name="cancel" value="Cancel" />
</td>
<td>Abandon this edit</td>
</tr>

</table>
<table cellpadding="5">
<tr><td class="tktDspLabel">Ticket&nbsp;UUID:</td>
<th1>
if {[hascap s]} {
  html "<td class='tktDspValue' colspan='3'>$tkt_uuid "
  html "($tkt_id)</td></tr>\n"
} else {
  html "<td class='tktDspValue' colspan='3'>$tkt_uuid</td></tr>\n"
}
</th1>
<tr><td class="tktDspLabel">Title:</td>
<td class="tktDspValue" colspan="3">
$<title>
</td></tr>
<tr><td class="tktDspLabel">Status:</td><td class="tktDspValue">
$<status>
</td>
<td class="tktDspLabel">Type:</td><td class="tktDspValue">
$<type>
</td></tr>
<tr><td class="tktDspLabel">Severity:</td><td class="tktDspValue">
$<severity>
</td>
<td class="tktDspLabel">Priority:</td><td class="tktDspValue">
$<priority>
</td></tr>
<tr><td class="tktDspLabel">Subsystem:</td><td class="tktDspValue">
$<subsystem>
</td>
<td class="tktDspLabel">Resolution:</td><td class="tktDspValue">
$<resolution>
</td></tr>
<tr><td class="tktDspLabel">Last&nbsp;Modified:</td><td class="tktDspValue">
$<tkt_datetime>
</td>
<th1>enable_output [hascap e]</th1>
  <td class="tktDspLabel">Contact:</td><td class="tktDspValue">
  $<private_contact>
  </td>
<th1>enable_output 1</th1>
</tr>
<tr><td class="tktDspLabel">Version&nbsp;Found&nbsp;In:</td>
<td colspan="3" valign="top" class="tktDspValue">
$<foundin>
</td></tr>
<tr>
  <td class="tktDspLabel">Blockers:</td>
  <td colspan="3" valign="top" class="tktDspValue">
  <th1>
   # Thanks to Brian Theado 
   # http://www.mail-archive.com/fossil-users@lists.fossil-scm.org/msg00852.html

   # Loop through the ticket uuids
   for {set x 0} {$x < [llength $blockers]} {set x [expr {$x + 1}]} {
     # Add braces so wiki formatter will make links.  Backslashes
     # hide those braces from interpretation by th1
     wiki \[[lindex $blockers $x]\]
   }
  </th1>
  </td>
</tr>

<th1>
if {[info exists comment] && [string length $comment]>10} {
  html {
    <tr><td class="tktDspLabel">Description:</td></tr>
    <tr><td colspan="5" class="tktDspValue">
  }
  if {[info exists plaintext]} {
    set r [randhex]
    wiki "<verbatim-$r links>\n$comment\n</verbatim-$r>"
  } else {
    wiki $comment
  }
}
set seenRow 0
set alwaysPlaintext [info exists plaintext]
query {SELECT datetime(tkt_mtime) AS xdate, login AS xlogin,
              mimetype as xmimetype, icomment AS xcomment,
              username AS xusername
         FROM ticketchng
        WHERE tkt_id=$tkt_id AND length(icomment)>0} {
  if {$seenRow} {
    html "<hr>\n"
  } else {
    html "<tr><td class='tktDspLabel'>User Comments:</td></tr>\n"
    html "<tr><td colspan='5' class='tktDspValue'>\n"
    set seenRow 1
  }
  html "[htmlize $xlogin]"
  if {$xlogin ne $xusername && [string length $xusername]>0} {
    html " (claiming to be [htmlize $xusername])"
  }
  html " added on $xdate:\n"
  if {$alwaysPlaintext || $xmimetype eq "text/plain"} {
    set r [randhex]
    if {$xmimetype ne "text/plain"} {html "([htmlize $xmimetype])\n"}
    wiki "<verbatim-$r>[string trimright $xcomment]</verbatim-$r>\n"
  } elseif {$xmimetype eq "text/x-fossil-wiki"} {
    wiki "<p>\n[string trimright $xcomment]\n</p>\n"
  } elseif {$xmimetype eq "text/html"} {
    wiki "<p><nowiki>\n[string trimright $xcomment]\n</nowiki>\n"
  } else {
    set r [randhex]
    wiki "<verbatim-$r links>[string trimright $xcomment]</verbatim-$r>\n"
  }
}
if {$seenRow} {html "</td></tr>\n"}
</th1>
</table>
_______________________________________________
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users

Reply via email to