Posted to tcl by fvogel at Sun Nov 26 20:59:17 GMT 2017view pretty

<th1>
query {SELECT datetime ($tkt_ctime) AS tkt_cdatetime} {}
query {SELECT datetime ($closedate) AS fmt_closedate} {}
query {SELECT rtrim($tkt_uuid,'f')  AS tkt_uuidtrim}  {}

if {![info exists mutype]}   {set mutype {Plain Text}}
if {![info exists icomment]} {set icomment {}}
if {![info exists username]} {set username $login}

if {![info exists cmutype]} {
    if {$cmimetype eq "text/x-fossil-wiki"} {
        set cmutype "Wiki"
    } elseif {$cmimetype eq "text/x-fossil-plain"} {
        set cmutype {[links only]}
    } elseif {$cmimetype eq "text/html"} {
        set cmutype "HTML"
    } else {
        set cmutype {Plain Text}
    }
}
if {![info exists comment]} {set comment {}}

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
    }
    if {$status eq "Closed" || $status eq "Deleted"} {
	set closer $login
	query {SELECT julianday('now') AS closedate} {}
    } else {
	set closer nobody
	unset closedate
    }

    submit_ticket
    set preview 1
}
</th1>

<table cellpadding="5">
<tr><td class="tktDspLabel">Ticket&nbsp;UUID:</td>
<th1>
if {[hascap s]} {
    html "<td class='tktDspValue' colspan='3'>$tkt_uuidtrim ($tkt_id)</td>\n"
} else {
    html "<td class='tktDspValue' colspan='3'>$tkt_uuidtrim</td>\n"
}
</th1>
</tr>
<tr>
    <td align="right">Title:</td>
    <td align="left" colspan="3"><input type="text" name="title" value="$<title>" size="60" /></td>
</tr>
<tr>
<tr>
    <td align="right">Type:</td>
    <td align="left" ><th1>combobox type $type_choices 1</th1></td>
    <td align="right">Version:</td>
    <td align="left" ><input type="text" name="foundin" size="50" value="$<foundin>" /></td>
</tr>
<tr>
    <td class="tktDspLabel">Submitter:</td>
    <td class="tktDspValue">$<submitter></td>
    <td class="tktDspLabel">Created&nbsp;on:</td>
    <td class="tktDspValue">$<tkt_cdatetime></td>
</tr>
<tr>
    <td align="right">Subsystem:</td>
    <td align="left"><th1>combobox subsystem $subsystem_choices 1</th1></td>
    <td align="right">Assigned&nbsp;To:</td>
    <td align="left" ><th1>combobox assignee $assignee_choices 1</th1></td>
</tr>
<tr>
    <td align="right">Priority:</td>
    <td align="left" ><th1>combobox priority $priority_choices 1</th1></td>
    <td align="right">Severity:</td>
    <td align="left" ><th1>combobox severity $severity_choices 1</th1></td>
</tr>
<tr>
    <td align="right">Status:</td>
    <td align="left" ><th1>combobox status $status_choices 1</th1></td>
    <td class="tktDspLabel">Last&nbsp;Modified:</td>
    <td class="tktDspValue">$<tkt_datetime></td>
</tr>
<tr>
    <td align="right">Resolution:</td>
    <td align="left" ><th1>combobox resolution $resolution_choices 1</th1></td>
    <td class="tktDspLabel">Closed&nbsp;By:</td>
    <td class="tktDspValue">$<closer></td>
</tr>
<tr>
<th1>enable_output [hascap e]</th1>
    <td align="right">Contact:</td>
    <td><input type="text" name="private_contact" size="40" value="$<private_contact>" /></td>
<th1>enable_output [expr {![hascap e]}]</th1>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
<th1>enable_output 1</th1>
    <td class="tktDspLabel">Closed&nbsp;on:</td>
    <td class="tktDspValue">$<fmt_closedate></td>
</tr>
<tr>
    <td align="right">Description:</td>
    <td align="left" colspan="3"><th1>combobox cmutype {{Plain Text} HTML Wiki} 1</th1>:</td>
</tr>
<tr>
    <td>&nbsp;</td>
    <td align="left"  colspan="4">
        <th1>set nline [linecount $comment 50 10]</th1>
        <textarea name="comment" cols="80" rows="$nline" wrap="virtual" class="wikiedit">$<comment></textarea>
    </td>
</tr>
<tr>
    <td>&nbsp;</td>
    <td colspan="2">Append Remark with format
        <th1>combobox mutype {{Plain Text} HTML Wiki} 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 {$cmutype eq "Wiki"} {
    wiki $comment
} elseif {$cmutype eq "Plain Text"} {
    set r [randhex]
    wiki "<verbatim-$r>\n[string trimright $comment]\n</verbatim-$r>"
} else {
    wiki "<nowiki>\n[string trimright $comment]\n</nowiki>"
}
</th1>
<hr>
</td></tr>
<tr><td colspan="2">
Comment 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>"
} 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 1</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>
<th1>
set seenRow 0
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
    ORDER BY tkt_mtime DESC
} {
  if {$seenRow} {
    html "<hr>\n"
  } else {
    html "<tr><td class='tktDspLabel' valign='top'>User Comments:</td>\n"
    html "    <td colspan='3' class='tktDspValue'>\n"
    set seenRow 1
  }
  if {[info exists showfields]} {
    html "<ul><p>date=$xdate<br>login=$xlogin<br>user=$xusername<br>mime=$xmimetype<br>comment=$xcomment</p></ul>"
  }
  html "[htmlize $xlogin]"
  if {$xlogin ne $xusername && [string length $xusername]>0} {
    html " (claiming to be [htmlize $xusername])"
  }
  html " added on $xdate:\n"
  if {$xmimetype eq "text/plain"} {
    set r [randhex]
    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>