<th1>
if {[capexpr {n}]} {
submenu link "Copy Ticket" $baseurl/tktnew/$tkt_uuid
}
if {[capexpr {nk}]} {
submenu link "Edit Wiki" $baseurl/wikiedit?name=ticket/$tkt_uuid
}
proc tkt_opt_list {name choices cur allowEmpty} {
html "<select id='tkt-side-$name' name='$name'>"
set found 0
if {$allowEmpty} {
set sel ""
if {$cur eq ""} { set sel " selected"; set found 1 }
html "<option value=''$sel>(unset)</option>"
}
foreach opt $choices {
set sel ""
if {$opt eq $cur} { set sel " selected"; set found 1 }
html "<option value='[htmlize $opt]'$sel>[htmlize $opt]</option>"
}
if {!$found && $cur ne ""} {
html "<option value='[htmlize $cur]' selected>[htmlize $cur]</option>"
}
html "</select>"
}
</th1>
<div class="tkt-shell" data-tkt-page="tktview" data-tkt-preview-url="$baseurl/ajax/preview-text" data-tkt-history-url="$baseurl/tkthistory/$<tkt_uuid>">
<div class="tkt-head">
<div class="tkt-head-top">
<th1>
set canWrite [expr {[capexpr {w}] && [info exists tkt_uuid]}]
if {$canWrite} {
html "<input type='checkbox' id='tkt-edit-title-toggle' class='tkt-toggle-sr'>\n"
html "<div class='tkt-title-wrap'><h2 class='tkt-title'>[htmlize $title]</h2>"
html "<label for='tkt-edit-title-toggle' class='tkt-pen-btn' title='Edit title inline'><svg viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='1.8' aria-hidden='true'><path d='M12 20h9M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4 12.5-12.5z'/></svg><span class='tkt-sr-only'>Edit title</span></label></div>\n"
html "<form class='tkt-title-edit' method='post' action='$baseurl/tktedit/[httpize $tkt_uuid]'>\n"
insertCsrf
html "<input type='hidden' name='submit' value='1'>\n"
html "<input type='text' name='title' value='[htmlize $title]' maxlength='200' required aria-label='Ticket title'>\n"
html "<label for='tkt-edit-title-toggle' class='tkt-btn'>Cancel</label>\n"
html "<button type='submit' class='tkt-btn tkt-btn-primary'>Save</button>\n"
html "</form>\n"
html "<a class='tkt-btn' href='$baseurl/tktedit/[httpize $tkt_uuid]'>Full edit</a>\n"
} else {
html "<h2 class='tkt-title'>[htmlize $title]</h2>\n"
}
</th1>
</div>
<div class="tkt-head-sub">
<th1>
set stcls "tkt-tag tkt-tag-ok"
if {$status eq "Review"} { set stcls "tkt-tag tkt-tag-warn" }
if {$status eq "Closed" || $status eq "Deferred" || $status eq "Fixed" || $status eq "Tested"} { set stcls "tkt-tag" }
html "<span class='$stcls'>[htmlize $status]"
if {($status eq "Closed" || $status eq "Fixed") && [info exists resolution] && $resolution ne "" && $resolution ne $status && $resolution ne "Open"} {
html " / [htmlize $resolution]"
}
html "</span>"
if {[info exists tkt_uuid]} {
copybtn hash-tk 0 $tkt_uuid 2
if {[hascap s]} { puts " (#$tkt_id)" }
} else {
html "<span class='tkt-tag tkt-tag-crit'>Deleted</span>"
}
if {[info exists tkt_cage]} {
html "<span>Created [htmlize $tkt_cage] ago</span>"
}
if {[info exists tkt_mage]} {
html "<span>Updated [htmlize $tkt_mage] ago</span>"
}
</th1>
</div>
</div>
<th1>wiki_assoc "ticket" $tkt_uuid</th1>
<div class="tkt-layout">
<div class="tkt-main">
<th1>
set hasAny 0
if {[info exists comment]} {
if {[string length [string trim $comment]] > 0} {
set hasAny 1
html "<div class='tkt-card'>"
html "<div class='tkt-card-hdr'><strong>Description</strong>"
if {[info exists tkt_datetime_creation]} {
html "<span>[htmlize $tkt_datetime_creation]</span>"
}
html "</div><div class='tkt-card-body'>"
if {[info exists plaintext]} {
set r [randhex]
wiki "<verbatim-$r links>\n$comment\n</verbatim-$r>"
} else {
wiki $comment
}
html "</div></div>\n"
}
}
if {[info exists tkt_uuid]} {
set refCount 0
set refHtml ""
query {
SELECT substr(b.uuid,1,10) AS xsrcid,
e.type AS xsrctype,
datetime(e.mtime, toLocal()) AS xsrcdate,
coalesce(e.ecomment, e.comment, '') AS xsrcmsg
FROM backlink bl
JOIN blob b ON b.rid = bl.srcid
JOIN event e ON e.objid = bl.srcid
WHERE bl.target = substr($tkt_uuid,1,10) OR bl.target = $tkt_uuid
ORDER BY e.mtime DESC
LIMIT 20
} {
set refCount [expr {$refCount + 1}]
set rlbl "ref"
set rico "<svg viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='1.8' aria-hidden='true'><circle cx='12' cy='12' r='4'/><path d='M2 12h6M16 12h6'/></svg>"
if {$xsrctype eq "ci"} { set rlbl "check-in" }
if {$xsrctype eq "f"} {
set rlbl "forum"
set rico "<svg viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='1.8' aria-hidden='true'><path d='M4 5h16v11H8l-4 4V5z'/></svg>"
}
if {$xsrctype eq "w"} { set rlbl "wiki" }
set refHtml "$refHtml<li>$rico<a href='$baseurl/info/[httpize $xsrcid]'><code>[htmlize $xsrcid]</code> [htmlize $xsrcmsg]</a> <span class='tkt-tag'>$rlbl</span> <span class='tkt-event-time'>[htmlize $xsrcdate]</span></li>\n"
}
if {$refCount > 0} {
html "<div class='tkt-card'><div class='tkt-card-hdr'><strong>Referenced by</strong><span>$refCount</span></div><ul class='tkt-refs-list'>\n"
html $refHtml
html "</ul></div>\n"
}
}
set alwaysPlaintext [info exists plaintext]
set evIdx 0
query {
SELECT e.objid AS xrid,
datetime(e.mtime, toLocal()) AS xdate,
coalesce(c.login, e.user, '') AS xlogin,
coalesce(c.username, '') AS xusername,
coalesce(c.mimetype, '') AS xmimetype,
coalesce(c.icomment, '') AS xcomment,
coalesce(e.brief, '') AS xbrief,
coalesce(e.comment, '') AS xevcomment
FROM tag tg
JOIN event e ON e.tagid = tg.tagid AND e.type = 't'
LEFT JOIN ticketchng c ON c.tkt_id = $tkt_id AND c.tkt_rid = e.objid
WHERE tg.tagname = 'tkt-' || $tkt_uuid
ORDER BY e.mtime ASC, e.objid ASC
} {
set evIdx [expr {$evIdx + 1}]
if {[string length [string trim $xcomment]] > 0} {
set hasAny 1
html "<div class='tkt-card tktCommentEntry' data-tkt-rid='[htmlize $xrid]'>"
html "<div class='tkt-card-hdr'><span class='tktDspCommenter'><strong>[htmlize $xlogin]</strong>"
if {$xlogin ne $xusername && [string length $xusername] > 0} {
html " (claiming to be [htmlize $xusername])"
}
html "</span><span>[htmlize $xdate]</span></div>"
html "<div class='tkt-card-body'>"
if {$alwaysPlaintext || $xmimetype eq "text/plain"} {
set r [randhex]
if {$xmimetype ne "text/plain"} { puts "($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/x-markdown"} {
html [lindex [markdown $xcomment] 1]
} 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"
}
html "</div></div>\n"
} elseif {$evIdx > 1} {
set hasAny 1
set evMsg $xbrief
if {[string length $evMsg] == 0} { set evMsg $xevcomment }
html "<div class='tkt-event-row' data-tkt-rid='[htmlize $xrid]'>"
html "<span class='tkt-event-ico' aria-hidden='true'><svg viewBox='0 0 16 16' fill='none' stroke='currentColor' stroke-width='1.6'><circle cx='8' cy='8' r='5'/><path d='M8 5v3l2 1.5'/></svg></span>"
html "<span class='tkt-event-body'><strong>[htmlize $xlogin]</strong> <span class='tkt-event-msg'>"
wiki $evMsg
html "</span> <a href='$baseurl/tkthistory/[httpize $tkt_uuid]'>\[History diff\]</a></span>"
html "<span class='tkt-event-time'>[htmlize $xdate]</span>"
html "</div>\n"
}
}
if {!$hasAny} {
html "<div class='tkt-card'><div class='tkt-empty'>No description or comments yet.</div></div>\n"
}
if {$canWrite} {
set isClosed 0
if {$status eq "Closed" || $status eq "Fixed" || $status eq "Tested" || $status eq "Deferred"} { set isClosed 1 }
html "<form class='tkt-card' method='post' action='$baseurl/tktedit/[httpize $tkt_uuid]' data-tkt-draft-form='comment-[htmlize $tkt_uuid]' data-pv-scope='view'>\n"
insertCsrf
html "<input type='hidden' name='submit' value='1'>\n"
html "<div class='tkt-card-hdr'><span class='tkt-card-hdr-l'><strong>Add comment</strong>"
html "<span class='tkt-tabs' role='tablist' aria-label='Comment mode'>"
html "<button type='button' class='tkt-tab' role='tab' aria-selected='true' data-pv-tab='write' data-pv-for='view'>Write</button>"
html "<button type='button' class='tkt-tab' role='tab' aria-selected='false' data-pv-tab='preview' data-pv-for='view'>Preview <span class='tkt-tab-dot' data-pv-dot='view' hidden></span></button>"
html "</span></span><span>Markdown (type <code>/</code> at line start for blocks)</span></div>\n"
html "<div class='tkt-form-stack tkt-composer-wrap'>\n"
html "<input type='hidden' name='mutype' value='Markdown'>\n"
html "<textarea name='icomment' rows='5' class='wikiedit' data-tkt-slash='1' data-tkt-draft='comment-[htmlize $tkt_uuid]' data-pv-input='view' aria-label='Add comment' placeholder='Write a Markdown comment...'></textarea>\n"
html "<div class='tkt-preview-pane markdown' data-pv-pane='view' hidden></div>\n"
html "<div class='tkt-form-actions'>\n"
html "<span class='tkt-help'><span class='tkt-draft-pill' data-tkt-draft-badge='comment-[htmlize $tkt_uuid]' hidden>Draft saved in tab · </span><span class='tkt-gate-note' data-pv-gate='view'>Preview Markdown before posting (empty close/reopen needs no preview).</span></span>\n"
html "<div class='tkt-form-btns'>\n"
html "<button type='submit' name='preview' value='1' class='tkt-btn' data-pv-btn='view'>Preview</button>\n"
if {$isClosed} {
html "<button type='submit' name='status' value='Open' class='tkt-btn' data-pv-submit-optional='view'>Reopen</button>\n"
} else {
html "<span class='tkt-close-group'><label class='tkt-help' for='tkt-close-res'>with</label>"
html "<select id='tkt-close-res' name='resolution' aria-label='Resolution'>"
foreach ropt $resolution_choices {
if {$ropt ne "Open"} {
set rsel ""; if {$ropt eq "Fixed"} { set rsel " selected" }
html "<option value='[htmlize $ropt]'$rsel>[htmlize $ropt]</option>"
}
}
html "</select>"
html "<button type='submit' name='status' value='Closed' class='tkt-btn' data-pv-submit-optional='view'>Comment & close</button></span>\n"
}
html "<button type='submit' name='submit' value='1' class='tkt-btn tkt-btn-primary' data-pv-submit='view' disabled>Comment</button>\n"
html "</div></div></div></form>\n"
}
</th1>
</div>
<aside class="tkt-sidebar" aria-label="Ticket properties">
<th1>
if {$canWrite} {
html "<form class='tkt-side-form' method='post' action='$baseurl/tktedit/[httpize $tkt_uuid]' data-tkt-autosave='1'>\n"
insertCsrf
html "<input type='hidden' name='submit' value='1'>\n"
html "<div class='tkt-side-status'><strong>Properties</strong><span class='tkt-saved-msg' data-tkt-save-msg='1'>auto-save</span></div>\n"
html "<div class='tkt-field'><label class='tkt-field-label' for='tkt-side-status'>Status</label>"
tkt_opt_list status $status_choices $status 0
html "</div>\n"
html "<div class='tkt-field'><label class='tkt-field-label' for='tkt-side-priority'>Priority</label>"
tkt_opt_list priority $priority_choices $priority 1
html "</div>\n"
html "<div class='tkt-field'><label class='tkt-field-label' for='tkt-side-severity'>Severity</label>"
tkt_opt_list severity $severity_choices $severity 1
html "</div>\n"
html "<div class='tkt-field'><label class='tkt-field-label' for='tkt-side-type'>Type</label>"
tkt_opt_list type $type_choices $type 1
html "</div>\n"
html "<div class='tkt-field'><label class='tkt-field-label' for='tkt-side-subsystem'>Subsystem</label>"
if {[llength $subsystem_choices] > 0} {
tkt_opt_list subsystem $subsystem_choices $subsystem 1
} else {
html "<input id='tkt-side-subsystem' type='text' name='subsystem' value='[htmlize $subsystem]' list='tkt-sub-datalist' placeholder='Subsystem'>"
html "<datalist id='tkt-sub-datalist'>"
query {SELECT DISTINCT subsystem AS sv FROM ticket WHERE length(subsystem)>0 ORDER BY subsystem} {
html "<option value='[htmlize $sv]'>"
}
html "</datalist>"
}
html "</div>\n"
html "<div class='tkt-field'><label class='tkt-field-label' for='tkt-side-resolution'>Resolution</label>"
tkt_opt_list resolution $resolution_choices $resolution 1
html "</div>\n"
html "<button type='submit' class='tkt-btn tkt-side-submit'>Update fields</button>\n"
html "</form>\n"
} else {
html "<div class='tkt-field'><span class='tkt-field-label'>Status</span><span class='tkt-field-val'>[htmlize $status]</span></div>\n"
html "<div class='tkt-field'><span class='tkt-field-label'>Type</span><span class='tkt-field-val'>[htmlize $type]</span></div>\n"
html "<div class='tkt-field'><span class='tkt-field-label'>Priority</span><span class='tkt-field-val'>[htmlize $priority]</span></div>\n"
html "<div class='tkt-field'><span class='tkt-field-label'>Severity</span><span class='tkt-field-val'>[htmlize $severity]</span></div>\n"
html "<div class='tkt-field'><span class='tkt-field-label'>Subsystem</span><span class='tkt-field-val'>[htmlize $subsystem]</span></div>\n"
html "<div class='tkt-field'><span class='tkt-field-label'>Resolution</span><span class='tkt-field-val'>[htmlize $resolution]</span></div>\n"
}
</th1>
<div class="tkt-field">
<span class="tkt-field-label">Version found in</span>
<span class="tkt-field-val">
<th1>
set versionlink ""
set urlfoundin [httpize $foundin]
set tagpattern {^[-0-9A-Za-z_\\.]+$}
if {[regexp $tagpattern $foundin]} {
query {SELECT count(*) AS match FROM tag
WHERE tagname=concat('sym-',$foundin)} {
if {$match} { set versionlink "timeline?t=$urlfoundin" }
}
}
set hashpattern {^[0-9a-f]+$}
if {[regexp $hashpattern $foundin]} {
set pattern $foundin*
query {SELECT count(*) AS match FROM blob WHERE uuid GLOB $pattern} {
if {$match} { set versionlink "info/$urlfoundin" }
}
}
if {$versionlink eq ""} {
puts $foundin
} else {
html "<a href='[htmlize $versionlink]'>[htmlize $foundin]</a>"
}
</th1>
</span>
</div>
<div class="tkt-field">
<span class="tkt-field-label">Created</span>
<span class="tkt-field-val"><th1>if {[info exists tkt_datetime_creation]} { puts $tkt_datetime_creation }</th1></span>
</div>
<div class="tkt-field">
<span class="tkt-field-label">Last modified</span>
<span class="tkt-field-val"><th1>if {[info exists tkt_datetime]} { puts $tkt_datetime }</th1></span>
</div>
<th1>
if {[hascap e]} {
html "<div class='tkt-field'><span class='tkt-field-label'>Contact</span><span class='tkt-field-val'>[htmlize $private_contact]</span></div>"
}
</th1>
</aside>
</div>
</div>